processSubmitDialog.vue 14 KB

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