Browse Source

全选问题修改

zhuxinbo 5 năm trước cách đây
mục cha
commit
b7dc57b8ab
1 tập tin đã thay đổi với 12 bổ sung10 xóa
  1. 12 10
      src/views/template/userorientation/modules/transferCity.vue

+ 12 - 10
src/views/template/userorientation/modules/transferCity.vue

@@ -68,6 +68,7 @@ p {
     <div class="transfer-box">
       <div class="content-box">
         <p class="content-title">省份</p>
+
         <div class="content">
           <p>
             <input type="checkbox" class="select_all" @change="checkAllBox" v-model="checkAll" /> 全选
@@ -241,16 +242,9 @@ export default {
       this.$emit('update:checkData', this.checkData)
     },
     checkOne(item, index) {
-      if (this.checkMatched.length == this.province.length) {
-        this.checkAll = true
-      } else {
-        this.checkAll = false
-      }
       if (this.checkMatched.indexOf(item.value) == -1) {
         var index1 = this.checkData.findIndex(v => v.value === item.value)
-        var index2 = this.checkMatched.findIndex(v => v === item.value)
         this.checkData.splice(index1, 1)
-        this.checkMatched.splice(index2, 1)
         if (this.nowProvince) {
           if (this.nowProvince.value == item.value) {
             this.checkMatchedCity = []
@@ -276,6 +270,7 @@ export default {
             }
           }
         })
+
         if (this.nowProvince) {
           if (item.value == this.nowProvince.value) {
             this.checkMatchedCity = this.city.map(item => {
@@ -284,7 +279,11 @@ export default {
           }
         }
       }
-
+      if (this.checkMatched.length == this.province.length) {
+        this.checkAll = true
+      } else {
+        this.checkAll = false
+      }
       this.$emit('update:checkData', this.checkData)
     },
     checkAllBoxCity() {
@@ -328,7 +327,11 @@ export default {
         if (allCity.length != this.city.length) {
           this.checkData.push(item)
         }
-        this.checkAll = true
+        if (this.checkMatched.length == this.province.length) {
+          this.checkAll = true
+        } else {
+          this.checkAll = false
+        }
       } else {
         if (this.checkMatched.indexOf(this.nowProvince.value) != -1) {
           var index1 = this.checkData.findIndex(v => v.value === this.nowProvince.value)
@@ -341,7 +344,6 @@ export default {
           })
           this.checkData.push(...data)
         } else {
-          this.checkAll = true
           var index1 = this.checkData.findIndex(v => v.value === item.value)
           this.checkData.splice(index1, 1)
         }