Browse Source

feat: 地址获取经纬度优化

zhangying 9 months ago
parent
commit
0eac766fdb

+ 8 - 6
vue/src/views/baseSettings/siteInfo/edit.vue

@@ -343,12 +343,14 @@ export default defineComponent({
 
     // 根据地址获取经纬度
     function detailAddressChange() {
-      getAddressLonLat(formData.dataModel.detailAddress).then((result: any) => {
-        if (result.lon && result.lat) {
-          formData.dataModel.siteLongitude = result.lon;
-          formData.dataModel.siteLatitude = result.lat;
-        }
-      });
+      if (formData.dataModel.detailAddress) {
+        getAddressLonLat(formData.dataModel.detailAddress).then((result: any) => {
+          if (result.lon && result.lat) {
+            formData.dataModel.siteLongitude = result.lon;
+            formData.dataModel.siteLatitude = result.lat;
+          }
+        });
+      }
     }
 
     return {

+ 10 - 6
vue/src/views/companyService/company/edit.vue

@@ -690,6 +690,8 @@ export default defineComponent(
                 formState.dataModel[key] = result[key];
               }
             })
+            // 调用地址变更事件
+            companyAddressChange();
             formRef.value?.validate();
           }
         }).finally(() => {
@@ -769,12 +771,14 @@ export default defineComponent(
 
       // 根据地址获取经纬度
       function companyAddressChange() {
-        getAddressLonLat(formState.dataModel.companyAddress).then((result: any) => {
-          if (result.lon && result.lat) {
-            formState.dataModel.longitude = result.lon;
-            formState.dataModel.latitude = result.lat;
-          }
-        });
+        if (formState.dataModel.companyAddress) {
+          getAddressLonLat(formState.dataModel.companyAddress).then((result: any) => {
+            if (result.lon && result.lat) {
+              formState.dataModel.longitude = result.lon;
+              formState.dataModel.latitude = result.lat;
+            }
+          });
+        }
       }
 
       return {

+ 8 - 6
vue/src/views/jobUserManager/jobuser/edit.vue

@@ -953,12 +953,14 @@ export default defineComponent(
 
       // 根据地址获取经纬度
       function addressChange() {
-        getAddressLonLat(formState.dataModel.address).then((result: any) => {
-          if (result.lon && result.lat) {
-            formState.dataModel.longitude = result.lon;
-            formState.dataModel.latitude = result.lat;
-          }
-        });
+        if (formState.dataModel.address) {
+          getAddressLonLat(formState.dataModel.address).then((result: any) => {
+            if (result.lon && result.lat) {
+              formState.dataModel.longitude = result.lon;
+              formState.dataModel.latitude = result.lat;
+            }
+          });
+        }
       }
 
       return {