From fa9d138094e2ffabf7b053e73779d1204097ce75 Mon Sep 17 00:00:00 2001
From: zhaowei <zhaowei>
Date: 星期二, 11 二月 2025 11:49:46 +0800
Subject: [PATCH] 产品结构树: 1、实现文档功能的删除功能 设备结构树: 1、实现获取对应设备的已发送的NC程序列表 2、实现设备层级导入NC程序功能 3、实现设备关联的已发送NC程序功能的删除功能

---
 src/views/dnc/base/modules/ProductStructure/ProductStructureMainTop.vue |  289 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 286 insertions(+), 3 deletions(-)

diff --git a/src/views/dnc/base/modules/ProductStructure/ProductStructureMainTop.vue b/src/views/dnc/base/modules/ProductStructure/ProductStructureMainTop.vue
index 3d1233e..151b5d4 100644
--- a/src/views/dnc/base/modules/ProductStructure/ProductStructureMainTop.vue
+++ b/src/views/dnc/base/modules/ProductStructure/ProductStructureMainTop.vue
@@ -16,6 +16,7 @@
 </template>
 
 <script>
+  import dncApi from '@/api/dnc'
   import NcDocumentTableList from './Document/NcDocumentTableList'
   import OtherDocumentTableList from './Document/OtherDocumentTableList'
   import TableContextMenu from '../../../common/TableContextMenu'
@@ -33,7 +34,8 @@
     },
     created() {
       this.$bus.$on('sendCurrentTreeNodeInfo', this.receiveCurrentTreeNodeInfo)
-      this.$bus.$on('importFileSuccess', this.reloadDocumentListData)
+      this.$bus.$on('reloadDocumentListData', this.reloadDocumentListData)
+      this.$bus.$on('tableMenuItemMethodTrigger', this.triggerCorrespondingMethod)
     },
     methods: {
       /**
@@ -42,6 +44,7 @@
        */
       handleTableContextMenuOpen(record) {
         this.currentRightClickedTableRowInfo = Object.assign({}, record)
+        console.log('currentRightClickedTableRowInfo', this.currentRightClickedTableRowInfo)
         this.$refs.tableContextMenuRef.currentMenuLevel = record.param
         this.$refs.tableContextMenuRef.menuStyle.top = event.clientY + 'px'
         this.$refs.tableContextMenuRef.menuStyle.left = event.clientX + 'px'
@@ -69,7 +72,7 @@
       },
 
       /**
-       * 涓婁紶鏂囦欢鎴愬姛鍚庤Е鍙�
+       * 鏂囨。浠ュ強NC绋嬪簭瀵煎叆/鍑哄簱/鍏ュ簱鎴愬姛鍚庤Е鍙戦噸鏂板姞杞芥枃妗e垪琛�
        * @param docClassCode 鏂囨。绫诲埆
        * @param attributionId 鑺傜偣Id
        */
@@ -83,12 +86,292 @@
         }
       },
 
+      // 涓嬭浇褰撳墠鍙抽敭閫変腑鏂囨。
+      handleDownload() {
+        const that = this
+        const { docId, docName } = this.currentRightClickedTableRowInfo
+        dncApi.downloadDocumentApi({ docId, docName })
+          .then(res => {
+            if (res && !res.success) {
+              that.$notification.error({
+                message: '娑堟伅',
+                description: res.message
+              })
+            }
+          })
+          .catch(err => {
+            that.$notification.error({
+              message: '娑堟伅',
+              description: err.message
+            })
+          })
+      },
+
+      // 鍒犻櫎褰撳墠鍙抽敭閫変腑鏂囨。
+      handleDelete() {
+        const { docId, param, attributionId } = this.currentRightClickedTableRowInfo
+        const that = this
+        that.$confirm({
+          title: '鎻愮ず',
+          content: `鍒犻櫎鍚庝笉鍙彇娑堬紝纭鍒犻櫎鍚楋紵`,
+          okText: '纭',
+          cancelText: '鍙栨秷',
+          onOk: () => {
+            dncApi.deleteDocumentApi(docId)
+              .then((res) => {
+                if (res.success) {
+                  that.$notification.success({
+                    message: '娑堟伅',
+                    description: res.message
+                  })
+                  that.reloadDocumentListData({ docClassCode: param, attributionId })
+                } else {
+                  that.$notification.warning({
+                    message: '娑堟伅',
+                    description: res.message
+                  })
+                }
+              })
+              .finally(() => {
+                that.$destroyAll()
+              })
+          },
+          onCancel: () => {
+            that.$destroyAll()
+          }
+        })
+      },
+
       /**
-       * 鎺у埗鍙抽敭鑿滃崟鐐瑰嚮鍏抽棴
+       * 鍑哄簱褰撳墠鍙抽敭閫変腑鏂囨。
+       * @param menuLabel
        */
