From 2ca94de8ede18ac07ccfd8dec7b6f6a707adde9b Mon Sep 17 00:00:00 2001
From: 张含笑 <zhx18749296735@163.com>
Date: Mon, 01 Sep 2025 11:20:24 +0800
Subject: [PATCH] Merge branch 'refs/heads/feature/v5.0/5.0.5' into patch_management

---
 src/views/resource/patchManagement.vue |   59 ++++++++++++++++++++++++++++++++++++-----------------------
 1 files changed, 36 insertions(+), 23 deletions(-)

diff --git a/src/views/resource/patchManagement.vue b/src/views/resource/patchManagement.vue
index 3285f03..371c723 100644
--- a/src/views/resource/patchManagement.vue
+++ b/src/views/resource/patchManagement.vue
@@ -88,7 +88,6 @@
   
   </basic-container>
 </template>
-
 <script setup>
 import {
   spotManagementTableApi,
@@ -151,6 +150,8 @@
 const selectionList = ref([]);
 
 const option = ref({
+ align: 'center', 
+  headerAlign: 'center',
   addBtn: false,
   tip: false,
   searchShow: true,
@@ -211,8 +212,9 @@
     },
     {
       label: '行政区划',
-      prop: 'area_code',
+      prop: 'areaName',
       span: 24,
+      width:180,
       searchLabelWidth: 100,
       search: true,
       searchSpan: 4,
@@ -262,7 +264,6 @@
 // ===== computed =====
 const userInfo = computed(() => store.getters.userInfo);
 const permission = computed(() => store.getters.permission);
-
 const permissionList = computed(() => ({
   addBtn: !!permission.value.oss_add,
   viewBtn: !!permission.value.oss_view,
@@ -272,13 +273,11 @@
 
 const ids = computed(() => selectionList.value.map(ele => ele.id).join(','));
 // 获取行政区划
-const regionalData = ref(null)
+const regionalData = ref([])
 const requestDockInfo = () => {
   getRegionTreeAll({ parentCode: userAreaCode.value }).then(res => { 
     const rawData = res.data.data ? [res.data.data] : []; 
-    regionalData.value = rawData
-        // console.log('quyu',regionalData.value);
-    // 过滤函数
+    regionalData.value = rawData; 
     const filterTree = nodes => {
       return nodes.filter(node => {
         const nodeCodeStr = node.id.toString();
@@ -295,6 +294,7 @@
       });
     };
     deptTreeData.value = filterTree(rawData);
+    onLoad(page.value); 
   });
 };
 // 获取搜索数据
@@ -449,30 +449,44 @@
   spotManagementTableApi(searchparams).then(res => {
     const d = res.data.data;
     page.value.total = d.total;
-    data.value = d.records.map(i=>({
+    data.value = d.records
+    .map(i=>({
       ...i,
       dataFrom:i.date_from === 0? '本地上传':'国土调查云',
-      // areaName: findAreaName(regionalData.value, i.area_code)
+      areaName: findAreaName(i.area_code)
     }));
      console.log('表格数据',data.value );
     loading.value = false;
     selectionClear();
   });
 };
-const findAreaName = (nodes, areaCode) => {
-  if (!nodes || nodes.length === 0) return '';
-  for (const node of nodes) {
-    if (node.id === areaCode) {
-      return node.name;
+const findAreaName = (areaCode) => {
+  const nodes = regionalData.value;
+  if (!nodes || nodes.length === 0) return areaCode;
+
+  const normalizeCode = (code) => {
+    if (!code) return '';
+    const strCode = String(code).replace(/0+$/, '');
+    return strCode.length >= 6 ? strCode : '';
+  };
+  const targetCode = normalizeCode(areaCode);
+  const findInTree = (treeNodes, needFullPath = false, parentPath = []) => {
+    for (const node of treeNodes) {
+      const currentPath = [...parentPath, node.name];
+      
+      if (normalizeCode(node.id) === targetCode) {
+        return needFullPath ? currentPath.join('/') : node.name;
+      }
+
+      if (node.childrens?.length > 0) {
+        const found = findInTree(node.childrens, needFullPath, currentPath);
+        if (found) return found;
+      }
     }
-    
-    if (node.childrens && node.childrens.length > 0) {
-      const found = findAreaName(node.childrens, areaCode);
-      if (found) return found;
-    }
-  }
-  
-  return '';
+    return null;
+  };
+
+  return findInTree(nodes, true) || areaCode;
 };
 // 图斑详情/编辑
 const uploadPatch = (row, type = 'detail') => {
@@ -532,7 +546,6 @@
 };
 provide('searchReset', searchReset);
 onMounted(() => {
-  requestDockInfo()
   getsearchManagementApi();
 
 });

--
Gitblit v1.9.3