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                                   |   57 +++--
 src/views/dnc/base/modules/ProductStructure/Part/PartModal.vue                  |   41 ++-
 src/views/dnc/base/modules/ProductStructure/Component/ComponentModal.vue        |   38 ++-
 src/views/dnc/base/modules/ProductStructure/Document/NcDocumentTableList.vue    |  173 +++-------------
 src/views/dnc/base/modules/ProductStructure/Process/ProcessModal.vue            |    2 
 src/views/dnc/base/modules/ProductStructure/Document/OtherDocumentTableList.vue |  105 +++------
 /dev/null                                                                       |    4 
 src/api/dnc.js                                                                  |    4 
 src/views/dnc/base/modules/ProductStructure/Document/NcDocumentAssignModal.vue  |    8 
 src/views/dnc/base/modules/ProductStructure/Product/ProductModal.vue            |   27 +
 src/views/dnc/base/modules/ProductStructure/Product/ProductModalForm.vue        |   15 
 src/views/dnc/base/modules/ProductStructure/ProductStructureMainTop.vue         |   47 ++++
 src/views/dnc/base/modules/ProductStructure/Component/ComponentModalForm.vue    |   15 
 src/views/dnc/base/modules/ProductStructure/Part/PartModalForm.vue              |   15 
 14 files changed, 247 insertions(+), 304 deletions(-)

diff --git a/.env.development b/.env.development
deleted file mode 100644
index e671550..0000000
--- a/.env.development
+++ /dev/null
@@ -1,7 +0,0 @@
-NODE_ENV=development
-VUE_APP_API_BASE_URL=http://127.0.0.1:9998
-VUE_APP_CAS_BASE_URL=http://cas.example.org:8443/cas
-VUE_APP_ONLINE_BASE_URL=http://fileview.jeecg.com/onlinePreview
-
-# 寰簲鐢ㄥ垪琛ㄥ繀椤籚UE_APP_SUB_寮�澶�,jeecg-app-1涓哄瓙搴旂敤鐨勯」鐩悕绉�,涔熸槸瀛愬簲鐢ㄧ殑璺敱鐖惰矾寰�
-VUE_APP_SUB_jeecg-app-1 = '//localhost:8092'
diff --git a/.env.production b/.env.production
deleted file mode 100644
index ddcf410..0000000
--- a/.env.production
+++ /dev/null
@@ -1,4 +0,0 @@
-NODE_ENV=production
-VUE_APP_API_BASE_URL=http://172.26.200.100:9999
-VUE_APP_CAS_BASE_URL=http://localhost:8888/cas
-VUE_APP_ONLINE_BASE_URL=http://fileview.jeecg.com/onlinePreview
\ No newline at end of file
diff --git a/src/api/dnc.js b/src/api/dnc.js
index d0628ec..99a74d1 100644
--- a/src/api/dnc.js
+++ b/src/api/dnc.js
@@ -1,5 +1,7 @@
 import { getAction, deleteAction, putAction, postAction, httpAction } from '@/api/manage'
 
 export default {
-  getProductStructureTreeApi: () => getAction('/nc/product/load/tree')
+  //-------------------------浜у搧缁撴瀯鏍�------------------------------------------------
+  getProductStructureTreeApi: () => getAction('/nc/product/load/tree'),
+
 }
