From f2d1b5615b05c002ec63db4df7164c9ed3ecc4a3 Mon Sep 17 00:00:00 2001
From: zhaowei <zhaowei>
Date: 星期二, 26 八月 2025 16:42:21 +0800
Subject: [PATCH] 1、优化产品结构树以及设备结构树、列表右键菜单重复右键后出现window菜单问题 2、优化产品结构树节点删除后的loading展示时机 3、优化产品以及设备结构树权限配置获取列表时的loading展示时机

---
 src/views/dnc/base/modules/ProductStructure/ProductStructureTree.vue |   50 +++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 41 insertions(+), 9 deletions(-)

diff --git a/src/views/dnc/base/modules/ProductStructure/ProductStructureTree.vue b/src/views/dnc/base/modules/ProductStructure/ProductStructureTree.vue
index 2c72304..011fb44 100644
--- a/src/views/dnc/base/modules/ProductStructure/ProductStructureTree.vue
+++ b/src/views/dnc/base/modules/ProductStructure/ProductStructureTree.vue
@@ -30,8 +30,12 @@
                   :selectedKeys="selectedKeys" :treeData="treeDataSource" :autoExpandParent="autoExpandParent"
                   @select="handleTreeSelect" @expand="handleTreeExpand" @rightClick="handleTreeRightClick">
             <template slot="title" slot-scope="{ label, parentId, key:treeKey,type}">
-              <ProductStructureTreeContextMenu ref="contextMenuRef"
-                                               :treeParams="{label,treeKey,searchValue,type}"/>
+              <span v-if="label.indexOf(searchValue) > -1">
+                {{label.substr(0, label.indexOf(searchValue))}}
+                <span class="replaceSearch">{{searchValue}}</span>
+                {{label.substr(label.indexOf(searchValue) + searchValue.length)}}
+              </span>
+              <span v-else>{{ label }}</span>
             </template>
 
             <a-icon slot="switcherIcon" type="down"/>
@@ -68,6 +72,10 @@
                              @submitSuccess="modalFormSubmitSuccess"/>
     <!--寮曠敤閮ㄤ欢-->
     <NcComponentBorrowModal :currentBorrowInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess"/>
+
+    <!--浜у搧缁撴瀯鏍戝彸閿彍鍗曪紙鏍戣妭鐐硅Е鍙戯級-->
+    <product-structure-tree-context-menu ref="mainContextmenuRef" :treeParams="rightClickSelected"/>
+
     <!--浜у搧缁撴瀯鏍戝熀鏈彸閿彍鍗�(绌虹櫧澶勮Е鍙�)-->
     <ProductStructureBaseContextMenu ref="baseContextmenuRef"/>
 
@@ -204,9 +212,10 @@
 
       /**
        * 鏍戣妭鐐瑰彸閿崟鍑昏妭鐐规椂瑙﹀彂
+       * @param event 浜嬩欢瀵硅薄
        * @param node 鑺傜偣瀵硅薄
        */
-      handleTreeRightClick({ node }) {
+      handleTreeRightClick({ event, node }) {
         if (this.$refs.baseContextmenuRef) this.$refs.baseContextmenuRef.menuVisible = false
         const that = this
         const record = node.dataRef
@@ -222,7 +231,9 @@
                   message: '娑堟伅',
                   description: '鏆傛棤璇ヨ妭鐐硅缁嗕俊鎭�'
                 })
+                return
               }
+              this.openMainContextMenu(event)
             } else {
               that.$notification.error({
                 message: '娑堟伅',
@@ -243,10 +254,7 @@
           okType: 'danger',
           cancelText: '鍙栨秷',
           onOk: () => {
-            if (!url.delete) {
-              this.$message.error('璇疯缃畊rl.delete灞炴��!')
-              return
-            }
+            that.loading = true
             deleteAction(url.delete + `/${id}/${type}`)
               .then((res) => {
                 if (res.success) {
@@ -272,7 +280,7 @@
         })
       },
 
-      // 鏍戣妭鐐瑰彸閿崟鍑昏彍鍗曚腑鍒犻櫎鎸夐挳鏃惰Е鍙�
+      // 鍙戦�乶c绋嬪簭鑷充笁缁村伐鑹�
       handleSendNcToPlm() {
         const that = this
         const { rightClickSelected: { id, type }, $confirm, url, $notification } = that
@@ -287,7 +295,7 @@
               this.$message.error('璇疯缃畊rl.webServiceDNCToPlm!')
               return
             }
-            getAction(url.webServiceDNCToPlm, {id: id})
+            getAction(url.webServiceDNCToPlm, { id: id })
               .then((res) => {
                 if (res.success) {
                   that.getTreeDataByApi()
@@ -446,12 +454,24 @@
       },
 
       /**
+       * 鎵撳紑鏍戣妭鐐硅彍鍗曚簨浠�
+       * @param event 鏍戣妭鐐逛簨浠跺璞�
+       */
+      openMainContextMenu(event) {
+        this.$refs.mainContextmenuRef.menuStyle.top = event.clientY + 'px'
+        this.$refs.mainContextmenuRef.menuStyle.left = event.clientX + 'px'
+        this.$refs.mainContextmenuRef.menuVisible = true
+        document.body.addEventListener('click', this.handleMainContextMenuClose)
+      },
+
+      /**
        * 鏍戞墍鍦ㄧ埗鍏冪礌鐨勫彸閿簨浠�
        * @param event 浜嬩欢瀵硅薄
        */
       openBaseContextMenu(event) {
         event.preventDefault()
         if (event.target.id !== 'tree-container') return
+        if (this.$refs.mainContextmenuRef) this.$refs.mainContextmenuRef.menuVisible = false
         this.$refs.baseContextmenuRef.menuStyle.top = event.clientY + 'px'
         this.$refs.baseContextmenuRef.menuStyle.left = event.clientX + 'px'
         this.$refs.baseContextmenuRef.menuVisible = true
@@ -484,6 +504,12 @@
             break
           default:
         }
+      },
+
+      // 鎺у埗涓昏鍙抽敭鑿滃崟鍏抽棴
+      handleMainContextMenuClose() {
+        if (this.$refs.mainContextmenuRef) this.$refs.mainContextmenuRef.menuVisible = false
+        document.body.removeEventListener('click', this.handleMainContextMenuClose)
       },
 
       // 鎺у埗鍩虹鍙抽敭鑿滃崟鍏抽棴
@@ -537,6 +563,12 @@
     align-items: center;
   }
 
+  .replaceSearch {
+    color: #40a9ff;
+    font-weight: bold;
+    background-color: rgb(204, 204, 204);
+  }
+
   @media screen and (min-width: 1920px) {
     .tree_con {
       height: 748px !important;

--
Gitblit v1.9.3