processSubmitDialog.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  1. <template>
  2. <ele-modal
  3. custom-class="ele-dialog-form long-dialog-form"
  4. :centered="true"
  5. :visible="processSubmitDialogFlag"
  6. title="提交审核"
  7. append-to-body
  8. :close-on-click-modal="false"
  9. width="50%"
  10. :before-close="isCloseRefresh ? cancel : cancel1"
  11. :maxable="true"
  12. :resizable="true"
  13. >
  14. <el-form
  15. ref="form"
  16. :rules="rules"
  17. class="el-form-box"
  18. :model="form"
  19. label-width="80px"
  20. >
  21. <el-row v-show="active == 0">
  22. <el-col :span="12">
  23. <el-form-item label="流程分类">
  24. <ele-tree-select
  25. @change="changeLCFL"
  26. clearable
  27. ref="processTypeRef"
  28. filterable
  29. :data="LCFLList"
  30. v-model="form.LCFL"
  31. childrenKey="children"
  32. valueKey="id"
  33. labelKey="name"
  34. placeholder="请选择"
  35. default-expand-all
  36. />
  37. </el-form-item>
  38. </el-col>
  39. <el-col :span="12">
  40. <el-form-item label="发起流程">
  41. <el-select
  42. filterable
  43. v-model="form.FQLC"
  44. @change="changeFQLC"
  45. style="width: 100%"
  46. >
  47. <el-option
  48. v-for="item in processList"
  49. :key="item.id"
  50. :value="item.id"
  51. :label="item.name"
  52. ></el-option>
  53. </el-select>
  54. </el-form-item>
  55. </el-col>
  56. </el-row>
  57. <el-row v-show="active == 0">
  58. <el-col :span="12">
  59. <el-form-item label="流程名称">
  60. <el-input v-model="form.name" clearable></el-input>
  61. </el-form-item>
  62. </el-col>
  63. <el-col :span="12">
  64. <el-form-item label="流程标识">
  65. <el-input v-model="form.key" disabled></el-input>
  66. </el-form-item>
  67. </el-col>
  68. </el-row>
  69. <headerTitle
  70. v-show="active == 0"
  71. title="流程执行人/流程图"
  72. style="margin-top: 30px"
  73. ></headerTitle>
  74. <el-table
  75. v-show="active == 0"
  76. :data="datasource"
  77. border
  78. style="margin-bottom: 10px"
  79. >
  80. <el-table-column
  81. label="任务节点"
  82. align="center"
  83. prop="taskDefinitionName"
  84. width="140"
  85. fixed
  86. />
  87. <el-table-column
  88. label="执行人"
  89. align="center"
  90. prop="options"
  91. min-width="140px"
  92. >
  93. <template v-slot="scope">
  94. <div
  95. v-if="
  96. scope.row.type !== 60 &&
  97. scope.row.type !== 70 &&
  98. scope.row.options.length > 0
  99. "
  100. >
  101. <el-tag
  102. size="medium"
  103. :key="option"
  104. v-for="option in scope.row.options"
  105. >
  106. {{ getAssignRuleOptionName(scope.row, option) }}
  107. </el-tag>
  108. </div>
  109. <el-tag
  110. size="medium"
  111. v-if="scope.row.type === 60 || scope.row.type === 70 || scope.row.type === 90"
  112. >
  113. {{ getAssignRuleOptionName(scope.row) }}
  114. </el-tag>
  115. </template>
  116. </el-table-column>
  117. </el-table>
  118. <my-process-viewer
  119. v-show="active == 0"
  120. style="min-width: 100%; height: 200px"
  121. key="designer"
  122. v-model="bpmnXML"
  123. />
  124. <el-table v-show="active == 1" :data="form.noticeScope" border>
  125. <el-table-column
  126. label="类型"
  127. align="center"
  128. prop="taskDefinitionName"
  129. width="140"
  130. fixed
  131. />
  132. <el-table-column
  133. label="结果"
  134. align="center"
  135. prop="options"
  136. min-width="140px"
  137. >
  138. </el-table-column>
  139. </el-table>
  140. </el-form>
  141. <div slot="footer">
  142. <el-button type="primary" size="small" @click="submit" :loading="loading"
  143. >提交</el-button
  144. >
  145. <el-button
  146. v-if="isNotNeedProcess && $hasPermission('main:common:submitrelease')"
  147. type="primary"
  148. size="small"
  149. @click="submit1"
  150. v-click-once
  151. >提交并发布</el-button
  152. >
  153. <el-button size="small" @click="isCloseRefresh ? cancel() : cancel1()"
  154. >关闭</el-button
  155. >
  156. </div>
  157. </ele-modal>
  158. </template>
  159. <script>
  160. import {
  161. getModelPage,
  162. getProcessDefinitionBpmnXML,
  163. getProcessDefinitionInfo,
  164. getTaskAssignRuleList,
  165. listAllUserBind,
  166. listSimpleUserGroups,
  167. processInstanceCreateAPI,
  168. businessOpportunityUpdateStatusAPI,
  169. quoteUpdateStatusAPI,
  170. purchaserequirementStatusAPI,
  171. purchaseplanStatusAPI,
  172. purchaseinquiryStatusAPI,
  173. contractStatusAPI,
  174. finfeeapplyStatusAPI,
  175. fininvoiceapplyStatusAPI,
  176. logistictrakplanStatusAPI
  177. } from './api';
  178. import { treeClassifyCodeEnum } from '@/enum/dict';
  179. import { listRoles } from '@/api/system/role';
  180. import { listOrganizations } from '@/api/system/organization';
  181. import dictMixins from '@/mixins/dictMixins';
  182. import { getByCode } from '@/api/system/dictionary-data';
  183. import { getProduceTreeByCode } from '@/api/main/index.js';
  184. import { topLevel1, topLevel2 } from '@/enum/dict';
  185. export default {
  186. name: 'processSubmitDialog',
  187. mixins: [dictMixins],
  188. props: {
  189. processSubmitDialogFlag: {
  190. type: Boolean,
  191. default: false
  192. },
  193. isNotNeedProcess: {
  194. type: Boolean,
  195. default: false
  196. },
  197. approvalStatus: {
  198. type: Number,
  199. default: 2
  200. },
  201. apiFunName: {
  202. type: String,
  203. default: ''
  204. },
  205. callBack: {
  206. type: Function,
  207. default: null
  208. },
  209. // 关闭弹窗时是否刷新列表
  210. isCloseRefresh: {
  211. type: Boolean,
  212. default: true
  213. }
  214. },
  215. data() {
  216. return {
  217. form: {
  218. LCFL: '',
  219. FQLC: '',
  220. processDefinitionId: '',
  221. name: '',
  222. businessId: '',
  223. noticeScope: [],
  224. businessKey: '',
  225. formCreateUserId: '',
  226. variables: {}
  227. },
  228. businessOpportunityUpdateStatusAPI,
  229. quoteUpdateStatusAPI,
  230. purchaserequirementStatusAPI,
  231. purchaseplanStatusAPI,
  232. purchaseinquiryStatusAPI,
  233. contractStatusAPI,
  234. finfeeapplyStatusAPI,
  235. fininvoiceapplyStatusAPI,
  236. logistictrakplanStatusAPI,
  237. active: 0,
  238. loading: false,
  239. bpmnXML: null,
  240. LCFLList: [],
  241. processList: [],
  242. datasource: [],
  243. roleOptions: [],
  244. deptOptions: [],
  245. deptTreeOptions: [],
  246. postOptions: [],
  247. userOptions: [],
  248. userGroupOptions: [],
  249. dictList: {},
  250. rules: {}
  251. };
  252. },
  253. async created() {
  254. let typeObj = await getProduceTreeByCode(
  255. treeClassifyCodeEnum['PROCESSTYPE']
  256. );
  257. this.LCFLList = typeObj[0].children;
  258. // 获得角色列表
  259. this.roleOptions = [];
  260. listRoles({
  261. current: 1,
  262. size: 9999
  263. }).then((data) => {
  264. this.roleOptions.push(...data.list);
  265. });
  266. // 获得部门列表
  267. this.deptOptions = [];
  268. this.deptTreeOptions = [];
  269. listOrganizations().then((data) => {
  270. this.deptOptions.push(...data);
  271. this.deptTreeOptions.push(...this.handleTree(data, 'id'));
  272. });
  273. // 获得岗位列表 暂无岗位概念
  274. this.postOptions = [];
  275. /*listSimplePosts().then(response => {
  276. this.postOptions.push(...response.data);
  277. });*/
  278. // 获得用户列表
  279. this.userOptions = [];
  280. listAllUserBind().then((data) => {
  281. this.userOptions.push(...data);
  282. });
  283. // 获得用户组列表
  284. this.userGroupOptions = [];
  285. listSimpleUserGroups().then((response) => {
  286. this.userGroupOptions.push(...response);
  287. });
  288. //this.dictEnum['工作流任务分配自定义脚本']
  289. await this.getDictList(this.dictEnum['工作流任务分配自定义脚本']);
  290. await this.getDictList(this.dictEnum['工种类型']);
  291. },
  292. methods: {
  293. init(row = {}) {
  294. this.form = { ...this.form, ...row };
  295. console.log(row);
  296. // this.form.businessId = row.id;
  297. // this.form.businessKey = row.businessKey;
  298. // this.form.formCreateUserId = row.createUserId;
  299. this.getDefaultInfo(row.businessKey);
  300. },
  301. async getDefaultInfo(businessKey) {
  302. let info = await getProcessDefinitionInfo({ code: businessKey });
  303. this.form.LCFL = info?.category;
  304. this.form.FQLC = info?.modelId;
  305. this.form.name = info?.name;
  306. this.form.key = info?.key;
  307. this.form.processDefinitionId = info?.id;
  308. if (this.form.LCFL) await this.getProcessList(this.form.LCFL);
  309. if (this.form.FQLC) {
  310. await this.getProcessDefinitionBpmnXMLInfo(info.id);
  311. await this.getTaskAssignRuleListInfo({
  312. modelId: info.modelId,
  313. processDefinitionId: info.id
  314. });
  315. }
  316. },
  317. async changeLCFL(val) {
  318. this.bpmnXML = null;
  319. this.form.processDefinitionId = null;
  320. this.form.FQLC = null;
  321. await this.getProcessList(val);
  322. },
  323. async getProcessList(val) {
  324. let params = {
  325. pageNo: 1,
  326. pageSize: 999,
  327. processTypeId: val
  328. };
  329. const { list } = await getModelPage(params);
  330. this.processList = list.filter((item) => item.processDefinition);
  331. },
  332. async changeFQLC(val) {
  333. if (!val) return;
  334. let find = this.processList.find((item) => item.id === val) || {};
  335. this.form.name = find.name;
  336. this.form.key = find.key;
  337. this.form.processDefinitionId = find.processDefinition.id;
  338. await this.getProcessDefinitionBpmnXMLInfo(find.processDefinition.id);
  339. await this.getTaskAssignRuleListInfo({
  340. modelId: find.id,
  341. processDefinitionId: find.processDefinition.id
  342. });
  343. },
  344. async getProcessDefinitionBpmnXMLInfo(val) {
  345. // 加载流程图
  346. this.bpmnXML = await getProcessDefinitionBpmnXML(val);
  347. },
  348. async getTaskAssignRuleListInfo(find) {
  349. this.datasource = await getTaskAssignRuleList({
  350. modelId: find.modelId,
  351. processDefinitionId: find.processDefinitionId
  352. });
  353. },
  354. getAssignRuleOptionName(row, option) {
  355. console.log(row, option);
  356. if (row.type == 10) {
  357. for (const roleOption of this.roleOptions) {
  358. if (roleOption.id === option) {
  359. return roleOption.name;
  360. }
  361. }
  362. } else if (row.type == 11) {
  363. for (const roleOption of this.roleOptions) {
  364. if (roleOption.id === option) {
  365. return roleOption.name;
  366. }
  367. }
  368. } else if (row.type === 20 || row.type === 21) {
  369. for (const deptOption of this.deptOptions) {
  370. if (deptOption.id === option) {
  371. return deptOption.name;
  372. }
  373. }
  374. } else if (row.type === 22) {
  375. option = option + ''; // 转换成 string
  376. return this.getDictV(this.dictEnum['工种类型'], option);
  377. } else if (row.type === 30 || row.type === 31 || row.type === 32) {
  378. for (const userOption of this.userOptions) {
  379. if (userOption.id === option) {
  380. return userOption.nickname || userOption.name;
  381. }
  382. }
  383. } else if (row.type === 40) {
  384. for (const userGroupOption of this.userGroupOptions) {
  385. if (userGroupOption.id === option) {
  386. return userGroupOption.name;
  387. }
  388. }
  389. } else if (row.type === 50) {
  390. option = option + ''; // 转换成 string
  391. return this.getDictV(
  392. this.dictEnum['工作流任务分配自定义脚本'],
  393. option
  394. );
  395. } else if (row.type === 60) {
  396. return row.variableName;
  397. } else if (row.type === 70) {
  398. let data = JSON.parse(row.variableName);
  399. if (data.direction == 1) {
  400. return topLevel2.find((item) => item.value == data.topLevel)?.label;
  401. } else {
  402. return topLevel1.find((item) => item.value == data.topLevel)?.label;
  403. }
  404. } else if (row.type === 90) {
  405. try {
  406. const cfg = row.ruleConfig ? JSON.parse(row.ruleConfig) : {};
  407. return (cfg.fieldLabel || cfg.field || '表单字段') + ' → ' + (cfg.strategy || '');
  408. } catch (e) {
  409. return '表单字段驱动审批人';
  410. }
  411. }
  412. return '未知(' + option + ')';
  413. },
  414. /**
  415. * 构造树型结构数据
  416. * @param {*} data 数据源
  417. * @param {*} id id字段 默认 'id'
  418. * @param {*} parentId 父节点字段 默认 'parentId'
  419. * @param {*} children 孩子节点字段 默认 'children'
  420. * @param {*} rootId 根Id 默认 0
  421. */
  422. handleTree(data, id, parentId, children, rootId) {
  423. id = id || 'id';
  424. parentId = parentId || 'parentId';
  425. children = children || 'children';
  426. rootId =
  427. rootId ||
  428. Math.min.apply(
  429. Math,
  430. data.map((item) => {
  431. return item[parentId];
  432. })
  433. ) ||
  434. 0;
  435. //对源数据深度克隆
  436. const cloneData = JSON.parse(JSON.stringify(data));
  437. //循环所有项
  438. const treeData = cloneData.filter((father) => {
  439. let branchArr = cloneData.filter((child) => {
  440. //返回每一项的子级数组
  441. return father[id] == child[parentId];
  442. });
  443. branchArr.length > 0 ? (father.children = branchArr) : '';
  444. //返回第一层
  445. return father[parentId] == rootId;
  446. });
  447. return treeData !== '' ? treeData : data;
  448. },
  449. getDictV(code, val) {
  450. if (!this.dictList[code]) return '';
  451. return this.dictList[code].find((item) => item.value == val)?.label;
  452. },
  453. async getDictList(code) {
  454. let { data: res } = await getByCode(code);
  455. this.dictList[code] = res.map((item) => {
  456. let values = Object.keys(item);
  457. return {
  458. value: values[0],
  459. label: item[values[0]]
  460. };
  461. });
  462. },
  463. async submit() {
  464. let code = 0;
  465. if (this.callBack) {
  466. code = await this.callBack();
  467. }
  468. if (code != 0) {
  469. return;
  470. }
  471. this.loading = true;
  472. try {
  473. console.log(this.form);
  474. let params = {
  475. ...this.form,
  476. variables: {
  477. // businessName: data.supplierName,
  478. ...this.form.variables
  479. }
  480. };
  481. await processInstanceCreateAPI(params);
  482. this.loading = false;
  483. this.$message('提交审核成功');
  484. // this.$emit('reload');
  485. this.cancel();
  486. } catch (error) {}
  487. this.loading = false;
  488. },
  489. async submit1() {
  490. let params = {
  491. id: this.form.businessId,
  492. approvalStatus: this.approvalStatus,
  493. ...this.form
  494. };
  495. await this[this.apiFunName](params);
  496. //await processInstanceUpdateStatusAPI(params);
  497. this.$message('提交发布成功');
  498. // this.$emit('reload');
  499. this.cancel();
  500. },
  501. cancel() {
  502. this.$emit('reload');
  503. this.$emit('update:processSubmitDialogFlag', false);
  504. },
  505. cancel1() {
  506. this.$emit('update:processSubmitDialogFlag', false);
  507. }
  508. }
  509. };
  510. </script>
  511. <style scoped lang="scss"></style>