|
@@ -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)
|
|
|
})
|
|
|
}
|
|
|
|