\ No newline at end of file
diff --git a/src/views/dnc/base/modules/ProductStructure/Component/ComponentModal.vue b/src/views/dnc/base/modules/ProductStructure/Component/ComponentModal.vue
index 2b8c8f6..f7a3045 100644
--- a/src/views/dnc/base/modules/ProductStructure/Component/ComponentModal.vue
+++ b/src/views/dnc/base/modules/ProductStructure/Component/ComponentModal.vue
@@ -29,7 +29,8 @@
       return {
         title: '',
         width: 700,
-        visible: false
+        visible: false,
+        isAddNextLevel: false // 鏄惁涓烘坊鍔犱笅绾э紝浣滀负鏍戣妭鐐规槸鍚﹀睍寮�鐨勫垽鏂�
       }
     },
     created() {
@@ -38,33 +39,37 @@
     methods: {
       /**
        * 娣诲姞褰撳墠浜у搧閮ㄤ欢
-       * @param modalTitle
        */
-      handleProductAddChild(modalTitle) {
-        this.title = modalTitle
+      handleProductAddChild() {
         this.visible = true
+        this.isAddNextLevel = true
         this.$nextTick(() => {
-          this.$refs.realForm.add()
+          this.$refs.realForm.add({ productId: this.currentTreeNodeInfo.id })
         })
       },
 
       /**
        * 娣诲姞褰撳墠閮ㄤ欢鐨勫瓙閮ㄤ欢
-       * @param modalTitle
        */
-      handleComponentAdd(modalTitle) {
-        this.title = modalTitle
+      handleComponentAdd() {
         this.visible = true
+        this.isAddNextLevel = true
         this.$nextTick(() => {
-          this.$refs.realForm.add()
+          this.$refs.realForm.add({
+            productId: this.currentTreeNodeInfo.parentId,
+            parentId: this.currentTreeNodeInfo.id
+          })
         })
       },
 
-      handleComponentEdit(modalTitle) {
-        this.title = modalTitle
+      /**
+       * 缂栬緫閮ㄤ欢淇℃伅
+       */
+      handleComponentEdit() {
         this.visible = true
+        this.isAddNextLevel = false
         this.$nextTick(() => {
-          this.$refs.realForm.edit(this.currentTreeNodeInfo.entity)
+          this.$refs.realForm.edit({ id: this.currentTreeNodeInfo.id, ...this.currentTreeNodeInfo.entity })
         })
       },
 
@@ -73,7 +78,7 @@
       },
 
       submitCallback() {
-        this.$emit('ok')
+        this.$emit('submitSuccess', this.isAddNextLevel)
         this.visible = false
       },
 
@@ -83,9 +88,10 @@
       },
 
       triggerCorrespondingMethod({ methodName, modalTitle }) {
-        console.log('methodName', methodName)
-        console.log('modalTitle', modalTitle)
-        if (this[methodName]) this[methodName](modalTitle)
+        if (this[methodName]) {
+          this[methodName]()
+          this.title = modalTitle
+        }
       }
     }
   }
diff --git a/src/views/dnc/base/modules/ProductStructure/Component/ComponentModalForm.vue b/src/views/dnc/base/modules/ProductStructure/Component/ComponentModalForm.vue
index e80380c..69dc447 100644
--- a/src/views/dnc/base/modules/ProductStructure/Component/ComponentModalForm.vue
+++ b/src/views/dnc/base/modules/ProductStructure/Component/ComponentModalForm.vue
@@ -112,8 +112,8 @@
           ]
         },
         url: {
-          add: '/mdc/mdcPartProcessInfo/add',
-          edit: '/mdc/mdcPartProcessInfo/edit'
+          add: '/nc/component/add',
+          edit: '/nc/component/edit'
         }
       }
     },
