mengy преди 3 години
родител
ревизия
a6b59b4630
променени са 1 файла, в които са добавени 24 реда и са изтрити 2 реда
  1. 24 2
      shanXiPlatform/src/views/systemManagement/earlyWarningManagement/addEarlyWarningManagement.vue

+ 24 - 2
shanXiPlatform/src/views/systemManagement/earlyWarningManagement/addEarlyWarningManagement.vue

@@ -51,7 +51,8 @@
51 51
         </el-form-item>
52 52
         <el-form-item label="检查人员:"  prop="warnTargetArr">
53 53
             <div style="border:1px solid #ccc;padding:15px;width:800px ">
54
-              <el-checkbox-group v-model="formData.warnTargetArr"  :disabled="isDetail" v-if="personList && personList.length>0">
54
+              <el-checkbox :indeterminate="isIndeterminate" :disabled="isDetail" v-model="checkAll" v-if="personList && personList.length>0" @change="handleCheckAllChange">全选</el-checkbox>
55
+              <el-checkbox-group v-model="formData.warnTargetArr"  :disabled="isDetail" v-if="personList && personList.length>0"  @change="handleCheckedCitiesChange">
55 56
                 <el-checkbox v-for="item in personList" :key="item.uId" :label="item.uId">{{item.personnelName}}</el-checkbox>
56 57
               </el-checkbox-group>
57 58
               <span v-if="!personList || personList.length == 0" style="color:#cccccc">暂无数据</span>
@@ -231,7 +232,10 @@ export default {
231 232
         levelDepotHouse: [{ required: true, message: '请选择预警单位类型', trigger: 'change' }],
232 233
       },
233 234
       isDetail:false,
234
-      loading:false
235
+      loading:false,
236
+      checkAll: false,
237
+      isIndeterminate: true,
238
+      personListIds: []
235 239
     }
236 240
   },
237 241
   mounted() {
@@ -308,6 +312,8 @@ export default {
308 312
             warnTargetIdArr.push(Number(item.substring(0, item.indexOf("|"))))
309 313
           })
310 314
           this.formData.warnTargetArr = JSON.parse(JSON.stringify(warnTargetIdArr))
315
+          this.checkAll = this.formData.warnTargetArr.length === this.personList.length;
316
+          this.isIndeterminate = this.formData.warnTargetArr.length > 0 && this.formData.warnTargetArr.length < this.personList.length;
311 317
         }
312 318
       }).catch((err) => {
313 319
         console.log(err)
@@ -369,7 +375,23 @@ export default {
369 375
         //   this.personList.push(JSON.parse(JSON.stringify(person)))
370 376
         // }
371 377
         this.personList = res.data
378
+        this.personList.forEach(item => {
379
+          this.personListIds.push(item.uId)
380
+        })
372 381
       })
382
+    },
383
+    handleCheckAllChange(val) {
384
+      if(val){
385
+        this.formData.warnTargetArr = this.personListIds
386
+      }else{
387
+        this.formData.warnTargetArr = []
388
+      }
389
+      this.isIndeterminate = false;
390
+    },
391
+    handleCheckedCitiesChange(value) {
392
+      let checkedCount = value.length;
393
+      this.checkAll = checkedCount === this.personList.length;
394
+      this.isIndeterminate = checkedCount > 0 && checkedCount < this.personList.length;
373 395
     }
374 396
   }
375 397
 }