Browse Source

仓房全选

mengy 5 years ago
parent
commit
34a87ead40

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

@@ -73,7 +73,8 @@
73
               <el-col :span="24" v-if="depotId && depotId != 1">
73
               <el-col :span="24" v-if="depotId && depotId != 1">
74
                 <el-form-item label="仓房:" prop="houseCheckList">
74
                 <el-form-item label="仓房:" prop="houseCheckList">
75
                     <div style="border:1px solid #ccc;padding:15px;width:864px;border-radius:10px ">
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
                         <el-checkbox v-for="item in houseList" :key="item.houseCode" :label="item.houseCode">{{item.houseName}}</el-checkbox>
78
                         <el-checkbox v-for="item in houseList" :key="item.houseCode" :label="item.houseCode">{{item.houseName}}</el-checkbox>
78
                       </el-checkbox-group>
79
                       </el-checkbox-group>
79
                     </div>
80
                     </div>
@@ -190,6 +191,7 @@ export default {
190
       roleList:[],
191
       roleList:[],
191
       depotIdList:[],
192
       depotIdList:[],
192
       houseList:[],
193
       houseList:[],
194
+      houseListIds:[],
193
       isdis: true,
195
       isdis: true,
194
       isDetail: false,
196
       isDetail: false,
195
       imageUrl: '',
197
       imageUrl: '',
@@ -291,7 +293,9 @@ export default {
291
       copyUname:'',
293
       copyUname:'',
292
       pageTitle:'',
294
       pageTitle:'',
293
       dialogVisible: false,
295
       dialogVisible: false,
294
-      copyUser:{}
296
+      copyUser:{},
297
+      checkAll: false,
298
+      isIndeterminate: true
295
     }
299
     }
296
   },
300
   },
297
   created() {
301
   created() {
@@ -355,6 +359,9 @@ export default {
355
     getWarehouseAllList() {
359
     getWarehouseAllList() {
356
       getWarehouseAll(this.$route.query.depotId).then(res => {
360
       getWarehouseAll(this.$route.query.depotId).then(res => {
357
         this.houseList = res.data
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
     goback() {
615
     goback() {
609
       this.dialogVisible = false
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
 }