赵士淞
2023-03-20 63dc884997f830508db8e56325f3756300f310e4
eladmin-web-master/src/views/task/task/index.vue
@@ -256,6 +256,7 @@
        <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"
            >
@@ -432,8 +433,14 @@
      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: [],
      // 父级任务列表
@@ -484,6 +491,10 @@
  methods: {
    // 钩子:在获取表格数据之前执行,false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      // 用户角色级别数组
      const userRolesLevel = this.$store.state.user.user.roles.map(({ level }) => level)
      // 用户最大角色级别
      this.userRolesLevelMin = Math.min(...userRolesLevel)
      // 获取项目
      this.getProject()
      // 获取用户
@@ -722,6 +733,26 @@
          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
        }
      }
    }
  }
}