Browse Source

花王只选直营城市

lurunzhen 2 months ago
parent
commit
5e2adfe8b8
1 changed files with 56 additions and 42 deletions
  1. 56 42
      src/views/goods/selectCity.vue

+ 56 - 42
src/views/goods/selectCity.vue

@@ -1,4 +1,3 @@
-
 <template>
     <el-dialog class="tag-dialog" title="请选择上线城市" :visible.sync="Pvisible" :close-on-click-modal="false">
         <div>
@@ -11,9 +10,15 @@
                         <div class="tag-group-name">{{ item }}</div>
                         <div class="tag-group-list flex">
                             <div class="tag-list">
-                                <el-button v-for="unit in citys.filter(city => city.province == item)" :key="unit.id"
-                                    :class="isChecked(unit) ? 'selected' : ''" @click="selectOneTag(unit)">{{ unit.cityName
-                                    }}</el-button>
+                                <template v-for="unit in citys.filter(city => city.province == item)">
+                                    <el-button :key="unit.id" v-if="ckhuawangcity(unit.id)"
+                                        :class="isChecked(unit) ? 'selected' : ''" @click="selectOneTag(unit)">{{
+        unit.cityName
+    }}</el-button>
+
+                                </template>
+
+                                <!--   -->
                             </div>
                         </div>
                     </div>
@@ -85,16 +90,16 @@ export default {
         loading: {
             type: Boolean,
             default: false,
-        }, 
-        activeTab:{
-            type:String,
-            default:() =>'抖音商城'
         },
-        tabs:{
-             type: Array,
-             default:() =>  ['抖音商城'],
+        activeTab: {
+            type: String,
+            default: () => '抖音商城'
         },
-       
+        tabs: {
+            type: Array,
+            default: () => ['抖音商城'],
+        },
+
     },
     data() {
         return {
@@ -102,7 +107,7 @@ export default {
             // tabs: ['抖音商城', '微信商城'],
             provinces: [],
             citys: [],
-            selectedCitys:this.selected, 
+            selectedCitys: this.selected,
             dialogVisibleAddTag: false,
         };
     },
@@ -115,7 +120,7 @@ export default {
                 this.$emit('update:visible', val);
             },
         },
-       
+
     },
     watch: {
         selected(val) {
@@ -127,6 +132,15 @@ export default {
         this.getCitys();
     },
     methods: {
+        ckhuawangcity(cityId) {
+            if(this.activeTab == '花王'){
+                let citys = "1,2,3,4,5,7,8,10,11,12,13,70,77".split(',');
+                console.log(citys);
+                console.log(citys.includes(cityId+''))
+                return citys.includes(cityId+''); 
+            }
+            return true;
+        },
         getCitys() {
             listAllCity().then(res => {
                 this.citys = res.data.data;
@@ -156,70 +170,70 @@ export default {
                 return this.selectedCitys.some((el) => {
                     return unit.id === el.cityId && el.channel === 5;
                 });
-            else if(this.activeTab == '抖音鲸致')
+            else if (this.activeTab == '抖音鲸致')
                 return this.selectedCitys.some((el) => {
                     return unit.id === el.cityId && el.channel === 26;
                 });
-            else if(this.activeTab == '抖音云嘉')
+            else if (this.activeTab == '抖音云嘉')
                 return this.selectedCitys.some((el) => {
                     return unit.id === el.cityId && el.channel === 107;
                 });
             else if (this.activeTab == '支付宝')
                 return this.selectedCitys.some((el) => {
                     return unit.id === el.cityId && el.channel === 110;
-                }); 
+                });
             else if (this.activeTab == '花王')
                 return this.selectedCitys.some((el) => {
                     return unit.id === el.cityId && el.channel === 112;
-                });       
+                });
         },
         selectOneTag(city) {
             // let channel = this.activeTab == '微信商城' ? 5 : 26;
-            let channel =5;
-            if(this.activeTab=='抖音鲸致'){
-                channel=26;
+            let channel = 5;
+            if (this.activeTab == '抖音鲸致') {
+                channel = 26;
             }
-            if(this.activeTab=='抖音云嘉'){
-                channel=107;
+            if (this.activeTab == '抖音云嘉') {
+                channel = 107;
             }
-            if(this.activeTab=='支付宝'){
-                channel=110;
+            if (this.activeTab == '支付宝') {
+                channel = 110;
             }
-            if(this.activeTab=='花王'){
-                channel=112;
+            if (this.activeTab == '花王') {
+                channel = 112;
             }
             const index = this.selectedCitys.findIndex((ele) => ele.cityId === city.id && ele.channel == channel);
             if (index === -1) {
                 this.selectedCitys.push({ cityId: city.id, city: city.cityName, channel: channel, province: city.province });
-            }else
-                this.selectedCitys.splice(index, 1); 
+            } else
+                this.selectedCitys.splice(index, 1);
         },
         deleteOneTag(city) {
             const index = this.selectedCitys.findIndex((ele) => ele.cityId === city.cityId && ele.channel == city.channel);
             if (index >= 0)
                 this.selectedCitys.splice(index, 1);
         },
-        selectAll() { 
+        selectAll() {
             // let channel = this.activeTab == '微信商城' ? 5 : 26;
-            let channel =5;
-            if(this.activeTab=='抖音鲸致'){
-                channel=26;
+            let channel = 5;
+            if (this.activeTab == '抖音鲸致') {
+                channel = 26;
             }
-            if(this.activeTab=='抖音云嘉'){
-                channel=107;
+            if (this.activeTab == '抖音云嘉') {
+                channel = 107;
             }
-            if(this.activeTab=='支付宝'){
-                channel=110;
+            if (this.activeTab == '支付宝') {
+                channel = 110;
             }
-            if(this.activeTab=='花王'){
-                channel=112;
+            if (this.activeTab == '花王') {
+                channel = 112;
             }
             let filterCity = this.selectedCitys.filter(item => item.channel != channel);
             this.selectedCitys = filterCity.concat(this.citys.map(city => { return { cityId: city.id, city: city.cityName, channel: channel, province: city.province } }))
         },
-           selectAllNo() {
-               this.selectedCitys=[];
-           }, 
+        selectAllNo() {
+            this.selectedCitys = [];
+        },
         closed() {
             this.selectedCitys = this.selected;
             this.Pvisible = false;