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/common/ProductStructureTree.vue |  374 +++++------------------------------------------------
 1 files changed, 36 insertions(+), 338 deletions(-)

diff --git a/src/views/dnc/common/ProductStructureTree.vue b/src/views/dnc/common/ProductStructureTree.vue
index 2d85dbf..c6d958f 100644
--- a/src/views/dnc/common/ProductStructureTree.vue
+++ b/src/views/dnc/common/ProductStructureTree.vue
@@ -16,7 +16,8 @@
               <a-icon type="bars"/>
             </a-button>
           </a-dropdown>
-          <a-button type="primary" @click="$refs.productModalFormRef.handleProductAdd('娣诲姞浜у搧')">
+          <a-button type="primary"
+                    @click="$refs.productModalFormRef.triggerCorrespondingMethod({modalTitle:'娣诲姞浜у搧',methodName:'handleProductAdd'})">
             <a-icon type="plus"></a-icon>
             浜у搧
           </a-button>
@@ -36,33 +37,40 @@
             <a-icon slot="product" type="shopping"/>
             <a-icon slot="component" type="camera"/>
             <a-icon slot="part" type="hdd"/>
+            <a-icon slot="process" type="apartment"/>
+            <a-icon slot="processStep" type="tool"/>
           </a-tree>
         </div>
       </div>
     </a-spin>
 
     <!--浜у搧寮圭獥-->
-    <ProductModal ref="productModalFormRef" :currentTreeNodeInfo="rightClickSelected"/>
+    <ProductModal ref="productModalFormRef" :currentTreeNodeInfo="rightClickSelected"
+                  @submitSuccess="queryTreeData"/>
+    <!--閮ㄤ欢寮圭獥-->
+    <ComponentModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess"/>
     <!--闆朵欢寮圭獥-->
-    <ComponentModal :currentTreeNodeInfo="rightClickSelected"/>
-    <!--瀵煎叆鏂囦欢鍏叡寮圭獥-->
-    <ImportFileModal/>
+    <PartModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess"/>
+    <!--宸ュ簭寮圭獥-->
+    <ProcessModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess"/>
   </a-card>
 </template>
 
 <script>
+  import dncApi from '@/api/dnc'
   import { deleteAction } from '@/api/manage'
-  import { mapActions } from 'vuex'
   import ProductStructureTreeContextMenu from './modules/ProductStructureTree/ProductStructureTreeContextMenu'
   import ProductModal from '../base/modules/ProductStructure/Product/ProductModal'
-  import ImportFileModal from './ImportFileModal'
   import ComponentModal from '../base/modules/ProductStructure/Component/ComponentModal'
+  import PartModal from '../base/modules/ProductStructure/Part/PartModal'
+  import ProcessModal from '../base/modules/ProductStructure/Process/ProcessModal'
 
   export default {
     name: 'ProductStructureTree',
     components: {
+      ProcessModal,
+      PartModal,
       ComponentModal,
-      ImportFileModal,
       ProductModal,
       ProductStructureTreeContextMenu
     },
@@ -82,7 +90,7 @@
         currentSelected: {},
         rightClickSelected: {},
         url: {
-          delete: ''
+          delete: '/nc/product/delete'
         }
       }
     },
