taskAssignRuleDialog.vue 25 KB

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