赵士淞
2023-01-31 c1ed896c45c3f04acaad3afd1f164e666d1c40fb
修复
2 files modified
40 ■■■■■ changed files
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/task/service/impl/TaskDaliyServiceImpl.java 24 ●●●●● patch | view | raw | blame | history
eladmin-web-master/src/views/task/taskDaliy/index.vue 16 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/task/service/impl/TaskDaliyServiceImpl.java
@@ -134,6 +134,8 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public TaskDaliyDto create(TaskDaliy resources) {
        // 新增修改删除验证
        checkAddOrUpdateOrDelete(resources);
        // 新增修改验证
        checkAddOrUpdate(resources);
        return taskDaliyMapper.toDto(taskDaliyRepository.save(resources));
@@ -144,6 +146,8 @@
    public void update(TaskDaliy resources) {
        TaskDaliy taskDaliy = taskDaliyRepository.findById(resources.getId()).orElseGet(TaskDaliy::new);
        ValidationUtil.isNull( taskDaliy.getId(),"TaskDaliy","id",resources.getId());
        // 新增修改删除验证
        checkAddOrUpdateOrDelete(taskDaliy);
        // 修改删除验证
        checkUpdateOrDelete(taskDaliy);
        // 新增修改验证
@@ -184,6 +188,8 @@
        for (Long id : ids) {
            TaskDaliy taskDaliy = taskDaliyRepository.findById(id).orElseGet(TaskDaliy::new);
            ValidationUtil.isNull( taskDaliy.getId(),"TaskDaliy","id",id);
            // 新增修改删除验证
            checkAddOrUpdateOrDelete(taskDaliy);
            // 修改删除验证
            checkUpdateOrDelete(taskDaliy);
            taskDaliyRepository.deleteById(id);
@@ -201,6 +207,24 @@
        }
    }
    /**
     * 新增修改删除验证
     * @param resources
     */
    private void checkAddOrUpdateOrDelete(TaskDaliy resources) {
        // 获取登录用户角色等级
        List<Integer> levels = roleService.findByUsersId(SecurityUtils.getCurrentUserId()).stream().map(RoleSmallDto::getLevel).collect(Collectors.toList());
        // 登录用户最大角色等级
        int min = Collections.min(levels);
        // 判断角色等级
        if (min == Constant.ROLE_LEVEL_MANAGER || min == Constant.ROLE_LEVEL_LEADER || min == Constant.ROLE_LEVEL_ORDINARY) {
            // 判断是否是自己的日报
            if (SecurityUtils.getCurrentUserId().longValue() != resources.getUserId().longValue()) {
                throw new BadRequestException("只能新增修改自己的任务日报!");
            }
        }
    }
    @Override
    public void download(List<TaskDaliyDto> all, HttpServletResponse response) throws IOException {
        List<Map<String, Object>> list = new ArrayList<>();
eladmin-web-master/src/views/task/taskDaliy/index.vue
@@ -39,7 +39,7 @@
            <el-date-picker v-model="form.fillDate" type="date" style="width: 340px;" :disabled="disabledFlagBySettlement" />
          </el-form-item>
          <el-form-item label="所属员工" prop="userId">
            <el-select v-model="form.userId" filterable clearable placeholder="请选择" style="width: 340px;" :disabled="disabledFlagBySettlement || userRolesLevelMin == roleLevelOrdinary" @change="formUserChange">
            <el-select v-model="form.userId" filterable clearable placeholder="请选择" style="width: 340px;" :disabled="disabledFlagBySettlement || (userRolesLevelMin != roleLevelSuper && userRolesLevelMin != roleLevelGeneral)" @change="formUserChange">
              <el-option
                v-for="item in users"
                :key="item.id"
@@ -85,7 +85,7 @@
              <template slot="append">%</template>
            </el-input>
          </el-form-item>
          <el-form-item v-if="userRolesLevelMin != roleLevelOrdinary && crud.status.edit == crudStatusPrepared" label="结算状态" prop="settlementStatus">
          <el-form-item v-if="(userRolesLevelMin == roleLevelSuper || userRolesLevelMin == roleLevelGeneral) && crud.status.edit == crudStatusPrepared" label="结算状态" prop="settlementStatus">
            <el-select v-model="form.settlementStatus" filterable placeholder="请选择" style="width: 340px;" :disabled="disabledFlagBySettlement">
              <el-option
                v-for="item in dict[settlementStatus]"
@@ -149,7 +149,7 @@
        <el-table-column v-if="checkPer(['admin','taskDaliy:edit','taskDaliy:del'])" label="操作" width="150px" align="center" fixed="right">
          <template slot-scope="scope">
            <udOperation
              v-if="userRolesLevelMin != roleLevelOrdinary || scope.row.userId == user.id"
              v-if="userRolesLevelMin == roleLevelSuper || userRolesLevelMin == roleLevelGeneral || scope.row.userId == user.id"
              :data="scope.row"
              :permission="permission"
            />
@@ -247,8 +247,10 @@
      standardWorkloadUnit: constant.STANDARD_WORKLOAD_UNIT,
      // 字典:结算状态
      settlementStatus: constant.SETTLEMENT_STATUS,
      // 角色级别:普通用户
      roleLevelOrdinary: constant.ROLE_LEVEL_ORDINARY,
      // 角色级别:超级管理员
      roleLevelSuper: constant.ROLE_LEVEL_SUPER,
      // 角色级别:总经理
      roleLevelGeneral: constant.ROLE_LEVEL_GENERAL,
      // CRUD状态
      crudStatusPrepared: CRUD.STATUS.PREPARED,
      // 用户最大角色级别
@@ -349,8 +351,8 @@
    [CRUD.HOOK.beforeToAdd]() {
      // 表单赋值
      this.form.consumedWorkloadUnit = null
      // 判断用户最大角色级别是否是角色级别:普通用户
      if (this.userRolesLevelMin === this.roleLevelOrdinary) {
      // 判断用户最大角色级别是否是角色级别:超级管理员或角色级别:总经理
      if (this.userRolesLevelMin !== this.roleLevelSuper && this.userRolesLevelMin !== this.roleLevelGeneral) {
        // 表单赋值
        this.form.userId = this.user.id
        // 表单用户变更