Commit 64a1d1f0f61af32b760ee48513731413f99d077a
1 parent
4e7f5489
BPM 模型重构 7:增加任务分配规则的列表 UI 界面
Showing
8 changed files
with
135 additions
and
24 deletions
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/BpmTaskAssignRuleController.java
| 1 | 1 | package cn.iocoder.yudao.adminserver.modules.bpm.controller.definition; |
| 2 | 2 | |
| 3 | -import cn.hutool.core.util.StrUtil; | |
| 4 | 3 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.rule.BpmTaskAssignRuleRespVO; |
| 5 | 4 | import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmTaskAssignRuleService; |
| 6 | 5 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| ... | ... | @@ -12,7 +11,6 @@ import org.springframework.web.bind.annotation.RequestParam; |
| 12 | 11 | import org.springframework.web.bind.annotation.RestController; |
| 13 | 12 | |
| 14 | 13 | import javax.annotation.Resource; |
| 15 | -import java.util.Collections; | |
| 16 | 14 | import java.util.List; |
| 17 | 15 | |
| 18 | 16 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| ... | ... | @@ -30,7 +28,7 @@ public class BpmTaskAssignRuleController { |
| 30 | 28 | public CommonResult<List<BpmTaskAssignRuleRespVO>> getTaskAssignRuleList( |
| 31 | 29 | @RequestParam(value = "modelId", required = false) String modelId, |
| 32 | 30 | @RequestParam(value = "processDefinitionId", required = false) String processDefinitionId) { |
| 33 | - return success(taskAssignRuleService.getTaskAssignRules(modelId, processDefinitionId)); | |
| 31 | + return success(taskAssignRuleService.getTaskAssignRuleList(modelId, processDefinitionId)); | |
| 34 | 32 | } |
| 35 | 33 | |
| 36 | 34 | } | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/enums/definition/BpmTaskAssignRuleTypeEnum.java
| ... | ... | @@ -12,16 +12,16 @@ import lombok.Getter; |
| 12 | 12 | @AllArgsConstructor |
| 13 | 13 | public enum BpmTaskAssignRuleTypeEnum { |
| 14 | 14 | |
| 15 | - ROLE(10, "指定角色"), | |
| 15 | + ROLE(10, "角色"), | |
| 16 | 16 | |
| 17 | - DEPT(20, "指定部门"), | |
| 18 | - DEPT_LEADER(21, "指定部门的负责人"), | |
| 17 | + DEPT(20, "部门的成员"), | |
| 18 | + DEPT_LEADER(21, "部门的负责人"), | |
| 19 | 19 | |
| 20 | - USER(30, "指定用户"), | |
| 20 | + USER(30, "用户"), | |
| 21 | 21 | |
| 22 | - USER_GROUP(40, "指定用户组"), // TODO 芋艿:预留,暂未实现 | |
| 22 | + USER_GROUP(40, "用户组"), // TODO 芋艿:预留,暂未实现 | |
| 23 | 23 | |
| 24 | - SCRIPT(50, "指定脚本"), // 例如说,发起人所在部门的领导、发起人所在部门的领导的领导 | |
| 24 | + SCRIPT(50, "自定义脚本"), // 例如说,发起人所在部门的领导、发起人所在部门的领导的领导 | |
| 25 | 25 | ; |
| 26 | 26 | |
| 27 | 27 | /** | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/behavior/BpmUserTaskActivitiBehavior.java
| ... | ... | @@ -53,7 +53,7 @@ public class BpmUserTaskActivitiBehavior extends UserTaskActivityBehavior { |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | private BpmTaskAssignRuleDO getTaskRule(TaskEntity task) { |
| 56 | - List<BpmTaskAssignRuleDO> taskRules = bpmTaskRuleService.getTaskAssignRulesByProcessDefinitionId(task.getProcessDefinitionId(), | |
| 56 | + List<BpmTaskAssignRuleDO> taskRules = bpmTaskRuleService.getTaskAssignRuleListByProcessDefinitionId(task.getProcessDefinitionId(), | |
| 57 | 57 | task.getTaskDefinitionKey()); |
| 58 | 58 | if (CollUtil.isEmpty(taskRules)) { |
| 59 | 59 | throw new ActivitiException(StrUtil.format("流程任务({}/{}/{}) 找不到符合的任务规则", | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/BpmTaskAssignRuleService.java
| ... | ... | @@ -20,8 +20,8 @@ public interface BpmTaskAssignRuleService { |
| 20 | 20 | * @param taskDefinitionKey 流程任务定义的 Key。允许空 |
| 21 | 21 | * @return 任务规则数组 |
| 22 | 22 | */ |
| 23 | - List<BpmTaskAssignRuleDO> getTaskAssignRulesByProcessDefinitionId(String processDefinitionId, | |
| 24 | - @Nullable String taskDefinitionKey); | |
| 23 | + List<BpmTaskAssignRuleDO> getTaskAssignRuleListByProcessDefinitionId(String processDefinitionId, | |
| 24 | + @Nullable String taskDefinitionKey); | |
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | * 获得流程模型的任务规则数组 |
| ... | ... | @@ -29,7 +29,7 @@ public interface BpmTaskAssignRuleService { |
| 29 | 29 | * @param modelId 流程模型的编号 |
| 30 | 30 | * @return 任务规则数组 |
| 31 | 31 | */ |
| 32 | - List<BpmTaskAssignRuleDO> getTaskAssignRulesByModelId(String modelId); | |
| 32 | + List<BpmTaskAssignRuleDO> getTaskAssignRuleListByModelId(String modelId); | |
| 33 | 33 | |
| 34 | 34 | |
| 35 | 35 | /** |
| ... | ... | @@ -39,7 +39,7 @@ public interface BpmTaskAssignRuleService { |
| 39 | 39 | * @param processDefinitionId 流程定义的编号 |
| 40 | 40 | * @return 任务规则数组 |
| 41 | 41 | */ |
| 42 | - List<BpmTaskAssignRuleRespVO> getTaskAssignRules(String modelId, String processDefinitionId); | |
| 42 | + List<BpmTaskAssignRuleRespVO> getTaskAssignRuleList(String modelId, String processDefinitionId); | |
| 43 | 43 | |
| 44 | 44 | // TODO 芋艿:创建任务规则 |
| 45 | 45 | // TODO 芋艿:复制任务规则 | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmTaskAssignRuleServiceImpl.java
| ... | ... | @@ -40,29 +40,29 @@ public class BpmTaskAssignRuleServiceImpl implements BpmTaskAssignRuleService { |
| 40 | 40 | private BpmProcessDefinitionService processDefinitionService; |
| 41 | 41 | |
| 42 | 42 | @Override |
| 43 | - public List<BpmTaskAssignRuleDO> getTaskAssignRulesByProcessDefinitionId(String processDefinitionId, | |
| 44 | - String taskDefinitionKey) { | |
| 43 | + public List<BpmTaskAssignRuleDO> getTaskAssignRuleListByProcessDefinitionId(String processDefinitionId, | |
| 44 | + String taskDefinitionKey) { | |
| 45 | 45 | return taskRuleMapper.selectListByProcessDefinitionId(processDefinitionId, taskDefinitionKey); |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | @Override |
| 49 | - public List<BpmTaskAssignRuleDO> getTaskAssignRulesByModelId(String modelId) { | |
| 49 | + public List<BpmTaskAssignRuleDO> getTaskAssignRuleListByModelId(String modelId) { | |
| 50 | 50 | return taskRuleMapper.selectListByModelId(modelId); |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | @Override |
| 54 | - public List<BpmTaskAssignRuleRespVO> getTaskAssignRules(String modelId, String processDefinitionId) { | |
| 54 | + public List<BpmTaskAssignRuleRespVO> getTaskAssignRuleList(String modelId, String processDefinitionId) { | |
| 55 | 55 | // 获得规则 |
| 56 | 56 | List<BpmTaskAssignRuleDO> rules = Collections.emptyList(); |
| 57 | 57 | BpmnModel model = null; |
| 58 | 58 | if (StrUtil.isNotEmpty(modelId)) { |
| 59 | - rules = getTaskAssignRulesByModelId(modelId); | |
| 59 | + rules = getTaskAssignRuleListByModelId(modelId); | |
| 60 | 60 | model = modelService.getBpmnModel(modelId); |
| 61 | 61 | } else if (StrUtil.isNotEmpty(processDefinitionId)) { |
| 62 | - rules = getTaskAssignRulesByProcessDefinitionId(processDefinitionId, null); | |
| 62 | + rules = getTaskAssignRuleListByProcessDefinitionId(processDefinitionId, null); | |
| 63 | 63 | model = processDefinitionService.getBpmnModel(processDefinitionId); |
| 64 | 64 | } |
| 65 | - if (CollUtil.isEmpty(rules) || model == null) { | |
| 65 | + if (model == null) { | |
| 66 | 66 | return Collections.emptyList(); |
| 67 | 67 | } |
| 68 | 68 | ... | ... |
yudao-admin-ui/src/api/bpm/taskAssignRule.js
0 → 100644
yudao-admin-ui/src/utils/dict.js
| ... | ... | @@ -37,9 +37,10 @@ export const DICT_TYPE = { |
| 37 | 37 | // bpm |
| 38 | 38 | BPM_MODEL_CATEGORY: 'bpm_model_category', |
| 39 | 39 | BPM_MODEL_FORM_TYPE: 'bpm_model_form_type', |
| 40 | + BPM_TASK_ASSIGN_RULE_TYPE: 'bpm_task_assign_rule_type', | |
| 40 | 41 | BPM_PROCESS_INSTANCE_STATUS: 'bpm_process_instance_status', |
| 41 | 42 | BPM_PROCESS_INSTANCE_RESULT: 'bpm_process_instance_result', |
| 42 | - OA_LEAVE_STATUS: 'flow_status', | |
| 43 | + OA_LEAVE_STATUS: 'flow_status', // todo 芋艿:可以删除 | |
| 43 | 44 | OA_LEAVE_TYPE: 'oa_leave_type' |
| 44 | 45 | } |
| 45 | 46 | ... | ... |
yudao-admin-ui/src/views/bpm/model/index.vue
| ... | ... | @@ -82,12 +82,15 @@ |
| 82 | 82 | </template> |
| 83 | 83 | </el-table-column> |
| 84 | 84 | </el-table-column> |
| 85 | - <el-table-column label="操作" align="center" width="380" fixed="right"> | |
| 85 | + <el-table-column label="操作" align="center" width="450" fixed="right"> | |
| 86 | 86 | <template slot-scope="scope"> |
| 87 | 87 | <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" |
| 88 | 88 | v-hasPermi="['bpm:model:update']">修改流程</el-button> |
| 89 | 89 | <el-button size="mini" type="text" icon="el-icon-setting" @click="handleDesign(scope.row)" |
| 90 | 90 | v-hasPermi="['bpm:model:update']">设计流程</el-button> |
| 91 | + <!-- TODO 权限 --> | |
| 92 | + <el-button size="mini" type="text" icon="el-icon-s-custom" @click="handleAssignRule(scope.row)" | |
| 93 | + v-hasPermi="['bpm:model:update']">分配规则</el-button> | |
| 91 | 94 | <el-button size="mini" type="text" icon="el-icon-thumb" @click="handleDeploy(scope.row)" |
| 92 | 95 | v-hasPermi="['bpm:model:deploy']">发布流程</el-button> |
| 93 | 96 | <el-button size="mini" type="text" icon="el-icon-ice-cream-round" @click="handleDefinitionList(scope.row)" |
| ... | ... | @@ -195,6 +198,53 @@ |
| 195 | 198 | <el-button @click="uploadClose">取 消</el-button> |
| 196 | 199 | </div> |
| 197 | 200 | </el-dialog> |
| 201 | + | |
| 202 | + <!-- ========== 流程任务分配规则 ========== --> | |
| 203 | + <!-- 列表弹窗 --> | |
| 204 | + <el-dialog title="任务分配规则" :visible.sync="taskAssignRule.listOpen" width="800px" append-to-body> | |
| 205 | + <el-table v-loading="taskAssignRule.loading" :data="taskAssignRule.list"> | |
| 206 | + <el-table-column label="任务名" align="center" prop="taskDefinitionName" width="120" fixed /> | |
| 207 | + <el-table-column label="任务标识" align="center" prop="taskDefinitionKey" width="300" /> | |
| 208 | + <el-table-column label="规则类型" align="center" prop="type"> | |
| 209 | + <template slot-scope="scope"> | |
| 210 | + <span>{{ getDictDataLabel(DICT_TYPE.BPM_TASK_ASSIGN_RULE_TYPE, scope.row.type) }}</span> | |
| 211 | + </template> | |
| 212 | + </el-table-column> | |
| 213 | + <el-table-column label="规则范围" align="center" prop="options" /> | |
| 214 | + <el-table-column label="操作" align="center" width="80" fixed="right"> | |
| 215 | + <template slot-scope="scope"> | |
| 216 | + <!-- TODO 权限 --> | |
| 217 | + <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdateTaskAssignRule(scope.row)" | |
| 218 | + v-hasPermi="['bpm:model:update']">修改</el-button> | |
| 219 | + </template> | |
| 220 | + </el-table-column> | |
| 221 | + </el-table> | |
| 222 | + </el-dialog> | |
| 223 | + <!-- 添加/修改弹窗 --> | |
| 224 | + <el-dialog title="修改任务规则" :visible.sync="taskAssignRule.open" width="500px" append-to-body> | |
| 225 | + <el-form ref="form" :model="taskAssignRule.form" :rules="taskAssignRule.rules" label-width="110px"> | |
| 226 | + <el-form-item label="任务名称" prop="taskDefinitionName"> | |
| 227 | + <el-input v-model="taskAssignRule.form.taskDefinitionName" disabled /> | |
| 228 | + </el-form-item> | |
| 229 | + <el-form-item label="任务标识" prop="taskDefinitionKey"> | |
| 230 | + <el-input v-model="taskAssignRule.form.taskDefinitionKey" disabled /> | |
| 231 | + </el-form-item> | |
| 232 | + <el-form-item label="规则类型" prop="type"> | |
| 233 | + <el-select v-model="taskAssignRule.form.type" clearable style="width: 100%"> | |
| 234 | + <el-option v-for="dict in taskAssignRuleDictDatas" :key="parseInt(dict.value)" :label="dict.label" :value="parseInt(dict.value)"/> | |
| 235 | + </el-select> | |
| 236 | + </el-form-item> | |
| 237 | + <el-form-item v-if="taskAssignRule.form.type === 10" label="指定角色" prop="roleIds"> | |
| 238 | + <el-select v-model="form.formId" clearable style="width: 100%"> | |
| 239 | + <el-option v-for="item in taskAssignRule.roleOptions" :key="parseInt(item.id)" :label="item.name" :value="parseInt(item.id)" /> | |
| 240 | + </el-select> | |
| 241 | + </el-form-item> | |
| 242 | + </el-form> | |
| 243 | + <div slot="footer" class="dialog-footer"> | |
| 244 | + <el-button type="primary" @click="submitForm">确 定</el-button> | |
| 245 | + <el-button @click="cancel">取 消</el-button> | |
| 246 | + </div> | |
| 247 | + </el-dialog> | |
| 198 | 248 | </div> |
| 199 | 249 | </template> |
| 200 | 250 | |
| ... | ... | @@ -213,6 +263,8 @@ import {getForm, getSimpleForms} from "@/api/bpm/form"; |
| 213 | 263 | import {decodeFields} from "@/utils/formGenerator"; |
| 214 | 264 | import Parser from '@/components/parser/Parser' |
| 215 | 265 | import {getBaseHeader} from "@/utils/request"; |
| 266 | +import {getTaskAssignRuleList} from "@/api/bpm/taskAssignRule"; | |
| 267 | +import {listSimpleRoles} from "@/api/system/role"; | |
| 216 | 268 | |
| 217 | 269 | export default { |
| 218 | 270 | name: "model", |
| ... | ... | @@ -262,6 +314,22 @@ export default { |
| 262 | 314 | formCustomViewPath: [{ required: true, message: "表单查看路由不能为空", trigger: "blur" }], |
| 263 | 315 | }, |
| 264 | 316 | |
| 317 | + // 任务分配规则表单 | |
| 318 | + taskAssignRule: { | |
| 319 | + row: undefined, // 选中的流程模型 | |
| 320 | + list: [], // 选中流程模型的任务分配规则们 | |
| 321 | + listOpen: false, // 列表是否打开 | |
| 322 | + loading: false, // 加载中 | |
| 323 | + open: false, // 是否打开 | |
| 324 | + form: {}, // 表单 | |
| 325 | + rules: { // 表单校验规则 | |
| 326 | + type: [{ required: true, message: "规则类型不能为空", trigger: "change" }], | |
| 327 | + roleIds: [{required: true, message: "指定角色不能为空", trigger: "change" }], | |
| 328 | + }, | |
| 329 | + // 各种下拉框 | |
| 330 | + roleOptions: [], | |
| 331 | + }, | |
| 332 | + | |
| 265 | 333 | // 流程导入参数 |
| 266 | 334 | upload: { |
| 267 | 335 | // 是否显示弹出层(用户导入) |
| ... | ... | @@ -285,7 +353,8 @@ export default { |
| 285 | 353 | |
| 286 | 354 | // 数据字典 |
| 287 | 355 | categoryDictDatas: getDictDatas(DICT_TYPE.BPM_MODEL_CATEGORY), |
| 288 | - modelFormTypeDictDatas: getDictDatas(DICT_TYPE.BPM_MODEL_FORM_TYPE) | |
| 356 | + modelFormTypeDictDatas: getDictDatas(DICT_TYPE.BPM_MODEL_FORM_TYPE), | |
| 357 | + taskAssignRuleDictDatas: getDictDatas(DICT_TYPE.BPM_TASK_ASSIGN_RULE_TYPE), | |
| 289 | 358 | }; |
| 290 | 359 | }, |
| 291 | 360 | created() { |
| ... | ... | @@ -504,6 +573,40 @@ export default { |
| 504 | 573 | this.$refs.upload.submit(); |
| 505 | 574 | }) |
| 506 | 575 | }, |
| 576 | + // ========== ========== | |
| 577 | + doGetTaskAssignRuleList() { | |
| 578 | + this.taskAssignRule.loading = true; | |
| 579 | + getTaskAssignRuleList({ | |
| 580 | + modelId: this.taskAssignRule.row.id | |
| 581 | + }).then(response => { | |
| 582 | + this.taskAssignRule.loading = false; | |
| 583 | + this.taskAssignRule.list = response.data; | |
| 584 | + }) | |
| 585 | + }, | |
| 586 | + /** 处理任务分配规则列表的按钮操作 */ | |
| 587 | + handleAssignRule(row) { | |
| 588 | + this.taskAssignRule.row = row; | |
| 589 | + this.taskAssignRule.listOpen = true; | |
| 590 | + this.doGetTaskAssignRuleList(); | |
| 591 | + // 获得角色列表 | |
| 592 | + this.taskAssignRule.roleOptions = []; | |
| 593 | + listSimpleRoles().then(response => { | |
| 594 | + // 处理 roleOptions 参数 | |
| 595 | + this.taskAssignRule.roleOptions.push(...response.data); | |
| 596 | + }); | |
| 597 | + }, | |
| 598 | + /** 处理修改任务分配规则的按钮操作 */ | |
| 599 | + handleUpdateTaskAssignRule(row) { | |
| 600 | + this.taskAssignRule.form = { | |
| 601 | + ...row, | |
| 602 | + options: [] | |
| 603 | + }; | |
| 604 | + // TODO 芋艿:需要搞一搞 | |
| 605 | + if (row.type === 10) { | |
| 606 | + this.taskAssignRule.form.role = row.options; | |
| 607 | + } | |
| 608 | + this.taskAssignRule.open = true; | |
| 609 | + } | |
| 507 | 610 | } |
| 508 | 611 | }; |
| 509 | 612 | </script> | ... | ... |