BPM 模型重构 7:增加任务分配规则的列表 UI 界面

This commit is contained in:
YunaiV 2022-01-13 00:56:57 +08:00
parent 4e7f5489a5
commit 64a1d1f0f6
8 changed files with 135 additions and 24 deletions

View File

@ -1,6 +1,5 @@
package cn.iocoder.yudao.adminserver.modules.bpm.controller.definition; 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.controller.definition.vo.rule.BpmTaskAssignRuleRespVO;
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmTaskAssignRuleService; import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmTaskAssignRuleService;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; 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 org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Collections;
import java.util.List; import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@ -30,7 +28,7 @@ public class BpmTaskAssignRuleController {
public CommonResult<List<BpmTaskAssignRuleRespVO>> getTaskAssignRuleList( public CommonResult<List<BpmTaskAssignRuleRespVO>> getTaskAssignRuleList(
@RequestParam(value = "modelId", required = false) String modelId, @RequestParam(value = "modelId", required = false) String modelId,
@RequestParam(value = "processDefinitionId", required = false) String processDefinitionId) { @RequestParam(value = "processDefinitionId", required = false) String processDefinitionId) {
return success(taskAssignRuleService.getTaskAssignRules(modelId, processDefinitionId)); return success(taskAssignRuleService.getTaskAssignRuleList(modelId, processDefinitionId));
} }
} }

View File

