From b9bd29a1a81f6f7de479e3cc3fdfe3d85fc660bf Mon Sep 17 00:00:00 2001
From: he wei <858544502@qq.com>
Date: 星期三, 23 四月 2025 13:35:06 +0800
Subject: [PATCH] UA 整理提交

---
 src/utils/tree.js |   78 +++++++++++++++++++++-----------------
 1 files changed, 43 insertions(+), 35 deletions(-)

diff --git a/src/utils/tree.js b/src/utils/tree.js
index cb290ed..50ef63c 100644
--- a/src/utils/tree.js
+++ b/src/utils/tree.js
@@ -1,37 +1,45 @@
-export function formatAreaTree(item, ids, list) {
-  // parentId 涓嶅湪id鍒楄〃涓�;
-  // if (item.parentId === 0) {
-  if (ids.indexOf(item.parentId) === -1) {
-    list.push({
-      label: item.areaName,
-      id: item.id,
-      data: item,
-      areaDescript: item.areaDescript,
-      charger: item.areaUsers.map((v) => v.uname).join(","),
-      children: [],
-    });
-  } else {
-    let isCurrentChild = false;
-    for (let i = 0; i < list.length; i++) {
-      const listItem = list[i];
-      if (listItem.id === item.parentId) {
-        isCurrentChild = true;
-        listItem.children.push({
-          label: item.areaName,
-          id: item.id,
-          data: item,
-          areaDescript: item.areaDescript,
-          charger: item.areaUsers.map((v) => v.uname).join(","),
-          children: [],
-        });
-      }
+export function formatAreaTree(list) {
+  return list.map(item => {
+    const result = {
+      label: item.stationName1,
+      children: []
+    };
+    if (item.cityList) {
+      result.children = item.cityList.map(city => {
+        const cityNode = {
+          label: city.stationName2,
+          children: []
+        };
+        if (city.countryList) {
+          cityNode.children = city.countryList.map(country => {
+            const countryNode = {
+              label: country.stationName3,
+              children: []
+            };
+            if (country.stationList) {
+              countryNode.children = country.stationList.map(station => {
+                const stationNode = {
+                  label: station.stationName4,
+                  stationId: station.stationId,
+                  children: []
+                };
+                if (station.baojiList) {
+                  stationNode.children = station.baojiList.map(baoji => {
+                    return {
+                      label: baoji.baojiName,
+                      id: `${baoji.id}-${station.stationId}`,
+                    };
+                  });
+                }
+                return stationNode;
+              });
+            }
+            return countryNode;
+          });
+        }
+        return cityNode;
+      });
     }
-
-    for (let i = 0; i < list.length; i++) {
-      const listItem = list[i];
-      if (!isCurrentChild && listItem.children !== 0) {
-        formatAreaTree(item, ids, listItem.children);
-      }
-    }
-  }
+    return result;
+  });
 }

--
Gitblit v1.9.1