From 46e81fa90c8e089a781fdc994b5427b6e57fb311 Mon Sep 17 00:00:00 2001
From: yyb <995253665@qq.com>
Date: 星期五, 27 三月 2026 14:52:02 +0800
Subject: [PATCH] feat(客户档案): 优化地区路径查找逻辑
---
src/views/basicData/customerFile/index.vue | 27 +++++++++++++++++++++++----
1 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/src/views/basicData/customerFile/index.vue b/src/views/basicData/customerFile/index.vue
index dae1f7f..326f3f9 100644
--- a/src/views/basicData/customerFile/index.vue
+++ b/src/views/basicData/customerFile/index.vue
@@ -980,6 +980,18 @@
}
return [];
};
+ const findRegionPathById = (tree, targetId, parentPath = []) => {
+ if (targetId === undefined || targetId === null || targetId === "") return [];
+ for (const item of tree || []) {
+ const currentPath = [...parentPath, item.id];
+ if (String(item.id) === String(targetId)) {
+ return currentPath;
+ }
+ const childResult = findRegionPathById(item.children || [], targetId, currentPath);
+ if (childResult.length) return childResult;
+ }
+ return [];
+ };
const addNewContact = () => {
formYYs.value.contactList.push({
contactPerson: "",
@@ -1050,14 +1062,21 @@
if (type === "edit") {
getCustomer(row.id).then(res => {
form.value = { ...res.data };
- formRegionPath.value = findRegionPathByName(
- regionTreeData.value,
- form.value.regions || ""
- );
+ const regionIdForEdit = form.value.regionsId || form.value.regionsld;
+ formRegionPath.value = findRegionPathById(regionTreeData.value, regionIdForEdit);
+ if (!formRegionPath.value.length) {
+ formRegionPath.value = findRegionPathByName(
+ regionTreeData.value,
+ form.value.regionsName || form.value.regions || ""
+ );
+ }
const selectedRegionId =
formRegionPath.value.length > 0
? formRegionPath.value[formRegionPath.value.length - 1]
: "";
+ if (selectedRegionId && !form.value.regions) {
+ form.value.regions = regionNodeMap.value.get(selectedRegionId)?.regionsName || "";
+ }
form.value.regionsId = form.value.regionsId || selectedRegionId;
form.value.regionsld = form.value.regionsld || form.value.regionsId || selectedRegionId;
formYYs.value.contactList = res.data.contactPerson
--
Gitblit v1.9.3