From 64a1d1f0f61af32b760ee48513731413f99d077a Mon Sep 17 00:00:00 2001 From: YunaiV Date: Thu, 13 Jan 2022 00:56:57 +0800 Subject: [PATCH] =?UTF-8?q?BPM=20=E6=A8=A1=E5=9E=8B=E9=87=8D=E6=9E=84=207?= =?UTF-8?q?=EF=BC=9A=E5=A2=9E=E5=8A=A0=E4=BB=BB=E5=8A=A1=E5=88=86=E9=85=8D?= =?UTF-8?q?=E8=A7=84=E5=88=99=E7=9A=84=E5=88=97=E8=A1=A8=20UI=20=E7=95=8C?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BpmTaskAssignRuleController.java | 4 +- .../definition/BpmTaskAssignRuleTypeEnum.java | 12 +- .../behavior/BpmUserTaskActivitiBehavior.java | 2 +- .../definition/BpmTaskAssignRuleService.java | 8 +- .../impl/BpmTaskAssignRuleServiceImpl.java | 14 +-- yudao-admin-ui/src/api/bpm/taskAssignRule.js | 9 ++ yudao-admin-ui/src/utils/dict.js | 3 +- yudao-admin-ui/src/views/bpm/model/index.vue | 107 +++++++++++++++++- 8 files changed, 135 insertions(+), 24 deletions(-) create mode 100644 yudao-admin-ui/src/api/bpm/taskAssignRule.js diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/BpmTaskAssignRuleController.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/BpmTaskAssignRuleController.java index 39e8b545e..4333f889f 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/BpmTaskAssignRuleController.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/BpmTaskAssignRuleController.java @@ -1,6 +1,5 @@ package cn.iocoder.yudao.adminserver.modules.bpm.controller.definition; -import cn.hutool.core.util.StrUtil; import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.rule.BpmTaskAssignRuleRespVO; import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmTaskAssignRuleService; import cn.iocoder.yudao.framework.common.pojo.CommonResult; @@ -12,7 +11,6 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; -import java.util.Collections; import java.util.List; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; @@ -30,7 +28,7 @@ public class BpmTaskAssignRuleController { public CommonResult> getTaskAssignRuleList( @RequestParam(value = "modelId", required = false) String modelId, @RequestParam(value = "processDefinitionId", required = false) String processDefinitionId) { - return success(taskAssignRuleService.getTaskAssignRules(modelId, processDefinitionId)); + return success(taskAssignRuleService.getTaskAssignRuleList(modelId, processDefinitionId)); } } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/enums/definition/BpmTaskAssignRuleTypeEnum.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/enums/definition/BpmTaskAssignRuleTypeEnum.java index e7cf89ab6..891d5f057 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/enums/definition/BpmTaskAssignRuleTypeEnum.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/enums/definition/BpmTaskAssignRuleTypeEnum.java @@ -12,16 +12,16 @@ import lombok.Getter; @AllArgsConstructor public enum BpmTaskAssignRuleTypeEnum { - ROLE(10, "指定角色"), + ROLE(10, "角色"), - DEPT(20, "指定部门"), - DEPT_LEADER(21, "指定部门的负责人"), + DEPT(20, "部门的成员"), + DEPT_LEADER(21, "部门的负责人"), - USER(30, "指定用户"), + USER(30, "用户"), - USER_GROUP(40, "指定用户组"), // TODO 芋艿:预留,暂未实现 + USER_GROUP(40, "用户组"), // TODO 芋艿:预留,暂未实现 - SCRIPT(50, "指定脚本"), // 例如说,发起人所在部门的领导、发起人所在部门的领导的领导 + SCRIPT(50, "自定义脚本"), // 例如说,发起人所在部门的领导、发起人所在部门的领导的领导 ; /** diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/behavior/BpmUserTaskActivitiBehavior.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/behavior/BpmUserTaskActivitiBehavior.java index 9858c39cb..077824f6b 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/behavior/BpmUserTaskActivitiBehavior.java +++ b/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 { } private BpmTaskAssignRuleDO getTaskRule(TaskEntity task) { - List taskRules = bpmTaskRuleService.getTaskAssignRulesByProcessDefinitionId(task.getProcessDefinitionId(), + List taskRules = bpmTaskRuleService.getTaskAssignRuleListByProcessDefinitionId(task.getProcessDefinitionId(), task.getTaskDefinitionKey()); if (CollUtil.isEmpty(taskRules)) { throw new ActivitiException(StrUtil.format("流程任务({}/{}/{}) 找不到符合的任务规则", diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/BpmTaskAssignRuleService.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/BpmTaskAssignRuleService.java index b5fff6878..172298808 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/BpmTaskAssignRuleService.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/BpmTaskAssignRuleService.java @@ -20,8 +20,8 @@ public interface BpmTaskAssignRuleService { * @param taskDefinitionKey 流程任务定义的 Key。允许空 * @return 任务规则数组 */ - List getTaskAssignRulesByProcessDefinitionId(String processDefinitionId, - @Nullable String taskDefinitionKey); + List getTaskAssignRuleListByProcessDefinitionId(String processDefinitionId, + @Nullable String taskDefinitionKey); /** * 获得流程模型的任务规则数组 @@ -29,7 +29,7 @@ public interface BpmTaskAssignRuleService { * @param modelId 流程模型的编号 * @return 任务规则数组 */ - List getTaskAssignRulesByModelId(String modelId); + List getTaskAssignRuleListByModelId(String modelId); /** @@ -39,7 +39,7 @@ public interface BpmTaskAssignRuleService { * @param processDefinitionId 流程定义的编号 * @return 任务规则数组 */ - List getTaskAssignRules(String modelId, String processDefinitionId); + List getTaskAssignRuleList(String modelId, String processDefinitionId); // TODO 芋艿:创建任务规则 // TODO 芋艿:复制任务规则 diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmTaskAssignRuleServiceImpl.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmTaskAssignRuleServiceImpl.java index a39bc8792..8c8d0e3d5 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmTaskAssignRuleServiceImpl.java +++ b/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 { private BpmProcessDefinitionService processDefinitionService; @Override - public List getTaskAssignRulesByProcessDefinitionId(String processDefinitionId, - String taskDefinitionKey) { + public List getTaskAssignRuleListByProcessDefinitionId(String processDefinitionId, + String taskDefinitionKey) { return taskRuleMapper.selectListByProcessDefinitionId(processDefinitionId, taskDefinitionKey); } @Override - public List getTaskAssignRulesByModelId(String modelId) { + public List getTaskAssignRuleListByModelId(String modelId) { return taskRuleMapper.selectListByModelId(modelId); } @Override - public List getTaskAssignRules(String modelId, String processDefinitionId) { + public List getTaskAssignRuleList(String modelId, String processDefinitionId) { // 获得规则 List rules = Collections.emptyList(); BpmnModel model = null; if (StrUtil.isNotEmpty(modelId)) { - rules = getTaskAssignRulesByModelId(modelId); + rules = getTaskAssignRuleListByModelId(modelId); model = modelService.getBpmnModel(modelId); } else if (StrUtil.isNotEmpty(processDefinitionId)) { - rules = getTaskAssignRulesByProcessDefinitionId(processDefinitionId, null); + rules = getTaskAssignRuleListByProcessDefinitionId(processDefinitionId, null); model = processDefinitionService.getBpmnModel(processDefinitionId); } - if (CollUtil.isEmpty(rules) || model == null) { + if (model == null) { return Collections.emptyList(); } diff --git a/yudao-admin-ui/src/api/bpm/taskAssignRule.js b/yudao-admin-ui/src/api/bpm/taskAssignRule.js new file mode 100644 index 000000000..4c24e3285 --- /dev/null +++ b/yudao-admin-ui/src/api/bpm/taskAssignRule.js @@ -0,0 +1,9 @@ +import request from '@/utils/request' + +export function getTaskAssignRuleList(query) { + return request({ + url: '/bpm/task-assign-rule/list', + method: 'get', + params: query + }) +} diff --git a/yudao-admin-ui/src/utils/dict.js b/yudao-admin-ui/src/utils/dict.js index ec8239029..32f32986d 100644 --- a/yudao-admin-ui/src/utils/dict.js +++ b/yudao-admin-ui/src/utils/dict.js @@ -37,9 +37,10 @@ export const DICT_TYPE = { // bpm BPM_MODEL_CATEGORY: 'bpm_model_category', BPM_MODEL_FORM_TYPE: 'bpm_model_form_type', + BPM_TASK_ASSIGN_RULE_TYPE: 'bpm_task_assign_rule_type', BPM_PROCESS_INSTANCE_STATUS: 'bpm_process_instance_status', BPM_PROCESS_INSTANCE_RESULT: 'bpm_process_instance_result', - OA_LEAVE_STATUS: 'flow_status', + OA_LEAVE_STATUS: 'flow_status', // todo 芋艿:可以删除 OA_LEAVE_TYPE: 'oa_leave_type' } diff --git a/yudao-admin-ui/src/views/bpm/model/index.vue b/yudao-admin-ui/src/views/bpm/model/index.vue index deb6e444a..2fb73052b 100644 --- a/yudao-admin-ui/src/views/bpm/model/index.vue +++ b/yudao-admin-ui/src/views/bpm/model/index.vue @@ -82,12 +82,15 @@ - + @@ -213,6 +263,8 @@ import {getForm, getSimpleForms} from "@/api/bpm/form"; import {decodeFields} from "@/utils/formGenerator"; import Parser from '@/components/parser/Parser' import {getBaseHeader} from "@/utils/request"; +import {getTaskAssignRuleList} from "@/api/bpm/taskAssignRule"; +import {listSimpleRoles} from "@/api/system/role"; export default { name: "model", @@ -262,6 +314,22 @@ export default { formCustomViewPath: [{ required: true, message: "表单查看路由不能为空", trigger: "blur" }], }, + // 任务分配规则表单 + taskAssignRule: { + row: undefined, // 选中的流程模型 + list: [], // 选中流程模型的任务分配规则们 + listOpen: false, // 列表是否打开 + loading: false, // 加载中 + open: false, // 是否打开 + form: {}, // 表单 + rules: { // 表单校验规则 + type: [{ required: true, message: "规则类型不能为空", trigger: "change" }], + roleIds: [{required: true, message: "指定角色不能为空", trigger: "change" }], + }, + // 各种下拉框 + roleOptions: [], + }, + // 流程导入参数 upload: { // 是否显示弹出层(用户导入) @@ -285,7 +353,8 @@ export default { // 数据字典 categoryDictDatas: getDictDatas(DICT_TYPE.BPM_MODEL_CATEGORY), - modelFormTypeDictDatas: getDictDatas(DICT_TYPE.BPM_MODEL_FORM_TYPE) + modelFormTypeDictDatas: getDictDatas(DICT_TYPE.BPM_MODEL_FORM_TYPE), + taskAssignRuleDictDatas: getDictDatas(DICT_TYPE.BPM_TASK_ASSIGN_RULE_TYPE), }; }, created() { @@ -504,6 +573,40 @@ export default { this.$refs.upload.submit(); }) }, + // ========== ========== + doGetTaskAssignRuleList() { + this.taskAssignRule.loading = true; + getTaskAssignRuleList({ + modelId: this.taskAssignRule.row.id + }).then(response => { + this.taskAssignRule.loading = false; + this.taskAssignRule.list = response.data; + }) + }, + /** 处理任务分配规则列表的按钮操作 */ + handleAssignRule(row) { + this.taskAssignRule.row = row; + this.taskAssignRule.listOpen = true; + this.doGetTaskAssignRuleList(); + // 获得角色列表 + this.taskAssignRule.roleOptions = []; + listSimpleRoles().then(response => { + // 处理 roleOptions 参数 + this.taskAssignRule.roleOptions.push(...response.data); + }); + }, + /** 处理修改任务分配规则的按钮操作 */ + handleUpdateTaskAssignRule(row) { + this.taskAssignRule.form = { + ...row, + options: [] + }; + // TODO 芋艿:需要搞一搞 + if (row.type === 10) { + this.taskAssignRule.form.role = row.options; + } + this.taskAssignRule.open = true; + } } };