processSubmitDialog.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518
  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"
  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 v-click-once type="primary" size="small" @click="submit" :loading="loading"
  143. >提交</el-button
  144. >
  145. <el-button
  146. v-if="isNotNeedProcess && $hasPermission('eom:common:submitrelease')"
  147. type="primary"
  148. size="small"
  149. @click="submit1"
  150. v-click-once
  151. >提交并发布</el-button
  152. >
  153. <el-button v-click-once size="small" @click="isCloseRefresh ? cancel() : cancel1()">关闭</el-button>
  154. </div>
  155. </ele-modal>
  156. </template>
  157. <script>
  158. import {
  159. getModelPage,
  160. getProcessDefinitionBpmnXML,
  161. getProcessDefinitionInfo,
  162. getTaskAssignRuleList,
  163. listAllUserBind,
  164. listSimpleUserGroups,
  165. processInstanceCreateAPI,
  166. businessOpportunityUpdateStatusAPI,
  167. quoteUpdateStatusAPI,
  168. purchaserequirementStatusAPI,
  169. purchaseplanStatusAPI,
  170. purchaseinquiryStatusAPI,
  171. contractStatusAPI,
  172. finfeeapplyStatusAPI,
  173. fininvoiceapplyStatusAPI,
  174. logistictrakplanStatusAPI,
  175. purchaseorderStatusAPI
  176. } from './api';
  177. import { treeClassifyCodeEnum } from '@/enum/dict';
  178. import { listRoles } from '@/api/system/role';
  179. import { listOrganizations } from '@/api/system/organization';
  180. import dictMixins from '@/mixins/dictMixins';
  181. import { getByCode } from '@/api/system/dictionary-data';
  182. import { getProduceTreeByCode } from '@/api/saleManage/quotation';
  183. import { topLevel1, topLevel2 } from '@/enum/dict';
  184. export default {
  185. name: 'processSubmitDialog',
  186. mixins: [dictMixins],
  187. props: {
  188. processSubmitDialogFlag: {
  189. type: Boolean,
  190. default: false
  191. },
  192. isNotNeedProcess: {
  193. type: Boolean,
  194. default: false
  195. },
  196. isSpecialeSubmit: {
  197. type: Boolean,
  198. default: false
  199. },
  200. approvalStatus: {
  201. type: Number,
  202. default: 2
  203. },
  204. apiFunName: {
  205. type: String,
  206. default: ''
  207. },
  208. callBack: {
  209. type: Function,
  210. default: null
  211. },
  212. // 关闭弹窗时是否刷新列表
  213. isCloseRefresh: {
  214. type: Boolean,
  215. default: true
  216. },
  217. },
  218. data() {
  219. return {
  220. form: {
  221. LCFL: '',
  222. FQLC: '',
  223. processDefinitionId: '',
  224. name: '',
  225. businessId: '',
  226. noticeScope: [],
  227. businessKey: '',
  228. formCreateUserId: '',
  229. variables: {}
  230. },
  231. businessOpportunityUpdateStatusAPI,
  232. quoteUpdateStatusAPI,
  233. purchaserequirementStatusAPI,
  234. purchaseplanStatusAPI,
  235. purchaseinquiryStatusAPI,
  236. contractStatusAPI,
  237. finfeeapplyStatusAPI,
  238. fininvoiceapplyStatusAPI,
  239. logistictrakplanStatusAPI,
  240. purchaseorderStatusAPI,
  241. active: 0,
  242. loading: false,
  243. bpmnXML: null,
  244. LCFLList: [],
  245. processList: [],
  246. datasource: [],
  247. roleOptions: [],
  248. deptOptions: [],
  249. deptTreeOptions: [],
  250. postOptions: [],
  251. userOptions: [],
  252. userGroupOptions: [],
  253. dictList: {},
  254. rules: {}
  255. };
  256. },
  257. async created() {
  258. let typeObj = await getProduceTreeByCode(
  259. treeClassifyCodeEnum['PROCESSTYPE']
  260. );
  261. this.LCFLList = typeObj[0].children;
  262. // 获得角色列表
  263. this.roleOptions = [];
  264. listRoles({
  265. current: 1,
  266. size: 9999
  267. }).then((data) => {
  268. this.roleOptions.push(...data.list);
  269. });
  270. // 获得部门列表
  271. this.deptOptions = [];
  272. this.deptTreeOptions = [];
  273. listOrganizations().then((data) => {
  274. this.deptOptions.push(...data);
  275. this.deptTreeOptions.push(...this.handleTree(data, 'id'));
  276. });
  277. // 获得岗位列表 暂无岗位概念
  278. this.postOptions = [];
  279. /*listSimplePosts().then(response => {
  280. this.postOptions.push(...response.data);
  281. });*/
  282. // 获得用户列表
  283. this.userOptions = [];
  284. listAllUserBind().then((data) => {
  285. this.userOptions.push(...data);
  286. });
  287. // 获得用户组列表
  288. this.userGroupOptions = [];
  289. listSimpleUserGroups().then((response) => {
  290. this.userGroupOptions.push(...response);
  291. });
  292. //this.dictEnum['工作流任务分配自定义脚本']
  293. await this.getDictList(this.dictEnum['工作流任务分配自定义脚本']);
  294. await this.getDictList(this.dictEnum['工种类型']);
  295. },
  296. methods: {
  297. init(row = {}) {
  298. this.form = { ...this.form, ...row };
  299. console.log(row)
  300. // this.form.businessId = row.id;
  301. // this.form.businessKey = row.businessKey;
  302. // this.form.formCreateUserId = row.createUserId;
  303. this.getDefaultInfo(row.businessKey);
  304. },
  305. async getDefaultInfo(businessKey) {
  306. let info = await getProcessDefinitionInfo({ code: businessKey });
  307. this.form.LCFL = info?.category;
  308. this.form.FQLC = info?.modelId;
  309. this.form.name = info?.name;
  310. this.form.key = info?.key;
  311. this.form.processDefinitionId = info?.id;
  312. if (this.form.LCFL) await this.getProcessList(this.form.LCFL);
  313. if (this.form.FQLC) {
  314. await this.getProcessDefinitionBpmnXMLInfo(info.id);
  315. await this.getTaskAssignRuleListInfo({
  316. modelId: info.modelId,
  317. processDefinitionId: info.id
  318. });
  319. }
  320. },
  321. async changeLCFL(val) {
  322. this.bpmnXML = null;
  323. this.form.processDefinitionId = null;
  324. this.form.FQLC = null;
  325. await this.getProcessList(val);
  326. },
  327. async getProcessList(val) {
  328. let params = {
  329. pageNo: 1,
  330. pageSize: 999,
  331. processTypeId: val
  332. };
  333. const { list } = await getModelPage(params);
  334. this.processList = list.filter((item) => item.processDefinition);
  335. },
  336. async changeFQLC(val) {
  337. if (!val) return;
  338. let find = this.processList.find((item) => item.id === val) || {};
  339. this.form.name = find.name;
  340. this.form.key = find.key;
  341. this.form.processDefinitionId = find.processDefinition.id;
  342. await this.getProcessDefinitionBpmnXMLInfo(find.processDefinition.id);
  343. await this.getTaskAssignRuleListInfo({
  344. modelId: find.id,
  345. processDefinitionId: find.processDefinition.id
  346. });
  347. },
  348. async getProcessDefinitionBpmnXMLInfo(val) {
  349. // 加载流程图
  350. this.bpmnXML = await getProcessDefinitionBpmnXML(val);
  351. },
  352. async getTaskAssignRuleListInfo(find) {
  353. this.datasource = await getTaskAssignRuleList({
  354. modelId: find.modelId,
  355. processDefinitionId: find.processDefinitionId
  356. });
  357. },
  358. getAssignRuleOptionName(row, option) {
  359. console.log(row, option);
  360. if (row.type == 10) {
  361. for (const roleOption of this.roleOptions) {
  362. if (roleOption.id === option) {
  363. return roleOption.name;
  364. }
  365. }
  366. } else if (row.type === 20 || row.type === 21) {
  367. for (const deptOption of this.deptOptions) {
  368. if (deptOption.id === option) {
  369. return deptOption.name;
  370. }
  371. }
  372. } else if (row.type === 22) {
  373. option = option + ''; // 转换成 string
  374. return this.getDictV(this.dictEnum['工种类型'], option);
  375. } else if (row.type === 30 || row.type === 31 || row.type === 32) {
  376. for (const userOption of this.userOptions) {
  377. if (userOption.id === option) {
  378. return userOption.nickname || userOption.name;
  379. }
  380. }
  381. } else if (row.type === 40) {
  382. for (const userGroupOption of this.userGroupOptions) {
  383. if (userGroupOption.id === option) {
  384. return userGroupOption.name;
  385. }
  386. }
  387. } else if (row.type === 50) {
  388. option = option + ''; // 转换成 string
  389. return this.getDictV(
  390. this.dictEnum['工作流任务分配自定义脚本'],
  391. option
  392. );
  393. } else if (row.type === 60) {
  394. return row.variableName;
  395. } else if (row.type === 70) {
  396. let data = JSON.parse(row.variableName);
  397. if (data.direction == 1) {
  398. return topLevel2.find((item) => item.value == data.topLevel)
  399. ?.label;
  400. } else {
  401. return topLevel1.find((item) => item.value == data.topLevel)
  402. ?.label;
  403. }
  404. }
  405. return '未知(' + option + ')';
  406. },
  407. /**
  408. * 构造树型结构数据
  409. * @param {*} data 数据源
  410. * @param {*} id id字段 默认 'id'
  411. * @param {*} parentId 父节点字段 默认 'parentId'
  412. * @param {*} children 孩子节点字段 默认 'children'
  413. * @param {*} rootId 根Id 默认 0
  414. */
  415. handleTree(data, id, parentId, children, rootId) {
  416. id = id || 'id';
  417. parentId = parentId || 'parentId';
  418. children = children || 'children';
  419. rootId =
  420. rootId ||
  421. Math.min.apply(
  422. Math,
  423. data.map((item) => {
  424. return item[parentId];
  425. })
  426. ) ||
  427. 0;
  428. //对源数据深度克隆
  429. const cloneData = JSON.parse(JSON.stringify(data));
  430. //循环所有项
  431. const treeData = cloneData.filter((father) => {
  432. let branchArr = cloneData.filter((child) => {
  433. //返回每一项的子级数组
  434. return father[id] == child[parentId];
  435. });
  436. branchArr.length > 0 ? (father.children = branchArr) : '';
  437. //返回第一层
  438. return father[parentId] == rootId;
  439. });
  440. return treeData !== '' ? treeData : data;
  441. },
  442. getDictV(code, val) {
  443. if (!this.dictList[code]) return '';
  444. return this.dictList[code].find((item) => item.value == val)?.label;
  445. },
  446. async getDictList(code) {
  447. let { data: res } = await getByCode(code);
  448. this.dictList[code] = res.map((item) => {
  449. let values = Object.keys(item);
  450. return {
  451. value: values[0],
  452. label: item[values[0]]
  453. };
  454. });
  455. },
  456. async submit() {
  457. let code = 0;
  458. if (this.callBack) {
  459. code = await this.callBack();
  460. }
  461. if (code != 0) {
  462. return;
  463. }
  464. this.loading = true;
  465. try {
  466. console.log(this.form)
  467. let params = {
  468. ...this.form,
  469. variables: {
  470. // businessName: data.supplierName,
  471. ...this.form.variables
  472. }
  473. };
  474. if(this.isSpecialeSubmit) {
  475. console.log('特殊提交', params)
  476. this.$emit('specialesubmit', params);
  477. } else {
  478. await processInstanceCreateAPI(params);
  479. this.loading = false;
  480. this.$message('提交审核成功');
  481. // this.$emit('reload');
  482. this.cancel();
  483. }
  484. } catch (error) {
  485. console.error('提交审批失败', error);
  486. }
  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>