From 33d8416c5a16fee7464df9774678bc60e47ff956 Mon Sep 17 00:00:00 2001
From: 田源 <lastanimals@163.com>
Date: 星期二, 19 三月 2024 09:53:25 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 Source/UBCS-WEB/src/components/Theme/ThemeClassifyTrees.vue |   67 ++++++++++++++++++++++-----------
 1 files changed, 44 insertions(+), 23 deletions(-)

diff --git a/Source/UBCS-WEB/src/components/Theme/ThemeClassifyTrees.vue b/Source/UBCS-WEB/src/components/Theme/ThemeClassifyTrees.vue
index 9b9671d..07fbb4f 100644
--- a/Source/UBCS-WEB/src/components/Theme/ThemeClassifyTrees.vue
+++ b/Source/UBCS-WEB/src/components/Theme/ThemeClassifyTrees.vue
@@ -62,6 +62,7 @@
                 </el-tooltip>
               </template>
             </avue-tree>
+            <div style="height: 25px"></div>
           </div>
 
         </div>
@@ -698,18 +699,10 @@
   mounted() {
     this.type = this.tabOption.column[0] || {label: '鍩烘湰淇℃伅', prop: 'tab1'};
     this.getAttr();
-    const treeEle = this.$refs.tree.$el
-    treeEle.addEventListener('click', (e) => {
-      if (e.target.nodeName !== 'SPAN') {
-        this.$refs.tree.setCurrentKey(null);
-        this.nodeClickList = {};
-        this.TreeFlagCode = true;
-        this.allButtons = false;
-        // this.$nextTick(()=>{
-        //   this.btnAuthList = [];
-        // })
-      }
-    }, true)
+    document.addEventListener('click', this.handleGlobalClick);
+  },
+  beforeDestroy() {
+    document.removeEventListener('click', this.handleGlobalClick);
   },
   computed: {
     ...mapGetters(["permission"]),
@@ -796,8 +789,26 @@
   created() {
   },
   methods: {
+    handleGlobalClick(event) {
+      // 鍒ゆ柇鏄惁瀛樺湪鏍戣妭鐐瑰紩鐢ㄤ互鍙婂紩鐢ㄧ殑鍏冪礌鏄惁瀛樺湪
+      if (this.$refs.tree && this.$refs.tree.$el) {
+        // 鍒ゆ柇鐐瑰嚮浜嬩欢鏄惁鍙戠敓鍦ㄦ爲鑺傜偣浠ュ鐨勫尯鍩�
+        const isOutsideTree = !this.$refs.tree.$el.contains(event.target);
+        if (isOutsideTree) {
+          this.clearNode();
+        }
+      }
+    },
+    clearNode(){
+      // this.getAttr()
+      this.$refs.tree.setCurrentKey(null);
+      this.nodeClickList = {};
+      this.TreeFlagCode = true;
+      this.allButtons = false;
+    },
     // 鍒嗙被鎺堟潈瀵硅瘽妗嗘墦寮�
-    classifyAuthHandler() {
+    classifyAuthHandler(event) {
+      event.stopPropagation();
       if (this.nodeClickList.oid === '' || this.nodeClickList.oid === undefined) {
         this.$message.warning('璇疯嚦灏戦�夋嫨涓�鏉℃暟鎹紒')
         return;
@@ -806,7 +817,8 @@
       this.classifyAuthVisible = true;
     },
     // 鏁版嵁鎺堟潈瀵硅瘽妗嗘墦寮�
-    dataAuthHandler() {
+    dataAuthHandler(event) {
+      event.stopPropagation();
       if (this.nodeClickList.oid === '' || this.nodeClickList.oid === undefined) {
         this.$message.warning('璇疯嚦灏戦�夋嫨涓�鏉℃暟鎹紒')
         return;
@@ -814,7 +826,8 @@
       // this.classifyData = this.nodeClickList;
       this.dataAuthVisible = true;
     },
-    flowingDependHandler() {
+    flowingDependHandler(event) {
+      event.stopPropagation();
       if (this.nodeClickList.length <= 0) {
         this.$message.warning('璇疯嚦灏戦�夋嫨涓�鏉℃暟鎹紒')
         return;
@@ -831,11 +844,13 @@
     },
     // 鍏抽棴寮圭獥
     /** 瀵煎叆 */
-    ImportExcel() {
+    ImportExcel(event) {
+      event.stopPropagation();
       this.ThemeImportVisible = true;
     },
     /** 瀵煎嚭 */
-    ExportExcel() {
+    ExportExcel(event) {
+      event.stopPropagation();
       if (this.nodeClickList) {
         exportClassify({oid: this.nodeClickList.oid}).then(res => {
           func.downloadFileByBlobHandler(res);
@@ -954,7 +969,8 @@
       }
     },
     //鏍戣妭鐐规坊鍔犳寜閽�
-    async TreeAdd() {
+    async TreeAdd(event) {
+      event.stopPropagation();
       const loading = this.$loading({
         lock: true,
         text: 'Loading',
@@ -1014,7 +1030,8 @@
       }
     },
     //鏍戣妭鐐瑰垹闄ゆ寜閽�
-    TreeDel() {
+    TreeDel(event) {
+      event.stopPropagation();
       this.$confirm('鏄惁鍒犻櫎褰撳墠閫夋嫨鐨勫垎绫伙紝灏嗕細鎶婂瓙鍒嗙被涓�骞跺垹闄わ紝濡傛灉瀛樺湪缂栫爜鏁版嵁灏嗕笉鑳借鍒犻櫎锛屾槸鍚︾户缁紵', '鎻愮ず', {
         confirmButtonText: '纭畾',
         cancelButtonText: '鍙栨秷',
@@ -1070,7 +1087,8 @@
       });
     },
     //淇敼鍥炲~
-    TreeEdit() {
+    TreeEdit(event) {
+      event.stopPropagation();
       if (Object.keys(this.nodeClickList).length < 1) {
         this.$message({
           type: 'warning',
@@ -1081,7 +1099,8 @@
       }
     },
     //鏍戝埛鏂�
-    async flushed() {
+    async flushed(event) {
+      event.stopPropagation();
       await this.getAttr()
       this.$refs.tree.setCurrentKey(null);
       this.nodeClickList = {};
@@ -1090,7 +1109,8 @@
     },
     //鍚敤鍜屽仠鐢ㄩ兘鍏堝垽鏂姸鎬�
     //鍚敤
-    async Enable() {
+    async Enable(event) {
+      event.stopPropagation();
       if (Object.keys(this.nodeClickList).length < 1) {
         this.$message.warning('璇峰厛浠庢爲涓婇�夋嫨涓�鏉℃暟鎹�');
         return;
@@ -1130,7 +1150,8 @@
         this.loading = false;
       }
     },
-    async Deactivate() {
+    async Deactivate(event) {
+      event.stopPropagation();
       if (Object.keys(this.nodeClickList).length < 1) {
         this.$message.warning('璇峰厛浠庢爲涓婇�夋嫨涓�鏉℃暟鎹�');
         return;

--
Gitblit v1.9.3