From 5bdaf416d66b675131004de1aba5d161772a52b0 Mon Sep 17 00:00:00 2001
From: liubp <1535785116@qq.com>
Date: 星期五, 19 十二月 2025 18:27:52 +0800
Subject: [PATCH] 添加所属小区字段
---
public/pages/common/communityManage/edit/edit.js | 75 ++++++++++++++++++++++++++++++++-----
1 files changed, 65 insertions(+), 10 deletions(-)
diff --git a/public/pages/common/communityManage/edit/edit.js b/public/pages/common/communityManage/edit/edit.js
index 7b57da9..d5e7e3e 100644
--- a/public/pages/common/communityManage/edit/edit.js
+++ b/public/pages/common/communityManage/edit/edit.js
@@ -367,7 +367,7 @@
if (!detail) {
return;
}
- // 澶勭悊琛屾斂鍖虹紪鐮侊紙濡�310115 -> 鐪侊細310000锛屽競锛�310100锛屽尯锛�310115锛�
+ // 浼樺厛浣跨敤 cityCode锛堣鏀垮尯缂栫爜锛屽310115 -> 鐪侊細310000锛屽競锛�310100锛屽尯锛�310115锛�
const areaCode = detail.cityCode || '';
if (areaCode && areaCode.length >= 6) {
const provCode = areaCode.substring(0, 2) + '0000';
@@ -378,8 +378,62 @@
// 鍏堝姞杞藉競锛屽啀鍔犺浇鍖�
vc.component._initArea('202', provCode);
vc.component._initArea('303', cityCode);
+ } else {
+ // 濡傛灉娌℃湁 cityCode锛屽垯鏍规嵁鎺ュ彛杩斿洖鐨勭渷甯傚尯鍚嶇О鍖归厤涓嬫媺閫夐」
+ // 杩欓噷鍦板尯鏁版嵁鏄紓姝ュ姞杞界殑锛屽洜姝ら噰鐢ㄩ噸璇曟柟寮忥紝鐩村埌鍖归厤鎴愬姛鎴栬揪鍒版渶澶ф鏁�
+ let retry = 0;
+ const maxRetry = 20;
+ const matchAreaByName = function() {
+ const provName = detail.projectAddressProvince || '';
+ const cityName = detail.projectAddressCity || '';
+ const districtName = detail.projectAddressDistrict || '';
+
+ // 1. 鍖归厤鐪�
+ if (provName && !vc.component.selectProv && vc.component.provs && vc.component.provs.length > 0) {
+ const prov = vc.component.provs.find(p => p.areaName === provName);
+ if (prov) {
+ vc.component.selectProv = prov.areaCode;
+ vc.component.selectProvName = prov.areaName;
+ vc.component.formData.projectAddressProvince = prov.areaName;
+ // 鍔犺浇甯傚垪琛�
+ vc.component._initArea('202', prov.areaCode);
+ }
+ }
+
+ // 2. 鍖归厤甯�
+ if (cityName && vc.component.selectProv && !vc.component.selectCity &&
+ vc.component.citys && vc.component.citys.length > 0) {
+ const city = vc.component.citys.find(c => c.areaName === cityName);
+ if (city) {
+ vc.component.selectCity = city.areaCode;
+ vc.component.selectCityName = city.areaName;
+ vc.component.formData.projectAddressCity = city.areaName;
+ // 鍔犺浇鍖哄垪琛�
+ vc.component._initArea('303', city.areaCode);
+ }
+ }
+
+ // 3. 鍖归厤鍖�
+ if (districtName && vc.component.selectCity && !vc.component.selectArea &&
+ vc.component.areas && vc.component.areas.length > 0) {
+ const area = vc.component.areas.find(a => a.areaName === districtName);
+ if (area) {
+ vc.component.selectArea = area.areaCode;
+ vc.component.selectAreaName = area.areaName;
+ vc.component.formData.projectAddressDistrict = area.areaName;
+ vc.component.formData.cityCode = area.areaCode;
+ }
+ }
+
+ // 濡傛灉杩樻病鏈夊畬鏁村尮閰嶅埌鍖猴紝骞朵笖鏈秴杩囬噸璇曟鏁帮紝鍒欑户缁噸璇�
+ if ((!vc.component.selectArea || !vc.component.formData.cityCode) && retry < maxRetry) {
+ retry++;
+ setTimeout(matchAreaByName, 100);
+ }
+ };
+ matchAreaByName();
}
- // 琛ラ綈鍚嶇О锛堢敤浜庢彁浜わ級
+ // 琛ラ綈鍚嶇О锛堢敤浜庢彁浜わ紝闃叉鎺ュ彛鏈夊�间絾涓婇潰鏈鐩栵級
vc.component.formData.projectAddressProvince = detail.projectAddressProvince || vc.component.formData.projectAddressProvince;
vc.component.formData.projectAddressCity = detail.projectAddressCity || vc.component.formData.projectAddressCity;
vc.component.formData.projectAddressDistrict = detail.projectAddressDistrict || vc.component.formData.projectAddressDistrict;
@@ -399,11 +453,11 @@
return fallback;
};
return {
- communityId: info.communityId || info.communityId || '',
+ communityId: info.communityId || '',
newBId: info.newBId || '',
feePrice: info.feePrice || '',
- projectAddressProvince: info.projectAddressProvince || info.provinceName || '',
- projectAddressCity: info.projectAddressCity || info.cityName || '',
+ projectAddressProvince: info.projectAddressProvince || '',
+ projectAddressCity: info.projectAddressCity || '',
projectAddressDistrict: info.projectAddressDistrict || info.areaName || '',
projectAddressTown: info.projectAddressTown || '',
projectAddressRoad: info.projectAddressRoad || '',
@@ -456,7 +510,7 @@
groundNonMotorVehicleArea: info.groundNonMotorVehicleArea || info.nonElectricCarGroundArea || '',
undergroundNonMotorVehicleArea: info.undergroundNonMotorVehicleArea || info.nonElectricCarUndergroundArea || '',
clubhouseArea: info.clubhouseArea || info.clubArea || '',
- hasDecorationRubbishPoint: toBoolString(info.hasDecorationRubbishPoint, info.garbageFixed ? 'true' : 'false'),
+ hasDecorationRubbishPoint: info.hasDecorationRubbishPoint === '鏄�' || info.garbageFixed == 1 ? '鏄�' : '鍚�',
securityEntranceCount: info.securityEntranceCount || info.gateGuardTotal || '',
elevatorCount: info.elevatorCount || info.elevatorTotal || '',
elevatorType: info.elevatorType || '',
@@ -626,18 +680,19 @@
submitData[field] = Number(submitData[field]);
}
});
- // 纭繚Integer瀛楁涓烘暣鏁扮被鍨�
+ // 纭繚Integer瀛楁涓烘暣鏁扮被鍨嬶紙浠呯敤浜庨渶瑕佷紶 0/1 鐨勫竷灏斿瓧娈碉級
const normalizeBoolToNumber = function(val) {
- if (val === true || val === 'true' || val === 1 || val === '1') {
+ if (val === true || val === 'true' || val === 1 || val === '1' || val === '鏄�') {
return 1;
}
- if (val === false || val === 'false' || val === 0 || val === '0') {
+ if (val === false || val === 'false' || val === 0 || val === '0' || val === '鍚�') {
return 0;
}
return val;
};
+ // 涓婂矖璇佷粛鐒舵寜 0/1 鎻愪氦
submitData.hasManagerCertificate = normalizeBoolToNumber(submitData.hasManagerCertificate);
- submitData.hasDecorationRubbishPoint = normalizeBoolToNumber(submitData.hasDecorationRubbishPoint);
+ // hasDecorationRubbishPoint 淇濇寔涓衡�滄槸 / 鍚︹�濓紝鐩存帴闅忚〃鍗曟彁浜�
// 鎻愪氦鏁版嵁
vc.http.apiPost(
'/community.updateCommunity',
--
Gitblit v1.8.0