Bladeren bron

feat:销售单地址选择组件修改

snow 1 jaar geleden
bovenliggende
commit
e83d96b553

+ 29 - 3
src/components/addr-add-edit-modal/index.vue

@@ -44,10 +44,19 @@
           :label="type == '1' ? '省市区(系统解析)' : '收货省市区'"
           prop="addr_code"
         >
-          <select-area
+          <!-- <select-area
             :value="ruleForm.addr_code"
             placeholder="收货省市区"
             @selectChange="select_area_change($event)"
+          /> -->
+
+          <search-area
+            :value="ruleForm.areaCode"
+            :is-detail="true"
+            :names="ruleForm.label"
+            placeholder="收货省市区"
+            :level="3"
+            @searchChange="areaChange($event)"
           />
         </el-form-item>
         <el-form-item label="详细地址" prop="addr">
@@ -241,8 +250,11 @@ export default {
             addr_code_name,
             addr,
             in_addr,
+            areaCode,
+            label,
             id
           } = this.sitem
+
           this.ruleForm = {
             receipt_quantity,
             contactor,
@@ -251,7 +263,9 @@ export default {
             addr_code: addr_code && addr_code.length === 3 ? addr_code : [],
             addr_code_name: addr_code_name || '',
             addr,
-            id: id || ''
+            id: id || '',
+            areaCode: areaCode ? [areaCode] : [],
+            label: label ? [label] : []
           }
         }
       })
@@ -263,7 +277,11 @@ export default {
           // addr_code_name
           this.$emit('refresh', {
             index: this.index,
-            item: JSON.parse(JSON.stringify(this.ruleForm))
+            item: {
+              ...JSON.parse(JSON.stringify(this.ruleForm)),
+              areaCode: Array.isArray(this.ruleForm.areaCode) ? this.ruleForm.areaCode[0] : this.ruleForm.areaCode,
+              label: Array.isArray(this.ruleForm.label) ? this.ruleForm.label[0] : this.ruleForm.label
+            }
           })
         } else {
           console.log('error submit!!')
@@ -271,6 +289,14 @@ export default {
         }
       })
     },
+    async areaChange(e) {
+      const { code, area_code, label, splitLabel } = e
+      this.ruleForm.addr_code = code ? code.split(',') : []
+      this.ruleForm.areaCode = area_code ? [area_code] : []
+      this.ruleForm.label = label ? [label] : []
+      this.ruleForm.addr_code_name = splitLabel ? splitLabel.split(',').join('/') : ''
+      this.$refs.ruleForm.validateField('addr_code')
+    },
     // 省市区选择
     async select_area_change(e) {
       this.ruleForm.addr_code = e

+ 5 - 1
src/components/globalComponents/search-area/main.vue

@@ -76,22 +76,25 @@ export default {
   },
   methods: {
     async selectChange(e) {
-      console.log(e)
       if (e && e.length > 0) {
         const index = this.options.findIndex((v) => v.code + "" === e[0] + "");
         if (index !== -1) {
           const { code, search_name, info } = this.options[index];
           const { province, city, area } = info;
           let arr_code = "";
+          let splitLabel = ""
           switch (this.formValue.level + "") {
             case "1":
               arr_code = province.code;
+              splitLabel = province.name;
               break;
             case "2":
               arr_code = `${province.code},${city.code}`;
+              splitLabel = `${province.name},${city.name}`;
               break;
             default:
               arr_code = `${province.code},${city.code},${area.code}`;
+              splitLabel = `${province.name},${city.name},${area.name}`;
               break;
           }
 
@@ -102,6 +105,7 @@ export default {
             city_code: city.code ?? "",
             area_code: area.code ?? "",
             label: search_name ?? "",
+            splitLabel:splitLabel ?? ""
           };
           this.$emit("searchChange", model);
         } else {

+ 240 - 230
src/components/in-addr-model/index.vue

@@ -11,12 +11,12 @@
     element-loading-text="拼命加载中"
     element-loading-spinner="el-icon-loading"
     element-loading-background="rgba(0, 0, 0, 0.8)"
-    @close="showModelThis = false"
     append-to-body
+    @close="showModelThis = false"
   >
     <el-card style="margin-top: -25px">
       <upload-excel :on-success="handleSuccess" :before-upload="beforeUpload" />
-      <el-form :model="ruleForm" ref="ruleForm" :size="'mini'">
+      <el-form ref="ruleForm" :model="ruleForm" :size="'mini'">
         <el-table
           :data="ruleForm.order_addr"
           border
@@ -62,24 +62,24 @@
           <el-table-column fixed="right" width="80" label="操作">
             <template slot-scope="scope">
               <el-tooltip effect="dark" content="编辑" placement="top">
-                <i class="el-icon-edit tb-icon" @click="openHouseModal(scope.$index)"></i>
+                <i class="el-icon-edit tb-icon" @click="openHouseModal(scope.$index)" />
               </el-tooltip>
               <el-tooltip effect="dark" content="删除" placement="top">
                 <i
                   class="el-icon-delete tb-icon"
                   @click="deleteRow(scope.$index, ruleForm.order_addr)"
-                ></i>
+                />
               </el-tooltip>
             </template>
           </el-table-column>
         </el-table>
       </el-form>
       <addr-add-edit-modal
-        :showModel="showAddrAddEditModal"
+        :show-model="showAddrAddEditModal"
         :index="AddrAddEditModalIndex"
         :sitem="AddrAddEditModalSitem"
-        @cancel="showAddrAddEditModal = false"
         :type="'1'"
+        @cancel="showAddrAddEditModal = false"
         @refresh="showAddrAddEditModalRefresh"
       />
       <div class="tr" style="padding: 10px 0 0 0">
@@ -89,8 +89,8 @@
   </el-dialog>
 </template>
 <script>
-import resToken from "@/mixins/resToken";
-import { province_list, city_list, county_list } from "@/assets/js/area-data";
+import resToken from '@/mixins/resToken'
+import { province_list, city_list, county_list } from '@/assets/js/area-data'
 import {
   isnumber,
   isMobile,
@@ -98,166 +98,166 @@ import {
   isEmoticon,
   isSpecialSymbol,
   hasSpace,
-  isAddr,
-} from "@/utils/validate";
-import AddrAddEditModal from "@/components/addr-add-edit-modal";
+  isAddr
+} from '@/utils/validate'
+import AddrAddEditModal from '@/components/addr-add-edit-modal'
 export default {
-  name: "inAddrModel",
-  props: ["showModel", "id", "sitem"],
-  mixins: [resToken],
+  name: 'InAddrModel',
   components: { AddrAddEditModal },
+  mixins: [resToken],
+  props: ['showModel', 'id', 'sitem'],
   data() {
     const validatemobile = (rule, value, callback) => {
-      if (value === "") {
-        callback(new Error("联系电话不能为空!"));
+      if (value === '') {
+        callback(new Error('联系电话不能为空!'))
       } else {
         if (!isMobile(value)) {
-          callback(new Error("联系电话格式不正确!"));
+          callback(new Error('联系电话格式不正确!'))
         } else {
-          callback();
+          callback()
         }
       }
-    };
+    }
     const validateWeight = (rule, value, callback) => {
-      if (value === "") {
-        callback(new Error("收货总数不能为空!"));
+      if (value === '') {
+        callback(new Error('收货总数不能为空!'))
       } else {
         if (!isnumber(value)) {
-          callback(new Error("收货总数仅支持整数!"));
+          callback(new Error('收货总数仅支持整数!'))
         } else {
-          callback();
+          callback()
         }
       }
-    };
+    }
     const validatecontactor = (rule, value, callback) => {
-      if (value === "") {
-        callback(new Error("联系人不能为空!"));
+      if (value === '') {
+        callback(new Error('联系人不能为空!'))
       } else {
         if (value.length < 2 || value.length > 10) {
-          callback(new Error("联系人规则为2~10位汉字!"));
+          callback(new Error('联系人规则为2~10位汉字!'))
         } else {
           if (!isChinese(value)) {
-            callback(new Error("联系人规则为2~10位汉字!"));
+            callback(new Error('联系人规则为2~10位汉字!'))
           } else if (isEmoticon(value)) {
-            callback(new Error("联系人规则为2~10位汉字!"));
+            callback(new Error('联系人规则为2~10位汉字!'))
           } else {
-            callback();
+            callback()
           }
         }
       }
-    };
+    }
     const validateAddr = (rule, value, callback) => {
-      if (value === "") {
-        callback(new Error("详细地址不能为空!"));
+      if (value === '') {
+        callback(new Error('详细地址不能为空!'))
       } else {
         if (hasSpace(value)) {
-          callback(new Error("不能出现回车/换行符!"));
+          callback(new Error('不能出现回车/换行符!'))
         } else if (isSpecialSymbol(value)) {
-          callback(new Error("不能使用英文特殊字符!"));
+          callback(new Error('不能使用英文特殊字符!'))
         } else if (isAddr(value)) {
-          callback();
+          callback()
         } else {
-          callback(new Error("详细地址填写不规范!"));
+          callback(new Error('详细地址填写不规范!'))
         }
       }
-    };
+    }
     return {
       showAddrAddEditModal: false,
       AddrAddEditModalIndex: -1,
       AddrAddEditModalSitem: {},
       tableData: [],
       tableHeader: [],
-      title: "",
+      title: '',
       showModelThis: false,
       loading: false,
       newTime: 0,
       pickerOptions: {
         disabledDate: (time) => {
-          return time.getTime() < new Date().valueOf();
-        },
+          return time.getTime() < new Date().valueOf()
+        }
       },
       rulesThis: this.rules,
       ruleForm: {
-        order_addr: [], //收货地址
+        order_addr: [] // 收货地址
       },
       rules: {
         receipt_quantity: [
           {
             required: true,
             validator: validateWeight,
-            trigger: "blur",
-          },
+            trigger: 'blur'
+          }
         ],
 
         contactor: [
           {
             required: true,
-            trigger: "blur",
-            validator: validatecontactor,
-          },
+            trigger: 'blur',
+            validator: validatecontactor
+          }
         ],
         mobile: [
           {
             required: true,
             validator: validatemobile,
-            trigger: "blur",
-          },
+            trigger: 'blur'
+          }
         ],
         addr_code: [
           {
-            type: "array",
+            type: 'array',
             required: false,
-            trigger: "change",
-          },
+            trigger: 'change'
+          }
         ],
         addr: [
           {
             required: true,
             validator: validateAddr,
-            trigger: "blur",
-          },
-        ],
-      },
-    };
+            trigger: 'blur'
+          }
+        ]
+      }
+    }
   },
   watch: {
-    showModel: function (val) {
-      this.showModelThis = val;
+    showModel: function(val) {
+      this.showModelThis = val
       if (val) {
-        this.initForm();
+        this.initForm()
       }
     },
     showModelThis(val) {
       if (!val) {
-        this.$emit("cancel");
+        this.$emit('cancel')
       }
-    },
+    }
   },
   mounted() {
-    this.get_code();
+    this.get_code()
   },
   methods: {
     async resetForm() {
       // 重置
       await this.$nextTick(() => {
         if (this.$refs.ruleForm) {
-          this.$refs.ruleForm.resetFields();
-          this.$refs.ruleForm.clearValidate();
+          this.$refs.ruleForm.resetFields()
+          this.$refs.ruleForm.clearValidate()
           this.ruleForm = {
-            order_addr: [],
-          };
+            order_addr: []
+          }
         }
-      });
+      })
     },
     // 省市区删除行操作
     deleteRow(index, rows) {
-      rows.splice(index, 1);
+      rows.splice(index, 1)
     },
     showAddrAddEditModalRefresh(e) {
-      const { index, item } = e;
+      const { index, item } = e
 
       if (index === -1) {
-        this.ruleForm.order_addr.push(JSON.parse(JSON.stringify(item)));
+        this.ruleForm.order_addr.push(JSON.parse(JSON.stringify(item)))
       } else {
         const {
           receipt_quantity,
@@ -265,98 +265,108 @@ export default {
           mobile,
           addr_code,
           addr_code_name,
+          areaCode,
+          areaLabel,
           addr,
           id,
-        } = JSON.parse(JSON.stringify(item));
-        this.ruleForm.order_addr[index].receipt_quantity = receipt_quantity;
-        this.ruleForm.order_addr[index].contactor = contactor;
-        this.ruleForm.order_addr[index].mobile = mobile;
-        this.ruleForm.order_addr[index].addr_code = addr_code;
-        this.ruleForm.order_addr[index].addr_code_name = addr_code_name;
-        this.ruleForm.order_addr[index].addr = addr;
-        this.ruleForm.order_addr[index].id = id;
+          label
+        } = JSON.parse(JSON.stringify(item))
+        this.ruleForm.order_addr[index].receipt_quantity = receipt_quantity
+        this.ruleForm.order_addr[index].contactor = contactor
+        this.ruleForm.order_addr[index].mobile = mobile
+        this.ruleForm.order_addr[index].addr_code = addr_code
+        this.ruleForm.order_addr[index].addr_code_name = addr_code_name
+        this.ruleForm.order_addr[index].addr = addr
+        this.ruleForm.order_addr[index].id = id
+        this.ruleForm.order_addr[index].areaCode = areaCode
+        this.ruleForm.order_addr[index].areaLabel = areaLabel
+        this.ruleForm.order_addr[index].label = label
       }
-      this.$refs.ruleForm.validateField("order_addr");
+      this.$refs.ruleForm.validateField('order_addr')
     },
     beforeUpload(file) {
-      const isLt1M = file.size / 1024 < 500;
+      const isLt1M = file.size / 1024 < 500
       if (isLt1M) {
-        return true;
+        return true
       }
       this.$message({
-        message: "请不要上传大于500KB的文件.",
-        type: "warning",
-      });
-      return false;
+        message: '请不要上传大于500KB的文件.',
+        type: 'warning'
+      })
+      return false
     },
     handleSuccess({ results, header }) {
       if (results.length === 0) {
-        this.$message.error("表格无有效数据!");
-        return;
+        this.$message.error('表格无有效数据!')
+        return
       }
       if (results.length > 500) {
-        this.$message.error("地址数据不能超过500条!");
-        return;
+        this.$message.error('地址数据不能超过500条!')
+        return
       }
-      let head = [
-        "收货总数",
-        "收货联系人",
-        "收货联系电话",
-        "收货省名称",
-        "收货市名称",
-        "收货区名称",
-        "详细地址",
-      ];
+      const head = [
+        '收货总数',
+        '收货联系人',
+        '收货联系电话',
+        '收货省名称',
+        '收货市名称',
+        '收货区名称',
+        '详细地址'
+      ]
       if (head.length !== header.length) {
-        this.$message.error("表头与导入模板不匹配!");
-        return;
+        this.$message.error('表头与导入模板不匹配!')
+        return
       }
-      let hederOk = true;
+      let hederOk = true
       head.forEach((v1, i1) => {
-        if (v1 !== header[i1].replace(/\s*/g, "")) {
-          hederOk = false;
+        if (v1 !== header[i1].replace(/\s*/g, '')) {
+          hederOk = false
         }
-      });
+      })
 
       if (!hederOk) {
-        this.$message.error("表头与导入模板不匹配!");
-        return;
+        this.$message.error('表头与导入模板不匹配!')
+        return
       }
-      this.tableHeader = header;
-      this.tableData = [];
-      let list = results;
-      let tableOk = true;
-      this.ruleForm.order_addr = [];
+      this.tableHeader = header
+      this.tableData = []
+      const list = results
+      const tableOk = true
+      this.ruleForm.order_addr = []
       list.forEach((v1) => {
-        let b = Object.values(v1);
-        let item = this.get_code(b[3], b[4], b[5]);
-        let model = {
-          receipt_quantity: b[0] + "",
-          contactor: b[1] + "",
-          mobile: b[2] + "",
-          in_addr: b[3] + "/" + b[4] + "/" + b[5],
-          addr_code_name: item.name + "",
+        const b = Object.values(v1)
+        const item = this.get_code(b[3], b[4], b[5])
+        const model = {
+          receipt_quantity: b[0] + '',
+          contactor: b[1] + '',
+          mobile: b[2] + '',
+          in_addr: b[3] + '/' + b[4] + '/' + b[5],
+          areaCode: item.code[item.code.length - 1],
+          addr_code_name: item.name + '',
           addr_code: item.code,
-          addr: b[6] + "",
-          edit: false,
-        };
-        this.ruleForm.order_addr.push(model);
-      });
+          label: b[3] + b[4] + b[5],
+          addr: b[6] + '',
+          edit: false
+        }
+        this.ruleForm.order_addr.push(model)
+      })
+
+      console.log(this.ruleForm.order_addr)
       if (!tableOk) {
-        this.$message.error("最晚收货日期不正确,请将表格格式转为文本上传!");
+        this.$message.error('最晚收货日期不正确,请将表格格式转为文本上传!')
       }
     },
     openHouseModal(index) {
-      this.AddrAddEditModalIndex = index;
+      this.AddrAddEditModalIndex = index
 
       if (index === -1) {
-        this.AddrAddEditModalSitem = {};
+        this.AddrAddEditModalSitem = {}
       } else {
         this.AddrAddEditModalSitem = JSON.parse(
           JSON.stringify(this.ruleForm.order_addr[index])
-        );
+        )
       }
