From b299fcd13492375b34e6fa3fd26a841d554c297a Mon Sep 17 00:00:00 2001
From: 田源 <lastanimals@163.com>
Date: 星期二, 19 三月 2024 09:53:19 +0800
Subject: [PATCH] 代码更新

---
 Source/UBCS-WEB/src/components/Theme/ThemeClassifyTrees.vue |   62 +++++++++++++++++++------------
 1 files changed, 38 insertions(+), 24 deletions(-)

diff --git a/Source/UBCS-WEB/src/components/Theme/ThemeClassifyTrees.vue b/Source/UBCS-WEB/src/components/Theme/ThemeClassifyTrees.vue
index d90f2a2..07fbb4f 100644
--- a/Source/UBCS-WEB/src/components/Theme/ThemeClassifyTrees.vue
+++ b/Source/UBCS-WEB/src/components/Theme/ThemeClassifyTrees.vue
@@ -4,7 +4,7 @@
     <!--    宸︿晶鑿滃崟-->
     <el-aside>
       <basic-container>
-        <div style="height: calc(100vh - 144px);!important;" @click="clearNode">
+        <div style="height: calc(100vh - 144px);!important;">
           <div class="headerCon" style="display: flex; flex-wrap: wrap;margin-bottom: 5px">
             <el-button v-if="permissionList.TreeAddStatus" plain size="small" type="primary" @click="TreeAdd">娣诲姞
             </el-button>
@@ -699,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"]),
@@ -797,14 +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;
@@ -813,7 +817,8 @@
       this.classifyAuthVisible = true;
     },
     // 鏁版嵁鎺堟潈瀵硅瘽妗嗘墦寮�
-    dataAuthHandler() {
+    dataAuthHandler(event) {
+      event.stopPropagation();
       if (this.nodeClickList.oid === '' || this.nodeClickList.oid === undefined) {
         this.$message.warning('璇疯嚦灏戦�夋嫨涓�鏉℃暟鎹紒')
         return;
@@ -821,7 +826,8 @@
       // this.classifyData = this.nodeClickList;
       this.dataAuthVisible = true;
     },
-    flowingDependHandler() {
+    flowingDependHandler(event) {
+      event.stopPropagation();
       if (this.nodeClickList.length <= 0) {
         this.$message.warning('璇疯嚦灏戦�夋嫨涓�鏉℃暟鎹紒')
         return;
@@ -838,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);
@@ -961,7 +969,8 @@
       }
     },
     //鏍戣妭鐐规坊鍔犳寜閽�
-    async TreeAdd() {
+    async TreeAdd(event) {
+      event.stopPropagation();
       const loading = this.$loading({
         lock: true,
         text: 'Loading',
@@ -1021,7 +1030,8 @@
       }
     },
     //鏍戣妭鐐瑰垹闄ゆ寜閽�
-    TreeDel() {
+    TreeDel(event) {
+      event.stopPropagation();
       this.$confirm('鏄惁鍒犻櫎褰撳墠閫夋嫨鐨勫垎绫伙紝灏嗕細鎶婂瓙鍒嗙被涓�骞跺垹闄わ紝濡傛灉瀛樺湪缂栫爜鏁版嵁灏嗕笉鑳借鍒犻櫎锛屾槸鍚︾户缁紵', '鎻愮ず', {
         confirmButtonText: '纭畾',
         cancelButtonText: '鍙栨秷',
@@ -1077,7 +1087,8 @@
       });
     },
     //淇敼鍥炲~
-    TreeEdit() {
+    TreeEdit(event) {
+      event.stopPropagation();
       if (Object.keys(this.nodeClickList).length < 1) {
         this.$message({
           type: 'warning',
@@ -1088,7 +1099,8 @@
       }
     },
     //鏍戝埛鏂�
-    async flushed() {
+    async flushed(event) {
+      event.stopPropagation();
       await this.getAttr()
       this.$refs.tree.setCurrentKey(null);
       this.nodeClickList = {};
@@ -1097,7 +1109,8 @@
     },
     //鍚敤鍜屽仠鐢ㄩ兘鍏堝垽鏂姸鎬�
     //鍚敤
-    async Enable() {
+    async Enable(event) {
+      event.stopPropagation();
       if (Object.keys(this.nodeClickList).length < 1) {
         this.$message.warning('璇峰厛浠庢爲涓婇�夋嫨涓�鏉℃暟鎹�');
         return;
@@ -1137,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