From 8be8c95d76bf7e805791e1c9ca1ddf680c02660d Mon Sep 17 00:00:00 2001
From: ‘chensiAb’ <‘chenchenco03@163.com’>
Date: Wed, 16 Apr 2025 18:25:24 +0800
Subject: [PATCH] fix:地区组件-三级区域不存在时默认二级区域,删除无效代码

---
 forms/chinaArea/ChinaLocations.js |   27 ++++++++++++++++-----------
 1 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/forms/chinaArea/ChinaLocations.js b/forms/chinaArea/ChinaLocations.js
index ee602ce..1b2f8c0 100644
--- a/forms/chinaArea/ChinaLocations.js
+++ b/forms/chinaArea/ChinaLocations.js
@@ -31,7 +31,6 @@
 });
 
 export class ChinaLocations {
-
     onReady(callback) {
         if (Tools.isEmptyObject(locationRes)) {
             readyCallbacks.push(callback);
@@ -43,7 +42,7 @@
     _createLocationTree(level) {
         const treeDatas = [];
         // lv1-省
-        Object.keys(locationRes).forEach((provinceCode) => {
+        Object.keys(locationRes).forEach(provinceCode => {
             const province = {
                 label: locationRes[provinceCode].name,
                 value: provinceCode,
@@ -51,10 +50,10 @@
             };
             // lv2-市
             const cityContainer = locationRes[provinceCode].children;
-            Object.keys(cityContainer).forEach((cityCode) => {
+            Object.keys(cityContainer).forEach(cityCode => {
                 const city = {
                     value: cityCode,
-                    area: cityContainer[cityCode].area,  // 电话区码
+                    area: cityContainer[cityCode].area, // 电话区码
                     children: [],
                 };
                 if (typeof cityContainer[cityCode] === 'string') {
@@ -184,12 +183,18 @@
                                                 codes[2] = distCode;
                                                 // 如果存在街道,继续转街道
                                                 if (regions[3]) {
-                                                    const streetContainer = distContainer[distCode].children;
-                                                    Object.keys(streetContainer).forEach(streetCode => {
-                                                        if (streetContainer[streetCode] === regions[3]) {
-                                                            codes[3] = streetCode;
-                                                        }
-                                                    });
+                                                    const streetContainer =
+                                                        distContainer[distCode].children;
+                                                    Object.keys(streetContainer).forEach(
+                                                        streetCode => {
+                                                            if (
+                                                                streetContainer[streetCode] ===
+                                                                regions[3]
+                                                            ) {
+                                                                codes[3] = streetCode;
+                                                            }
+                                                        },
+                                                    );
                                                 }
                                                 break;
                                             }
@@ -248,4 +253,4 @@
     }
 }
 
-export const $locations = new ChinaLocations();
\ No newline at end of file
+export const $locations = new ChinaLocations();

--
Gitblit v1.9.1