-      this.showAddrAddEditModal = true;
+      this.showAddrAddEditModal = true
       // let findex = this.ruleForm.order_addr.findIndex((v) => v.edit === true);
       // if (findex !== -1) {
       //   this.$message.warning("当前已有地址在编辑,请保存后再试!");
@@ -366,184 +376,184 @@ export default {
       // }
     },
     unique(arr) {
-      let hash = [];
+      const hash = []
       for (let i = 0; i < arr.length; i++) {
-        let index = hash.findIndex((v1) => v1.inv_number === arr[i].inv_number);
+        const index = hash.findIndex((v1) => v1.inv_number === arr[i].inv_number)
         if (index === -1) {
-          hash.push(arr[i]);
+          hash.push(arr[i])
         }
       }
-      return hash;
+      return hash
     },
     setTime(time) {
-      time = time.replace(/\//g, "-");
-      time = time.replace(/\./g, "-");
-      let key = new Date(time).valueOf() + "";
+      time = time.replace(/\//g, '-')
+      time = time.replace(/\./g, '-')
+      const key = new Date(time).valueOf() + ''
       if (key.length !== 13) {
-        time = "";
+        time = ''
       }
-      return time;
+      return time
     },
     async initForm() {
-      this.rulesThis = this.rules;
-      await this.resetForm();
-      this.newTime = 0;
-      this.loading = true;
-      this.tableData = [];
-      this.tableHeader = [];
-      this.step = 1;
-      this.title = "批量导入收货地址信息";
+      this.rulesThis = this.rules
+      await this.resetForm()
+      this.newTime = 0
+      this.loading = true
+      this.tableData = []
+      this.tableHeader = []
+      this.step = 1
+      this.title = '批量导入收货地址信息'
 
-      this.changea();
-      this.loading = false;
+      this.changea()
+      this.loading = false
     },
     refreshAll() {
-      this.showModelThis = false;
-      this.$emit("refresh");
+      this.showModelThis = false
+      this.$emit('refresh')
     },
     changea() {
-      this.newTime = new Date().valueOf();
+      this.newTime = new Date().valueOf()
     },
 
     async submitForm() {
       if (!this.loading) {
-        this.loading = true;
-        const { order_addr } = this.ruleForm;
+        this.loading = true
+        const { order_addr } = this.ruleForm
         if (order_addr.length < 1) {
-          this.$message.error("导入数据不能为空!");
-          this.loading = false;
-          return;
+          this.$message.error('导入数据不能为空!')
+          this.loading = false
+          return
         }
-        let isEdit = false;
+        let isEdit = false
         order_addr.forEach((v) => {
-          v.err = false;
+          v.err = false
           if (v.edit) {
-            v.err = true;
-            isEdit = true;
+            v.err = true
+            isEdit = true
           }
-        });
+        })
         if (isEdit) {
-          this.$message.error("当前收货地址已在编辑,请保存后再试!");
-          this.loading = false;
-          return;
+          this.$message.error('当前收货地址已在编辑,请保存后再试!')
+          this.loading = false
+          return
         }
-        let cItem = null;
+        let cItem = null
         order_addr.some((x, i) => {
-          cItem = this.checkItem(x);
+          cItem = this.checkItem(x)
           if (!cItem.isok) {
-            cItem.index = i;
-            return true;
+            cItem.index = i
+            return true
           }
-        });
+        })
         if (cItem && !cItem.isok) {
-          this.$message.error(`第${cItem.index + 1}行,${cItem.message}`);
-          this.loading = false;
-          return;
+          this.$message.error(`第${cItem.index + 1}行,${cItem.message}`)
+          this.loading = false
+          return
         }
