Explorar o código

省市区回显bug

@dongkboy %!s(int64=3) %!d(string=hai) anos
pai
achega
e681d61909
Modificáronse 2 ficheiros con 34 adicións e 6 borrados
  1. 13 0
      src/utils/validate.js
  2. 21 6
      src/views/Letter/Letter.vue

+ 13 - 0
src/utils/validate.js

@@ -1,3 +1,4 @@
+import {codeToText } from "element-china-area-data";
 /**
  * 邮箱
  * @param {*} s
@@ -146,3 +147,15 @@ export function validateSfz(rule, value, callback) {
     }
   }, 200);
 };
+//根据省市区name查找code
+export function searchkey(cityName){
+  const targetValues = cityName;
+  const matchedKeys = [];
+  for (const key in codeToText) {
+    const value = codeToText[key];
+    if (targetValues.includes(value)) {
+      matchedKeys.push(key)
+    }
+  }
+  return matchedKeys
+}

+ 21 - 6
src/views/Letter/Letter.vue

@@ -1628,7 +1628,7 @@
 import QRCode from "qrcodejs2";
 import Cookies from "js-cookie";
 import CommonUtil from "@/utils/comutil.js";
-import { getAgeByIdCard } from "@/utils/validate.js";
+import { getAgeByIdCard,searchkey } from "@/utils/validate.js";
 import { regionData, codeToText } from "element-china-area-data";
 export default {
   inject: ["reload"],
@@ -2730,6 +2730,7 @@ export default {
   },
   created() {
 
+
     this.getDicType("vehicleType");//车辆种类
     this.getDicType("trafficManagementVehicleType");//车辆类型
     this.getDicType("energyType");//能源种类
@@ -2757,7 +2758,6 @@ export default {
     }
     //--订单编辑回显--
     this.paramsEdit = this.$route.query.data; //接收参数
-
     if (this.paramsEdit) {
       var _this = this;
       this.jqchecked = false;
@@ -2774,7 +2774,26 @@ export default {
       _this.ownerInfo.age = getAgeByIdCard(_this.ownerInfo.identifyNumber)
       _this.policyHolderInfo.age = getAgeByIdCard(_this.policyHolderInfo.identifyNumber)
       _this.insuredPersonInfo.age = getAgeByIdCard(_this.insuredPersonInfo.identifyNumber)
+      const ownerInfoObject={
+        province:_this.ownerInfo.province,
+        city:_this.ownerInfo.city,
+        county:_this.ownerInfo.county,
+      }
+      const policyHolderInfoObject={
+        province:_this.policyHolderInfo.province,
+        city:_this.policyHolderInfo.city,
+        county:_this.policyHolderInfo.county,
+      }
+      const insuredPersonInfoObject={
+        province:_this.insuredPersonInfo.province,
+        city:_this.insuredPersonInfo.city,
+        county:_this.insuredPersonInfo.county,
+      }
+      this.selectedOptions1=searchkey(Object.values(ownerInfoObject))
+      this.selectedOptions2=searchkey(Object.values(policyHolderInfoObject))
+      this.selectedOptions3=searchkey(Object.values(insuredPersonInfoObject))
       if (_this.paramsEdit.carinfo.transferFlag) {
+
         this.transferDateShow = true;
       }
       _this.paramsEdit.risk.map(ele => {
@@ -2860,10 +2879,6 @@ export default {
     },
     //省市区
     areahandleChange(event, info) {
-      console.log(this.selectedOptions1)
-      console.log(event)
-      console.log(info)
-      console.log(codeToText)
       if (event[0] != null && event[1] != null && event[2] != null) {
         this[info].province = codeToText[event[0]]
         this[info].city = codeToText[event[1]]