BPM 模型重构 7:增加任务分配规则的列表 UI 界面(增加角色的规则配置)
parent
3f6a5f06fa
commit
9f0cd04fa6
|
@ -31,8 +31,8 @@ public class BpmTaskAssignRuleController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
public CommonResult<String> createTaskAssignRule(@Valid @RequestBody BpmTaskAssignRuleCreateReqVO reqVO) {
|
public CommonResult<Long> createTaskAssignRule(@Valid @RequestBody BpmTaskAssignRuleCreateReqVO reqVO) {
|
||||||
return success("1024");
|
return success(taskAssignRuleService.createTaskAssignRule(reqVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update")
|
@PutMapping("/update")
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
package cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.rule;
|
package cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.rule;
|
||||||
|
|
||||||
import java.util.Set;
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public class BpmTaskAssignRuleCreateReqVO extends BpmTaskAssignRuleBaseVO {
|
public class BpmTaskAssignRuleCreateReqVO extends BpmTaskAssignRuleBaseVO {
|
||||||
|
|
||||||
private String modelId;
|
private String modelId;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package cn.iocoder.yudao.adminserver.modules.bpm.convert.definition;
|
package cn.iocoder.yudao.adminserver.modules.bpm.convert.definition;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.rule.BpmTaskAssignRuleCreateReqVO;
|
||||||
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.dal.dataobject.definition.BpmTaskAssignRuleDO;
|
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition.BpmTaskAssignRuleDO;
|
||||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||||
|
@ -33,4 +34,6 @@ public interface BpmTaskAssignRuleConvert {
|
||||||
|
|
||||||
BpmTaskAssignRuleRespVO convert(BpmTaskAssignRuleDO bean);
|
BpmTaskAssignRuleRespVO convert(BpmTaskAssignRuleDO bean);
|
||||||
|
|
||||||
|
BpmTaskAssignRuleDO convert(BpmTaskAssignRuleCreateReqVO bean);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,4 +24,12 @@ public interface BpmTaskAssignRuleMapper extends BaseMapperX<BpmTaskAssignRuleDO
|
||||||
.eq("process_definition_id", BpmTaskAssignRuleDO.PROCESS_DEFINITION_ID_NULL));
|
.eq("process_definition_id", BpmTaskAssignRuleDO.PROCESS_DEFINITION_ID_NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default BpmTaskAssignRuleDO selectListByModelIdAndTaskDefinitionKey(String modelId,
|
||||||
|
String taskDefinitionKey) {
|
||||||
|
return selectOne(new QueryWrapperX<BpmTaskAssignRuleDO>()
|
||||||
|
.eq("model_id", modelId)
|
||||||
|
.eq("process_definition_id", BpmTaskAssignRuleDO.PROCESS_DEFINITION_ID_NULL)
|
||||||
|
.eq("task_definition_key", taskDefinitionKey));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,9 +37,12 @@ public interface BpmErrorCodeConstants {
|
||||||
ErrorCode PROCESS_INSTANCE_CANCEL_FAIL_NOT_EXISTS = new ErrorCode(1009004001, "流程取消失败,流程不处于运行中");
|
ErrorCode PROCESS_INSTANCE_CANCEL_FAIL_NOT_EXISTS = new ErrorCode(1009004001, "流程取消失败,流程不处于运行中");
|
||||||
ErrorCode PROCESS_INSTANCE_CANCEL_FAIL_NOT_SELF = new ErrorCode(1009004002, "流程取消失败,该流程不是你发起的");
|
ErrorCode PROCESS_INSTANCE_CANCEL_FAIL_NOT_SELF = new ErrorCode(1009004002, "流程取消失败,该流程不是你发起的");
|
||||||
|
|
||||||
// ========== 流程实例 1-009-005-000 ==========
|
// ========== 流程任务 1-009-005-000 ==========
|
||||||
ErrorCode TASK_COMPLETE_FAIL_NOT_EXISTS = new ErrorCode(1009004000, "审批任务失败,原因:该任务不处于未审批");
|
ErrorCode TASK_COMPLETE_FAIL_NOT_EXISTS = new ErrorCode(1009004000, "审批任务失败,原因:该任务不处于未审批");
|
||||||
|
|
||||||
|
// ========== 流程任务分配规则 1-009-006-000 ==========
|
||||||
|
ErrorCode TASK_ASSIGN_RULE_EXISTS = new ErrorCode(1009006000, "流程({}) 的任务({}) 已经存在分配规则");
|
||||||
|
|
||||||
// ========== 动态表单模块 1-009-010-000 ==========
|
// ========== 动态表单模块 1-009-010-000 ==========
|
||||||
ErrorCode FORM_NOT_EXISTS = new ErrorCode(1009010000, "动态表单不存在");
|
ErrorCode FORM_NOT_EXISTS = new ErrorCode(1009010000, "动态表单不存在");
|
||||||
ErrorCode FORM_FIELD_REPEAT = new ErrorCode(1009010000, "表单项({}) 和 ({}) 使用了相同的字段名({})");
|
ErrorCode FORM_FIELD_REPEAT = new ErrorCode(1009010000, "表单项({}) 和 ({}) 使用了相同的字段名({})");
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
package cn.iocoder.yudao.adminserver.modules.bpm.service.definition;
|
package cn.iocoder.yudao.adminserver.modules.bpm.service.definition;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.rule.BpmTaskAssignRuleCreateReqVO;
|
||||||
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.dal.dataobject.definition.BpmTaskAssignRuleDO;
|
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition.BpmTaskAssignRuleDO;
|
||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -35,13 +37,20 @@ public interface BpmTaskAssignRuleService {
|
||||||
/**
|
/**
|
||||||
* 获得流程定义的任务分配规则数组
|
* 获得流程定义的任务分配规则数组
|
||||||
*
|
*
|
||||||
* @param processDefinitionId 流程模型的编号
|
* @param modelId 流程模型的编号
|
||||||
* @param processDefinitionId 流程定义的编号
|
* @param processDefinitionId 流程定义的编号
|
||||||
* @return 任务规则数组
|
* @return 任务规则数组
|
||||||
*/
|
*/
|
||||||
List<BpmTaskAssignRuleRespVO> getTaskAssignRuleList(String modelId, String processDefinitionId);
|
List<BpmTaskAssignRuleRespVO> getTaskAssignRuleList(String modelId, String processDefinitionId);
|
||||||
|
|
||||||
// TODO 芋艿:创建任务规则
|
/**
|
||||||
|
* 创建任务分配规则
|
||||||
|
*
|
||||||
|
* @param reqVO 创建信息
|
||||||
|
* @return 规则编号
|
||||||
|
*/
|
||||||
|
Long createTaskAssignRule(@Valid BpmTaskAssignRuleCreateReqVO reqVO);
|
||||||
|
|
||||||
// TODO 芋艿:复制任务规则
|
// TODO 芋艿:复制任务规则
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,14 +2,19 @@ package cn.iocoder.yudao.adminserver.modules.bpm.service.definition.impl;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.rule.BpmTaskAssignRuleCreateReqVO;
|
||||||
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.convert.definition.BpmTaskAssignRuleConvert;
|
import cn.iocoder.yudao.adminserver.modules.bpm.convert.definition.BpmTaskAssignRuleConvert;
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition.BpmTaskAssignRuleDO;
|
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition.BpmTaskAssignRuleDO;
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.definition.BpmTaskAssignRuleMapper;
|
import cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.definition.BpmTaskAssignRuleMapper;
|
||||||
|
import cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants;
|
||||||
|
import cn.iocoder.yudao.adminserver.modules.bpm.enums.definition.BpmTaskAssignRuleTypeEnum;
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmModelService;
|
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmModelService;
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmProcessDefinitionService;
|
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmProcessDefinitionService;
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmTaskAssignRuleService;
|
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmTaskAssignRuleService;
|
||||||
|
import cn.iocoder.yudao.adminserver.modules.system.service.permission.SysRoleService;
|
||||||
import cn.iocoder.yudao.framework.activiti.core.util.ActivitiUtils;
|
import cn.iocoder.yudao.framework.activiti.core.util.ActivitiUtils;
|
||||||
|
import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.activiti.bpmn.model.BpmnModel;
|
import org.activiti.bpmn.model.BpmnModel;
|
||||||
import org.activiti.bpmn.model.UserTask;
|
import org.activiti.bpmn.model.UserTask;
|
||||||
|
@ -20,6 +25,10 @@ import org.springframework.validation.annotation.Validated;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BPM 任务分配规则 Service 实现类
|
* BPM 任务分配规则 Service 实现类
|
||||||
|
@ -38,6 +47,8 @@ public class BpmTaskAssignRuleServiceImpl implements BpmTaskAssignRuleService {
|
||||||
@Resource
|
@Resource
|
||||||
@Lazy // 解决循环依赖
|
@Lazy // 解决循环依赖
|
||||||
private BpmProcessDefinitionService processDefinitionService;
|
private BpmProcessDefinitionService processDefinitionService;
|
||||||
|
@Resource
|
||||||
|
private SysRoleService roleService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<BpmTaskAssignRuleDO> getTaskAssignRuleListByProcessDefinitionId(String processDefinitionId,
|
public List<BpmTaskAssignRuleDO> getTaskAssignRuleListByProcessDefinitionId(String processDefinitionId,
|
||||||
|
@ -76,4 +87,31 @@ public class BpmTaskAssignRuleServiceImpl implements BpmTaskAssignRuleService {
|
||||||
return BpmTaskAssignRuleConvert.INSTANCE.convertList(userTasks, rules);
|
return BpmTaskAssignRuleConvert.INSTANCE.convertList(userTasks, rules);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long createTaskAssignRule(BpmTaskAssignRuleCreateReqVO reqVO) {
|
||||||
|
// 校验参数
|
||||||
|
validTaskAssignRuleOptions(reqVO.getType(), reqVO.getOptions());
|
||||||
|
// 校验是否已经配置
|
||||||
|
BpmTaskAssignRuleDO existRule = taskRuleMapper.selectListByModelIdAndTaskDefinitionKey(
|
||||||
|
reqVO.getModelId(), reqVO.getTaskDefinitionKey());
|
||||||
|
if (existRule != null) {
|
||||||
|
throw exception(BpmErrorCodeConstants.TASK_ASSIGN_RULE_EXISTS,
|
||||||
|
reqVO.getModelId(), reqVO.getTaskDefinitionKey());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 存储
|
||||||
|
BpmTaskAssignRuleDO rule = BpmTaskAssignRuleConvert.INSTANCE.convert(reqVO)
|
||||||
|
.setProcessDefinitionId(BpmTaskAssignRuleDO.PROCESS_DEFINITION_ID_NULL); // 只有流程模型,才允许新建
|
||||||
|
taskRuleMapper.insert(rule);
|
||||||
|
return rule.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validTaskAssignRuleOptions(Integer type, Set<Long> options) {
|
||||||
|
if (Objects.equals(type, BpmTaskAssignRuleTypeEnum.ROLE.getType())) {
|
||||||
|
roleService.validRoles(options);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,7 +97,7 @@ public class SysRoleController {
|
||||||
@OperateLog(type = EXPORT)
|
@OperateLog(type = EXPORT)
|
||||||
@PreAuthorize("@ss.hasPermission('system:role:export')")
|
@PreAuthorize("@ss.hasPermission('system:role:export')")
|
||||||
public void export(HttpServletResponse response, @Validated SysRoleExportReqVO reqVO) throws IOException {
|
public void export(HttpServletResponse response, @Validated SysRoleExportReqVO reqVO) throws IOException {
|
||||||
List<SysRoleDO> list = roleService.getRoles(reqVO);
|
List<SysRoleDO> list = roleService.getRoleList(reqVO);
|
||||||
List<SysRoleExcelVO> data = SysRoleConvert.INSTANCE.convertList03(list);
|
List<SysRoleExcelVO> data = SysRoleConvert.INSTANCE.convertList03(list);
|
||||||
// 输出
|
// 输出
|
||||||
ExcelUtils.write(response, "角色数据.xls", "角色列表", SysRoleExcelVO.class, data);
|
ExcelUtils.write(response, "角色数据.xls", "角色列表", SysRoleExcelVO.class, data);
|
||||||
|
|
|
@ -31,6 +31,7 @@ public interface SysErrorCodeConstants {
|
||||||
ErrorCode ROLE_NAME_DUPLICATE = new ErrorCode(1002003001, "已经存在名为【{}】的角色");
|
ErrorCode ROLE_NAME_DUPLICATE = new ErrorCode(1002003001, "已经存在名为【{}】的角色");
|
||||||
ErrorCode ROLE_CODE_DUPLICATE = new ErrorCode(1002003002, "已经存在编码为【{}】的角色");
|
ErrorCode ROLE_CODE_DUPLICATE = new ErrorCode(1002003002, "已经存在编码为【{}】的角色");
|
||||||
ErrorCode ROLE_CAN_NOT_UPDATE_SYSTEM_TYPE_ROLE = new ErrorCode(1002003004, "不能操作类型为系统内置的角色");
|
ErrorCode ROLE_CAN_NOT_UPDATE_SYSTEM_TYPE_ROLE = new ErrorCode(1002003004, "不能操作类型为系统内置的角色");
|
||||||
|
ErrorCode ROLE_IS_DISABLE = new ErrorCode(1002003004, "名字为【{}】的角色已被禁用");
|
||||||
|
|
||||||
// ========== 用户模块 1002004000 ==========
|
// ========== 用户模块 1002004000 ==========
|
||||||
ErrorCode USER_USERNAME_EXISTS = new ErrorCode(1002004000, "用户账号已经存在");
|
ErrorCode USER_USERNAME_EXISTS = new ErrorCode(1002004000, "用户账号已经存在");
|
||||||
|
|
|
@ -127,6 +127,15 @@ public interface SysRoleService {
|
||||||
* @param reqVO 列表查询
|
* @param reqVO 列表查询
|
||||||
* @return 角色列表
|
* @return 角色列表
|
||||||
*/
|
*/
|
||||||
List<SysRoleDO> getRoles(SysRoleExportReqVO reqVO);
|
List<SysRoleDO> getRoleList(SysRoleExportReqVO reqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验角色们是否有效。如下情况,视为无效:
|
||||||
|
* 1. 角色编号不存在
|
||||||
|
* 2. 角色被禁用
|
||||||
|
*
|
||||||
|
* @param ids 角色编号数组
|
||||||
|
*/
|
||||||
|
void validRoles(Collection<Long> ids);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollectionUtil;
|
||||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||||
import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil;
|
import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||||
import cn.iocoder.yudao.adminserver.modules.system.controller.permission.vo.role.SysRoleCreateReqVO;
|
import cn.iocoder.yudao.adminserver.modules.system.controller.permission.vo.role.SysRoleCreateReqVO;
|
||||||
import cn.iocoder.yudao.adminserver.modules.system.controller.permission.vo.role.SysRoleExportReqVO;
|
import cn.iocoder.yudao.adminserver.modules.system.controller.permission.vo.role.SysRoleExportReqVO;
|
||||||
|
@ -33,9 +34,11 @@ import org.springframework.util.StringUtils;
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.function.Consumer;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.adminserver.modules.system.enums.SysErrorCodeConstants.*;
|
import static cn.iocoder.yudao.adminserver.modules.system.enums.SysErrorCodeConstants.*;
|
||||||
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色 Service 实现类
|
* 角色 Service 实现类
|
||||||
|
@ -234,10 +237,30 @@ public class SysRoleServiceImpl implements SysRoleService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SysRoleDO> getRoles(SysRoleExportReqVO reqVO) {
|
public List<SysRoleDO> getRoleList(SysRoleExportReqVO reqVO) {
|
||||||
return roleMapper.listRoles(reqVO);
|
return roleMapper.listRoles(reqVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void validRoles(Collection<Long> ids) {
|
||||||
|
if (CollUtil.isEmpty(ids)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 获得角色信息
|
||||||
|
List<SysRoleDO> roles = roleMapper.selectBatchIds(ids);
|
||||||
|
Map<Long, SysRoleDO> roleMap = CollectionUtils.convertMap(roles, SysRoleDO::getId);
|
||||||
|
// 校验
|
||||||
|
ids.forEach(id -> {
|
||||||
|
SysRoleDO role = roleMap.get(id);
|
||||||
|
if (role == null) {
|
||||||
|
throw exception(ROLE_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
if (!CommonStatusEnum.ENABLE.getStatus().equals(role.getStatus())) {
|
||||||
|
throw exception(ROLE_IS_DISABLE, role.getName());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验角色的唯一字段是否重复
|
* 校验角色的唯一字段是否重复
|
||||||
*
|
*
|
||||||
|
@ -253,7 +276,7 @@ public class SysRoleServiceImpl implements SysRoleService {
|
||||||
// 1. 该 name 名字被其它角色所使用
|
// 1. 该 name 名字被其它角色所使用
|
||||||
SysRoleDO role = roleMapper.selectByName(name);
|
SysRoleDO role = roleMapper.selectByName(name);
|
||||||
if (role != null && !role.getId().equals(id)) {
|
if (role != null && !role.getId().equals(id)) {
|
||||||
throw ServiceExceptionUtil.exception(ROLE_NAME_DUPLICATE, name);
|
throw exception(ROLE_NAME_DUPLICATE, name);
|
||||||
}
|
}
|
||||||
// 2. 是否存在相同编码的角色
|
// 2. 是否存在相同编码的角色
|
||||||
if (!StringUtils.hasText(code)) {
|
if (!StringUtils.hasText(code)) {
|
||||||
|
@ -262,7 +285,7 @@ public class SysRoleServiceImpl implements SysRoleService {
|
||||||
// 该 code 编码被其它角色所使用
|
// 该 code 编码被其它角色所使用
|
||||||
role = roleMapper.selectByCode(code);
|
role = roleMapper.selectByCode(code);
|
||||||
if (role != null && !role.getId().equals(id)) {
|
if (role != null && !role.getId().equals(id)) {
|
||||||
throw ServiceExceptionUtil.exception(ROLE_CODE_DUPLICATE, code);
|
throw exception(ROLE_CODE_DUPLICATE, code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,18 +298,12 @@ public class SysRoleServiceImpl implements SysRoleService {
|
||||||
public void checkUpdateRole(Long id) {
|
public void checkUpdateRole(Long id) {
|
||||||
SysRoleDO roleDO = roleMapper.selectById(id);
|
SysRoleDO roleDO = roleMapper.selectById(id);
|
||||||
if (roleDO == null) {
|
if (roleDO == null) {
|
||||||
throw ServiceExceptionUtil.exception(ROLE_NOT_EXISTS);
|
throw exception(ROLE_NOT_EXISTS);
|
||||||
}
|
}
|
||||||
// 内置角色,不允许删除
|
// 内置角色,不允许删除
|
||||||
if (SysRoleTypeEnum.SYSTEM.getType().equals(roleDO.getType())) {
|
if (SysRoleTypeEnum.SYSTEM.getType().equals(roleDO.getType())) {
|
||||||
throw ServiceExceptionUtil.exception(ROLE_CAN_NOT_UPDATE_SYSTEM_TYPE_ROLE);
|
throw exception(ROLE_CAN_NOT_UPDATE_SYSTEM_TYPE_ROLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override
|
|
||||||
// @DataScope(deptAlias = "d")
|
|
||||||
// public List<SysRole> selectRoleList(SysRole role) {
|
|
||||||
// return roleMapper.selectRoleList(role);
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -210,7 +210,13 @@
|
||||||
<span>{{ getDictDataLabel(DICT_TYPE.BPM_TASK_ASSIGN_RULE_TYPE, scope.row.type) }}</span>
|
<span>{{ getDictDataLabel(DICT_TYPE.BPM_TASK_ASSIGN_RULE_TYPE, scope.row.type) }}</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="规则范围" align="center" prop="options" />
|
<el-table-column label="规则范围" align="center" prop="options" width="200px">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-tag size="medium" v-if="scope.row.options" v-for="option in scope.row.options">
|
||||||
|
{{ getAssignRuleOptionName(scope.row.type, option) }}
|
||||||
|
</el-tag>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
<el-table-column label="操作" align="center" width="80" fixed="right">
|
<el-table-column label="操作" align="center" width="80" fixed="right">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<!-- TODO 权限 -->
|
<!-- TODO 权限 -->
|
||||||
|
@ -604,9 +610,9 @@ export default {
|
||||||
...row,
|
...row,
|
||||||
options: []
|
options: []
|
||||||
};
|
};
|
||||||
// TODO 芋艿:需要搞一搞
|
// 将 options 赋值到对应的 roleIds 等选项
|
||||||
if (row.type === 10) {
|
if (row.type === 10) {
|
||||||
this.taskAssignRule.form.role = row.options;
|
this.taskAssignRule.form.roleIds = row.options;
|
||||||
}
|
}
|
||||||
this.taskAssignRule.open = true;
|
this.taskAssignRule.open = true;
|
||||||
},
|
},
|
||||||
|
@ -619,12 +625,14 @@ export default {
|
||||||
...this.taskAssignRule.form,
|
...this.taskAssignRule.form,
|
||||||
taskDefinitionName: undefined,
|
taskDefinitionName: undefined,
|
||||||
};
|
};
|
||||||
|
// 将 roleIds 等选项赋值到 options 中
|
||||||
if (form.type === 10) {
|
if (form.type === 10) {
|
||||||
form.options = form.roleIds;
|
form.options = form.roleIds;
|
||||||
}
|
}
|
||||||
form.roleIds = undefined;
|
form.roleIds = undefined;
|
||||||
// 新增
|
// 新增
|
||||||
if (!form.id) {
|
if (!form.id) {
|
||||||
|
form.modelId = this.taskAssignRule.row.id // 模型编号
|
||||||
createTaskAssignRule(form).then(response => {
|
createTaskAssignRule(form).then(response => {
|
||||||
this.msgSuccess("修改成功");
|
this.msgSuccess("修改成功");
|
||||||
this.taskAssignRule.open = false;
|
this.taskAssignRule.open = false;
|
||||||
|
@ -647,10 +655,20 @@ export default {
|
||||||
this.taskAssignRule.open = false;
|
this.taskAssignRule.open = false;
|
||||||
this.resetAssignRuleForm();
|
this.resetAssignRuleForm();
|
||||||
},
|
},
|
||||||
// 表单重置
|
/** 表单重置 */
|
||||||
resetAssignRuleForm() {
|
resetAssignRuleForm() {
|
||||||
this.taskAssignRule.form = {};
|
this.taskAssignRule.form = {};
|
||||||
this.resetForm("taskAssignRuleForm");
|
this.resetForm("taskAssignRuleForm");
|
||||||
|
},
|
||||||
|
getAssignRuleOptionName(type, option) {
|
||||||
|
if (type === 10) {
|
||||||
|
for (const roleOption of this.taskAssignRule.roleOptions) {
|
||||||
|
if (roleOption.id === option) {
|
||||||
|
return roleOption.name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return '未知(' + option + ')';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue