taskAssignRuleDialog.vue 26 KB

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