@@ -127,14 +127,13 @@
       this.modelDefault = JSON.parse(JSON.stringify(this.model))
     },
     methods: {
-      add() {
-        this.edit(this.modelDefault)
+      add(params) {
+        this.edit({ ...this.modelDefault, ...params })
       },
 
       edit(record) {
         this.model = Object.assign({}, record)
         console.log('model', this.model)
-        this.visible = true
       },
 
       submitForm() {
@@ -144,11 +143,13 @@
           if (valid) {
             that.confirmLoading = true
             let httpUrl = ''
-            let method = 'post'
+            let method = ''
             if (!this.model.id) {
               httpUrl += this.url.add
+              method = 'post'
             } else {
-              httpUrl += this.url.edit
+              httpUrl += this.url.edit + `/${this.model.id}`
+              method = 'put'
             }
             httpAction(httpUrl, this.model, method).then((res) => {
               if (res.success) {
diff --git a/src/views/dnc/base/modules/ProductStructure/Document/NcDocumentAssignModal.vue b/src/views/dnc/base/modules/ProductStructure/Document/NcDocumentAssignModal.vue
index 8934eb2..01a4e69 100644
--- a/src/views/dnc/base/modules/ProductStructure/Document/NcDocumentAssignModal.vue
+++ b/src/views/dnc/base/modules/ProductStructure/Document/NcDocumentAssignModal.vue
@@ -15,7 +15,7 @@
 
                   <a-col :md="11" :sm="11">
                     <a-form-item label="涓婁紶鏃堕棿">
-                      <a-range-picker placeholder="璇烽�夋嫨涓婁紶鏃堕棿" v-model="queryParam.collectTime"></a-range-picker>
+                      <a-range-picker v-model="queryParam.collectTime"></a-range-picker>
                     </a-form-item>
                   </a-col>
 
@@ -52,6 +52,12 @@
   export default {
     name: 'NcDocumentAssignModal',
     components: {},
+    mixins: [JeecgListMixin],
+    props: {
+      size: {
+        type: String
+      }
+    },
     data() {
       return {
         disableMixinCreated: true,
diff --git a/src/views/dnc/base/modules/ProductStructure/Document/NcDocumentTableList.vue b/src/views/dnc/base/modules/ProductStructure/Document/NcDocumentTableList.vue
index f8364fe..d7cfd63 100644
--- a/src/views/dnc/base/modules/ProductStructure/Document/NcDocumentTableList.vue
+++ b/src/views/dnc/base/modules/ProductStructure/Document/NcDocumentTableList.vue
@@ -7,11 +7,12 @@
 
     <DocumentModal ref="modalForm" @ok="modalFormOk"/>
 
-    <NcDocumentAssignModal ref="documentAssignModalRef"/>
+    <NcDocumentAssignModal :size="size" ref="documentAssignModalRef"/>
   </div>
 </template>
 
 <script>
+  import { getAction } from '@/api/manage'
   import { JeecgListMixin } from '@/mixins/JeecgListMixin'
   import DocumentModal from './DocumentModal'
   import NcDocumentAssignModal from './NcDocumentAssignModal'
@@ -21,12 +22,16 @@
     components: { NcDocumentAssignModal, DocumentModal },
     mixins: [JeecgListMixin],
     props: {
+      currentTreeNodeInfo: {
+        type: Object
+      },
       size: {
         type: String
       }
     },
     data() {
       return {
+        disableMixinCreated: true,
         columns: [
           {
             title: '搴忓彿',
@@ -45,142 +50,9 @@
           { title: '绯荤粺鎸囧畾鐗堟湰', dataIndex: 'publishVersion', align: 'center' },
           { title: '涓婁紶鏃堕棿', dataIndex: 'createTime', align: 'center' }
         ],
-        dataSource: [
-          {
-            'docId': '1876099281127645185',
-            'docName': 'avatar2.jpg',
-            'docAlias': null,
-            'docCode': null,
-            'docSuffix': 'jpg',
-            'docStatus': 1,
-            'publishFileId': '1876099281458995202',
-            'publishVersion': 'a.1',
-            'description': null,
-            'createTime': '2025-01-06 10:51:40',
-            'updateTime': null,
-            'createUser': '1254966905669160962',
-            'updateUser': null,
-            'docClassCode': null,
-            'pullStatus': 1,
-            'pullUser': null,
-            'attributionType': 5,
-            'attributionId': '1868504592315248641',
-            'classificationId': '1257965381181095938',
-            'syncStatus': null
-          },
-          {
-            'docId': '1876114720452943873',
-            'docName': 'color.less',
-            'docAlias': null,
-            'docCode': null,
-            'docSuffix': 'less',
-            'docStatus': 1,
-            'publishFileId': '1876114720582967297',
-            'publishVersion': 'a.1',
-            'description': null,
-            'createTime': '2025-01-06 11:53:01',
-            'updateTime': null,
-            'createUser': '1254966905669160962',
-            'updateUser': null,
-            'docClassCode': null,
-            'pullStatus': 1,
-            'pullUser': null,
-            'attributionType': 5,
-            'attributionId': '1868504592315248641',
-            'classificationId': '1257965381181095938',
-            'syncStatus': null
-          },
-          {
-            'docId': '1876114736512933889',
-            'docName': 'index.html',
-            'docAlias': null,
-            'docCode': null,
-            'docSuffix': 'html',
-            'docStatus': 1,
-            'publishFileId': '1876114736705871874',
-            'publishVersion': 'a.1',
-            'description': null,
-            'createTime': '2025-01-06 11:53:05',
-            'updateTime': null,
-            'createUser': '1254966905669160962',
-            'updateUser': null,
-            'docClassCode': null,
-            'pullStatus': 1,
-            'pullUser': null,
-            'attributionType': 5,
-            'attributionId': '1868504592315248641',
-            'classificationId': '1257965381181095938',
-            'syncStatus': null
-          },
-          {
-            'docId': '1876114746621206529',
-            'docName': 'logo.png',
-            'docAlias': null,
-            'docCode': null,
-            'docSuffix': 'png',
-            'docStatus': 1,
-            'publishFileId': '1876114746818338818',
-            'publishVersion': 'a.1',
-            'description': null,
-            'createTime': '2025-01-06 11:53:07',
-            'updateTime': null,
-            'createUser': '1254966905669160962',
-            'updateUser': null,
-            'docClassCode': null,
-            'pullStatus': 1,
-            'pullUser': null,
-            'attributionType': 5,
-            'attributionId': '1868504592315248641',
-            'classificationId': '1257965381181095938',
-            'syncStatus': null
-          },
-          {
-            'docId': '1876114758923100161',
-            'docName': 'lxzn.png',
-            'docAlias': null,
-            'docCode': null,
-            'docSuffix': 'png',
-            'docStatus': 1,
-            'publishFileId': '1876114759111843842',
-            'publishVersion': 'a.1',
-            'description': null,
-            'createTime': '2025-01-06 11:53:10',
-            'updateTime': null,
-            'createUser': '1254966905669160962',
-            'updateUser': null,
-            'docClassCode': null,
-            'pullStatus': 1,
-            'pullUser': null,
-            'attributionType': 5,
-            'attributionId': '1868504592315248641',
-            'classificationId': '1257965381181095938',
-            'syncStatus': null
-          },
-          {
-            'docId': '1876114776241381377',
-            'docName': 'v2.js',
-            'docAlias': null,
-            'docCode': null,
-            'docSuffix': 'js',
-            'docStatus': 1,
-            'publishFileId': '1876114776438513666',
-            'publishVersion': 'a.1',
-            'description': null,
-            'createTime': '2025-01-06 11:53:14',
-            'updateTime': null,
-            'createUser': '1254966905669160962',
-            'updateUser': null,
-            'docClassCode': null,
-            'pullStatus': 1,
-            'pullUser': null,
-            'attributionType': 5,
-            'attributionId': '1868504592315248641',
-            'classificationId': '1257965381181095938',
-            'syncStatus': null
-          }
-        ],
+        dataSource: [],
         url: {
-          list: ''
+          list: '/nc/doc/find/page'
         }
       }
     },
@@ -188,6 +60,35 @@
       this.$bus.$on('tableMenuItemMethodTrigger', this.triggerCorrespondingMethod)
     },
     methods: {
+      loadData(arg) {
+        if (!this.url.list) {
+          this.$message.error('璇疯缃畊rl.list灞炴��!')
+          return
+        }
+        //鍔犺浇鏁版嵁 鑻ヤ紶鍏ュ弬鏁�1鍒欏姞杞界涓�椤电殑鍐呭
+        if (arg === 1) this.ipagination.current = 1
+        var params = this.getQueryParams()//鏌ヨ鏉′欢
+        params.attributionId = this.currentTreeNodeInfo.id
+        params.attributionType = this.currentTreeNodeInfo.type
+        params.docClassCode = 'NC'
+        if (!params) return false
+        this.loading = true
+        getAction(this.url.list + `/${this.ipagination.current}/${this.ipagination.pageSize}`, params).then((res) => {
+          if (res.success) {
+            this.dataSource = res.page.records
+            if (res.page.total) {
+              this.ipagination.total = res.page.total
+            } else {
+              this.ipagination.total = 0
+            }
+          } else {
+            this.$message.warning(res.message)
+          }
+        }).finally(() => {
+          this.loading = false
+        })
+      },
+
       customRow(record) {
         return {
           on: {
diff --git a/src/views/dnc/base/modules/ProductStructure/Document/OtherDocumentTableList.vue b/src/views/dnc/base/modules/ProductStructure/Document/OtherDocumentTableList.vue
index d58789b..22d4d31 100644
--- a/src/views/dnc/base/modules/ProductStructure/Document/OtherDocumentTableList.vue
+++ b/src/views/dnc/base/modules/ProductStructure/Document/OtherDocumentTableList.vue
@@ -10,6 +10,7 @@
 </template>
 
 <script>
+  import { getAction } from '@/api/manage'
   import { JeecgListMixin } from '@/mixins/JeecgListMixin'
   import DocumentModal from './DocumentModal'
 
@@ -18,12 +19,16 @@
     components: { DocumentModal },
     mixins: [JeecgListMixin],
     props: {
+      currentTreeNodeInfo: {
+        type: Object
+      },
       size: {
         type: String
       }
     },
     data() {
       return {
+        disableMixinCreated: true,
         columns: [
           {
             title: '搴忓彿',
@@ -42,76 +47,9 @@
           { title: '绯荤粺鎸囧畾鐗堟湰', dataIndex: 'publishVersion', align: 'center' },
           { title: '涓婁紶鏃堕棿', dataIndex: 'createTime', align: 'center' }
         ],
-        dataSource: [
-          {
-            'docId': '1868943615190044674',
-            'docName': '娴嬭瘯.nc',
-            'docAlias': null,
-            'docCode': null,
-            'docSuffix': 'nc',
-            'docStatus': 1,
-            'publishFileId': '1868943615454285825',
-            'publishVersion': 'a.1',
-            'description': null,
-            'createTime': '2024-12-17 16:57:36',
-            'updateTime': null,
-            'createUser': '1254966905669160962',
-            'updateUser': null,
-            'docClassCode': null,
-            'pullStatus': 1,
-            'pullUser': null,
-            'attributionType': 1,
-            'attributionId': '1326377675659276290',
-            'classificationId': '1257965467827027969',
-            'syncStatus': null
-          },
-          {
-            'docId': '1868946627732103170',
-            'docName': 'nacos-config.sh',
-            'docAlias': null,
-            'docCode': null,
-            'docSuffix': 'sh',
-            'docStatus': 1,
-            'publishFileId': '1868946628004732930',
-            'publishVersion': 'a.1',
-            'description': null,
-            'createTime': '2024-12-17 17:09:34',
-            'updateTime': null,
-            'createUser': '1254966905669160962',
-            'updateUser': null,
-            'docClassCode': null,
-            'pullStatus': 1,
-            'pullUser': null,
-            'attributionType': 1,
-            'attributionId': '1326377675659276290',
-            'classificationId': '1257965467827027969',
-            'syncStatus': null
-          },
-          {
-            'docId': '1868947564353740801',
-            'docName': 'dir.sql',
-            'docAlias': null,
-            'docCode': null,
-            'docSuffix': 'sql',
-            'docStatus': 1,
-            'publishFileId': '1868947564487958530',
-            'publishVersion': 'a.1',
-            'description': null,
-            'createTime': '2024-12-17 17:13:17',
-            'updateTime': null,
-            'createUser': '1254966905669160962',
-            'updateUser': null,
-            'docClassCode': null,
-            'pullStatus': 1,
-            'pullUser': null,
-            'attributionType': 1,
-            'attributionId': '1326377675659276290',
-            'classificationId': '1257965467827027969',
-            'syncStatus': null
-          }
-        ],
+        dataSource: [],
         url: {
-          list: ''
+          list: '/nc/doc/find/page'
         }
       }
     },
@@ -119,6 +57,35 @@
       this.$bus.$on('tableMenuItemMethodTrigger', this.triggerCorrespondingMethod)
     },
     methods: {
+      loadData(arg) {
+        if (!this.url.list) {
+          this.$message.error('璇疯缃畊rl.list灞炴��!')
+          return
+        }
+        //鍔犺浇鏁版嵁 鑻ヤ紶鍏ュ弬鏁�1鍒欏姞杞界涓�椤电殑鍐呭
+        if (arg === 1) this.ipagination.current = 1
+        var params = this.getQueryParams()//鏌ヨ鏉′欢
+        params.attributionId = this.currentTreeNodeInfo.id
+        params.attributionType = this.currentTreeNodeInfo.type
+        params.docClassCode = 'OTHER'
+        if (!params) return false
+        this.loading = true
+        getAction(this.url.list + `/${this.ipagination.current}/${this.ipagination.pageSize}`, params).then((res) => {
+          if (res.success) {
+            this.dataSource = res.page.records
+            if (res.page.total) {
+              this.ipagination.total = res.page.total
+            } else {
+              this.ipagination.total = 0
+            }
+          } else {
+            this.$message.warning(res.message)
+          }
+        }).finally(() => {
+          this.loading = false
+        })
+      },
+
       customRow(record) {
         return {
           on: {
diff --git a/src/views/dnc/base/modules/ProductStructure/Part/PartModal.vue b/src/views/dnc/base/modules/ProductStructure/Part/PartModal.vue
index 263951c..5e64f94 100644
--- a/src/views/dnc/base/modules/ProductStructure/Part/PartModal.vue
+++ b/src/views/dnc/base/modules/ProductStructure/Part/PartModal.vue
@@ -29,7 +29,8 @@
       return {
         title: '',
         width: 700,
-        visible: false
+        visible: false,
+        isAddNextLevel: false // 鏄惁涓烘坊鍔犱笅绾э紝浣滀负鏍戣妭鐐规槸鍚﹀睍寮�鐨勫垽鏂�
       }
     },
     created() {
@@ -37,38 +38,41 @@
     },
     methods: {
       /**
-       * 娣诲姞褰撳墠閮ㄤ欢闆朵欢
-       * @param modalTitle
+       * 娣诲姞閮ㄤ欢涓嬬骇闆朵欢
        */
-      handleComponentAddChild(modalTitle) {
-        this.title = modalTitle
+      handleComponentAddChild() {
         this.visible = true
+        this.isAddNextLevel = true
         this.$nextTick(() => {
-          this.$refs.realForm.add()
+          this.$refs.realForm.add({
+            productId: this.currentTreeNodeInfo.rfield,
+            componentId: this.currentTreeNodeInfo.id
+          })
         })
       },
 
       /**
-       * 娣诲姞闆朵欢
-       * @param modalTitle
+       * 鐐瑰嚮闆朵欢灞傜骇娣诲姞鍚岀骇闆朵欢
        */
-      handlePartsAdd(modalTitle) {
-        this.title = modalTitle
+      handlePartsAdd() {
         this.visible = true
+        this.isAddNextLevel = false
         this.$nextTick(() => {
-          this.$refs.realForm.add()
+          this.$refs.realForm.add({
+            productId: this.currentTreeNodeInfo.rfield,
+            componentId: this.currentTreeNodeInfo.parentId
+          })
         })
       },
 
       /**
        * 缂栬緫闆朵欢淇℃伅
-       * @param modalTitle
        */
-      handlePartsEdit(modalTitle) {
-        this.title = modalTitle
+      handlePartsEdit() {
         this.visible = true
+        this.isAddNextLevel = false
         this.$nextTick(() => {
-          this.$refs.realForm.edit(this.currentTreeNodeInfo.entity)
+          this.$refs.realForm.edit({ id: this.currentTreeNodeInfo.id, ...this.currentTreeNodeInfo.entity })
         })
       },
 
@@ -77,7 +81,7 @@
       },
 
       submitCallback() {
-        this.$emit('ok')
+        this.$emit('submitSuccess', this.isAddNextLevel)
         this.visible = false
       },
 
@@ -87,7 +91,10 @@
       },
 
       triggerCorrespondingMethod({ methodName, modalTitle }) {
-        if (this[methodName]) this[methodName](modalTitle)
+        if (this[methodName]) {
+          this[methodName](modalTitle)
+          this.title = modalTitle
+        }
       }
     }
   }
diff --git a/src/views/dnc/base/modules/ProductStructure/Part/PartModalForm.vue b/src/views/dnc/base/modules/ProductStructure/Part/PartModalForm.vue
index 43aad42..5d70dd7 100644
--- a/src/views/dnc/base/modules/ProductStructure/Part/PartModalForm.vue
+++ b/src/views/dnc/base/modules/ProductStructure/Part/PartModalForm.vue
@@ -112,8 +112,8 @@
           ]
         },
         url: {
-          add: '/mdc/mdcPartProcessInfo/add',
-          edit: '/mdc/mdcPartProcessInfo/edit'
+          add: '/nc/parts/add',
+          edit: '/nc/parts/edit'
         }
       }
     },
@@ -127,14 +127,13 @@
       this.modelDefault = JSON.parse(JSON.stringify(this.model))
     },
     methods: {
-      add() {
-        this.edit(this.modelDefault)
+      add(params) {
+        this.edit({ ...this.modelDefault, ...params })
       },
 
       edit(record) {
         this.model = Object.assign({}, record)
         console.log('model', this.model)
-        this.visible = true
       },
 
       submitForm() {
@@ -144,11 +143,13 @@
           if (valid) {
             that.confirmLoading = true
             let httpUrl = ''
-            let method = 'post'
+            let method = ''
             if (!this.model.id) {
               httpUrl += this.url.add
+              method = 'post'
             } else {
-              httpUrl += this.url.edit
+              httpUrl += this.url.edit + `/${this.model.id}`
+              method = 'put'
             }
             httpAction(httpUrl, this.model, method).then((res) => {
               if (res.success) {
diff --git a/src/views/dnc/base/modules/ProductStructure/Process/ProcessModal.vue b/src/views/dnc/base/modules/ProductStructure/Process/ProcessModal.vue
index fa309d6..9f265d2 100644
--- a/src/views/dnc/base/modules/ProductStructure/Process/ProcessModal.vue
+++ b/src/views/dnc/base/modules/ProductStructure/Process/ProcessModal.vue
@@ -77,7 +77,7 @@
       },
 
       submitCallback() {
-        this.$emit('ok')
+        this.$emit('submitSuccess')
         this.visible = false
       },
 
diff --git a/src/views/dnc/base/modules/ProductStructure/Product/ProductModal.vue b/src/views/dnc/base/modules/ProductStructure/Product/ProductModal.vue
index e808a87..ceaa455 100644
--- a/src/views/dnc/base/modules/ProductStructure/Product/ProductModal.vue
+++ b/src/views/dnc/base/modules/ProductStructure/Product/ProductModal.vue
@@ -29,41 +29,52 @@
       return {
         title: '',
         width: 500,
-        visible: false
+        visible: false,
       }
     },
     created() {
       this.$bus.$on('treeMenuItemMethodTrigger', this.triggerCorrespondingMethod)
     },
     methods: {
-      handleProductAdd(modalTitle) {
-        this.title = modalTitle
+      /**
+       * 娣诲姞浜у搧
+       */
+      handleProductAdd() {
         this.visible = true
         this.$nextTick(() => {
           this.$refs.realForm.add()
         })
       },
-      handleProductEdit(modalTitle) {
-        this.title = modalTitle
+
+      /**
+       * 缂栬緫浜у搧淇℃伅
+       */
+      handleProductEdit() {
         this.visible = true
         this.$nextTick(() => {
-          this.$refs.realForm.edit(this.currentTreeNodeInfo.entity)
+          this.$refs.realForm.edit({ id: this.currentTreeNodeInfo.id, ...this.currentTreeNodeInfo.entity })
         })
       },
+
       handleOk() {
         this.$refs.realForm.submitForm()
       },
+
       submitCallback() {
-        this.$emit('ok')
+        this.$emit('submitSuccess')
         this.visible = false
       },
+
       handleCancel() {
         this.$emit('close')
         this.visible = false
       },
 
       triggerCorrespondingMethod({ methodName, modalTitle }) {
-        if (this[methodName]) this[methodName](modalTitle)
+        if (this[methodName]) {
+          this[methodName](modalTitle)
+          this.title = modalTitle
+        }
       }
     }
   }
diff --git a/src/views/dnc/base/modules/ProductStructure/Product/ProductModalForm.vue b/src/views/dnc/base/modules/ProductStructure/Product/ProductModalForm.vue
index 2f79dd6..7e73ef9 100644
--- a/src/views/dnc/base/modules/ProductStructure/Product/ProductModalForm.vue
+++ b/src/views/dnc/base/modules/ProductStructure/Product/ProductModalForm.vue
@@ -30,7 +30,7 @@
 </template>
 
 <script>
-  import { httpAction, getAction } from '@/api/manage'
+  import { httpAction } from '@/api/manage'
 
   export default {
     name: 'ProductModalForm',
@@ -61,11 +61,11 @@
           ],
           productNo: [
             { required: true, message: '璇疯緭鍏ヤ骇鍝佷唬鍙�!' }
-          ],
+          ]
         },
         url: {
-          add: '/mdc/mdcPartProcessInfo/add',
-          edit: '/mdc/mdcPartProcessInfo/edit'
+          add: '/nc/product/add',
+          edit: '/nc/product/edit'
         }
       }
     },
@@ -86,7 +86,6 @@
       edit(record) {
         this.model = Object.assign({}, record)
         console.log('model', this.model)
-        this.visible = true
       },
 
       submitForm() {
@@ -96,11 +95,13 @@
           if (valid) {
             that.confirmLoading = true
             let httpUrl = ''
-            let method = 'post'
+            let method = ''
             if (!this.model.id) {
               httpUrl += this.url.add
+              method = 'post'
             } else {
-              httpUrl += this.url.edit
+              method = 'put'
+              httpUrl += this.url.edit + `/${this.model.id}`
             }
             httpAction(httpUrl, this.model, method).then((res) => {
               if (res.success) {
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)
+        }
       },
 
       /**
diff --git a/src/views/dnc/common/ProductStructureTree.vue b/src/views/dnc/common/ProductStructureTree.vue
index de6e889..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>
@@ -44,18 +45,20 @@
     </a-spin>
 
     <!--浜у搧寮圭獥-->
-    <ProductModal ref="productModalFormRef" :currentTreeNodeInfo="rightClickSelected"/>
+    <ProductModal ref="productModalFormRef" :currentTreeNodeInfo="rightClickSelected"
+                  @submitSuccess="queryTreeData"/>
     <!--閮ㄤ欢寮圭獥-->
-    <ComponentModal :currentTreeNodeInfo="rightClickSelected"/>
+    <ComponentModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess"/>
     <!--闆朵欢寮圭獥-->
-    <PartModal :currentTreeNodeInfo="rightClickSelected"/>
+    <PartModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess"/>
     <!--宸ュ簭寮圭獥-->
-    <ProcessModal :currentTreeNodeInfo="rightClickSelected"/>
+    <ProcessModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess"/>
   </a-card>
 </template>
 
 <script>
   import dncApi from '@/api/dnc'
+  import { deleteAction } from '@/api/manage'
   import ProductStructureTreeContextMenu from './modules/ProductStructureTree/ProductStructureTreeContextMenu'
   import ProductModal from '../base/modules/ProductStructure/Product/ProductModal'
   import ComponentModal from '../base/modules/ProductStructure/Component/ComponentModal'
@@ -87,7 +90,7 @@
         currentSelected: {},
         rightClickSelected: {},
         url: {
-          delete: ''
+          delete: '/nc/product/delete'
         }
       }
     },
@@ -107,8 +110,7 @@
             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)
           }
@@ -158,26 +160,35 @@
               return
             }
             const that = this
-            // deleteAction(that.url.delete, { id: this.rightClickSelected.id })
-            //   .then((res) => {
-            //     if (res.success) {
-            //       that.queryTreeData()
-            //       that.$notification.success({
-            //         message: '娑堟伅',
-            //         description: res.message
-            //       })
-            //     } else {
-            //       that.$notification.warning({
-            //         message: '娑堟伅',
-            //         description: res.message
-            //       })
-            //     }
-            //   })
+            deleteAction(that.url.delete, { id: this.rightClickSelected.id })
+              .then((res) => {
+                if (res.success) {
+                  that.queryTreeData()
+                  that.$notification.success({
+                    message: '娑堟伅',
+                    description: res.message
+                  })
+                } else {
+                  that.$notification.warning({
+                    message: '娑堟伅',
+                    description: res.message
+                  })
+                }
+              })
           }
         })
       },
 
       /**
+       * 鑷姩灞曞紑娣诲姞涓嬬骇鑺傜偣鐨勭埗鑺傜偣
+       */
+      modalFormSubmitSuccess(isAddNextLevel) {
+        // 鍒ゆ柇鏄惁涓烘坊鍔犱笅绾у苟涓斿垽鏂埗鑺傜偣鏄惁灞曞紑
+        if (isAddNextLevel && !this.expandedKeys.includes(this.rightClickSelected.id)) this.expandedKeys.push(this.rightClickSelected.id)
+        this.queryTreeData()
+      },
+
+      /**
        * 鏍戣妭鐐瑰睍寮�鍚堝苟鏃惰Е鍙�
        * @param expandedKeys 灞曞紑椤筴ey
        */

--
Gitblit v1.9.3