+      handlePull(menuLabel) {
+        const that = this
+        const { docId, docName, param, attributionId } = this.currentRightClickedTableRowInfo
+        that.$confirm({
+          title: '鎻愮ず',
+          content: `纭${menuLabel}鍚楋紵`,
+          okText: '纭',
+          cancelText: '鍙栨秷',
+          onOk: () => {
+            dncApi.documentOutboundApi({ docId, docName })
+              .then(res => {
+                console.log('res------------------', res)
+                if (res.success) {
+                  that.reloadDocumentListData({ docClassCode: param, attributionId })
+                  that.$notification.success({
+                    message: '娑堟伅',
+                    description: `${menuLabel}鎴愬姛`
+                  })
+                } else {
+                  that.$notification.error({
+                    message: '娑堟伅',
+                    description: res.message
+                  })
+                }
+              })
+              .catch(err => {
+                that.$notification.error({
+                  message: '娑堟伅',
+                  description: err.message
+                })
+              })
+              .finally(() => {
+                that.$destroyAll()
+              })
+          },
+          onCancel: () => {
+            that.$destroyAll()
+          }
+        })
+      },
+
+      /**
+       * 鍙栨秷鍑哄簱褰撳墠鍙抽敭閫変腑鏂囨。
+       * @param menuLabel
+       */
+      handleCancelPull(menuLabel) {
+        const that = this
+        const { docId, param, attributionId } = this.currentRightClickedTableRowInfo
+        that.$confirm({
+          title: '鎻愮ず',
+          content: `纭${menuLabel}鍚楋紵`,
+          okText: '纭',
+          cancelText: '鍙栨秷',
+          onOk: () => {
+            dncApi.documentCancelOutboundApi(docId)
+              .then(res => {
+                if (res.success) {
+                  this.reloadDocumentListData({ docClassCode: param, attributionId })
+                  that.$notification.success({
+                    message: '娑堟伅',
+                    description: res.message
+                  })
+                } else {
+                  that.$notification.error({
+                    message: '娑堟伅',
+                    description: res.message
+                  })
+                }
+              })
+              .catch(err => {
+                that.$notification.error({
+                  message: '娑堟伅',
+                  description: err.message
+                })
+              })
+              .finally(() => {
+                that.$destroyAll()
+              })
+          },
+          onCancel() {
+            that.$destroyAll()
+          }
+        })
+      },
+
+      /**
+       * 鍙戝竷褰撳墠鍙抽敭閫変腑鏂囨。
+       * @param menuLabel
+       */
+      handlePublish(menuLabel) {
+        const that = this
+        const { docId, param, attributionId } = this.currentRightClickedTableRowInfo
+        that.$confirm({
+          title: '鎻愮ず',
+          content: `纭${menuLabel}鍚楋紵`,
+          okText: '纭',
+          cancelText: '鍙栨秷',
+          onOk: () => {
+            dncApi.documentPublishApi(docId)
+              .then(res => {
+                if (res.success) {
+                  this.reloadDocumentListData({ docClassCode: param, attributionId })
+                  this.$bus.$emit('reloadMainBottomTableData', 'documentVersion')
+                  that.$notification.success({
+                    message: '娑堟伅',
+                    description: res.message
+                  })
+                } else {
+                  that.$notification.error({
+                    message: '娑堟伅',
+                    description: res.message
+                  })
+                }
+              })
+              .catch(err => {
+                that.$notification.error({
+                  message: '娑堟伅',
+                  description: err.message
+                })
+              })
+              .finally(() => {
+                that.$destroyAll()
+              })
+          },
+          onCancel() {
+            that.$destroyAll()
+          }
+        })
+      },
+
+      /**
+       * 閲嶆柊鍙戝竷褰撳墠鍙抽敭閫変腑鏂囨。骞堕噸鏂板彂甯冮��鍥炰笂涓�鏂囨。鐗堟湰
+       * @param menuLabel
+       */
+      handleRepublish(menuLabel) {
+        const that = this
+        const { docId, param, attributionId } = this.currentRightClickedTableRowInfo
+        that.$confirm({
+          title: '鎻愮ず',
+          content: `纭${menuLabel}鍚楋紵`,
+          okText: '纭',
+          cancelText: '鍙栨秷',
+          onOk: () => {
+            dncApi.documentRepublishApi(docId)
+              .then(res => {
+                if (res.success) {
+                  this.reloadDocumentListData({ docClassCode: param, attributionId })
+                  that.$notification.success({
+                    message: '娑堟伅',
+                    description: res.message
+                  })
+                } else {
+                  that.$notification.error({
+                    message: '娑堟伅',
+                    description: res.message
+                  })
+                }
+              })
+              .catch(err => {
+                that.$notification.error({
+                  message: '娑堟伅',
+                  description: err.message
+                })
+              })
+              .finally(() => {
+                that.$destroyAll()
+              })
+          },
+          onCancel() {
+            that.$destroyAll()
+          }
+        })
+      },
+
+      /**
+       * 閲嶅綊妗e綋鍓嶅彸閿�変腑鏂囨。涓斿悗缁棤娉曠户缁彂甯冩垨褰掓。
+       * @param menuLabel
+       */
+      handlePigeonhole(menuLabel) {
+        const that = this
+        const { docId, param, attributionId } = this.currentRightClickedTableRowInfo
+        that.$confirm({
+          title: '鎻愮ず',
+          content: `${menuLabel}鍚庝笉鍙彇娑堬紝纭${menuLabel}鍚楋紵`,
+          okText: '纭',
+          cancelText: '鍙栨秷',
+          onOk: () => {
+            dncApi.documentPigeonholeApi(docId)
+              .then(res => {
+                if (res.success) {
+                  this.reloadDocumentListData({ docClassCode: param, attributionId })
+                  that.$notification.success({
+                    message: '娑堟伅',
+                    description: res.message
+                  })
+                } else {
+                  that.$notification.error({
+                    message: '娑堟伅',
+                    description: res.message
+                  })
+                }
+              })
+              .catch(err => {
+                that.$notification.error({
+                  message: '娑堟伅',
+                  description: err.message
+                })
+              })
+              .finally(() => {
+                that.$destroyAll()
+              })
+          },
+          onCancel() {
+            that.$destroyAll()
+          }
+        })
+      },
+
+      // 鎺у埗鍙抽敭鑿滃崟鍏抽棴
       handleMenuClose() {
         this.$refs.tableContextMenuRef.menuVisible = false
         document.body.removeEventListener('click', this.handleMenuClose)
+      },
+
+      triggerCorrespondingMethod({ methodName, modalTitle }) {
+        if (this[methodName]) this[methodName](modalTitle)
       }
     }
   }

--
Gitblit v1.9.3