taskAssignRuleDialog.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807
  1. <template>
  2. <div>
  3. <!-- 列表弹窗 -->
  4. <el-dialog
  5. title="任务分配规则"
  6. :visible.sync="visible"
  7. width="800px"
  8. append-to-body
  9. >
  10. <el-table v-loading="loading" :data="list">
  11. <el-table-column
  12. label="任务名"
  13. align="center"
  14. prop="taskDefinitionName"
  15. width="120"
  16. fixed
  17. />
  18. <el-table-column
  19. label="任务标识"
  20. align="center"
  21. prop="taskDefinitionKey"
  22. width="120"
  23. show-tooltip-when-overflow
  24. />
  25. <el-table-column
  26. label="规则类型"
  27. align="center"
  28. prop="type"
  29. width="120"
  30. >
  31. <template v-slot="scope">
  32. {{ getDictValue('工作流任务分配规则的类型', scope.row.type + '') }}
  33. </template>
  34. </el-table-column>
  35. <el-table-column
  36. label="规则范围"
  37. align="center"
  38. prop="options"
  39. width="440px"
  40. >
  41. <template v-slot="scope">
  42. <el-tag
  43. size="medium"
  44. v-if="scope.row.type !== 60 && scope.row.options.length > 0"
  45. :key="option"
  46. v-for="option in scope.row.options"
  47. >
  48. {{ getAssignRuleOptionName(scope.row, option) }}
  49. </el-tag>
  50. <el-tag
  51. size="medium"
  52. v-if="
  53. scope.row.type === 60 ||
  54. scope.row.type === 70 ||
  55. scope.row.type === 80
  56. "
  57. >
  58. {{ getAssignRuleOptionName(scope.row) }}
  59. </el-tag>
  60. </template>
  61. </el-table-column>
  62. <el-table-column
  63. v-if="modelId"
  64. label="操作"
  65. align="center"
  66. width="250"
  67. fixed="right"
  68. >
  69. <template v-slot="scope">
  70. <el-button
  71. size="mini"
  72. type="text"
  73. icon="el-icon-edit"
  74. @click="handleUpdateTaskAssignRule(scope.row)"
  75. >修改任务规则</el-button
  76. >
  77. <el-button
  78. size="mini"
  79. type="text"
  80. icon="el-icon-edit"
  81. @click="ccHandleUpdateTaskAssignRule(scope.row)"
  82. >修改抄送规则</el-button
  83. >
  84. </template>
  85. </el-table-column>
  86. </el-table>
  87. </el-dialog>
  88. <!-- 添加/修改弹窗 -->
  89. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  90. <el-form
  91. ref="taskAssignRuleForm"
  92. :model="form"
  93. :rules="rules"
  94. label-width="110px"
  95. >
  96. <el-form-item label="任务名称" prop="taskDefinitionName">
  97. <el-input v-model="form.taskDefinitionName" disabled />
  98. </el-form-item>
  99. <el-form-item label="任务标识" prop="taskDefinitionKey">
  100. <el-input v-model="form.taskDefinitionKey" disabled />
  101. </el-form-item>
  102. <el-form-item label="规则类型" prop="typeS">
  103. <el-select
  104. v-model="form.typeS"
  105. clearable
  106. style="width: 100%"
  107. @change="emptyingRules"
  108. >
  109. <el-option
  110. v-for="dict in this.dict[
  111. this.dictEnum['工作流任务分配规则的类型']
  112. ] || []"
  113. :key="parseInt(dict.dictCode)"
  114. :label="dict.dictValue"
  115. :value="parseInt(dict.dictCode)"
  116. />
  117. </el-select>
  118. </el-form-item>
  119. <el-form-item v-if="form.typeS === 10" label="指定角色" prop="roleIds">
  120. <el-select
  121. v-model="form.roleIds"
  122. multiple
  123. clearable
  124. style="width: 100%"
  125. >
  126. <el-option
  127. v-for="item in roleOptions"
  128. :key="item.id"
  129. :label="item.name"
  130. :value="item.id"
  131. />
  132. </el-select>
  133. </el-form-item>
  134. <el-form-item
  135. v-if="form.typeS === 20 || form.typeS === 21"
  136. label="指定部门"
  137. prop="deptIds"
  138. >
  139. <treeSelect
  140. v-model="form.deptIds"
  141. :options="deptTreeOptions"
  142. multiple
  143. flat
  144. :defaultExpandLevel="3"
  145. placeholder="请选择指定部门"
  146. :normalizer="normalizer"
  147. />
  148. </el-form-item>
  149. <el-form-item
  150. v-if="form.typeS === 22"
  151. label="指定工种"
  152. prop="workTypeIds"
  153. >
  154. <el-select
  155. v-model="form.workTypeIds"
  156. multiple
  157. clearable
  158. style="width: 100%"
  159. >
  160. <el-option
  161. v-for="dict in this.dict[this.dictEnum['工种']] || []"
  162. :key="dict.dictCode"
  163. :label="dict.dictValue"
  164. :value="dict.dictCode"
  165. />
  166. </el-select>
  167. </el-form-item>
  168. <el-form-item
  169. v-if="form.typeS === 30 || form.typeS === 31 || form.typeS === 32"
  170. label="指定用户"
  171. prop="userIds"
  172. >
  173. <el-select
  174. v-model="form.userIds"
  175. multiple
  176. clearable
  177. style="width: 100%"
  178. :filterable="true"
  179. >
  180. <el-option
  181. v-for="item in userOptions"
  182. :key="item.id"
  183. :label="item.name"
  184. :value="item.id"
  185. />
  186. </el-select>
  187. </el-form-item>
  188. <el-form-item
  189. v-if="form.type === 40"
  190. label="指定用户组"
  191. prop="userGroupIds"
  192. >
  193. <el-select
  194. v-model="form.userGroupIds"
  195. multiple
  196. clearable
  197. style="width: 100%"
  198. >
  199. <el-option
  200. v-for="item in userGroupOptions"
  201. :key="item.id"
  202. :label="item.name"
  203. :value="item.id"
  204. />
  205. </el-select>
  206. </el-form-item>
  207. <el-form-item v-if="form.typeS === 50" label="指定脚本" prop="scripts">
  208. <el-select
  209. v-model="form.scripts"
  210. multiple
  211. clearable
  212. style="width: 100%"
  213. >
  214. <el-option
  215. v-for="dict in this.dict[
  216. this.dictEnum['工作流任务分配自定义脚本']
  217. ] || []"
  218. :key="dict.dictCode"
  219. :label="dict.dictValue"
  220. :value="dict.dictCode"
  221. />
  222. </el-select>
  223. </el-form-item>
  224. <el-form-item
  225. v-if="form.typeS === 70 && title != '修改抄送规则'"
  226. label="审核方向"
  227. prop="direction"
  228. >
  229. <el-select
  230. v-model="form.direction"
  231. clearable
  232. style="width: 100%"
  233. @change="handleChangeDirection"
  234. >
  235. <el-option key="0" label="从下到上" value="0" />
  236. <el-option key="1" label="从上到下" value="1" />
  237. </el-select>
  238. </el-form-item>
  239. <el-form-item
  240. v-if="form.typeS === 70 && title != '修改抄送规则'"
  241. label="指定部门负责人"
  242. prop="topLevel"
  243. >
  244. <el-select
  245. v-if="form.direction == 0"
  246. v-model="form.topLevel"
  247. clearable
  248. style="width: 100%"
  249. >
  250. <el-option
  251. v-for="(item, index) in topLevel1"
  252. :key="index"
  253. :label="item.label"
  254. :value="item.value"
  255. />
  256. </el-select>
  257. <el-select
  258. v-else
  259. v-model="form.topLevel"
  260. clearable
  261. style="width: 100%"
  262. >
  263. <el-option
  264. v-for="(item, index) in topLevel2"
  265. :key="index"
  266. :label="item.label"
  267. :value="item.value"
  268. />
  269. </el-select>
  270. </el-form-item>
  271. <el-form-item
  272. v-if="form.typeS === 60"
  273. label="自定义变量"
  274. prop="variableName"
  275. >
  276. <el-input
  277. placeholder="请输入自定义变量名称"
  278. v-model="form.variableName"
  279. clearable
  280. >
  281. </el-input>
  282. </el-form-item>
  283. <el-form-item
  284. v-if="form.typeS === 80 && title != '修改抄送规则'"
  285. label="指定部门负责人"
  286. prop="topLevel"
  287. >
  288. <el-select v-model="form.topLevel" clearable style="width: 100%">
  289. <el-option
  290. v-for="(item, index) in topLevel3"
  291. :key="index"
  292. :label="item.label"
  293. :value="item.value"
  294. />
  295. </el-select>
  296. </el-form-item>
  297. </el-form>
  298. <div slot="footer" class="dialog-footer">
  299. <el-button
  300. type="primary"
  301. @click="submitAssignRuleForm"
  302. v-if="title == '修改任务规则'"
  303. >确 定</el-button
  304. >
  305. <el-button
  306. type="primary"
  307. @click="ccSubmitAssignRuleForm"
  308. v-if="title == '修改抄送规则'"
  309. >确 定</el-button
  310. >
  311. <el-button @click="cancelAssignRuleForm">取 消</el-button>
  312. </div>
  313. </el-dialog>
  314. </div>
  315. </template>
  316. <script>
  317. import dictMixins from '@/mixins/dictMixins';
  318. import {
  319. createTaskAssignRule,
  320. getTaskAssignRuleList,
  321. updateTaskAssignRule
  322. } from '@/api/bpm/taskAssignRule';
  323. import { listRoles } from '@/api/system/role';
  324. import {
  325. listOrganizations,
  326. listAllUserBind
  327. } from '@/api/system/organization';
  328. // import {listSimplePosts} from "@/api/system/post";
  329. import { listSimpleUserGroups } from '@/api/bpm/userGroup';
  330. import { topLevel1, topLevel2, topLevel3 } from '@/enum/dict';
  331. import treeSelect from '@riophae/vue-treeselect';
  332. import '@riophae/vue-treeselect/dist/vue-treeselect.css';
  333. export default {
  334. name: 'BpmTaskAssignRule',
  335. components: {
  336. treeSelect
  337. },
  338. mixins: [dictMixins],
  339. data() {
  340. const varValidator = (rule, value, callback) => {
  341. if (/[a-zA-z]$/.test(value) === false) {
  342. callback(new Error('请输入英文'));
  343. } else {
  344. callback();
  345. }
  346. };
  347. return {
  348. topLevel1,
  349. topLevel2,
  350. topLevel3,
  351. // 如下参数,可传递
  352. modelId: undefined, // 流程模型的编号。如果 modelId 非空,则用于流程模型的查看与配置
  353. processDefinitionId: undefined, // 流程定义的编号。如果 processDefinitionId 非空,则用于流程定义的查看,不支持配置
  354. visible: false,
  355. title: '',
  356. // 任务分配规则表单
  357. row: undefined, // 选中的流程模型
  358. list: [], // 选中流程模型的任务分配规则们
  359. loading: false, // 加载中
  360. open: false, // 是否打开
  361. form: {}, // 表单
  362. rules: {
  363. // 表单校验规则
  364. typeS: [
  365. { required: true, message: '规则类型不能为空', trigger: 'change' }
  366. ],
  367. roleIds: [
  368. { required: true, message: '指定角色不能为空', trigger: 'change' }
  369. ],
  370. deptIds: [
  371. { required: true, message: '指定部门不能为空', trigger: 'change' }
  372. ],
  373. workTypeIds: [
  374. { required: true, message: '指定工种不能为空', trigger: 'change' }
  375. ],
  376. userIds: [
  377. { required: true, message: '指定用户不能为空', trigger: 'change' }
  378. ],
  379. userGroupIds: [
  380. { required: true, message: '指定用户组不能为空', trigger: 'change' }
  381. ],
  382. scripts: [
  383. { required: true, message: '指定脚本不能为空', trigger: 'change' }
  384. ],
  385. direction: [
  386. { required: true, message: '审核方向不能为空', trigger: 'change' }
  387. ],
  388. variableName: [
  389. { required: true, validator: varValidator, trigger: 'blur' }
  390. ]
  391. },
  392. // 各种下拉框
  393. roleOptions: [],
  394. deptOptions: [],
  395. deptTreeOptions: [],
  396. postOptions: [],
  397. userOptions: [],
  398. userGroupOptions: []
  399. };
  400. },
  401. created() {
  402. this.requestDict('工作流任务分配规则的类型');
  403. this.requestDict('工作流任务分配自定义脚本');
  404. this.requestDict('工种');
  405. },
  406. methods: {
  407. initModel(modelId) {
  408. this.modelId = modelId;
  409. this.processDefinitionId = undefined;
  410. // 初始化所有下拉框
  411. this.init0();
  412. },
  413. initProcessDefinition(processDefinitionId) {
  414. this.modelId = undefined;
  415. this.processDefinitionId = processDefinitionId;
  416. // 初始化所有下拉框
  417. this.init0();
  418. },
  419. /** 初始化 */
  420. init0() {
  421. // 设置可见
  422. this.visible = true;
  423. // 获得列表
  424. this.getList();
  425. // 获得角色列表
  426. this.roleOptions = [];
  427. listRoles({
  428. current: 1,
  429. size: 9999
  430. }).then((data) => {
  431. this.roleOptions.push(...data.list);
  432. });
  433. // 获得部门列表
  434. this.deptOptions = [];
  435. this.deptTreeOptions = [];
  436. listOrganizations().then((data) => {
  437. this.deptOptions.push(...data);
  438. this.deptTreeOptions.push(...this.handleTree(data, 'id'));
  439. });
  440. // 获得岗位列表 暂无岗位概念
  441. this.postOptions = [];
  442. /*listSimplePosts().then(response => {
  443. this.postOptions.push(...response.data);
  444. });*/
  445. // 获得用户列表
  446. this.userOptions = [];
  447. listAllUserBind().then((data) => {
  448. this.userOptions.push(...data);
  449. });
  450. // 获得用户组列表
  451. this.userGroupOptions = [];
  452. listSimpleUserGroups().then((response) => {
  453. this.userGroupOptions.push(...response);
  454. });
  455. },
  456. /**
  457. * 构造树型结构数据
  458. * @param {*} data 数据源
  459. * @param {*} id id字段 默认 'id'
  460. * @param {*} parentId 父节点字段 默认 'parentId'
  461. * @param {*} children 孩子节点字段 默认 'children'
  462. * @param {*} rootId 根Id 默认 0
  463. */
  464. handleTree(data, id, parentId, children, rootId) {
  465. id = id || 'id';
  466. parentId = parentId || 'parentId';
  467. children = children || 'children';
  468. rootId =
  469. rootId ||
  470. Math.min.apply(
  471. Math,
  472. data.map((item) => {
  473. return item[parentId];
  474. })
  475. ) ||
  476. 0;
  477. //对源数据深度克隆
  478. const cloneData = JSON.parse(JSON.stringify(data));
  479. //循环所有项
  480. const treeData = cloneData.filter((father) => {
  481. let branchArr = cloneData.filter((child) => {
  482. //返回每一项的子级数组
  483. return father[id] == child[parentId];
  484. });
  485. branchArr.length > 0 ? (father.children = branchArr) : '';
  486. //返回第一层
  487. return father[parentId] == rootId;
  488. });
  489. return treeData !== '' ? treeData : data;
  490. },
  491. /** 获得任务分配规则列表 */
  492. getList() {
  493. this.loading = true;
  494. getTaskAssignRuleList({
  495. modelId: this.modelId,
  496. processDefinitionId: this.processDefinitionId
  497. }).then((data) => {
  498. this.loading = false;
  499. this.list = data;
  500. });
  501. },
  502. // 选择规则清空上一次选择内容
  503. emptyingRules(val) {
  504. if (this.title == '修改任务规则') {
  505. this.form.options = [];
  506. this.form.variableName = '';
  507. this.$set(this.form, 'direction', val == '70' ? '0' : '');
  508. this.$set(this.form, 'topLevel', val == '70' ? '1' : '');
  509. } else {
  510. this.form.ccOptions = [];
  511. this.form.ccVariableName = '';
  512. }
  513. this.form.roleIds = [];
  514. this.form.deptIds = [];
  515. this.form.workTypeIds = [];
  516. this.form.userIds = [];
  517. this.form.userGroupIds = [];
  518. this.form.scripts = [];
  519. },
  520. // 选择规则清空上一次选择内容
  521. handleChangeDirection(val) {
  522. this.$set(this.form, 'topLevel', val == '0' ? '1' : '99');
  523. },
  524. /** 处理修改抄送 分配规则的按钮操作 */
  525. ccHandleUpdateTaskAssignRule(row) {
  526. this.title = '修改抄送规则';
  527. // 先重置标识
  528. this.resetAssignRuleForm();
  529. // 设置表单
  530. this.form = {
  531. ...row,
  532. ccOptions: [],
  533. roleIds: [],
  534. deptIds: [],
  535. workTypeIds: [],
  536. userIds: [],
  537. userGroupIds: [],
  538. scripts: []
  539. };
  540. this.$set(this.form, 'typeS', row.ccType);
  541. // 将 options 赋值到对应的 roleIds 等选项
  542. if (row.ccType === 10) {
  543. this.form.roleIds.push(...row.ccOptions);
  544. } else if (row.ccType === 20 || row.ccType === 21) {
  545. this.form.deptIds.push(...row.ccOptions);
  546. } else if (row.ccType === 22) {
  547. this.form.workTypeIds.push(...row.ccOptions);
  548. } else if (
  549. row.ccType === 30 ||
  550. row.ccType === 31 ||
  551. row.ccType === 32
  552. ) {
  553. this.form.userIds.push(...row.ccOptions);
  554. } else if (row.ccType === 40) {
  555. this.form.userGroupIds.push(...row.ccOptions);
  556. } else if (row.ccType === 50) {
  557. this.form.scripts.push(...row.ccOptions);
  558. }
  559. this.open = true;
  560. },
  561. /** 处理修改任务分配规则的按钮操作 */
  562. handleUpdateTaskAssignRule(row) {
  563. this.title = '修改任务规则';
  564. // 先重置标识
  565. this.resetAssignRuleForm();
  566. // 设置表单
  567. this.form = {
  568. ...row,
  569. options: [],
  570. roleIds: [],
  571. deptIds: [],
  572. workTypeIds: [],
  573. userIds: [],
  574. userGroupIds: [],
  575. scripts: []
  576. };
  577. this.$set(this.form, 'typeS', row.type);
  578. // 将 options 赋值到对应的 roleIds 等选项
  579. if (row.type === 10) {
  580. this.form.roleIds.push(...row.options);
  581. } else if (row.type === 20 || row.type === 21) {
  582. this.form.deptIds.push(...row.options);
  583. } else if (row.type === 22) {
  584. this.form.workTypeIds.push(...row.options);
  585. } else if (row.type === 30 || row.type === 31 || row.type === 32) {
  586. this.form.userIds.push(...row.options);
  587. } else if (row.type === 40) {
  588. this.form.userGroupIds.push(...row.options);
  589. } else if (row.type === 50) {
  590. this.form.scripts.push(...row.options);
  591. } else if (row.type === 70 || row.type === 80) {
  592. let res = row.variableName ? JSON.parse(row.variableName) : {};
  593. this.$set(this.form, 'direction', res.direction);
  594. this.$set(this.form, 'topLevel', res.topLevel);
  595. }
  596. this.open = true;
  597. },
  598. /** 提交任务分配规则的表单 */
  599. submitAssignRuleForm() {
  600. this.$refs['taskAssignRuleForm'].validate((valid) => {
  601. if (valid) {
  602. // 构建表单
  603. this.form.type = this.form.typeS;
  604. let form = {
  605. ...this.form,
  606. taskDefinitionName: undefined
  607. };
  608. // 将 roleIds 等选项赋值到 options 中
  609. if (form.type === 10) {
  610. form.options = form.roleIds;
  611. } else if (form.type === 20 || form.type === 21) {
  612. form.options = form.deptIds;
  613. } else if (form.type === 22) {
  614. form.options = form.workTypeIds;
  615. } else if (
  616. form.type === 30 ||
  617. form.type === 31 ||
  618. form.type === 32
  619. ) {
  620. form.options = form.userIds;
  621. } else if (form.type === 40) {
  622. form.options = form.userGroupIds;
  623. } else if (form.type === 50) {
  624. form.options = form.scripts;
  625. } else if (form.type === 70 || form.type === 80) {
  626. form.variableName = JSON.stringify({
  627. direction: form.direction,
  628. topLevel: form.topLevel
  629. });
  630. }
  631. form.roleIds = undefined;
  632. form.deptIds = undefined;
  633. form.workTypeIds = undefined;
  634. form.userIds = undefined;
  635. form.userGroupIds = undefined;
  636. form.scripts = undefined;
  637. form.direction = undefined;
  638. form.topLevel = undefined;
  639. // 新增
  640. if (!form.id) {
  641. form.modelId = this.modelId; // 模型编号
  642. createTaskAssignRule(form).then((response) => {
  643. this.$message.success('修改成功');
  644. this.open = false;
  645. this.getList();
  646. });
  647. // 修改
  648. } else {
  649. form.taskDefinitionKey = undefined; // 无法修改
  650. updateTaskAssignRule(form).then((response) => {
  651. this.$message.success('修改成功');
  652. this.open = false;
  653. this.getList();
  654. });
  655. }
  656. }
  657. });
  658. },
  659. /** 提交任务分配规则的表单 */
  660. ccSubmitAssignRuleForm() {
  661. this.$refs['taskAssignRuleForm'].validate((valid) => {
  662. if (valid) {
  663. // 构建表单
  664. this.form.ccType = this.form.typeS;
  665. let form = {
  666. ...this.form,
  667. taskDefinitionName: undefined
  668. };
  669. // 将 roleIds 等选项赋值到 options 中
  670. if (form.ccType === 10) {
  671. form.ccOptions = form.roleIds;
  672. console.log(form.ccOptions);
  673. } else if (form.ccType === 20 || form.ccType === 21) {
  674. form.ccOptions = form.deptIds;
  675. } else if (form.ccType === 22) {
  676. form.ccOptions = form.workTypeIds;
  677. } else if (
  678. form.ccType === 30 ||
  679. form.ccType === 31 ||
  680. form.ccType === 32
  681. ) {
  682. form.ccOptions = form.userIds;
  683. } else if (form.ccType === 40) {
  684. form.ccOptions = form.userGroupIds;
  685. } else if (form.ccType === 50) {
  686. form.ccOptions = form.scripts;
  687. }
  688. form.roleIds = undefined;
  689. form.deptIds = undefined;
  690. form.workTypeIds = undefined;
  691. form.userIds = undefined;
  692. form.userGroupIds = undefined;
  693. form.scripts = undefined;
  694. form.direction = undefined;
  695. form.topLevel = undefined;
  696. console.log(form);
  697. // 新增
  698. if (!form.id) {
  699. form.modelId = this.modelId; // 模型编号
  700. createTaskAssignRule(form).then((response) => {
  701. this.$message.success('修改成功');
  702. this.open = false;
  703. this.getList();
  704. });
  705. // 修改
  706. } else {
  707. form.taskDefinitionKey = undefined; // 无法修改
  708. updateTaskAssignRule(form).then((response) => {
  709. this.$message.success('修改成功');
  710. this.open = false;
  711. this.getList();
  712. });
  713. }
  714. }
  715. });
  716. },
  717. /** 取消任务分配规则的表单 */
  718. cancelAssignRuleForm() {
  719. this.resetAssignRuleForm();
  720. this.open = false;
  721. },
  722. /** 表单重置 */
  723. resetAssignRuleForm() {
  724. this.form = {};
  725. this.resetForm('taskAssignRuleForm');
  726. },
  727. getAssignRuleOptionName(row, option) {
  728. if (row.type === 10) {
  729. for (const roleOption of this.roleOptions) {
  730. if (roleOption.id === option) {
  731. return roleOption.name;
  732. }
  733. }
  734. } else if (row.type === 20 || row.type === 21) {
  735. for (const deptOption of this.deptOptions) {
  736. if (deptOption.id === option) {
  737. return deptOption.name;
  738. }
  739. }
  740. } else if (row.type === 22) {
  741. option = option + ''; // 转换成 string
  742. for (const dictData of this.dict[this.dictEnum['工种']] || []) {
  743. if (dictData.dictCode === option) {
  744. return dictData.dictValue;
  745. }
  746. }
  747. } else if (row.type === 30 || row.type === 31 || row.type === 32) {
  748. for (const userOption of this.userOptions) {
  749. if (userOption.id === option) {
  750. return userOption.nickname || userOption.name;
  751. }
  752. }
  753. } else if (row.type === 40) {
  754. for (const userGroupOption of this.userGroupOptions) {
  755. if (userGroupOption.id === option) {
  756. return userGroupOption.name;
  757. }
  758. }
  759. } else if (row.type === 50) {
  760. option = option + ''; // 转换成 string
  761. for (const dictData of this.dict[
  762. this.dictEnum['工作流任务分配自定义脚本']
  763. ] || []) {
  764. if (dictData.dictCode === option) {
  765. return dictData.dictValue;
  766. }
  767. }
  768. } else if (row.type === 60) {
  769. return row.variableName;
  770. } else if (row.type === 70) {
  771. let data = JSON.parse(row.variableName);
  772. if (data.direction == 1) {
  773. return topLevel2.find((item) => item.value == data.topLevel)?.label;
  774. } else {
  775. return topLevel1.find((item) => item.value == data.topLevel)?.label;
  776. }
  777. } else if (row.type === 80) {
  778. let data = JSON.parse(row.variableName);
  779. return topLevel3.find((item) => item.value == data.topLevel)?.label;
  780. }
  781. return '未知(' + option + ')';
  782. },
  783. // 格式化部门的下拉框
  784. normalizer(node) {
  785. return {
  786. id: node.id,
  787. label: node.name,
  788. children: node.children
  789. };
  790. }
  791. }
  792. };
  793. </script>