index.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. <template>
  2. <div class="user">
  3. <div class="tree">
  4. <treeList :data="treeListData" v-model="sourceList.pagination.tenantId" node-key="id" @change="treeChange">
  5. </treeList>
  6. </div>
  7. <div class="content">
  8. <byTable :source="sourceList.data" :pagination="sourceList.pagination" :config="config" :loading="loading" highlight-current-row
  9. :selectConfig="selectConfig" :table-events="{
  10. //element talbe事件都能传
  11. select: select,
  12. }" :action-list="[
  13. {
  14. text: '添加流程',
  15. action: () => openModal('add'),
  16. disabled: !sourceList.pagination.tenantId,
  17. },
  18. ]" @get-list="getList">
  19. <template #slotName="{ item }">
  20. {{ item.createTime }}
  21. </template>
  22. </byTable>
  23. </div>
  24. <el-dialog :title="modalType == 'add' ? '新增' : '编辑'" v-model="dialogVisible" width="500" v-loading="loading">
  25. <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="byform">
  26. </byForm>
  27. <template #footer>
  28. <el-button @click="dialogVisible = false" size="default">取 消</el-button>
  29. <el-button type="primary" @click="submitForm" size="default" :loading="submitLoading">
  30. 确 定
  31. </el-button>
  32. </template>
  33. </el-dialog>
  34. <!-- 版本切换模态框 -->
  35. <el-dialog title="版本切换" v-model="versionVisible" width="500" v-loading="loading">
  36. <el-form>
  37. <el-form-item label="流程名称">
  38. <el-input v-model="formData.flowName" disabled placeholder="请输入流程名称"></el-input>
  39. </el-form-item>
  40. <el-form-item label="当前版本">
  41. <el-select v-model="formData.version" placeholder="请选择">
  42. <el-option v-for="item in versionList" :key="item.id" :label="'v' + item.versionNumber" :value="item.id"></el-option>
  43. </el-select>
  44. </el-form-item>
  45. </el-form>
  46. <template #footer>
  47. <el-button @click="versionVisible = false" size="default">取 消</el-button>
  48. <el-button type="primary" @click="changeVersion(formData.version)" size="default" :loading="submitLoading">
  49. 确 定
  50. </el-button>
  51. </template>
  52. </el-dialog>
  53. </div>
  54. </template>
  55. <script setup name="ProcessConfig">
  56. /* eslint-disable vue/no-unused-components */
  57. import { ElMessage, ElMessageBox } from "element-plus";
  58. import byTable from "@/components/byTable/index";
  59. import byForm from "@/components/byForm/index";
  60. import treeList from "@/components/treeList/index";
  61. import { computed, defineComponent, ref } from "vue";
  62. const loading = ref(false);
  63. const submitLoading = ref(false);
  64. const sourceList = ref({
  65. data: [],
  66. pagination: {
  67. total: 3,
  68. pageNum: 1,
  69. pageSize: 10,
  70. },
  71. });
  72. let dialogVisible = ref(false);
  73. const versionVisible = ref(false);
  74. let modalType = ref("add");
  75. let rules = ref({
  76. roleKey: [{ required: true, message: "请选择部门", trigger: "blur" }],
  77. nickName: [{ required: true, message: "姓名不能为空", trigger: "blur" }],
  78. userName: [{ required: true, message: "用户名不能为空", trigger: "blur" }],
  79. });
  80. const { proxy } = getCurrentInstance();
  81. const selectConfig = computed(() => {
  82. return [];
  83. });
  84. const config = computed(() => {
  85. return [
  86. {
  87. attrs: {
  88. label: "功能模块",
  89. prop: "classifyName",
  90. },
  91. },
  92. {
  93. attrs: {
  94. label: "流程标识",
  95. prop: "flowKey",
  96. },
  97. },
  98. {
  99. attrs: {
  100. label: "流程名称",
  101. prop: "flowName",
  102. },
  103. },
  104. {
  105. attrs: {
  106. label: "当前版本",
  107. },
  108. // 渲染 el-button,一般用在最后一列。
  109. renderHTML(row) {
  110. return [
  111. {
  112. attrs: {
  113. label: "v" + row.versionNumber,
  114. type: "primary",
  115. text: true,
  116. },
  117. el: "button",
  118. click() {
  119. getVersionList(row);
  120. },
  121. },
  122. ];
  123. },
  124. },
  125. {
  126. attrs: {
  127. label: "操作",
  128. width: "200",
  129. align: "right",
  130. },
  131. // 渲染 el-button,一般用在最后一列。
  132. renderHTML(row) {
  133. return [
  134. {
  135. attrs: {
  136. label: "新建版本",
  137. type: "primary",
  138. text: true,
  139. },
  140. el: "button",
  141. click() {
  142. getDtl(row);
  143. },
  144. },
  145. ];
  146. },
  147. },
  148. ];
  149. });
  150. let versionList = ref([]);
  151. const getVersionList = (row) => {
  152. formData.flowName = row.flowName;
  153. formData.version = row.id;
  154. versionVisible.value = true;
  155. proxy
  156. .post("/flowDefinition/getVersionList", {
  157. flowKey: row.flowKey,
  158. tenantId: row.tenantId,
  159. })
  160. .then((message) => {
  161. versionList.value = message;
  162. console.log(versionList);
  163. });
  164. };
  165. const changeVersion = (id) => {
  166. if (!id) {
  167. ElMessage.error("请选择版本");
  168. return;
  169. }
  170. proxy
  171. .post("/flowDefinition/updateVersion", {
  172. id: id,
  173. })
  174. .then((message) => {
  175. ElMessage.success("切换成功");
  176. versionVisible.value = false;
  177. getList();
  178. });
  179. };
  180. let formData = reactive({
  181. data: {},
  182. });
  183. const formOption = reactive({
  184. inline: true,
  185. labelWidth: 100,
  186. itemWidth: 100,
  187. rules: [],
  188. });
  189. const byform = ref(null);
  190. const treeListData = ref([]);
  191. const formConfig = computed(() => {
  192. return [
  193. {
  194. type: "select",
  195. label: "功能模块",
  196. prop: "titleTemplate",
  197. isLoad: {
  198. url: `/flowInfo/getClassifyList`,
  199. labelKey: "stringArray",
  200. labelVal: "stringArray",
  201. method: "post",
  202. resUrl: "",
  203. },
  204. fn: (data) => {
  205. getFlowList(data);
  206. },
  207. },
  208. {
  209. type: "select",
  210. label: "流程名称",
  211. prop: "flowInfoId",
  212. data: [],
  213. },
  214. ];
  215. });
  216. const getFlowList = (name) => {
  217. proxy
  218. .post("/flowInfo/page", {
  219. pageNum: 1,
  220. pageSize: 1000,
  221. status: 1,
  222. classifyName: name,
  223. })
  224. .then((message) => {
  225. formConfig.value[1].data = message.rows.map((item) => {
  226. return {
  227. label: item.flowName,
  228. value: item.id,
  229. };
  230. });
  231. });
  232. };
  233. const newPassword = () => {
  234. formData.data.password = generatePassword();
  235. };
  236. const generatePassword = () => {
  237. var length = 12,
  238. charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
  239. password = "";
  240. for (var i = 0, n = charset.length; i < length; ++i) {
  241. password += charset.charAt(Math.floor(Math.random() * n));
  242. }
  243. return password;
  244. };
  245. const getTreeList = () => {
  246. proxy.post("/tenantInfo/list").then((message) => {
  247. message.map((item) => {
  248. item.label = item.enterpriseName;
  249. item.id = item.tenantId;
  250. item.children = [];
  251. });
  252. treeListData.value = message;
  253. console.log(treeListData.value);
  254. });
  255. };
  256. const getList = async (req) => {
  257. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  258. loading.value = true;
  259. proxy
  260. .post("/flowDefinition/page", sourceList.value.pagination)
  261. .then((message) => {
  262. sourceList.value.data = message.rows;
  263. sourceList.value.pagination.total = message.total;
  264. setTimeout(() => {
  265. loading.value = false;
  266. }, 200);
  267. });
  268. };
  269. const treeChange = (e) => {
  270. console.log(e);
  271. sourceList.value.pagination.tenantId = e.id;
  272. getList({ tenantId: e.id });
  273. };
  274. const openModal = () => {
  275. dialogVisible.value = true;
  276. modalType.value = "add";
  277. formData.data = {
  278. userType: 1,
  279. };
  280. };
  281. const TreetenantId = ref("");
  282. const selection = ref({
  283. data: [],
  284. });
  285. const select = (_selection, row) => {
  286. selection.value.data = _selection;
  287. console.log(_selection.length);
  288. };
  289. const tree = ref(null);
  290. const submitForm = () => {
  291. byform.value.handleSubmit((valid) => {
  292. proxy
  293. .post("/flowDefinition/" + modalType.value, {
  294. ...formData.data,
  295. tenantId: sourceList.value.pagination.tenantId,
  296. })
  297. .then((res) => {
  298. ElMessage({
  299. message: modalType.value == "add" ? "添加成功" : "编辑成功",
  300. type: "success",
  301. });
  302. dialogVisible.value = false;
  303. getList();
  304. });
  305. });
  306. };
  307. const getDept = () => {
  308. proxy.get("/system/user/deptTree").then((res) => {
  309. //formConfig.value[0].data = res.data
  310. });
  311. };
  312. const router = useRouter();
  313. const getDtl = (row) => {
  314. formData.data = { ...row };
  315. router.push({
  316. path: "processChart",
  317. query: {
  318. id: row.id,
  319. flowInfoId: row.flowInfoId,
  320. tenantId: row.tenantId,
  321. },
  322. });
  323. };
  324. getTreeList();
  325. getList();
  326. </script>
  327. <style lang="scss" scoped>
  328. .user {
  329. padding: 10px;
  330. display: flex;
  331. justify-content: space-between;
  332. .tree {
  333. width: 300px;
  334. }
  335. .content {
  336. width: calc(100% - 310px);
  337. }
  338. }
  339. </style>