Prechádzať zdrojové kódy

审核可选人员优化,只显示可查看项目的有审批权限的人员

yanshichao 10 mesiacov pred
rodič
commit
59e4431585
1 zmenil súbory, kde vykonal 37 pridanie a 18 odobranie
  1. 37 18
      src/views/task/task.vue

+ 37 - 18
src/views/task/task.vue

@@ -194,10 +194,16 @@
                           :open-on-click="true"
                           :normalizer="normalizer"
                           @select="treeProjectChange"
-                          :flat="true"
+                          :disable-branch-nodes="true"
                           :defaultExpandLevel="1"
                           style="width: 220px"
-                          placeholder="请选择"/>
+                          placeholder="请选择">
+                <label slot="option-label"
+                       slot-scope="{ node, shouldShowCount, count, labelClassName, countClassName }">
+                  <span v-if="node.isBranch">{{ node.label }}</span>
+                  <span v-else style="font-weight: normal">{{ node.label }}</span>
+                </label>
+              </treeselect>
             </el-form-item>
           </el-col>
           <el-col :span="12">
@@ -351,7 +357,7 @@ import {
   splitTask,
   projectAuditConfigs, taskAuditConfigs, addTaskFeedback, delTaskWithReason
 } from "@/api/task/task";
-import {getProjectTree, listProject} from "@/api/task/project";
+import {getProjectTree, getProject} from "@/api/task/project";
 import {getDeptUserTree, getAuditUsers, resetUserPwd} from "@/api/system/user";
 import Treeselect from "@riophae/vue-treeselect";
 import "@riophae/vue-treeselect/dist/vue-treeselect.css";
@@ -475,7 +481,6 @@ export default {
     },
     /** 搜索按钮操作 */
     handleQuery() {
-      console.log(11);
       this.queryParams.pageNum = 1;
       this.getList();
     },
@@ -570,14 +575,35 @@ export default {
         id: node.id,
         label: node.projectName || node.name,
         children: node.children,
-        isDisabled: node.type === '分类'
+        // isDisabled: node.type === '分类'
       };
       return newVar;
     },
     treeProjectChange(node) {
-      projectAuditConfigs({projectId: node.id}).then(res => {
-        this.projectAuditConfigs = res.data
-      })
+      this.getTaskAuditData(node.id)
+    },
+
+    async getTaskAuditData(projectId) {
+      let arr = []
+      let viewableUserIds = []
+      arr.push(
+        getAuditUsers().then(res => {
+          this.auditUsers = res.data
+        })
+      )
+      if (projectId) {
+        arr.push(
+          getProject(projectId).then(res => {
+            this.projectAuditConfigs = res.data.auditConfigs
+            let viewable = res.data.viewable
+            if (viewable) {
+              viewableUserIds = viewable.split(',');
+            }
+          })
+        )
+      }
+      await Promise.all(arr)
+      this.auditUsers = this.auditUsers.filter(user => viewableUserIds.indexOf(user.id) > -1)
     },
 
     /** 新增按钮操作 */
@@ -585,22 +611,17 @@ export default {
       this.reset();
       this.open = true;
       this.title = "添加任务";
-      getProjectTree({status:'0'}).then(response => {
+      getProjectTree({status: '0'}).then(response => {
         this.projectOptions = response.data
         if (this.selectProjectId && this.projectOptions.length > 0) {
           let ids = this.projectOptions.map(item => item.id);
           if (ids.indexOf(this.selectProjectId) < 0) {
             this.form.projectId = this.selectProjectId
-            projectAuditConfigs({projectId: this.form.projectId}).then(res => {
-              this.projectAuditConfigs = res.data
-            })
+            this.getTaskAuditData(this.form.projectId)
           }
         }
         this.$set(this.form, 'priority', '4')
       })
-      getAuditUsers().then(res => {
-        this.auditUsers = res.data
-      })
     },
     async handleEdit(row) {
       this.open = true;
@@ -608,9 +629,7 @@ export default {
       taskAuditConfigs({taskId: row.id}).then(res => {
         this.projectAuditConfigs = res.data
       })
-      getAuditUsers().then(res => {
-        this.auditUsers = res.data
-      })
+      this.getTaskAuditData(row.projectId)
       let arr = []
       arr.push(getTask(row.id).then(res => {
           this.form = res.data;