index.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. <template>
  2. <div class="tenant">
  3. <!-- <Banner /> -->
  4. <div class="content">
  5. <byTable
  6. :source="sourceList.data"
  7. :pagination="sourceList.pagination"
  8. :config="config"
  9. :loading="loading"
  10. highlight-current-row
  11. :selectConfig="selectConfig"
  12. :table-events="{
  13. //element talbe事件都能传
  14. select: select,
  15. }"
  16. :action-list="[
  17. {
  18. text: '添加流程',
  19. action: () => openModal('add'),
  20. },
  21. ]"
  22. @get-list="getList">
  23. <template #slotName="{ item }">
  24. {{ item.createTime }}
  25. </template>
  26. </byTable>
  27. </div>
  28. <el-dialog :title="modalType == 'add' ? '添加流程' : '编辑流程'" v-model="dialogVisible" width="400" v-loading="loading">
  29. <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="byform"> </byForm>
  30. <template #footer>
  31. <el-button @click="dialogVisible = false" size="large">取 消</el-button>
  32. <el-button type="primary" @click="submitForm('byform')" size="large" :loading="submitLoading">确 定</el-button>
  33. </template>
  34. </el-dialog>
  35. </div>
  36. </template>
  37. <script setup>
  38. /* eslint-disable vue/no-unused-components */
  39. import { ElMessage, ElMessageBox } from "element-plus";
  40. import byTable from "@/components/byTable/index";
  41. import byForm from "@/components/byForm/index";
  42. import { computed, defineComponent, ref } from "vue";
  43. const loading = ref(false);
  44. const submitLoading = ref(false);
  45. const dictCommonModal = ref(false);
  46. const sourceList = ref({
  47. data: [],
  48. pagination: {
  49. total: 3,
  50. pageNum: 1,
  51. pageSize: 10,
  52. },
  53. });
  54. let dialogVisible = ref(false);
  55. let roomDialogVisible = ref(false);
  56. let modalType = ref("add");
  57. let rules = ref({
  58. classifyName: [{ required: true, message: "请输入功能模块", trigger: "blur" }],
  59. flowKey: [{ required: true, message: "请输入流程标识", trigger: "blur" }],
  60. flowName: [{ required: true, message: "请输入流程名称", trigger: "blur" }],
  61. });
  62. const { proxy } = getCurrentInstance();
  63. const status = ref([
  64. {
  65. label: "禁用",
  66. value: 0,
  67. },
  68. {
  69. label: "启用",
  70. value: 1,
  71. },
  72. ]);
  73. const selectConfig = computed(() => {
  74. return [
  75. {
  76. label: "流程状态",
  77. prop: "status",
  78. data: status.value,
  79. },
  80. ];
  81. });
  82. const config = computed(() => {
  83. return [
  84. {
  85. attrs: {
  86. label: "功能模块",
  87. prop: "classifyName",
  88. },
  89. },
  90. {
  91. attrs: {
  92. label: "流程标识",
  93. prop: "flowKey",
  94. },
  95. },
  96. {
  97. attrs: {
  98. label: "流程名称",
  99. prop: "flowName",
  100. },
  101. },
  102. {
  103. attrs: {
  104. label: "状态",
  105. width: 100,
  106. prop: "status",
  107. },
  108. render(status) {
  109. //1审核中 2审核通过 3审核不通过
  110. return status == 0 ? "禁用" : "启用";
  111. },
  112. },
  113. {
  114. attrs: {
  115. label: "创建时间",
  116. prop: "createTime",
  117. },
  118. },
  119. {
  120. attrs: {
  121. label: "操作",
  122. width: "200",
  123. align: "right",
  124. },
  125. // 渲染 el-button,一般用在最后一列。
  126. renderHTML(row) {
  127. return [
  128. {
  129. attrs: {
  130. label: "修改",
  131. type: "primary",
  132. text: true,
  133. },
  134. el: "button",
  135. click() {
  136. getDtl(row);
  137. },
  138. },
  139. {
  140. attrs: {
  141. label: row.status == 1 ? "禁用" : "启用",
  142. type: "primary",
  143. text: true,
  144. },
  145. el: "button",
  146. click() {
  147. changeStatus(row);
  148. },
  149. },
  150. ];
  151. },
  152. },
  153. ];
  154. });
  155. let dtlData = reactive({
  156. data: {},
  157. });
  158. let formData = reactive({
  159. data: {},
  160. treeData: [],
  161. });
  162. const formOption = reactive({
  163. inline: true,
  164. labelWidth: 100,
  165. itemWidth: 100,
  166. rules: [],
  167. });
  168. const byform = ref(null);
  169. const treeData = ref([]);
  170. const formConfig = computed(() => {
  171. return [
  172. {
  173. type: "input",
  174. prop: "classifyName",
  175. label: "功能模块",
  176. },
  177. {
  178. type: "input",
  179. prop: "flowKey",
  180. label: "流程标识",
  181. isHide: modalType.value == "edit",
  182. },
  183. {
  184. type: "input",
  185. prop: "flowName",
  186. label: "流程名称",
  187. },
  188. ];
  189. });
  190. const getList = async (req) => {
  191. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  192. loading.value = true;
  193. proxy.post("/flowInfo/page", sourceList.value.pagination).then((message) => {
  194. sourceList.value.data = message.rows;
  195. sourceList.value.pagination.total = message.total;
  196. setTimeout(() => {
  197. loading.value = false;
  198. }, 200);
  199. });
  200. };
  201. const openModal = () => {
  202. dialogVisible.value = true;
  203. modalType.value = "add";
  204. formData.data = {};
  205. };
  206. const selection = ref({
  207. data: [],
  208. });
  209. const select = (_selection, row) => {
  210. selection.value.data = _selection;
  211. };
  212. const tree = ref(null);
  213. const submitTree = () => {
  214. proxy
  215. .post("/tenantInfo/bindingMenu", {
  216. tenantId: selection.value.data[0].tenantId,
  217. menuIdList: tree.value.getCheckedKeys(),
  218. })
  219. .then((res) => {
  220. ElMessage({
  221. message: "保存成功",
  222. type: "success",
  223. });
  224. roomDialogVisible.value = false;
  225. });
  226. };
  227. const submitForm = () => {
  228. byform.value.handleSubmit((valid) => {
  229. submitLoading.value = true;
  230. proxy.post("/flowInfo/" + modalType.value, formData.data).then((res) => {
  231. ElMessage({
  232. message: modalType.value == "add" ? "添加成功" : "编辑成功",
  233. type: "success",
  234. });
  235. dialogVisible.value = false;
  236. submitLoading.value = false;
  237. getList();
  238. });
  239. });
  240. };
  241. const getDtl = (row) => {
  242. formData.data = { ...row };
  243. modalType.value = "edit";
  244. dialogVisible.value = true;
  245. };
  246. const changeStatus = (row) => {
  247. modalType.value = "edit";
  248. proxy.post("/flowInfo/edit", { ...row, status: row.status === 0 ? 1 : 0 }).then((res) => {
  249. ElMessage({
  250. message: "操作成功",
  251. type: "success",
  252. });
  253. getList();
  254. });
  255. };
  256. getList();
  257. </script>
  258. <style lang="scss" scoped>
  259. .tenant {
  260. padding: 20px;
  261. }
  262. </style>