From 9ed9db9716f36e797141d9a80119fd0c1f4ac7a5 Mon Sep 17 00:00:00 2001
From: zhaowei <zhaowei>
Date: 星期二, 14 一月 2025 15:12:14 +0800
Subject: [PATCH] 1、产品/部件/零件的新增与编辑以及根据层级查询对应文档功能已完成后端联调 2、产品结构树新增节点展开记忆功能方便新增节点后查看

---
 src/views/dnc/base/modules/ProductStructure/ProductStructureMainTop.vue |   47 ++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 40 insertions(+), 7 deletions(-)

diff --git a/src/views/dnc/base/modules/ProductStructure/ProductStructureMainTop.vue b/src/views/dnc/base/modules/ProductStructure/ProductStructureMainTop.vue
index e6bb019..790df03 100644
--- a/src/views/dnc/base/modules/ProductStructure/ProductStructureMainTop.vue
+++ b/src/views/dnc/base/modules/ProductStructure/ProductStructureMainTop.vue
@@ -1,12 +1,14 @@
 <template>
-  <a-tabs v-model="activeTabKey" @contextmenu.native="e=>e.preventDefault()"
+  <a-tabs v-model="activeTabKey" @change="handleTabChange" @contextmenu.native="e=>e.preventDefault()"
           v-if="Object.keys(currentTreeNodeInfo).length!==0">
     <a-tab-pane :key="1" tab="NC鏂囨。" v-if="currentTreeNodeInfo.type!==1">
-      <NcDocumentTableList @handleTableContextMenuOpen="handleTableContextMenuOpen" :size="tableContainerSize"/>
+      <NcDocumentTableList ref="ncDocumentTableListRef" :currentTreeNodeInfo="currentTreeNodeInfo"
+                           @handleTableContextMenuOpen="handleTableContextMenuOpen" :size="tableContainerSize"/>
     </a-tab-pane>
 
     <a-tab-pane :key="2" tab="鍏朵粬鏂囨。">
-      <OtherDocumentTableList @handleTableContextMenuOpen="handleTableContextMenuOpen" :size="tableContainerSize"/>
+      <OtherDocumentTableList ref="otherDocumentTableListRef" :currentTreeNodeInfo="currentTreeNodeInfo"
+                              @handleTableContextMenuOpen="handleTableContextMenuOpen" :size="tableContainerSize"/>
     </a-tab-pane>
 
     <TableContextMenu :tableRowInfo="currentRightClickedTableRowInfo" ref="tableContextMenuRef"/>
@@ -23,7 +25,8 @@
     components: { TableContextMenu, OtherDocumentTableList, NcDocumentTableList },
     data() {
       return {
-        activeTabKey: '1',
+        activeTabKey: null,
+        hasLoadingDataTabKey: [],
         tableContainerSize: 'small',
         currentRightClickedTableRowInfo: {},
         currentTreeNodeInfo: {}
@@ -31,6 +34,19 @@
     },
     created() {
       this.$bus.$on('sendCurrentTreeNodeInfo', this.receiveCurrentTreeNodeInfo)
+    },
+    watch: {
+      activeTabKey: {
+        handler(value) {
+          // tab鍒囨崲鏃跺姞杞藉搴旀枃妗e垪琛紝褰撳墠鏍戣妭鐐逛笅宸茬粡鍔犺浇杩囩殑鏂囨。鍒楄〃涓嶅啀閲嶅鍔犺浇
+          if (!this.hasLoadingDataTabKey.includes(value)) {
+            if (value === 1) this.$nextTick(() => this.$refs.ncDocumentTableListRef.loadData(1))
+            else this.$nextTick(() => this.$refs.otherDocumentTableListRef.loadData(1))
+            this.hasLoadingDataTabKey.push(value)
+          }
+        },
+        deep: true
+      }
     },
     methods: {
       /**
@@ -48,13 +64,30 @@
 
       /**
        * 鎺ユ敹鏍戠粍浠朵紶鏉ョ殑褰撳墠閫変腑鐨勬爲鑺傜偣淇℃伅
-       * @param treeNodeInfo
+       * @param treeNodeInfo 鏍戣妭鐐逛俊鎭�
        */
       receiveCurrentTreeNodeInfo(treeNodeInfo) {
         // 浠庢爲缁勪欢鎺ュ彈鏍戣妭鐐逛俊鎭悗浠庣埗缁勪欢娴佸叆瀛愮粍浠�
         this.currentTreeNodeInfo = treeNodeInfo
-        if (treeNodeInfo.type !== 1) this.activeTabKey = 1
-        else this.activeTabKey = 2
+        // 娓呯┖涓婁竴鑺傜偣宸茬粡鍔犺浇杩囧緱鏂囨。鍒楄〃tabKey
+        this.hasLoadingDataTabKey = []
+        if (treeNodeInfo.type !== 1) {
+          this.activeTabKey = 1
+          this.$nextTick(() => this.$refs.ncDocumentTableListRef.loadData(1))
+        } else {
+          this.activeTabKey = 2
+          this.$nextTick(() => this.$refs.otherDocumentTableListRef.loadData(1))
+        }
+        this.hasLoadingDataTabKey.push(this.activeTabKey)
+      },
+
+      handleTabChange(activeTabKey) {
+        // tab鍒囨崲鏃跺姞杞藉搴旀枃妗e垪琛紝褰撳墠鏍戣妭鐐逛笅宸茬粡鍔犺浇杩囩殑鏂囨。鍒楄〃涓嶅啀閲嶅鍔犺浇
+        if (!this.hasLoadingDataTabKey.includes(activeTabKey)) {
+          if (activeTabKey === 1) this.$nextTick(() => this.$refs.ncDocumentTableListRef.loadData(1))
+          else this.$nextTick(() => this.$refs.otherDocumentTableListRef.loadData(1))
+          this.hasLoadingDataTabKey.push(activeTabKey)
+        }
       },
 
       /**

--
Gitblit v1.9.3