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/Permission/AssignPermissionModal.vue |  214 +++++++++++++++++++++++++++-------------------------
 1 files changed, 111 insertions(+), 103 deletions(-)

diff --git a/src/views/dnc/base/modules/ProductStructure/Permission/AssignPermissionModal.vue b/src/views/dnc/base/modules/ProductStructure/Permission/AssignPermissionModal.vue
index 6491b13..464e7df 100644
--- a/src/views/dnc/base/modules/ProductStructure/Permission/AssignPermissionModal.vue
+++ b/src/views/dnc/base/modules/ProductStructure/Permission/AssignPermissionModal.vue
@@ -27,123 +27,131 @@
 </template>
 
 <script>
-import dncApi from '@/api/dnc'
-import DepartPermissionTransfer from './DepartPermissionTransfer'
-import UserPermissionTransfer from './UserPermissionTransfer'
+  import dncApi from '@/api/dnc'
+  import DepartPermissionTransfer from './DepartPermissionTransfer'
+  import UserPermissionTransfer from './UserPermissionTransfer'
 
-export default {
-  name: 'AssignPermissionModal',
-  components: { UserPermissionTransfer, DepartPermissionTransfer },
-  props: {
-    currentTreeNodeInfo: {
-      type: Object
-    }
-  },
-  data() {
-    return {
-      visible: false,
-      title: '',
-      isAssignSonNode: true,
-      activeTabKey: 1,
-      allDepartmentsList: [],
-      allUsersList: [],
-      allTreeKeys: [],
-      hasLoadedDataTabKeyArray: []
-    }
-  },
-  watch: {
-    visible: {
-      handler(value) {
-        if (value) {
-          this.activeTabKey = 1
-          this.isAssignSonNode = true
-          this.getAllDepartmentsListByApi()
+  export default {
+    name: 'AssignPermissionModal',
+    components: { UserPermissionTransfer, DepartPermissionTransfer },
+    props: {
+      currentTreeNodeInfo: {
+        type: Object
+      }
+    },
+    data() {
+      return {
+        visible: false,
+        title: '',
+        isAssignSonNode: true,
+        activeTabKey: 1,
+        allDepartmentsList: [],
+        allUsersList: [],
+        allTreeKeys: [],
+        hasLoadedDataTabKeyArray: []
+      }
+    },
+    watch: {
+      visible: {
+        handler(value) {
+          if (value) {
+            this.activeTabKey = 1
+            this.isAssignSonNode = true
+            this.getAllDepartmentsListByApi()
+          }
+        }
+      },
+      activeTabKey: {
+        handler(value) {
+          if (this.hasLoadedDataTabKeyArray.includes(value)) return
+          if (value === 2) this.getAllUsersListByApi()
+          this.hasLoadedDataTabKeyArray.push(value)
         }
       }
     },
-    activeTabKey: {
-      handler(value) {
-        if (this.hasLoadedDataTabKeyArray.includes(value)) return
-        if (value === 2) this.getAllUsersListByApi()
-        this.hasLoadedDataTabKeyArray.push(value)
-      }
-    }
-  },
-  created() {
-    this.$bus.$on('treeMenuItemMethodTrigger', this.triggerCorrespondingMethod)
-  },
-  methods: {
-    // 鐐瑰嚮鏍戣妭鐐瑰彸閿彍鍗曟潈闄愰厤缃寜閽悗瑙﹀彂
-    handleAssignPermission() {
-      this.visible = true
+    created() {
+      this.$bus.$on('treeMenuItemMethodTrigger', this.triggerCorrespondingMethod)
     },
+    methods: {
+      // 鐐瑰嚮鏍戣妭鐐瑰彸閿彍鍗曟潈闄愰厤缃寜閽悗瑙﹀彂
+      handleAssignPermission() {
+        this.visible = true
+      },
 
-    // 璋冪敤鎺ュ彛鑾峰彇鎵�鏈夎溅闂村垪琛�
-    getAllDepartmentsListByApi() {
-      this.allTreeKeys = []
-      dncApi.getAllDepartmentsListApi()
-        .then(res => {
-          if (res.success) {
-            this.allDepartmentsList = res.result
-            this.generateList(this.allDepartmentsList)
-            this.$nextTick(() => {
-              this.$refs.departPermissionTransferRef.getHasPermissionDepartByApi()
-              this.$refs.departPermissionTransferRef.expandedKeys = this.allTreeKeys
-              this.$refs.departPermissionTransferRef.flatten(JSON.parse(JSON.stringify(this.allDepartmentsList)))
-            })
-            // 鍙湁涓婃閫�鍑烘椂鍦ㄨ溅闂村垎閰峵ab鐣岄潰鎵嶄細杩涘叆姝ゅ垽鏂�
-            // 鑻ヤ笂娆¢��鍑烘椂鍦ㄧ敤鎴峰垎閰峵ab鐣岄潰鍒欏啀娆¤繘鍏ユ椂key鐢�2鍙樹负1鏃朵細瑙﹀彂watch鐩戞祴activeTabKey鍙樺寲鍒欎細灏唊ey:1鍔犲叆hasLoadedDataTabKeyArray锛屽洜姝ゆ棤闇�鍐嶆鍔犲叆key:1
-            if (!this.hasLoadedDataTabKeyArray.includes(this.activeTabKey)) this.hasLoadedDataTabKeyArray.push(this.activeTabKey)
-          }
+      // 璋冪敤鎺ュ彛鑾峰彇鎵�鏈夎溅闂村垪琛�
+      getAllDepartmentsListByApi() {
+        this.allTreeKeys = this.allDepartmentsList = []
+        this.$nextTick(() => {
+          this.$refs.departPermissionTransferRef.targetKeys = this.$refs.departPermissionTransferRef.dataSource = []
+          this.$refs.departPermissionTransferRef.spinning = true
         })
-    },
+        dncApi.getAllDepartmentsListApi()
+          .then(res => {
+            if (res.success) {
+              this.allDepartmentsList = res.result
+              this.generateList(this.allDepartmentsList)
+              this.$nextTick(() => {
+                this.$refs.departPermissionTransferRef.getHasPermissionDepartByApi()
+                this.$refs.departPermissionTransferRef.expandedKeys = this.allTreeKeys
+                this.$refs.departPermissionTransferRef.flatten(JSON.parse(JSON.stringify(this.allDepartmentsList)))
+              })
+              // 鍙湁涓婃閫�鍑烘椂鍦ㄨ溅闂村垎閰峵ab鐣岄潰鎵嶄細杩涘叆姝ゅ垽鏂�
+              // 鑻ヤ笂娆¢��鍑烘椂鍦ㄧ敤鎴峰垎閰峵ab鐣岄潰鍒欏啀娆¤繘鍏ユ椂key鐢�2鍙樹负1鏃朵細瑙﹀彂watch鐩戞祴activeTabKey鍙樺寲鍒欎細灏唊ey:1鍔犲叆hasLoadedDataTabKeyArray锛屽洜姝ゆ棤闇�鍐嶆鍔犲叆key:1
+              if (!this.hasLoadedDataTabKeyArray.includes(this.activeTabKey)) this.hasLoadedDataTabKeyArray.push(this.activeTabKey)
+            }
+          })
+      },
 
-    /**
-     * 閫掑綊鑾峰緱鎵�鏈夋爲鑺傜偣key
-     * @param data
-     */
-    generateList(data) {
-      for (let i = 0; i < data.length; i++) {
-        const node = data[i]
-        const key = node.key
-        this.allTreeKeys.push(key)
-        if (node.children) this.generateList(node.children)
-      }
-    },
-
-    // 璋冪敤鎺ュ彛鑾峰彇鎵�鏈夌敤鎴峰垪琛�
-    getAllUsersListByApi() {
-      dncApi.getAllUsersListApi()
-        .then(res => {
-          if (res.success) {
-            this.allUsersList = res.result.records
-            this.$nextTick(() => this.$refs.userPermissionTransferRef.getHasPermissionUserByApi())
-          }
-        })
-    },
-
-    setAdminDisabled() {
-      this.allUsersList = this.allUsersList.map(item => {
-        return {
-          ...item,
-          disabled: item.username === 'admin'
+      /**
+       * 閫掑綊鑾峰緱鎵�鏈夋爲鑺傜偣key
+       * @param data
+       */
+      generateList(data) {
+        for (let i = 0; i < data.length; i++) {
+          const node = data[i]
+          const key = node.key
+          this.allTreeKeys.push(key)
+          if (node.children) this.generateList(node.children)
         }
-      })
-    },
+      },
 
-    handleModalClose() {
-      this.visible = false
-      this.hasLoadedDataTabKeyArray = []
-    },
+      // 璋冪敤鎺ュ彛鑾峰彇鎵�鏈夌敤鎴峰垪琛�
+      getAllUsersListByApi() {
+        this.$nextTick(() => {
+          this.allUsersList = []
+          this.$refs.userPermissionTransferRef.spinning = true
+        })
+        dncApi.getAllUsersListApi()
+          .then(res => {
+            if (res.success) {
+              this.allUsersList = res.result
+              this.$nextTick(() => this.$refs.userPermissionTransferRef.getHasPermissionUserByApi())
+            }
+          })
+      },
 
-    triggerCorrespondingMethod({ methodName, modalTitle }) {
-      if (this[methodName]) {
-        this[methodName]()
-        this.title = modalTitle
+      setAdminDisabled() {
+        this.allUsersList = this.allUsersList.map(item => {
+          return {
+            ...item,
+            disabled: item.username === 'admin'
+          }
+        })
+      },
+
+      handleModalClose() {
+        this.visible = false
+        this.hasLoadedDataTabKeyArray = []
+      },
+
+      triggerCorrespondingMethod({ methodName, modalTitle }) {
+        if (this[methodName]) {
+          this[methodName]()
+          this.title = modalTitle
+        }
       }
     }
   }
-}
 </script>
 
 <style scoped>

--
Gitblit v1.9.3