瀏覽代碼

用户定向回显

zhuxinbo 5 年之前
父節點
當前提交
a52dcad849

+ 9 - 2
src/views/template/userorientation/modules/ByteDanceUserOrientationTemplateModal.vue

@@ -33,7 +33,7 @@
           :labelCol="labelCol"
           :wrapperCol="wrapperCol"
           class="else-width"
-          v-if="area!='NONE'"
+          v-if="areaType!='NONE'"
         >
           <transfer-city v-if="areaType == 'CITY'" :checkData.sync="cityList"></transfer-city>
           <transfer v-if="areaType == 'COUNTY'" :checkData.sync="areaList"></transfer>
@@ -70,7 +70,10 @@
           class="else-width"
           v-if="intrestType=='ZDY'"
         >
-          <intrest-category v-if="intrestType == 'ZDY'" :checkData.sync="intrestCategoryList"></intrest-category>
+          <intrest-category v-if="intrestType == 'ZDY'" :checkData.sync="intrestCategoryList" :dataValue="editData"></intrest-category>
+          {{intrestCategoryList}}
+          
+          <div @click="addData">tianji</div>
         </a-form-item>
         <a-form-item label="平台" :labelCol="labelCol" :wrapperCol="wrapperCol">
           <a-radio-group v-model="platformType">
@@ -166,6 +169,7 @@ export default {
       platformType:"NONE",
       mobileType:[],
       intrestCategoryList:[],
+      editData:[ { "label": "游戏", "value": 10001 }, { "label": "家装建材", "value": 10201 }, { "label": "家居家纺", "value": 10202 }, { "label": "家电维修", "value": 10204 }, { "label": "日用百货", "value": 10205 }],
       smartFl:"0",
       intrestType:"NONE",
       title: '操作',
@@ -320,6 +324,9 @@ export default {
     onSelect() {
       console.log(...arguments)
     },
+    addData(){
+        this.intrestCategoryList.push({ "label": "游戏", "value": 10001 })
+    },
     handleSubmit(e) {
       e.preventDefault()
       this.form.validateFields((err, values) => {

+ 35 - 8
src/views/template/userorientation/modules/IntrestCategory.vue

@@ -65,10 +65,10 @@ p {
 
 <template>
   <div class="transfer">
+      
     <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" /> 全选
@@ -94,12 +94,14 @@ p {
           </p>
         </div>
       </div>
+      
       <div
         class="content-box"
         :style="{borderRight:!showClass?'0px':'1px solid #dadfe3'}"
         v-show="showCityData"
       >
         <p class="content-title">二级分类</p>
+        
         <div class="content">
           <!-- <p>
             <input
@@ -157,6 +159,14 @@ import $ from 'jquery'
 export default {
   name: 'ByteDanceUserOrientationTemplateList',
   components: {},
+  props: {
+    dataValue: {
+      type: Array,
+      default() {
+        return []
+      }
+    }
+  },
   data() {
     return {
       showClass: false,
@@ -179,6 +189,27 @@ export default {
   mounted() {
     this.$nextTick(() => {
       this.getData()
+      if (this.dataValue.length > 0) {
+        this.checkData = this.dataValue
+        this.checkMatched = this.dataValue.filter(item => {
+          if (item.value < 10090) {
+            return item.value
+          }
+        })
+        this.checkMatched = this.checkMatched.map(item => {
+          return item.value
+        })
+        this.checkMatchedCity = this.dataValue.filter(item => {
+          if (item.value > 10090) {
+            return item.value
+          }
+        })
+        this.checkMatchedCity = this.checkMatchedCity.map(item => {
+          return item.value
+        })
+        console.log(this.checkMatchedCity)
+        this.$emit('update:checkData', this.checkData)
+      }
     })
   },
   methods: {
@@ -305,18 +336,14 @@ export default {
     },
     checkOneCity(item, index) {
       var allCity = this.checkMatchedCity.filter(v => {
-        return v.toString().slice(0, 2) == this.nowProvince.value
+        return v.toString().substr(2, 1) == this.nowProvince.value.toString().substr(4, 1)
       })
-
       if (allCity.length == this.city.length) {
         this.checkMatched.push(this.nowProvince.value)
         this.checkData.push(this.nowProvince)
-        for (var i = 0; i < this.checkMatchedCity.length; i++) {
+        for (var i = 0; i < allCity.length; i++) {
           for (var j = 0; j < this.checkData.length; j++) {
-            if (
-              this.checkMatchedCity[i] == this.checkData[j].value &&
-              this.checkMatchedCity[i].toString().slice(0, 2) == this.nowProvince.value
-            ) {
+            if (allCity[i] == this.checkData[j].value) {
               this.checkData.splice(j, 1)
               j--
             }

+ 29 - 8
src/views/template/userorientation/modules/transferCity.vue

@@ -68,8 +68,11 @@ p {
     <div class="transfer-box">
       <div class="content-box">
         <p class="content-title">省份</p>
-
-        <div class="content">
+        <div class="content" style="position:relative">
+          <div
+            style="position:absolute;top:0;left:0;width:100%;height:100%;background: rgba(0, 0, 0, 0.5)"
+            v-if="loading"
+          ></div>
           <p>
             <input type="checkbox" class="select_all" @change="checkAllBox" v-model="checkAll" /> 全选
           </p>
@@ -157,6 +160,14 @@ import $ from 'jquery'
 export default {
   name: 'ByteDanceUserOrientationTemplateList',
   components: {},
+  props: {
+    editData: {
+      type: Array,
+      default() {
+        return []
+      }
+    }
+  },
   data() {
     return {
       showClass: false,
@@ -172,17 +183,29 @@ export default {
       checkAll: false,
       checkMatchedCity: [],
       checkAllCity: false,
-      nowProvince: null
+      nowProvince: null,
+      loading: false
     }
   },
   computed: {},
   mounted() {
     this.$nextTick(() => {
       this.getData()
+      if (this.dataValue.length > 0) {
+        this.checkData = this.dataValue
+        this.checkMatched = this.dataValue.map(item => {
+          return item.value
+        })
+        this.checkMatchedCity = this.dataValue.map(item => {
+          return item.value
+        })
+        this.$emit('update:checkData', this.checkData)
+      }
     })
   },
   methods: {
     getData() {
+      this.loading = true
       getProvince(this.CityData, { parentCode: '' }).then(res => {
         if (res.code == '0') {
           //   this.province.push(...res.result.records)
@@ -192,6 +215,7 @@ export default {
               value: item.id
             }
           })
+          this.loading = false
         }
       })
     },
@@ -311,12 +335,9 @@ export default {
       if (allCity.length == this.city.length) {
         this.checkMatched.push(this.nowProvince.value)
         this.checkData.push(this.nowProvince)
-        for (var i = 0; i < this.checkMatchedCity.length; i++) {
+        for (var i = 0; i < allCity.length; i++) {
           for (var j = 0; j < this.checkData.length; j++) {
-            if (
-              this.checkMatchedCity[i] == this.checkData[j].value &&
-              this.checkMatchedCity[i].toString().slice(0, 2) == this.nowProvince.value
-            ) {
+            if (allCity[i] == this.checkData[j].value) {
               this.checkData.splice(j, 1)
               j--
             }