-        this.loading = false;
-        this.showModelThis = false;
-        let list = JSON.parse(JSON.stringify(order_addr));
-        console.log(list);
-        this.$emit("refresh", { list: list });
+        this.loading = false
+        this.showModelThis = false
+        const list = JSON.parse(JSON.stringify(order_addr))
+        console.log(list)
+        this.$emit('refresh', { list: list })
       }
     },
     checkItem(sitem) {
-      let model = {
+      const model = {
         isok: true,
-        message: "",
-      };
-      const { arrive_time, receipt_quantity, contactor, mobile, addr_code, addr } = sitem;
-      if (receipt_quantity === "" && model.isok) {
-        model.isok = false;
-        model.message = "收货总数不能为空!";
+        message: ''
+      }
+      const { arrive_time, receipt_quantity, contactor, mobile, addr_code, addr } = sitem
+      if (receipt_quantity === '' && model.isok) {
+        model.isok = false
+        model.message = '收货总数不能为空!'
       }
       if (!isnumber(receipt_quantity) && model.isok) {
-        model.isok = false;
-        model.message = "收货总数仅支持整数!";
+        model.isok = false
+        model.message = '收货总数仅支持整数!'
       }
-      if (arrive_time === "" && model.isok) {
-        model.isok = false;
-        model.message = "最晚收货日期不能为空!";
+      if (arrive_time === '' && model.isok) {
+        model.isok = false
+        model.message = '最晚收货日期不能为空!'
       }
 
-      if (contactor === "" && model.isok) {
-        model.isok = false;
-        model.message = "收货联系人不能为空!";
+      if (contactor === '' && model.isok) {
+        model.isok = false
+        model.message = '收货联系人不能为空!'
       }
-      if (mobile === "" && model.isok) {
-        model.isok = false;
-        model.message = "收货联系电话不能为空!";
+      if (mobile === '' && model.isok) {
+        model.isok = false
+        model.message = '收货联系电话不能为空!'
       }
       if (!isMobile(mobile) && model.isok) {
-        model.isok = false;
-        model.message = "收货联系电话格式不正确!";
+        model.isok = false
+        model.message = '收货联系电话格式不正确!'
       }
       // if (addr_code.length !== 3 && model.isok) {
       //   model.isok = false;
       //   model.message = "收货省市区不能为空!";
       // }
-      if (addr === "" && model.isok) {
-        model.isok = false;
-        model.message = "详细地址不能为空!";
+      if (addr === '' && model.isok) {
+        model.isok = false
+        model.message = '详细地址不能为空!'
       }
-      return model;
+      return model
     },
     get_code(name1, name2, name3) {
-      let name = "",
-        code = [];
+      let name = ''
+      let code = []
       if (name1 && name2 && name3) {
-        for (let x in province_list) {
+        for (const x in province_list) {
           if (name1 === province_list[x]) {
-            code.push(x);
-            name += province_list[x];
-            break;
+            code.push(x)
+            name += province_list[x]
+            break
           }
         }
         if (code.length === 1) {
-          for (let y in city_list) {
+          for (const y in city_list) {
             if (name2 === city_list[y]) {
-              code.push(y);
-              name += "/" + city_list[y];
-              break;
+              code.push(y)
+              name += '/' + city_list[y]
+              break
             }
           }
         }
         if (code.length === 2) {
-          for (let z in county_list) {
+          for (const z in county_list) {
             if (name3 === county_list[z]) {
-              code.push(z);
-              name += "/" + county_list[z];
-              break;
+              code.push(z)
+              name += '/' + county_list[z]
+              break
             }
           }
         }
 
         if (code.length === 3) {
-          let str1 = "",
-            str2 = "",
-            isok = false;
-          str1 = code[0].slice(0, 2);
-          str2 = code[1].slice(2, 4);
+          let str1 = ''
+          let str2 = ''
+          let isok = false
+          str1 = code[0].slice(0, 2)
+          str2 = code[1].slice(2, 4)
           if (
             code[1].indexOf(str1) === 0 &&
             code[2].indexOf(str1) === 0 &&
             code[2].indexOf(str2) == 2
           ) {
-            isok = true;
+            isok = true
           }
           if (!isok) {
-            name = "";
-            code = [];
+            name = ''
+            code = []
           }
         } else {
-          name = "";
-          code = [];
+          name = ''
+          code = []
         }
       }
-      return { name: name, code: code };
-    },
-  },
-};
+      return { name: name, code: code }
+    }
+  }
+}
 </script>
 
 <style lang="scss" scoped>

+ 1 - 1
src/config/env.development.js

@@ -23,7 +23,7 @@ module.exports = {
   // 结算平台url
   settlementPlatformUrl: 'http://webcx.test241.wanyuhengtong.com/',
   // 工单管理系统url
-  GDUrl: 'http://localhost:8080/',
+  GDUrl: 'http://http://bugweb.test241.wanyuhengtong.com/',
   // token加密key
   secretKey: 'key123',
   loginTitle: '',

+ 4 - 4
src/views/sellOut/filing/cpns/exam-form.vue

@@ -119,6 +119,7 @@ export default {
   data() {
     return {
       loading: false,
+      isInit:true,
       is_determine_price: "",
       cgd_charge: "",
       price: "",
@@ -231,8 +232,7 @@ export default {
        this.$refs.ruleForm && this.$refs.ruleForm.validateField("platform_id");
     },
     async number_change(e, key) {
-      console.log(e,key)
-      if(Number(this.ruleForm[key]) === e) {
+      if(Number(this.ruleForm[key]).toFixed(2) === Number(e).toFixed(2)) {
         return
       }     
       this.ruleForm[key] = e + "" || "0";
@@ -289,7 +289,6 @@ export default {
         await this.set_number_change("service_proportion", rate);
       }
 
-      return
       if (!is_sale && key === "service_proportion") {
         if (rate === 100) {
           this.$message.error("服务费比例不能等于100!");
@@ -298,7 +297,8 @@ export default {
           return;
         }
         qrdAdd = accDiv(cgdAdd, accSub(100, rate));
-        serAdd = accSub(qrdAdd, cgdAdd);
+        serAdd = accSub(Number(qrdAdd).toFixed(2), cgdAdd);
+        console.log(serAdd)
 
         await this.set_number_change("service_charge", serAdd);
       }

+ 24 - 2
src/views/sellOut/salesOrder/components/addForm.vue

@@ -476,12 +476,23 @@
                   :size="'mini'"
                   :style="{ marginBottom: scope.row.edit ? '13px' : '0' }"
                 >
-                  <select-area
+                  <!-- <select-area
                     :value="scope.row.addr_code"
                     placeholder="收货省市区"
                     :disabled="!scope.row.edit"
                     :size="'mini'"
                     @selectChange="select_area_change($event, scope.$index)"
+                  /> -->
+
+                  <search-area 
+                    :value="scope.row.code"
+                    size="mini" 
+                    :disabled="!scope.row.edit"
+                    :is-detail="scope.row.edit"
+                    :names="scope.row.names"
+                    placeholder="收货省市区" 
+                    :level="3" 
+                    @searchChange="areaChange($event,scope.$index)"
                   />
                 </el-form-item>
                 <span v-if="!scope.row.edit">{{ scope.row.addr_code_name }}</span>
@@ -1033,7 +1044,12 @@ export default {
       this.$refs.ruleForm.validateField("proof_id");
     },
     addrRefresh(e) {
-      const { list } = e;
+      const list = JSON.parse(JSON.stringify(e.list));
+      list.forEach(item => {
+        item.code = item.areaCode ? [item.areaCode] :[]
+        item.names = item.label ? [item.label] : []
+      })
+      console.log(list)
       this.addrForm.order_addr.push(...list);
     },
     async resultList(e) {
@@ -1269,6 +1285,12 @@ export default {
     select_area_change(e, index) {
       this.addrForm.order_addr[index].addr_code = e;
     },
+    areaChange(e,index){
+      const { code,area_code,label } = e
+      this.addrForm.order_addr[index].names = label ? [label] : [];
+      this.addrForm.order_addr[index].code = area_code ? [area_code] : [];
+      this.addrForm.order_addr[index].addr_code = code ? code.split(',') : [];
+    },
     //省市区保存某一行
     async checkRow(rowIndex) {
       await this.$refs.addrForm.validate(async (valid) => {

+ 21 - 1
src/views/sellOut/salesOrder/components/out-order-add-model.vue

@@ -69,11 +69,21 @@
                   prop="addr_code"
                   :label-width="'99px'"
                 >
-                  <select-area
+                  <!-- <select-area
                     :value="ruleForm.addr_code"
                     :size="'mini'"
                     placeholder="收货省市区"
                     @selectChange="select_area_change($event)"
+                  /> -->
+
+                  <search-area
+                    :value="code"
+                    :is-detail="true"
+                    size="mini"
+                    :names="label"
+                    placeholder="收货省市区"
+                    :level="3"
+                    @searchChange="areaChange($event)"
                   />
                 </el-form-item>
               </el-col>
@@ -176,6 +186,8 @@ export default {
       }
     }
     return {
+      code: [],
+      label: [],
       roleList: [],
       loading: false,
       title: '新建发货单',
@@ -247,6 +259,14 @@ export default {
     }
   },
   methods: {
+    async areaChange(e) {
+      const { code, area_code, label } = e
+      this.ruleForm.addr_code = code ? code.split(',') : []
+      this.code = area_code ? [area_code] : []
+      this.label = label ? [label] : []
+      this.$refs.ruleForm.validateField('addr_code')
+    },
+
     closeModel() {
       console.log('closeModel!!')
       this.showModelThis = false