mengy 3 vuotta sitten
vanhempi
commit
34a87ead40

+ 22 - 2
shanXiPlatform/src/views/systemManagement/userManagement/userManagement/addUser.vue

@@ -73,7 +73,8 @@
73 73
               <el-col :span="24" v-if="depotId && depotId != 1">
74 74
                 <el-form-item label="仓房:" prop="houseCheckList">
75 75
                     <div style="border:1px solid #ccc;padding:15px;width:864px;border-radius:10px ">
76
-                      <el-checkbox-group v-model="user.houseCheckList"  :disabled="isDetail">
76
+                      <el-checkbox :indeterminate="isIndeterminate" :disabled="isDetail" v-model="checkAll" @change="handleCheckAllChange">全选</el-checkbox>
77
+                      <el-checkbox-group v-model="user.houseCheckList"  :disabled="isDetail"  @change="handleCheckedCitiesChange">
77 78
                         <el-checkbox v-for="item in houseList" :key="item.houseCode" :label="item.houseCode">{{item.houseName}}</el-checkbox>
78 79
                       </el-checkbox-group>
79 80
                     </div>
@@ -190,6 +191,7 @@ export default {
190 191
       roleList:[],
191 192
       depotIdList:[],
192 193
       houseList:[],
194
+      houseListIds:[],
193 195
       isdis: true,
194 196
       isDetail: false,
195 197
       imageUrl: '',
@@ -291,7 +293,9 @@ export default {
291 293
       copyUname:'',
292 294
       pageTitle:'',
293 295
       dialogVisible: false,
294
-      copyUser:{}
296
+      copyUser:{},
297
+      checkAll: false,
298
+      isIndeterminate: true
295 299
     }
296 300
   },
297 301
   created() {
@@ -355,6 +359,9 @@ export default {
355 359
     getWarehouseAllList() {
356 360
       getWarehouseAll(this.$route.query.depotId).then(res => {
357 361
         this.houseList = res.data
362
+        this.houseList.forEach(item => {
363
+          this.houseListIds.push(item.houseCode)
364
+        })
358 365
       })
359 366
     },
360 367
 
@@ -607,6 +614,19 @@ export default {
607 614
     },
608 615
     goback() {
609 616
       this.dialogVisible = false
617
+    },
618
+    handleCheckAllChange(val) {
619
+      if(val){
620
+        this.user.houseCheckList = this.houseListIds
621
+      }else{
622
+        this.user.houseCheckList = []
623
+      }
624
+      this.isIndeterminate = false;
625
+    },
626
+    handleCheckedCitiesChange(value) {
627
+      let checkedCount = value.length;
628
+      this.checkAll = checkedCount === this.houseList.length;
629
+      this.isIndeterminate = checkedCount > 0 && checkedCount < this.houseList.length;
610 630
     }
611 631
   }
612 632
 }