From ba9490368b8bf27e0d4a6471420044dadf5b720e Mon Sep 17 00:00:00 2001
From: zhaowei <zhaowei>
Date: 星期二, 21 一月 2025 15:33:42 +0800
Subject: [PATCH] 产品结构树: 1、新增指定文档为当前版本功能与文档版本内容差异比对功能(新增插件vue-code-diff) 2、调整产品及部件属性tab栏标题为属性信息 3、删除产品及部件属性信息中对应层级名称 全局: 调整设置后端接口地址方式由vue.config.js改为env环境文件配置

---
 src/views/dnc/base/modules/ProductStructure/ProductStructureMainTop.vue |  274 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 261 insertions(+), 13 deletions(-)

diff --git a/src/views/dnc/base/modules/ProductStructure/ProductStructureMainTop.vue b/src/views/dnc/base/modules/ProductStructure/ProductStructureMainTop.vue
index 9a6a8e1..d53279f 100644
--- a/src/views/dnc/base/modules/ProductStructure/ProductStructureMainTop.vue
+++ b/src/views/dnc/base/modules/ProductStructure/ProductStructureMainTop.vue
@@ -1,37 +1,41 @@
 <template>
   <a-tabs v-model="activeTabKey" @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"/>
+    <a-tab-pane :key="1" tab="NC鏂囨。" v-if="currentTreeNodeInfo.type===5||currentTreeNodeInfo.type===6">
+      <NcDocumentTableList ref="ncDocumentTableListRef" :currentTreeNodeInfo="currentTreeNodeInfo"
+                           @handleTableContextMenuOpen="handleTableContextMenuOpen" :size="tableContainerSize"/>
     </a-tab-pane>
 
-    <a-tab-pane :key="2" tab="鍏朵粬鏂囨。">
-      <OtherDocumentTableList @handleTableContextMenuOpen="handleTableContextMenuOpen" :size="tableContainerSize"/>
+    <a-tab-pane :key="1" tab="鍏朵粬鏂囨。" v-else>
+      <OtherDocumentTableList ref="otherDocumentTableListRef" :currentTreeNodeInfo="currentTreeNodeInfo"
+                              @handleTableContextMenuOpen="handleTableContextMenuOpen" :size="tableContainerSize"/>
     </a-tab-pane>
 
-    <TableContextMenu :currentTableRowInfo="currentTableRowInfo" ref="tableContextMenuRef"/>
+    <TableContextMenu :tableRowInfo="currentRightClickedTableRowInfo" ref="tableContextMenuRef"/>
   </a-tabs>
 </template>
 
 <script>
