From a46d9dd934920dd4b764c4f54dad903da2d1f619 Mon Sep 17 00:00:00 2001
From: churf <123456>
Date: Tue, 29 Aug 2023 06:18:24 +0000
Subject: [PATCH] Merge branch 'toMongo' of http://192.168.1.110:5678/r/pms-upgrade into crf and (抽屉数据回显)

---
 eladmin-web-master/src/views/task/task/index.vue |   95 ++++++++++++++++++++++++++++++++++-------------
 1 files changed, 68 insertions(+), 27 deletions(-)

diff --git a/eladmin-web-master/src/views/task/task/index.vue b/eladmin-web-master/src/views/task/task/index.vue
index ceda39a..a424368 100644
--- a/eladmin-web-master/src/views/task/task/index.vue
+++ b/eladmin-web-master/src/views/task/task/index.vue
@@ -59,10 +59,12 @@
         </el-select>
         <div class="block">
           <el-cascader
+            v-model="queryUser"
             :options="options"
-            :props="props"
-            collapse-tags
             clearable
+            placeholder="任务负责人"
+            :show-all-levels="false"
+            style="width: 185px;"
           />
         </div>
         <rrOperation :crud="crud" />
@@ -141,31 +143,34 @@
             </el-input>
           </el-form-item>
           <el-form-item label="任务成员" prop="containUserList">
-            <el-select v-model="form.containUserList" multiple filterable clearable placeholder="请选择" style="width: 340px;" @change="getContainUserList">
-              <el-option
-                v-for="item in users"
-                :key="item.id"
-                :label="item.nickName"
-                :value="item.id"
-              >
-                <span style="float: left">{{ item.nickName }}</span>
-                <span style="float: right; color: #8492a6; font-size: 13px">{{ item.levelName }}</span>
-              </el-option>
-            </el-select>
+            <div class="block">
+              <el-cascader
+                v-model="selectedValue"
+                :filterable="true"
+                :options="options"
+                :props="props"
+                clearable
+                placeholder="任务负责人"
+                :show-all-levels="false"
+                style="width: 340px;"
+              />
+            </div>
           </el-form-item>
           <el-form-item label="任务负责人" prop="userId">
-            <el-select v-model="form.userIdList" :no-data-text=" '没有任务成员' " multiple filterable clearable placeholder="请选择" style="width: 340px;">
+            <el-select v-if="form.containUserList" v-model="form.userIdList" :no-data-text=" '没有任务成员' " multiple filterable clearable placeholder="请选择" style="width: 340px;">
               <el-option
                 v-for="item in users"
                 v-show="form.containUserList != undefined && form.containUserList.some(animal => animal === item.id)"
                 :key="item.id"
                 :label="item.nickName"
                 :value="item.id"
+                :show-all-levels="false"
               >
                 <span style="float: left">{{ item.nickName }}</span>
                 <span style="float: right; color: #8492a6; font-size: 13px">{{ item.levelName }}</span>
               </el-option>
             </el-select>
+            <el-select v-else v-model="form.userIdList" :no-data-text=" '没有任务成员' " multiple filterable clearable placeholder="请选择" style="width: 340px;" />
           </el-form-item>
         </el-form>
         <div slot="footer" class="dialog-footer">
@@ -356,10 +361,28 @@
       inputVisible: false,
       inputValue: null,
       containUserList: [],
+      userList: [],
       options: [],
-      deptList: [],
-      jobList: [],
-      userList: []
+      selectedValue: [],
+      queryUser: [],
+      selectedValue_flag: false
+    }
+  },
+  watch: {
+    'selectedValue': function(newVal) {
+      this.form.containUserList = []
+      for (let i = 0; i < newVal.length; i++) {
+        var temp = []
+        temp = newVal[i]
+        if (!this.form.containUserList.includes(temp[newVal[i].length - 1])) {
+          // 如果不在
+          this.form.containUserList.push(temp[newVal[i].length - 1])
+        }
+      }
+    },
+
+    'queryUser': function(newVal) {
+      // this.query.userId = newVal[newVal.length - 1]
     }
   },
   created() {
@@ -374,25 +397,26 @@
   },
   methods: {
     [CRUD.HOOK.afterSubmit]() {
-      this.form.containUserList = null
+      this.form.containUserList = []
+      this.selectedValue = null
     },
     [CRUD.HOOK.afterEditError]() {
-      this.form.containUserList = null
+      this.form.containUserList = []
+      this.selectedValue = null
     },
     [CRUD.HOOK.afterEditCancel]() {
-      this.form.containUserList = null
+      this.form.containUserList = []
+      this.selectedValue = null
     },
     [CRUD.HOOK.afterAddCancel]() {
-      this.form.containUserList = null
+      this.form.containUserList = []
+      this.selectedValue = null
     },
     [CRUD.HOOK.afterAddError]() {
-      this.form.containUserList = null
-    },
-    [CRUD.HOOK.beforeToCU]() {
-      this.form.containUserList = null
+      this.form.containUserList = []
+      this.selectedValue = null
     },
     getContainUserList(e) {
-      console.log(e)
       this.form.containUserList = e
     },
     getTags() {
@@ -411,6 +435,11 @@
       this.userRolesLevelMin = Math.min(...userRolesLevel)
 
       return true
+    },
+    [CRUD.HOOK.beforeToEdit]() {
+      crudUser.getUserPidDept(this.form.containUserList).then(res => {
+        this.selectedValue = res
+      })
     },
     [CRUD.HOOK.beforeSubmit]() {
       if (!this.form.taskStatus) {
@@ -464,7 +493,8 @@
     },
     handleInputConfirm() {
       const inputValue = this.inputValue
-      if (inputValue !== '') {
+      console.log(inputValue)
+      if (inputValue !== '' && inputValue !== null && inputValue !== ' ') {
         this.form.tagList.push(inputValue)
       }
       this.inputVisible = false
@@ -584,4 +614,15 @@
     margin-left: 10px;
     vertical-align: bottom;
   }
+
+  .block{
+    display: inline-block;
+    vertical-align: middle;
+    margin: 0 3px 10px 0;
+
+      input {
+      height: 30.5px;
+      line-height: 30.5px;
+      }
+    }
 </style>

--
Gitblit v1.9.3