wanggaokun 3 долоо хоног өмнө
parent
commit
064d7d1a46

+ 0 - 1
.eslintrc-auto-import.json

@@ -6,7 +6,6 @@
     "DirectiveBinding": true,
     "EffectScope": true,
     "ElMessage": true,
-    "ElMessageBox": true,
     "ExtractDefaultPropTypes": true,
     "ExtractPropTypes": true,
     "ExtractPublicPropTypes": true,

+ 0 - 1
src/types/auto-imports.d.ts

@@ -339,7 +339,6 @@ declare module 'vue' {
   interface ComponentCustomProperties {
     readonly EffectScope: UnwrapRef<(typeof import('vue'))['EffectScope']>
     readonly ElMessage: UnwrapRef<(typeof import('element-plus/es'))['ElMessage']>
-    readonly ElMessageBox: UnwrapRef<(typeof import('element-plus/es'))['ElMessageBox']>
     readonly acceptHMRUpdate: UnwrapRef<(typeof import('pinia'))['acceptHMRUpdate']>
     readonly asyncComputed: UnwrapRef<(typeof import('@vueuse/core'))['asyncComputed']>
     readonly autoResetRef: UnwrapRef<(typeof import('@vueuse/core'))['autoResetRef']>

+ 23 - 6
src/views/system/role/components/PermissionsDrawer.vue

@@ -165,18 +165,35 @@ const getPermissions = (roleId: string) => {
 }
 
 const handelAllPermissions = (allPerms: PermissionsVO[], hasPerms: string[]) => {
+  const itemMap = ref(new Map<string, boolean>())
+  const parentMapCount = ref(new Map<string, number>())
+  const itemMapCount = ref(new Map<string, number>())
+  const nameCount = ref(0)
+  const count = ref(0)
   mergeData.value = allPerms.map(item => {
-    return { ...item, parentCheck: false, itemCheck: false }
-  })
-
-  mergeData.value.forEach(perm => {
+    if (!parentMapCount.value.get(item.moduleName)) {
+      nameCount.value = 0
+    }
+    parentMapCount.value.set(item.moduleName, ++nameCount.value)
     if (hasPerms.length > 0) {
       hasPerms.forEach(permId => {
-        if (perm.id === permId) {
-          perm.itemCheck = true
+        if (item.id === permId) {
+          itemMap.value.set(item.id, true)
+          if (!itemMapCount.value.get(item.moduleName)) {
+            count.value = 0
+          }
+          itemMapCount.value.set(item.moduleName, ++count.value)
         }
       })
     }
+    return {
+      ...item,
+      parentCheck: false,
+      itemCheck: itemMap.value.get(item.id) || false
+    }
+  })
+  mergeData.value.forEach(item => {
+    item.parentCheck = parentMapCount.value.get(item.moduleName) === itemMapCount.value.get(item.moduleName)
   })
 }