Commit 9f0cd04fa6bce4ad34bbbc2ba606c66810a4b500
1 parent
3f6a5f06
BPM 模型重构 7:增加任务分配规则的列表 UI 界面(增加角色的规则配置)
Showing
12 changed files
with
132 additions
and
23 deletions
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/BpmTaskAssignRuleController.java
| ... | ... | @@ -31,8 +31,8 @@ public class BpmTaskAssignRuleController { |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | @PostMapping("/create") |
| 34 | - public CommonResult<String> createTaskAssignRule(@Valid @RequestBody BpmTaskAssignRuleCreateReqVO reqVO) { | |
| 35 | - return success("1024"); | |
| 34 | + public CommonResult<Long> createTaskAssignRule(@Valid @RequestBody BpmTaskAssignRuleCreateReqVO reqVO) { | |
| 35 | + return success(taskAssignRuleService.createTaskAssignRule(reqVO)); | |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | @PutMapping("/update") | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/vo/rule/BpmTaskAssignRuleCreateReqVO.java
| 1 | 1 | package cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.rule; |
| 2 | 2 | |
| 3 | -import java.util.Set; | |
| 3 | +import lombok.Data; | |
| 4 | +import lombok.EqualsAndHashCode; | |
| 4 | 5 | |
| 6 | +@Data | |
| 7 | +@EqualsAndHashCode(callSuper = true) | |
| 5 | 8 | public class BpmTaskAssignRuleCreateReqVO extends BpmTaskAssignRuleBaseVO { |
| 6 | 9 | |
| 7 | 10 | private String modelId; | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/definition/BpmTaskAssignRuleConvert.java
| 1 | 1 | package cn.iocoder.yudao.adminserver.modules.bpm.convert.definition; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | +import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.rule.BpmTaskAssignRuleCreateReqVO; | |
| 4 | 5 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.rule.BpmTaskAssignRuleRespVO; |
| 5 | 6 | import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition.BpmTaskAssignRuleDO; |
| 6 | 7 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| ... | ... | @@ -33,4 +34,6 @@ public interface BpmTaskAssignRuleConvert { |
| 33 | 34 | |
| 34 | 35 | BpmTaskAssignRuleRespVO convert(BpmTaskAssignRuleDO bean); |
| 35 | 36 | |
| 37 | + BpmTaskAssignRuleDO convert(BpmTaskAssignRuleCreateReqVO bean); | |
| 38 | + | |
| 36 | 39 | } | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/mysql/definition/BpmTaskAssignRuleMapper.java
| ... | ... | @@ -24,4 +24,12 @@ public interface BpmTaskAssignRuleMapper extends BaseMapperX<BpmTaskAssignRuleDO |
| 24 | 24 | .eq("process_definition_id", BpmTaskAssignRuleDO.PROCESS_DEFINITION_ID_NULL)); |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | + default BpmTaskAssignRuleDO selectListByModelIdAndTaskDefinitionKey(String modelId, | |
| 28 | + String taskDefinitionKey) { | |
| 29 | + return selectOne(new QueryWrapperX<BpmTaskAssignRuleDO>() | |
| 30 | + .eq("model_id", modelId) | |
| 31 | + .eq("process_definition_id", BpmTaskAssignRuleDO.PROCESS_DEFINITION_ID_NULL) | |
| 32 | + .eq("task_definition_key", taskDefinitionKey)); | |
| 33 | + } | |
| 34 | + | |
| 27 | 35 | } | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/enums/BpmErrorCodeConstants.java
| ... | ... | @@ -37,9 +37,12 @@ public interface BpmErrorCodeConstants { |
| 37 | 37 | ErrorCode PROCESS_INSTANCE_CANCEL_FAIL_NOT_EXISTS = new ErrorCode(1009004001, "流程取消失败,流程不处于运行中"); |
| 38 | 38 | ErrorCode PROCESS_INSTANCE_CANCEL_FAIL_NOT_SELF = new ErrorCode(1009004002, "流程取消失败,该流程不是你发起的"); |
| 39 | 39 | |
| 40 | - // ========== 流程实例 1-009-005-000 ========== | |
| 40 | + // ========== 流程任务 1-009-005-000 ========== | |
| 41 | 41 | ErrorCode TASK_COMPLETE_FAIL_NOT_EXISTS = new ErrorCode(1009004000, "审批任务失败,原因:该任务不处于未审批"); |
| 42 | 42 | |
| 43 | + // ========== 流程任务分配规则 1-009-006-000 ========== | |
| 44 | + ErrorCode TASK_ASSIGN_RULE_EXISTS = new ErrorCode(1009006000, "流程({}) 的任务({}) 已经存在分配规则"); | |
| 45 | + | |
| 43 | 46 | // ========== 动态表单模块 1-009-010-000 ========== |
| 44 | 47 | ErrorCode FORM_NOT_EXISTS = new ErrorCode(1009010000, "动态表单不存在"); |
| 45 | 48 | ErrorCode FORM_FIELD_REPEAT = new ErrorCode(1009010000, "表单项({}) 和 ({}) 使用了相同的字段名({})"); | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/BpmTaskAssignRuleService.java
| 1 | 1 | package cn.iocoder.yudao.adminserver.modules.bpm.service.definition; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.rule.BpmTaskAssignRuleCreateReqVO; | |
| 3 | 4 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.rule.BpmTaskAssignRuleRespVO; |
| 4 | 5 | import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition.BpmTaskAssignRuleDO; |
| 5 | 6 | import org.springframework.lang.Nullable; |
| 6 | 7 | |
| 8 | +import javax.validation.Valid; | |
| 7 | 9 | import java.util.List; |
| 8 | 10 | |
| 9 | 11 | /** |
| ... | ... | @@ -35,13 +37,20 @@ public interface BpmTaskAssignRuleService { |
| 35 | 37 | /** |
| 36 | 38 | * 获得流程定义的任务分配规则数组 |
| 37 | 39 | * |
| 38 | - * @param processDefinitionId 流程模型的编号 | |
| 40 | + * @param modelId 流程模型的编号 | |
| 39 | 41 | * @param processDefinitionId 流程定义的编号 |
| 40 | 42 | * @return 任务规则数组 |
| 41 | 43 | */ |
| 42 | 44 | List<BpmTaskAssignRuleRespVO> getTaskAssignRuleList(String modelId, String processDefinitionId); |
| 43 | 45 | |
| 44 | - // TODO 芋艿:创建任务规则 | |
| 46 | + /** | |
| 47 | + * 创建任务分配规则 | |
| 48 | + * | |
| 49 | + * @param reqVO 创建信息 | |
| 50 | + * @return 规则编号 | |
| 51 | + */ | |
| 52 | + Long createTaskAssignRule(@Valid BpmTaskAssignRuleCreateReqVO reqVO); | |
| 53 | + | |
| 45 | 54 | // TODO 芋艿:复制任务规则 |
| 46 | 55 | |
| 47 | 56 | } | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmTaskAssignRuleServiceImpl.java
| ... | ... | @@ -2,14 +2,19 @@ package cn.iocoder.yudao.adminserver.modules.bpm.service.definition.impl; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | 4 | import cn.hutool.core.util.StrUtil; |
| 5 | +import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.rule.BpmTaskAssignRuleCreateReqVO; | |
| 5 | 6 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.rule.BpmTaskAssignRuleRespVO; |
| 6 | 7 | import cn.iocoder.yudao.adminserver.modules.bpm.convert.definition.BpmTaskAssignRuleConvert; |
| 7 | 8 | import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition.BpmTaskAssignRuleDO; |
| 8 | 9 | import cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.definition.BpmTaskAssignRuleMapper; |
| 10 | +import cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants; | |
| 11 | +import cn.iocoder.yudao.adminserver.modules.bpm.enums.definition.BpmTaskAssignRuleTypeEnum; | |
| 9 | 12 | import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmModelService; |
| 10 | 13 | import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmProcessDefinitionService; |
| 11 | 14 | import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmTaskAssignRuleService; |
| 15 | +import cn.iocoder.yudao.adminserver.modules.system.service.permission.SysRoleService; | |
| 12 | 16 | import cn.iocoder.yudao.framework.activiti.core.util.ActivitiUtils; |
| 17 | +import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; | |
| 13 | 18 | import lombok.extern.slf4j.Slf4j; |
| 14 | 19 | import org.activiti.bpmn.model.BpmnModel; |
| 15 | 20 | import org.activiti.bpmn.model.UserTask; |
| ... | ... | @@ -20,6 +25,10 @@ import org.springframework.validation.annotation.Validated; |
| 20 | 25 | import javax.annotation.Resource; |
| 21 | 26 | import java.util.Collections; |
| 22 | 27 | import java.util.List; |
| 28 | +import java.util.Objects; | |
| 29 | +import java.util.Set; | |
| 30 | + | |
| 31 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | |
| 23 | 32 | |
| 24 | 33 | /** |
| 25 | 34 | * BPM 任务分配规则 Service 实现类 |
| ... | ... | @@ -38,6 +47,8 @@ public class BpmTaskAssignRuleServiceImpl implements BpmTaskAssignRuleService { |
| 38 | 47 | @Resource |
| 39 | 48 | @Lazy // 解决循环依赖 |
| 40 | 49 | private BpmProcessDefinitionService processDefinitionService; |
| 50 | + @Resource | |
| 51 | + private SysRoleService roleService; | |
| 41 | 52 | |
| 42 | 53 | @Override |
| 43 | 54 | public List<BpmTaskAssignRuleDO> getTaskAssignRuleListByProcessDefinitionId(String processDefinitionId, |
| ... | ... | @@ -76,4 +87,31 @@ public class BpmTaskAssignRuleServiceImpl implements BpmTaskAssignRuleService { |
| 76 | 87 | return BpmTaskAssignRuleConvert.INSTANCE.convertList(userTasks, rules); |
| 77 | 88 | } |
| 78 | 89 | |
| 90 | + @Override | |
| 91 | + public Long createTaskAssignRule(BpmTaskAssignRuleCreateReqVO reqVO) { | |
| 92 | + // 校验参数 | |
| 93 | + validTaskAssignRuleOptions(reqVO.getType(), reqVO.getOptions()); | |
| 94 | + // 校验是否已经配置 | |
| 95 | + BpmTaskAssignRuleDO existRule = taskRuleMapper.selectListByModelIdAndTaskDefinitionKey( | |
| 96 | + reqVO.getModelId(), reqVO.getTaskDefinitionKey()); | |
| 97 | + if (existRule != null) { | |
| 98 | + throw exception(BpmErrorCodeConstants.TASK_ASSIGN_RULE_EXISTS, | |
| 99 | + reqVO.getModelId(), reqVO.getTaskDefinitionKey()); | |
| 100 | + } | |
| 101 | + | |
| 102 | + // 存储 | |
| 103 | + BpmTaskAssignRuleDO rule = BpmTaskAssignRuleConvert.INSTANCE.convert(reqVO) | |
| 104 | + .setProcessDefinitionId(BpmTaskAssignRuleDO.PROCESS_DEFINITION_ID_NULL); // 只有流程模型,才允许新建 | |
| 105 | + taskRuleMapper.insert(rule); | |
| 106 | + return rule.getId(); | |
| 107 | + } | |
| 108 | + | |
| 109 | + private void validTaskAssignRuleOptions(Integer type, Set<Long> options) { | |
| 110 | + if (Objects.equals(type, BpmTaskAssignRuleTypeEnum.ROLE.getType())) { | |
| 111 | + roleService.validRoles(options); | |
| 112 | + return; | |
| 113 | + } | |
| 114 | + | |
| 115 | + } | |
| 116 | + | |
| 79 | 117 | } | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/controller/permission/SysRoleController.java
| ... | ... | @@ -97,7 +97,7 @@ public class SysRoleController { |
| 97 | 97 | @OperateLog(type = EXPORT) |
| 98 | 98 | @PreAuthorize("@ss.hasPermission('system:role:export')") |
| 99 | 99 | public void export(HttpServletResponse response, @Validated SysRoleExportReqVO reqVO) throws IOException { |
| 100 | - List<SysRoleDO> list = roleService.getRoles(reqVO); | |
| 100 | + List<SysRoleDO> list = roleService.getRoleList(reqVO); | |
| 101 | 101 | List<SysRoleExcelVO> data = SysRoleConvert.INSTANCE.convertList03(list); |
| 102 | 102 | // 输出 |
| 103 | 103 | ExcelUtils.write(response, "角色数据.xls", "角色列表", SysRoleExcelVO.class, data); | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/enums/SysErrorCodeConstants.java
| ... | ... | @@ -31,6 +31,7 @@ public interface SysErrorCodeConstants { |
| 31 | 31 | ErrorCode ROLE_NAME_DUPLICATE = new ErrorCode(1002003001, "已经存在名为【{}】的角色"); |
| 32 | 32 | ErrorCode ROLE_CODE_DUPLICATE = new ErrorCode(1002003002, "已经存在编码为【{}】的角色"); |
| 33 | 33 | ErrorCode ROLE_CAN_NOT_UPDATE_SYSTEM_TYPE_ROLE = new ErrorCode(1002003004, "不能操作类型为系统内置的角色"); |
| 34 | + ErrorCode ROLE_IS_DISABLE = new ErrorCode(1002003004, "名字为【{}】的角色已被禁用"); | |
| 34 | 35 | |
| 35 | 36 | // ========== 用户模块 1002004000 ========== |
| 36 | 37 | ErrorCode USER_USERNAME_EXISTS = new ErrorCode(1002004000, "用户账号已经存在"); | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/permission/SysRoleService.java
| ... | ... | @@ -127,6 +127,15 @@ public interface SysRoleService { |
| 127 | 127 | * @param reqVO 列表查询 |
| 128 | 128 | * @return 角色列表 |
| 129 | 129 | */ |
| 130 | - List<SysRoleDO> getRoles(SysRoleExportReqVO reqVO); | |
| 130 | + List<SysRoleDO> getRoleList(SysRoleExportReqVO reqVO); | |
| 131 | + | |
| 132 | + /** | |
| 133 | + * 校验角色们是否有效。如下情况,视为无效: | |
| 134 | + * 1. 角色编号不存在 | |
| 135 | + * 2. 角色被禁用 | |
| 136 | + * | |
| 137 | + * @param ids 角色编号数组 | |
| 138 | + */ | |
| 139 | + void validRoles(Collection<Long> ids); | |
| 131 | 140 | |
| 132 | 141 | } | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/permission/impl/SysRoleServiceImpl.java
| ... | ... | @@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollectionUtil; |
| 5 | 5 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| 6 | 6 | import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; |
| 7 | 7 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 8 | +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | |
| 8 | 9 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| 9 | 10 | import cn.iocoder.yudao.adminserver.modules.system.controller.permission.vo.role.SysRoleCreateReqVO; |
| 10 | 11 | import cn.iocoder.yudao.adminserver.modules.system.controller.permission.vo.role.SysRoleExportReqVO; |
| ... | ... | @@ -33,9 +34,11 @@ import org.springframework.util.StringUtils; |
| 33 | 34 | import javax.annotation.PostConstruct; |
| 34 | 35 | import javax.annotation.Resource; |
| 35 | 36 | import java.util.*; |
| 37 | +import java.util.function.Consumer; | |
| 36 | 38 | import java.util.stream.Collectors; |
| 37 | 39 | |
| 38 | 40 | import static cn.iocoder.yudao.adminserver.modules.system.enums.SysErrorCodeConstants.*; |
| 41 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | |
| 39 | 42 | |
| 40 | 43 | /** |
| 41 | 44 | * 角色 Service 实现类 |
| ... | ... | @@ -234,10 +237,30 @@ public class SysRoleServiceImpl implements SysRoleService { |
| 234 | 237 | } |
| 235 | 238 | |
| 236 | 239 | @Override |
| 237 | - public List<SysRoleDO> getRoles(SysRoleExportReqVO reqVO) { | |
| 240 | + public List<SysRoleDO> getRoleList(SysRoleExportReqVO reqVO) { | |
| 238 | 241 | return roleMapper.listRoles(reqVO); |
| 239 | 242 | } |
| 240 | 243 | |
| 244 | + @Override | |
| 245 | + public void validRoles(Collection<Long> ids) { | |
| 246 | + if (CollUtil.isEmpty(ids)) { | |
| 247 | + return; | |
| 248 | + } | |
| 249 | + // 获得角色信息 | |
| 250 | + List<SysRoleDO> roles = roleMapper.selectBatchIds(ids); | |
| 251 | + Map<Long, SysRoleDO> roleMap = CollectionUtils.convertMap(roles, SysRoleDO::getId); | |
| 252 | + // 校验 | |
| 253 | + ids.forEach(id -> { | |
| 254 | + SysRoleDO role = roleMap.get(id); | |
| 255 | + if (role == null) { | |
| 256 | + throw exception(ROLE_NOT_EXISTS); | |
| 257 | + } | |
| 258 | + if (!CommonStatusEnum.ENABLE.getStatus().equals(role.getStatus())) { | |
| 259 | + throw exception(ROLE_IS_DISABLE, role.getName()); | |
| 260 | + } | |
| 261 | + }); | |
| 262 | + } | |
| 263 | + | |
| 241 | 264 | /** |
| 242 | 265 | * 校验角色的唯一字段是否重复 |
| 243 | 266 | * |
| ... | ... | @@ -253,7 +276,7 @@ public class SysRoleServiceImpl implements SysRoleService { |
| 253 | 276 | // 1. 该 name 名字被其它角色所使用 |
| 254 | 277 | SysRoleDO role = roleMapper.selectByName(name); |
| 255 | 278 | if (role != null && !role.getId().equals(id)) { |
| 256 | - throw ServiceExceptionUtil.exception(ROLE_NAME_DUPLICATE, name); | |
| 279 | + throw exception(ROLE_NAME_DUPLICATE, name); | |
| 257 | 280 | } |
| 258 | 281 | // 2. 是否存在相同编码的角色 |
| 259 | 282 | if (!StringUtils.hasText(code)) { |
| ... | ... | @@ -262,7 +285,7 @@ public class SysRoleServiceImpl implements SysRoleService { |
| 262 | 285 | // 该 code 编码被其它角色所使用 |
| 263 | 286 | role = roleMapper.selectByCode(code); |
| 264 | 287 | if (role != null && !role.getId().equals(id)) { |
| 265 | - throw ServiceExceptionUtil.exception(ROLE_CODE_DUPLICATE, code); | |
| 288 | + throw exception(ROLE_CODE_DUPLICATE, code); | |
| 266 | 289 | } |
| 267 | 290 | } |
| 268 | 291 | |
| ... | ... | @@ -275,18 +298,12 @@ public class SysRoleServiceImpl implements SysRoleService { |
| 275 | 298 | public void checkUpdateRole(Long id) { |
| 276 | 299 | SysRoleDO roleDO = roleMapper.selectById(id); |
| 277 | 300 | if (roleDO == null) { |
| 278 | - throw ServiceExceptionUtil.exception(ROLE_NOT_EXISTS); | |
| 301 | + throw exception(ROLE_NOT_EXISTS); | |
| 279 | 302 | } |
| 280 | 303 | // 内置角色,不允许删除 |
| 281 | 304 | if (SysRoleTypeEnum.SYSTEM.getType().equals(roleDO.getType())) { |
| 282 | - throw ServiceExceptionUtil.exception(ROLE_CAN_NOT_UPDATE_SYSTEM_TYPE_ROLE); | |
| 305 | + throw exception(ROLE_CAN_NOT_UPDATE_SYSTEM_TYPE_ROLE); | |
| 283 | 306 | } |
| 284 | 307 | } |
| 285 | 308 | |
| 286 | -// @Override | |
| 287 | -// @DataScope(deptAlias = "d") | |
| 288 | -// public List<SysRole> selectRoleList(SysRole role) { | |
| 289 | -// return roleMapper.selectRoleList(role); | |
| 290 | -// } | |
| 291 | - | |
| 292 | 309 | } | ... | ... |
yudao-admin-ui/src/views/bpm/model/index.vue
| ... | ... | @@ -210,7 +210,13 @@ |
| 210 | 210 | <span>{{ getDictDataLabel(DICT_TYPE.BPM_TASK_ASSIGN_RULE_TYPE, scope.row.type) }}</span> |
| 211 | 211 | </template> |
| 212 | 212 | </el-table-column> |
| 213 | - <el-table-column label="规则范围" align="center" prop="options" /> | |
| 213 | + <el-table-column label="规则范围" align="center" prop="options" width="200px"> | |
| 214 | + <template slot-scope="scope"> | |
| 215 | + <el-tag size="medium" v-if="scope.row.options" v-for="option in scope.row.options"> | |
| 216 | + {{ getAssignRuleOptionName(scope.row.type, option) }} | |
| 217 | + </el-tag> | |
| 218 | + </template> | |
| 219 | + </el-table-column> | |
| 214 | 220 | <el-table-column label="操作" align="center" width="80" fixed="right"> |
| 215 | 221 | <template slot-scope="scope"> |
| 216 | 222 | <!-- TODO 权限 --> |
| ... | ... | @@ -604,9 +610,9 @@ export default { |
| 604 | 610 | ...row, |
| 605 | 611 | options: [] |
| 606 | 612 | }; |
| 607 | - // TODO 芋艿:需要搞一搞 | |
| 613 | + // 将 options 赋值到对应的 roleIds 等选项 | |
| 608 | 614 | if (row.type === 10) { |
| 609 | - this.taskAssignRule.form.role = row.options; | |
| 615 | + this.taskAssignRule.form.roleIds = row.options; | |
| 610 | 616 | } |
| 611 | 617 | this.taskAssignRule.open = true; |
| 612 | 618 | }, |
| ... | ... | @@ -619,12 +625,14 @@ export default { |
| 619 | 625 | ...this.taskAssignRule.form, |
| 620 | 626 | taskDefinitionName: undefined, |
| 621 | 627 | }; |
| 628 | + // 将 roleIds 等选项赋值到 options 中 | |
| 622 | 629 | if (form.type === 10) { |
| 623 | 630 | form.options = form.roleIds; |
| 624 | 631 | } |
| 625 | 632 | form.roleIds = undefined; |
| 626 | 633 | // 新增 |
| 627 | 634 | if (!form.id) { |
| 635 | + form.modelId = this.taskAssignRule.row.id // 模型编号 | |
| 628 | 636 | createTaskAssignRule(form).then(response => { |
| 629 | 637 | this.msgSuccess("修改成功"); |
| 630 | 638 | this.taskAssignRule.open = false; |
| ... | ... | @@ -647,10 +655,20 @@ export default { |
| 647 | 655 | this.taskAssignRule.open = false; |
| 648 | 656 | this.resetAssignRuleForm(); |
| 649 | 657 | }, |
| 650 | - // 表单重置 | |
| 658 | + /** 表单重置 */ | |
| 651 | 659 | resetAssignRuleForm() { |
| 652 | 660 | this.taskAssignRule.form = {}; |
| 653 | 661 | this.resetForm("taskAssignRuleForm"); |
| 662 | + }, | |
| 663 | + getAssignRuleOptionName(type, option) { | |
| 664 | + if (type === 10) { | |
| 665 | + for (const roleOption of this.taskAssignRule.roleOptions) { | |
| 666 | + if (roleOption.id === option) { | |
| 667 | + return roleOption.name; | |
| 668 | + } | |
| 669 | + } | |
| 670 | + } | |
| 671 | + return '未知(' + option + ')'; | |
| 654 | 672 | } |
| 655 | 673 | } |
| 656 | 674 | }; | ... | ... |