Browse Source

feat: 优化省份选择事件emit逻辑

cuiyalong 1 year ago
parent
commit
44d550344a
1 changed files with 18 additions and 8 deletions
  1. 18 8
      apps/bigmember_pc/src/components/filter-items/RegionSelector.vue

+ 18 - 8
apps/bigmember_pc/src/components/filter-items/RegionSelector.vue

@@ -282,7 +282,7 @@ export default {
         }
       })
       this.getAllCheckBoxSelectedStatus()
-      this.$emit('change', this.getState())
+      this.onSelectChange()
     },
     // 整理城市数据列表
     initAreaMap () {
@@ -561,7 +561,7 @@ export default {
       // 选择超出可选区域冒泡事件
       if (this.isExceed) {
         province.checked = !checked
-        this.$emit('exceed')
+        this.onSelectExceed()
         return
       }
       province.checked = checked
@@ -605,7 +605,7 @@ export default {
       // 没有权限 冒泡事件
       if (!this.vip) {
         city.checked = !checked
-        this.$emit('limit', city)
+        this.onNoPowerLimit(city)
         return
       }
       // 选择超出可选区域冒泡事件
@@ -616,7 +616,7 @@ export default {
         if (this.isExceed) {
           city.checked = !checked
           this.setCitiesChangeCommon(!checked, city)
-          this.$emit('exceed')
+          this.onSelectExceed()
           return
         }
       } else {
@@ -624,7 +624,7 @@ export default {
         city.checked = false
         this.setCitiesChangeCommon(checked, city)
       }
-      this.$emit('change', this.getState())
+      this.onSelectChange()
     },
     setCountryChangeCommon (checked, country) {
       if (country.name === '全部') {
@@ -642,7 +642,7 @@ export default {
       // 没有权限 冒泡事件
       if (!this.vip) {
         country.checked = !checked
-        this.$emit('limit', country)
+        this.onNoPowerLimit(country)
         return
       }
       // 选择超出可选区域冒泡事件
@@ -653,14 +653,14 @@ export default {
         if (this.isExceed) {
           country.checked = !checked
           this.setCountryChangeCommon(!checked, country)
-          this.$emit('exceed')
+          this.onSelectExceed()
           return
         }
       } else {
         country.checked = false
         this.setCountryChangeCommon(checked, country)
       }
-      this.$emit('change', this.getState())
+      this.onSelectChange()
     },
     // 下拉框出现/隐藏时触发
     onVisibleChange (flag) {
@@ -670,6 +670,16 @@ export default {
         this.$emit('showSelect', this.getState())
       }
     },
+    onNoPowerLimit(payload) {
+      this.$emit('limit', payload)
+    },
+    onSelectExceed() {
+      this.$emit('exceed')
+    },
+    onSelectChange() {
+      const state = this.getState()
+      this.$emit('change', state)
+    },
     // 省市县区三级结构拆分省市(省:[市])和区县(地市:[区县])
     formatProvinceAndCities (regionMap) {
       let area = {}