任务详情、任务分配:非项目负责人无法进行新增、修改、分配操作
| | |
| | | /** 项目名称 */ |
| | | private String projectName; |
| | | |
| | | /** 项目责任人ID */ |
| | | private Long projectLiableUserId; |
| | | |
| | | /** 父任务名称 */ |
| | | private String pidName; |
| | | |
| | |
| | | /** 项目名称 */ |
| | | private String projectName; |
| | | |
| | | /** 项目责任人ID */ |
| | | private Long projectLiableUserId; |
| | | |
| | | /** 任务名称 */ |
| | | private String taskName; |
| | | |
| | |
| | | ValidationUtil.isNull(project.getId(),"Project","id",taskDto.getProjectId()); |
| | | // 项目名称 |
| | | taskDto.setProjectName(project.getName()); |
| | | // 项目责任人ID |
| | | taskDto.setProjectLiableUserId(project.getLiableUserId()); |
| | | // 判断父级任务ID是否为空 |
| | | if (taskDto.getPid() != null) { |
| | | // 根据父级任务ID查询任务信息 |
| | |
| | | ValidationUtil.isNull(project.getId(),"Project","id",taskUserDto.getProjectId()); |
| | | // 项目名称 |
| | | taskUserDto.setProjectName(project.getName()); |
| | | // 项目责任人ID |
| | | taskUserDto.setProjectLiableUserId(project.getLiableUserId()); |
| | | // 根据任务ID查询任务信息 |
| | | Task task = taskRepository.findById(taskUserDto.getTaskId()).orElseGet(Task::new); |
| | | ValidationUtil.isNull(task.getId(),"Task","id",taskUserDto.getTaskId()); |
| | |
| | | <el-table-column v-if="checkPer(['admin','task:divide','task:edit','task:del'])" label="操作" width="180px" align="center" fixed="right"> |
| | | <template slot-scope="scope"> |
| | | <udOperation |
| | | v-if="userRolesLevelMin == roleLevelSuper || userRolesLevelMin == roleLevelGeneral || scope.row.projectLiableUserId == $store.state.user.user.id" |
| | | :data="scope.row" |
| | | :permission="permission" |
| | | > |
| | |
| | | taskStatus: constant.TASK_STATUS, |
| | | // 字典:批准状态-未承认 |
| | | approveStatusUnrecognized: constant.APPROVE_STATUS_UNRECOGNIZED, |
| | | // 角色级别:超级管理员 |
| | | roleLevelSuper: constant.ROLE_LEVEL_SUPER, |
| | | // 角色级别:总经理 |
| | | roleLevelGeneral: constant.ROLE_LEVEL_GENERAL, |
| | | // CRUD状态 |
| | | crudStatusPrepared: CRUD.STATUS.PREPARED, |
| | | // 用户最大角色级别 |
| | | userRolesLevelMin: null, |
| | | // 项目列表 |
| | | projects: [], |
| | | // 父级任务列表 |
| | |
| | | methods: { |
| | | // 钩子:在获取表格数据之前执行,false 则代表不获取数据 |
| | | [CRUD.HOOK.beforeRefresh]() { |
| | | // 用户角色级别数组 |
| | | const userRolesLevel = this.$store.state.user.user.roles.map(({ level }) => level) |
| | | // 用户最大角色级别 |
| | | this.userRolesLevelMin = Math.min(...userRolesLevel) |
| | | // 获取项目 |
| | | this.getProject() |
| | | // 获取用户 |
| | |
| | | return false |
| | | } |
| | | }) |
| | | }, |
| | | // 钩子:提交 - 之前 |
| | | [CRUD.HOOK.beforeSubmit]() { |
| | | // 判断用户角色 |
| | | if (this.userRolesLevelMin === this.roleLevelSuper || this.userRolesLevelMin === this.roleLevelGeneral) { |
| | | return true |
| | | } else { |
| | | // 检索选中项目信息 |
| | | const chooseProject = this.projects.filter((item) => { |
| | | return item.id === this.form.projectId |
| | | }) |
| | | // 判断是否是项目责任人 |
| | | if (chooseProject.projectLiableUserId === this.$store.state.user.user.id) { |
| | | return true |
| | | } else { |
| | | // 消息提示 |
| | | this.crud.notify('您不是当前项目责任人,无法添加/修改任务详情', CRUD.NOTIFICATION_TYPE.WARNING) |
| | | return false |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | <el-table-column v-if="checkPer(['admin','taskUser:edit','taskUser:del'])" label="操作" width="150px" align="center" fixed="right"> |
| | | <template slot-scope="scope"> |
| | | <udOperation |
| | | v-if="userRolesLevelMin == roleLevelSuper || userRolesLevelMin == roleLevelGeneral || scope.row.projectLiableUserId == $store.state.user.user.id || scope.row.userId == $store.state.user.user.id" |
| | | :data="scope.row" |
| | | :permission="permission" |
| | | /> |
| | |
| | | standardWorkloadUnit: constant.STANDARD_WORKLOAD_UNIT, |
| | | // 字典:批准状态-未承认 |
| | | approveStatusUnrecognized: constant.APPROVE_STATUS_UNRECOGNIZED, |
| | | // 角色级别:超级管理员 |
| | | roleLevelSuper: constant.ROLE_LEVEL_SUPER, |
| | | // 角色级别:总经理 |
| | | roleLevelGeneral: constant.ROLE_LEVEL_GENERAL, |
| | | // 角色级别:普通用户 |
| | | roleLevelOrdinary: constant.ROLE_LEVEL_ORDINARY, |
| | | // CRUD状态 |
| | |
| | | this.form.divideUserIds = res |
| | | }) |
| | | } |
| | | }, |
| | | // 钩子:提交 - 之前 |
| | | [CRUD.HOOK.beforeSubmit]() { |
| | | // 判断用户角色 |
| | | if (this.userRolesLevelMin === this.roleLevelSuper || this.userRolesLevelMin === this.roleLevelGeneral) { |
| | | return true |
| | | } else { |
| | | // 检索选中项目信息 |
| | | const chooseProject = this.projects.filter((item) => { |
| | | return item.id === this.form.projectId |
| | | }) |
| | | // 判断是否是项目责任人 |
| | | if (chooseProject.projectLiableUserId === this.$store.state.user.user.id || this.form.userId === this.$store.state.user.user.id) { |
| | | return true |
| | | } else { |
| | | // 消息提示 |
| | | this.crud.notify('您不是当前项目责任人,无法添加/修改任务分配', CRUD.NOTIFICATION_TYPE.WARNING) |
| | | return false |
| | | } |
| | | } |
| | | } |
| | | } |
| | | </script> |