-  import ProcessTableList from './Process/ProcessTableList'
+  import dncApi from '@/api/dnc'
   import NcDocumentTableList from './Document/NcDocumentTableList'
   import OtherDocumentTableList from './Document/OtherDocumentTableList'
   import TableContextMenu from '../../../common/TableContextMenu'
 
   export default {
     name: 'ProductStructureMainTop',
-    components: { TableContextMenu, OtherDocumentTableList, NcDocumentTableList, ProcessTableList },
+    components: { TableContextMenu, OtherDocumentTableList, NcDocumentTableList },
     data() {
       return {
-        activeTabKey: '1',
+        activeTabKey: 1,
         tableContainerSize: 'small',
-        currentTableRowInfo: {},
+        currentRightClickedTableRowInfo: {},
         currentTreeNodeInfo: {}
       }
     },
     created() {
       this.$bus.$on('sendCurrentTreeNodeInfo', this.receiveCurrentTreeNodeInfo)
+      this.$bus.$on('reloadDocumentListData', this.reloadDocumentListData)
+      this.$bus.$on('tableMenuItemMethodTrigger', this.triggerCorrespondingMethod)
     },
     methods: {
       /**
@@ -39,7 +43,8 @@
        * @param record 褰撳墠琛ㄦ牸琛屼俊鎭�
        */
       handleTableContextMenuOpen(record) {
-        this.currentTableRowInfo = Object.assign({}, 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'
@@ -49,13 +54,252 @@
 
       /**
        * 鎺ユ敹鏍戠粍浠朵紶鏉ョ殑褰撳墠閫変腑鐨勬爲鑺傜偣淇℃伅
-       * @param treeNodeInfo
+       * @param treeNodeInfo 鏍戣妭鐐逛俊鎭�
        */
       receiveCurrentTreeNodeInfo(treeNodeInfo) {
         // 浠庢爲缁勪欢鎺ュ彈鏍戣妭鐐逛俊鎭悗浠庣埗缁勪欢娴佸叆瀛愮粍浠�
         this.currentTreeNodeInfo = treeNodeInfo
-        if (treeNodeInfo.type !== 1) this.activeTabKey = 1
-        else this.activeTabKey = 2
+        // 娓呯┖涓婁竴鑺傜偣宸茬粡鍔犺浇杩囧緱鏂囨。鍒楄〃tabKey
+        if (treeNodeInfo.type === 5 || treeNodeInfo.type === 6) {
+          this.$nextTick(() => {
+            if (this.$refs.ncDocumentTableListRef) this.$refs.ncDocumentTableListRef.loadData(1)
+          })
+        } else {
+          this.$nextTick(() => {
+            if (this.$refs.otherDocumentTableListRef) this.$refs.otherDocumentTableListRef.loadData(1)
+          })
+        }
+      },
+
+      /**
+       * 鏂囨。浠ュ強NC绋嬪簭瀵煎叆/鍑哄簱/鍏ュ簱鎴愬姛鍚庤Е鍙戦噸鏂板姞杞芥枃妗e垪琛�
+       * @param docClassCode 鏂囨。绫诲埆
+       * @param attributionId 鑺傜偣Id
+       */
+      reloadDocumentListData({ docClassCode, attributionId }) {
+        // 濡傛灉涓婁紶鐨勬枃妗d笉鏄墍灞炰簬褰撳墠鎵�灞曠ず鑺傜偣鐨勬枃妗e垯涓嶉噸鏂拌幏鍙栨枃妗e垪琛�
+        if (this.currentTreeNodeInfo.id !== attributionId) return
+        if (docClassCode === 'NC') {
+          if (this.$refs.ncDocumentTableListRef) this.$refs.ncDocumentTableListRef.loadData(1)
+        } else {
+          if (this.$refs.otherDocumentTableListRef) this.$refs.otherDocumentTableListRef.loadData(1)
+        }
+      },
+
+      /**
+       * 鐐瑰嚮涓嬭浇鏃惰Е鍙戜笅杞藉綋鍓嶆枃妗�
+       */
+      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
+            })
+          })
+      },
+
+      /**
+       * 鐐瑰嚮鍑哄簱鏃惰Е鍙戝綋鍓嶆枃妗e嚭搴�
+       * @param menuLabel
+       */
+      handlePull(menuLabel) {
+        const that = this
+        const { docId, docName, param, attributionId } = this.currentRightClickedTableRowInfo
+        this.$confirm({
+          title: '鎻愮ず',
+          content: `纭${menuLabel}鍚楋紵`,
+          okText: '纭',
+          cancelText: '鍙栨秷',
+          onOk: () => {
+            dncApi.documentOutboundApi({ docId, docName })
+              .then(res => {
+                console.log('res------------------', res)
+                if (res.success) {
+                  this.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
+                })
+              })
+          }
+        })
+      },
+
+      /**
+       * 鐐瑰嚮鍙栨秷鍑哄簱鏃惰Е鍙戝綋鍓嶆枃妗e彇娑堝嚭搴�
+       * @param menuLabel
+       */
+      handleCancelPull(menuLabel) {
+        const that = this
+        const { docId, param, attributionId } = this.currentRightClickedTableRowInfo
+        this.$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
+                })
+              })
+          }
+        })
+      },
+
+
+      /**
+       * 鐐瑰嚮鍙戝竷鏃惰Е鍙戝綋鍓嶆枃妗e彂甯�
+       * @param menuLabel
+       */
+      handlePublish(menuLabel) {
+        const that = this
+        const { docId, param, attributionId } = this.currentRightClickedTableRowInfo
+        this.$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
+                })
+              })
+          }
+        })
+      },
+
+      /**
+       * 鐐瑰嚮閲嶆柊鍙戝竷鏃惰Е鍙戝綋鍓嶆枃妗i噸鏂板彂甯冮��鍥炰笂涓�鐗堟湰
+       * @param menuLabel
+       */
+      handleRepublish(menuLabel) {
+        const that = this
+        const { docId, param, attributionId } = this.currentRightClickedTableRowInfo
+        this.$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
+                })
+              })
+          }
+        })
+      },
+
+      /**
+       * 鐐瑰嚮褰掓。鏃惰Е鍙戝綋鍓嶆枃妗e綊妗d笖鍚庣画鏃犳硶缁х画鍙戝竷鎴栧綊妗�
+       * @param menuLabel
+       */
+      handlePigeonhole(menuLabel) {
+        const that = this
+        const { docId, param, attributionId } = this.currentRightClickedTableRowInfo
+        this.$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
+                })
+              })
+          }
+        })
       },
 
       /**
@@ -64,6 +308,10 @@
       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