@ -12,16 +12,16 @@ import lombok.Getter;
@AllArgsConstructor @AllArgsConstructor
public enum BpmTaskAssignRuleTypeEnum { public enum BpmTaskAssignRuleTypeEnum {
ROLE(10, "指定角色"), ROLE(10, "角色"),
DEPT(20, "指定部门"), DEPT(20, "部门的成员"),
DEPT_LEADER(21, "指定部门的负责人"), DEPT_LEADER(21, "部门的负责人"),
USER(30, "指定用户"), USER(30, "用户"),
USER_GROUP(40, "指定用户组"), // TODO 芋艿预留暂未实现 USER_GROUP(40, "用户组"), // TODO 芋艿预留暂未实现
SCRIPT(50, "指定脚本"), // 例如说发起人所在部门的领导发起人所在部门的领导的领导 SCRIPT(50, "自定义脚本"), // 例如说发起人所在部门的领导发起人所在部门的领导的领导
; ;
/** /**

View File

@ -53,7 +53,7 @@ public class BpmUserTaskActivitiBehavior extends UserTaskActivityBehavior {
} }
private BpmTaskAssignRuleDO getTaskRule(TaskEntity task) { private BpmTaskAssignRuleDO getTaskRule(TaskEntity task) {
List<BpmTaskAssignRuleDO> taskRules = bpmTaskRuleService.getTaskAssignRulesByProcessDefinitionId(task.getProcessDefinitionId(), List<BpmTaskAssignRuleDO> taskRules = bpmTaskRuleService.getTaskAssignRuleListByProcessDefinitionId(task.getProcessDefinitionId(),
task.getTaskDefinitionKey()); task.getTaskDefinitionKey());
if (CollUtil.isEmpty(taskRules)) { if (CollUtil.isEmpty(taskRules)) {
throw new ActivitiException(StrUtil.format("流程任务({}/{}/{}) 找不到符合的任务规则", throw new ActivitiException(StrUtil.format("流程任务({}/{}/{}) 找不到符合的任务规则",

View File

@ -20,8 +20,8 @@ public interface BpmTaskAssignRuleService {
* @param taskDefinitionKey 流程任务定义的 Key允许空 * @param taskDefinitionKey 流程任务定义的 Key允许空
* @return 任务规则数组 * @return 任务规则数组
*/ */
List<BpmTaskAssignRuleDO> getTaskAssignRulesByProcessDefinitionId(String processDefinitionId, List<BpmTaskAssignRuleDO> getTaskAssignRuleListByProcessDefinitionId(String processDefinitionId,
@Nullable String taskDefinitionKey); @Nullable String taskDefinitionKey);
/** /**
* 获得流程模型的任务规则数组 * 获得流程模型的任务规则数组
@ -29,7 +29,7 @@ public interface BpmTaskAssignRuleService {
* @param modelId 流程模型的编号 * @param modelId 流程模型的编号
* @return 任务规则数组 * @return 任务规则数组
*/ */
List<BpmTaskAssignRuleDO> getTaskAssignRulesByModelId(String modelId); List<BpmTaskAssignRuleDO> getTaskAssignRuleListByModelId(String modelId);
/** /**
@ -39,7 +39,7 @@ public interface BpmTaskAssignRuleService {
* @param processDefinitionId 流程定义的编号 * @param processDefinitionId 流程定义的编号
* @return 任务规则数组 * @return 任务规则数组
*/ */
List<BpmTaskAssignRuleRespVO> getTaskAssignRules(String modelId, String processDefinitionId); List<BpmTaskAssignRuleRespVO> getTaskAssignRuleList(String modelId, String processDefinitionId);
// TODO 芋艿创建任务规则 // TODO 芋艿创建任务规则
// TODO 芋艿复制任务规则 // TODO 芋艿复制任务规则

View File

@ -40,29 +40,29 @@ public class BpmTaskAssignRuleServiceImpl implements BpmTaskAssignRuleService {
private BpmProcessDefinitionService processDefinitionService; private BpmProcessDefinitionService processDefinitionService;
@Override @Override
public List<BpmTaskAssignRuleDO> getTaskAssignRulesByProcessDefinitionId(String processDefinitionId, public List<BpmTaskAssignRuleDO> getTaskAssignRuleListByProcessDefinitionId(String processDefinitionId,
String taskDefinitionKey) { String taskDefinitionKey) {
return taskRuleMapper.selectListByProcessDefinitionId(processDefinitionId, taskDefinitionKey); return taskRuleMapper.selectListByProcessDefinitionId(processDefinitionId, taskDefinitionKey);
} }
@Override @Override
public List<BpmTaskAssignRuleDO> getTaskAssignRulesByModelId(String modelId) { public List<BpmTaskAssignRuleDO> getTaskAssignRuleListByModelId(String modelId) {
return taskRuleMapper.selectListByModelId(modelId); return taskRuleMapper.selectListByModelId(modelId);
} }
@Override @Override
public List<BpmTaskAssignRuleRespVO> getTaskAssignRules(String modelId, String processDefinitionId) { public List<BpmTaskAssignRuleRespVO> getTaskAssignRuleList(String modelId, String processDefinitionId) {
// 获得规则 // 获得规则
List<BpmTaskAssignRuleDO> rules = Collections.emptyList(); List<BpmTaskAssignRuleDO> rules = Collections.emptyList();
BpmnModel model = null; BpmnModel model = null;
if (StrUtil.isNotEmpty(modelId)) { if (StrUtil.isNotEmpty(modelId)) {
rules = getTaskAssignRulesByModelId(modelId); rules = getTaskAssignRuleListByModelId(modelId);
model = modelService.getBpmnModel(modelId); model = modelService.getBpmnModel(modelId);
} else if (StrUtil.isNotEmpty(processDefinitionId)) { } else if (StrUtil.isNotEmpty(processDefinitionId)) {
rules = getTaskAssignRulesByProcessDefinitionId(processDefinitionId, null); rules = getTaskAssignRuleListByProcessDefinitionId(processDefinitionId, null);
model = processDefinitionService.getBpmnModel(processDefinitionId); model = processDefinitionService.getBpmnModel(processDefinitionId);
} }
if (CollUtil.isEmpty(rules) || model == null) { if (model == null) {
return Collections.emptyList(); return Collections.emptyList();
} }

View File

@ -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
})
}

View File

@ -37,9 +37,10 @@ export const DICT_TYPE = {
// bpm // bpm
BPM_MODEL_CATEGORY: 'bpm_model_category', BPM_MODEL_CATEGORY: 'bpm_model_category',
BPM_MODEL_FORM_TYPE: 'bpm_model_form_type', 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_STATUS: 'bpm_process_instance_status',
BPM_PROCESS_INSTANCE_RESULT: 'bpm_process_instance_result', 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' OA_LEAVE_TYPE: 'oa_leave_type'
} }

View File

@ -82,12 +82,15 @@
</template> </template>
</el-table-column> </el-table-column>
</el-table-column> </el-table-column>
<el-table-column label="操作" align="center" width="380" fixed="right"> <el-table-column label="操作" align="center" width="450" fixed="right">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
v-hasPermi="['bpm:model:update']">修改流程</el-button> v-hasPermi="['bpm:model:update']">修改流程</el-button>
<el-button size="mini" type="text" icon="el-icon-setting" @click="handleDesign(scope.row)" <el-button size="mini" type="text" icon="el-icon-setting" @click="handleDesign(scope.row)"
v-hasPermi="['bpm:model:update']">设计流程</el-button> v-hasPermi="['bpm:model:update']">设计流程</el-button>
<!-- TODO 权限 -->
<el-button size="mini" type="text" icon="el-icon-s-custom" @click="handleAssignRule(scope.row)"
v-hasPermi="['bpm:model:update']">分配规则</el-button>
<el-button size="mini" type="text" icon="el-icon-thumb" @click="handleDeploy(scope.row)" <el-button size="mini" type="text" icon="el-icon-thumb" @click="handleDeploy(scope.row)"
v-hasPermi="['bpm:model:deploy']">发布流程</el-button> v-hasPermi="['bpm:model:deploy']">发布流程</el-button>
<el-button size="mini" type="text" icon="el-icon-ice-cream-round" @click="handleDefinitionList(scope.row)" <el-button size="mini" type="text" icon="el-icon-ice-cream-round" @click="handleDefinitionList(scope.row)"
@ -195,6 +198,53 @@
<el-button @click="uploadClose"> </el-button> <el-button @click="uploadClose"> </el-button>
</div> </div>
</el-dialog> </el-dialog>
<!-- ========== 流程任务分配规则 ========== -->
<!-- 列表弹窗 -->
<el-dialog title="任务分配规则" :visible.sync="taskAssignRule.listOpen" width="800px" append-to-body>
<el-table v-loading="taskAssignRule.loading" :data="taskAssignRule.list">
<el-table-column label="任务名" align="center" prop="taskDefinitionName" width="120" fixed />
<el-table-column label="任务标识" align="center" prop="taskDefinitionKey" width="300" />
<el-table-column label="规则类型" align="center" prop="type">
<template slot-scope="scope">
<span>{{ getDictDataLabel(DICT_TYPE.BPM_TASK_ASSIGN_RULE_TYPE, scope.row.type) }}</span>
</template>
</el-table-column>
<el-table-column label="规则范围" align="center" prop="options" />
<el-table-column label="操作" align="center" width="80" fixed="right">
<template slot-scope="scope">
<!-- TODO 权限 -->
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdateTaskAssignRule(scope.row)"
v-hasPermi="['bpm:model:update']">修改</el-button>
</template>
</el-table-column>
</el-table>
</el-dialog>
<!-- 添加/修改弹窗 -->
<el-dialog title="修改任务规则" :visible.sync="taskAssignRule.open" width="500px" append-to-body>
<el-form ref="form" :model="taskAssignRule.form" :rules="taskAssignRule.rules" label-width="110px">
<el-form-item label="任务名称" prop="taskDefinitionName">
<el-input v-model="taskAssignRule.form.taskDefinitionName" disabled />
</el-form-item>
<el-form-item label="任务标识" prop="taskDefinitionKey">
<el-input v-model="taskAssignRule.form.taskDefinitionKey" disabled />
</el-form-item>
<el-form-item label="规则类型" prop="type">
<el-select v-model="taskAssignRule.form.type" clearable style="width: 100%">
<el-option v-for="dict in taskAssignRuleDictDatas" :key="parseInt(dict.value)" :label="dict.label" :value="parseInt(dict.value)"/>
</el-select>
</el-form-item>
<el-form-item v-if="taskAssignRule.form.type === 10" label="指定角色" prop="roleIds">
<el-select v-model="form.formId" clearable style="width: 100%">
<el-option v-for="item in taskAssignRule.roleOptions" :key="parseInt(item.id)" :label="item.name" :value="parseInt(item.id)" />
</el-select>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div> </div>
</template> </template>
@ -213,6 +263,8 @@ import {getForm, getSimpleForms} from "@/api/bpm/form";
import {decodeFields} from "@/utils/formGenerator"; import {decodeFields} from "@/utils/formGenerator";
import Parser from '@/components/parser/Parser' import Parser from '@/components/parser/Parser'
import {getBaseHeader} from "@/utils/request"; import {getBaseHeader} from "@/utils/request";
import {getTaskAssignRuleList} from "@/api/bpm/taskAssignRule";
import {listSimpleRoles} from "@/api/system/role";
export default { export default {
name: "model", name: "model",
@ -262,6 +314,22 @@ export default {
formCustomViewPath: [{ required: true, message: "表单查看路由不能为空", trigger: "blur" }], 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: { upload: {
// //
@ -285,7 +353,8 @@ export default {
// //
categoryDictDatas: getDictDatas(DICT_TYPE.BPM_MODEL_CATEGORY), 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() { created() {
@ -504,6 +573,40 @@ export default {
this.$refs.upload.submit(); 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;
}
} }
}; };
</script> </script>