Explorar el Código

feat:销售模块地址选择组件更换

snow hace 1 año
padre
commit
2288b21ba8

+ 51 - 33
src/views/sellOut/zixunOrder/components/buyGoodModal.vue

@@ -425,12 +425,15 @@
                     :size="'mini'"
                     :style="{ marginBottom: scope.row.edit ? '13px' : '0' }"
                   >
-                    <select-area
-                      :value="scope.row.addr_code"
+                    <search-area
+                      :value="scope.row.code"
+                      :is-detail="scope.row.edit"
                       :disabled="!scope.row.edit"
+                      size="mini"
+                      :names="scope.row.label"
                       placeholder="收货省市区"
-                      :size="'mini'"
-                      @selectChange="select_area_change($event, scope.$index)"
+                      :level="3"
+                      @searchChange="areaChange($event,scope.$index)"
                     />
                   </el-form-item>
                   <span v-if="!scope.row.edit">{{ scope.row.addr_code_name }}</span>
@@ -872,7 +875,11 @@ export default {
       this.loading = false
     },
     addrRefresh(e) {
-      const { list } = e
+      const list = JSON.parse(JSON.stringify(e.list))
+      list.forEach(item => {
+        item.label = [item.label]
+        item.code = [item.areaCode]
+      })
       this.addrForm.order_addr.push(...list)
     },
 
@@ -929,41 +936,52 @@ export default {
             contactor: '',
             mobile: '',
             addr_code: [],
-            addr: ''
+            addr: '',
+            code: [],
+            label: []
           })
         } else {
           this.addrForm.order_addr[index].edit = true
         }
       }
     },
-    // 省市区选择
-    async select_area_change(e, index) {
-      this.addrForm.order_addr[index].addr_code = e
-      const { addr_code } = this.addrForm.order_addr[index]
-      if (addr_code && addr_code.length === 3) {
-        const arrCode = addr_code[addr_code.length - 1]
-        // console.log(model);
-        const { code, data, message } = await asyncRequest.addrall({
-          code: arrCode
-        })
-        if (code === 0) {
-          const { province, city, area } = data
-          const province_name = province && province.name ? province.name : ''
-          const city_name = city && city.name ? city.name : ''
-          const area_name = area && area.name ? area.name : ''
-          this.addrForm.order_addr[index].addr_code_name =
-            province_name && city_name && area_name
-              ? `${province_name}/${city_name}/${area_name}`
-              : ''
-        } else if (code >= 100 && code <= 104) {
-          await this.logout()
-        } else {
-          this.$message.warning(message)
-        }
-      } else {
-        this.addrForm.order_addr[index].addr_code_name = ''
-      }
+    async areaChange(e, index) {
+      const { code, area_code, label, splitLabel } = e
+      // this.addrForm.order_addr[index] = e
+      this.addrForm.order_addr[index].addr_code_name = splitLabel ? splitLabel.split(',').join('/') : ''
+      this.addrForm.order_addr[index].addr_code = code ? code.split(',') : []
+      this.addrForm.order_addr[index].code = area_code ? [area_code] : []
+      this.addrForm.order_addr[index].label = label ? [label] : []
+      // this.$refs.ruleForm.validateField('addr_code')
     },
+    // 省市区选择
+    // async select_area_change(e, index) {
+    //   this.addrForm.order_addr[index].addr_code = e
+    //   const { addr_code } = this.addrForm.order_addr[index]
+    //   if (addr_code && addr_code.length === 3) {
+    //     const arrCode = addr_code[addr_code.length - 1]
+    //     // console.log(model);
+    //     const { code, data, message } = await asyncRequest.addrall({
+    //       code: arrCode
+    //     })
+    //     if (code === 0) {
+    //       const { province, city, area } = data
+    //       const province_name = province && province.name ? province.name : ''
+    //       const city_name = city && city.name ? city.name : ''
+    //       const area_name = area && area.name ? area.name : ''
+    //       this.addrForm.order_addr[index].addr_code_name =
+    //         province_name && city_name && area_name
+    //           ? `${province_name}/${city_name}/${area_name}`
+    //           : ''
+    //     } else if (code >= 100 && code <= 104) {
+    //       await this.logout()
+    //     } else {
+    //       this.$message.warning(message)
+    //     }
+    //   } else {
+    //     this.addrForm.order_addr[index].addr_code_name = ''
+    //   }
+    // },
     // 省市区保存某一行
     checkRow(rowIndex) {
       this.$refs.addrForm.validate((valid) => {

+ 16 - 5
src/views/supplierSellOut/supplierSellAfterApply/components/supplier-confirm.vue

@@ -17,12 +17,14 @@
         <el-input v-model="formData.mobile" :maxlength="11" />
       </el-form-item>
       <el-form-item label="退货地址" prop="addr_code">
-        <select-area
-          :placeholder="'省/市/区'"
-          :value="formData.addr_code"
+        <search-area
+          :value="code"
           :is-detail="true"
-          :size="'mini'"
-          @selectChange="addr_selectChange"
+          size="mini"
+          :names="label"
+          placeholder="收货省市区"
+          :level="3"
+          @searchChange="areaChange($event)"
         />
       </el-form-item>
 
@@ -82,6 +84,8 @@ export default {
   props: ['sitem'],
   data() {
     return {
+      code: [],
+      label: [],
       formData: {
         status: '4',
         remark: '',
@@ -154,6 +158,13 @@ export default {
       this.formData.addr_code = e || []
       this.$refs.formRef.validateField('addr_code')
     },
+    async areaChange(e) {
+      const { code, area_code, label } = e
+      this.formData.addr_code = code ? code.split(',') : []
+      this.code = area_code ? [area_code] : []
+      this.label = label ? [label] : []
+      this.$refs.formRef.validateField('addr_code')
+    },
     submit() {
       this.$refs.formRef.validate(isValid => {
         if (!isValid) return

+ 16 - 5
src/views/supplierSellOut/supplierSellAfterApply/components/supplier_exam.vue

@@ -17,12 +17,14 @@
         <el-input v-model="formData.mobile" :maxlength="11" />
       </el-form-item>
       <el-form-item label="退货地址" prop="addr_code">
-        <select-area
-          :placeholder="'省/市/区'"
-          :value="formData.addr_code"
+        <search-area
+          :value="code"
           :is-detail="true"
-          :size="'mini'"
-          @selectChange="addr_selectChange"
+          size="mini"
+          :names="label"
+          placeholder="收货省市区"
+          :level="3"
+          @searchChange="areaChange($event)"
         />
       </el-form-item>
 
@@ -83,6 +85,8 @@ export default {
   props: ['sitem'],
   data() {
     return {
+      code: [],
+      label: [],
       formData: {
         status: '4',
         remark: '',
@@ -153,6 +157,13 @@ export default {
   mounted() {
   },
   methods: {
+    async areaChange(e) {
+      const { code, area_code, label } = e
+      this.formData.addr_code = code ? code.split(',') : []
+      this.code = area_code ? [area_code] : []
+      this.label = label ? [label] : []
+      this.$refs.formRef.validateField('addr_code')
+    },
     addr_selectChange(e) {
       this.formData.addr_code = e || []
       this.$refs.formRef.validateField('addr_code')