@@ -91,343 +99,18 @@
       this.$bus.$on('treeMenuItemMethodTrigger', this.triggerCorrespondingMethod)
     },
     methods: {
-      ...mapActions(['QueryProduction']),
-
       queryTreeData() {
         this.loading = true
         this.cardLoading = true
-        this.QueryProduction().then(res => {
+        dncApi.getProductStructureTreeApi().then(res => {
+          console.log('res', res)
           if (res.success) {
             this.dataList = []
             this.allTreeKeys = []
-            // this.treeDataSource = res.result
-            this.treeDataSource = [
-              {
-                'id': '1869253349344432129',
-                'label': '[璁╁浜篯娴嬭瘯',
-                'iconClass': '',
-                'parentId': '1869253349344432129',
-                'children': [
-                  {
-                    'id': '1869254044432879617',
-                    'label': '[378]qgwqg',
-                    'iconClass': '',
-                    'parentId': '1869253349344432129',
-                    'children': [
-                      {
-                        'id': '1869260302133137410',
-                        'label': '[ggjuk]璋旇皵鍘�',
-                        'iconClass': '',
-                        'parentId': '1869254044432879617',
-                        'children': [
-                          {
-                            'id': '1869294654070075393',
-                            'label': '[8989]qwfq',
-                            'iconClass': '',
-                            'parentId': '1869260302133137410',
-                            'children': null,
-                            'type': 2,
-                            'entity': {
-                              'componentId': '1869294654070075393',
-                              'parentId': '1869260302133137410',
-                              'productId': '1869253349344432129',
-                              'componentName': 'qwfq',
-                              'materielCode': '',
-                              'materielDesp': '',
-                              'componentModel': '',
-                              'componentScale': '',
-                              'componentWeight': null,
-                              'rankLevel': 3,
-                              'assembleType': null,
-                              'produceType': null,
-                              'processType': null,
-                              'structureType': null,
-                              'componentCode': '8989',
-                              'componentStatus': 1,
-                              'description': '',
-                              'createTime': '2024-12-18 16:12:30',
-                              'updateTime': null,
-                              'createUser': '1254966905669160962',
-                              'updateUser': ''
-                            },
-                            'leaf': false,
-                            'rfield': '1869253349344432129'
-                          },
-                          {
-                            'id': '1869294701801254913',
-                            'label': '[888]7878',
-                            'iconClass': '',
-                            'parentId': '1869260302133137410',
-                            'children': null,
-                            'type': 2,
-                            'entity': {
-                              'componentId': '1869294701801254913',
-                              'parentId': '1869260302133137410',
-                              'productId': '1869253349344432129',
-                              'componentName': '7878',
-                              'materielCode': '',
-                              'materielDesp': '',
-                              'componentModel': '',
-                              'componentScale': '',
-                              'componentWeight': null,
-                              'rankLevel': 3,
-                              'assembleType': null,
-                              'produceType': null,
-                              'processType': null,
-                              'structureType': null,
-                              'componentCode': '888',
-                              'componentStatus': 1,
-                              'description': '',
-                              'createTime': '2024-12-18 16:12:41',
-                              'updateTime': null,
-                              'createUser': '1254966905669160962',
-                              'updateUser': ''
-                            },
-                            'leaf': false,
-                            'rfield': '1869253349344432129'
-                          },
-                          {
-                            'id': '1869294780935188482',
-                            'label': '[6855]ww',
-                            'iconClass': '',
-                            'parentId': '1869260302133137410',
-                            'children': null,
-                            'type': 2,
-                            'entity': {
-                              'componentId': '1869294780935188482',
-                              'parentId': '1869260302133137410',
-                              'productId': '1869253349344432129',
-                              'componentName': 'ww',
-                              'materielCode': '',
-                              'materielDesp': '',
-                              'componentModel': '',
-                              'componentScale': '',
-                              'componentWeight': null,
-                              'rankLevel': 3,
-                              'assembleType': null,
-                              'produceType': null,
-                              'processType': null,
-                              'structureType': null,
-                              'componentCode': '6855',
-                              'componentStatus': 1,
-                              'description': '',
-                              'createTime': '2024-12-18 16:13:00',
-                              'updateTime': null,
-                              'createUser': '1254966905669160962',
-                              'updateUser': ''
-                            },
-                            'leaf': false,
-                            'rfield': '1869253349344432129'
-                          },
-                          {
-                            'id': '1876199480437153794',
-                            'label': '[354]zzzzzzzzzzzzzzzzz',
-                            'iconClass': '',
-                            'parentId': '1869260302133137410',
-                            'children': null,
-                            'type': 3,
-                            'entity': {
-                              'partsId': '1876199480437153794',
-                              'partsName': 'zzzzzzzzzzzzzzzzz',
-                              'productId': '1869253349344432129',
-                              'componentId': '1869260302133137410',
-                              'materielCode': '',
-                              'materielDesp': '',
-                              'partsModel': '',
-                              'partsScale': '',
-                              'partsWeight': null,
-                              'assembleType': null,
-                              'produceType': null,
-                              'processType': null,
-                              'structureType': null,
-                              'partsCode': '354',
-                              'partsStatus': 1,
-                              'description': '',
-                              'createTime': '2025-01-06 17:29:49',
-                              'updateTime': null,
-                              'createUser': '1254966905669160962',
-                              'updateUser': ''
-                            },
-                            'leaf': false,
-                            'rfield': '1869260302133137410'
-                          }
-                        ],
-                        'type': 2,
-                        'entity': {
-                          'componentId': '1869260302133137410',
-                          'parentId': '1869254044432879617',
-                          'productId': '1869253349344432129',
-                          'componentName': '璋旇皵鍘�',
-                          'materielCode': '',
-                          'materielDesp': '',
-                          'componentModel': '',
-                          'componentScale': '',
-                          'componentWeight': null,
-                          'rankLevel': 2,
-                          'assembleType': null,
-                          'produceType': null,
-                          'processType': null,
-                          'structureType': null,
-                          'componentCode': 'ggjuk',
-                          'componentStatus': 1,
-                          'description': '',
-                          'createTime': '2024-12-18 13:56:00',
-                          'updateTime': null,
-                          'createUser': '1254966905669160962',
-                          'updateUser': ''
-                        },
-                        'leaf': false,
-                        'rfield': '1869253349344432129'
-                      }
-                    ],
-                    'type': 2,
-                    'entity': {
-                      'componentId': '1869254044432879617',
-                      'parentId': null,
-                      'productId': '1869253349344432129',
-                      'componentName': 'qgwqg',
-                      'materielCode': '',
-                      'materielDesp': '',
-                      'componentModel': '',
-                      'componentScale': '',
-                      'componentWeight': null,
-                      'rankLevel': 1,
-                      'assembleType': null,
-                      'produceType': null,
-                      'processType': null,
-                      'structureType': null,
-                      'componentCode': '378',
-                      'componentStatus': 1,
-                      'description': '88',
-                      'createTime': '2022-12-18 13:32:48',
-                      'updateTime': '2024-12-18 13:32:48',
-                      'createUser': '1254966905669160962',
-                      'updateUser': '1254966905669160962'
-                    },
-                    'leaf': false,
-                    'rfield': '1869253349344432129'
-                  },
-                  {
-                    'id': '1869253419041181697',
-                    'label': '[876]涓哄叏鍥藉墠浜旂粰',
-                    'iconClass': '',
-                    'parentId': '1869253349344432129',
-                    'children': null,
-                    'type': 2,
-                    'entity': {
-                      'componentId': '1869253419041181697',
-                      'parentId': null,
-                      'productId': '1869253349344432129',
-                      'componentName': '涓哄叏鍥藉墠浜旂粰',
-                      'materielCode': '',
-                      'materielDesp': '',
-                      'componentModel': '56',
-                      'componentScale': '',
-                      'componentWeight': null,
-                      'rankLevel': 1,
-                      'assembleType': null,
-                      'produceType': null,
-                      'processType': null,
-                      'structureType': null,
-                      'componentCode': '876',
-                      'componentStatus': 1,
-                      'description': '',
-                      'createTime': '2024-12-18 13:28:39',
-                      'updateTime': '2024-12-18 14:03:55',
-                      'createUser': '1254966905669160962',
-                      'updateUser': '1254966905669160962'
-                    },
-                    'leaf': false,
-                    'rfield': '1869253349344432129'
-                  },
-                  {
-                    'id': '1869294861876867073',
-                    'label': '[777]he',
-                    'iconClass': '',
-                    'parentId': '1869253349344432129',
-                    'children': [
-                      {
-                        'id': '1876087437913108481',
-                        'label': '[ddd]鍜岀淮鎶�',
-                        'iconClass': '',
-                        'parentId': '1869294861876867073',
-                        'children': null,
-                        'type': 2,
-                        'entity': {
-                          'componentId': '1876087437913108481',
-                          'parentId': '1869294861876867073',
-                          'productId': '1869253349344432129',
-                          'componentName': '鍜岀淮鎶�',
-                          'materielCode': '',
-                          'materielDesp': '',
-                          'componentModel': '',
-                          'componentScale': '',
-                          'componentWeight': null,
-                          'rankLevel': 2,
-                          'assembleType': null,
-                          'produceType': null,
-                          'processType': null,
-                          'structureType': null,
-                          'componentCode': 'ddd',
-                          'componentStatus': 1,
-                          'description': '',
-                          'createTime': '2025-01-06 10:04:36',
-                          'updateTime': null,
-                          'createUser': '1254966905669160962',
-                          'updateUser': ''
-                        },
-                        'leaf': false,
-                        'rfield': '1869253349344432129'
-                      }
-                    ],
-                    'type': 2,
-                    'entity': {
-                      'componentId': '1869294861876867073',
-                      'parentId': null,
-                      'productId': '1869253349344432129',
-                      'componentName': 'he',
-                      'materielCode': '',
-                      'materielDesp': '',
-                      'componentModel': '',
-                      'componentScale': '',
-                      'componentWeight': null,
-                      'rankLevel': 1,
-                      'assembleType': null,
-                      'produceType': null,
-                      'processType': null,
-                      'structureType': null,
-                      'componentCode': '777',
-                      'componentStatus': 1,
-                      'description': '',
-                      'createTime': '2024-12-18 16:13:20',
-                      'updateTime': null,
-                      'createUser': '1254966905669160962',
-                      'updateUser': ''
-                    },
-                    'leaf': false,
-                    'rfield': '1869253349344432129'
-                  }
-                ],
-                'type': 1,
-                'entity': {
-                  'productId': '1869253349344432129',
-                  'productNo': '璁╁浜�',
-                  'productModel': '',
-                  'productName': '娴嬭瘯',
-                  'productStatus': 1,
-                  'createTime': '2024-12-18 13:28:22',
-                  'updateTime': null,
-                  'createUser': '1254966905669160962',
-                  'updateUser': null
-                },
-                'leaf': false,
-                'rfield': null
-              }
-            ]
+            this.treeDataSource = res.list
             this.generateList(this.treeDataSource)
             // this.expandedKeys = this.allTreeKeys
-            this.expandedKeys = [this.treeDataSource[0].id]
-            console.log('treeDataSource', this.treeDataSource)
+            if (this.expandedKeys.length === 0) this.expandedKeys = [this.treeDataSource[0].id]
           } else {
             this.$message.warn(res.message)
           }
@@ -494,6 +177,15 @@
               })
           }
         })
+      },
+
+      /**
+       * 鑷姩灞曞紑娣诲姞涓嬬骇鑺傜偣鐨勭埗鑺傜偣
+       */
+      modalFormSubmitSuccess(isAddNextLevel) {
+        // 鍒ゆ柇鏄惁涓烘坊鍔犱笅绾у苟涓斿垽鏂埗鑺傜偣鏄惁灞曞紑
+        if (isAddNextLevel && !this.expandedKeys.includes(this.rightClickSelected.id)) this.expandedKeys.push(this.rightClickSelected.id)
+        this.queryTreeData()
       },
 
       /**
@@ -582,6 +274,12 @@
           case 3:
             treeNode.slots = { icon: 'part' }
             break
+          case 4:
+            treeNode.slots = { icon: 'process' }
+            break
+          case 5:
+            treeNode.slots = { icon: 'processStep' }
+            break
           default:
         }
       }

--
Gitblit v1.9.3