index.vue 5.4 KB

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