fix: bug#16179
This commit is contained in:
parent
1b8168786e
commit
6093e544b9
|
@ -48,6 +48,7 @@
|
||||||
</template>
|
</template>
|
||||||
<!-- 表格内容 -->
|
<!-- 表格内容 -->
|
||||||
<template #bodyCell="{ column, record }">
|
<template #bodyCell="{ column, record }">
|
||||||
|
<div :id="record.id"></div>
|
||||||
<div v-if="column.key === 'menu'">
|
<div v-if="column.key === 'menu'">
|
||||||
<j-checkbox
|
<j-checkbox
|
||||||
v-model:checked="record.granted"
|
v-model:checked="record.granted"
|
||||||
|
@ -110,6 +111,7 @@ import {
|
||||||
USER_CENTER_MENU_CODE
|
USER_CENTER_MENU_CODE
|
||||||
} from '@/utils/consts'
|
} from '@/utils/consts'
|
||||||
import { isNoCommunity } from '@/utils/utils'
|
import { isNoCommunity } from '@/utils/utils'
|
||||||
|
import {useIndirectMenusMap} from "@/views/system/Role/Detail/components/util";
|
||||||
|
|
||||||
const emits = defineEmits(['update:selectItems']);
|
const emits = defineEmits(['update:selectItems']);
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
@ -270,6 +272,8 @@ const init = () => {
|
||||||
};
|
};
|
||||||
init();
|
init();
|
||||||
|
|
||||||
|
const { PermissionsMap } = useIndirectMenusMap(tableData)
|
||||||
|
|
||||||
function getAllPermiss() {
|
function getAllPermiss() {
|
||||||
const id = route.params.id as string;
|
const id = route.params.id as string;
|
||||||
getPrimissTree_api(id).then((resp) => {
|
getPrimissTree_api(id).then((resp) => {
|
||||||
|
@ -297,6 +301,16 @@ function getAllPermiss() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const hasIndirectMenus = (data: any) => {
|
||||||
|
if (data.children) {
|
||||||
|
const has = data.children.find(item => item.indirectMenus)
|
||||||
|
console.log(has)
|
||||||
|
} else if (data?.indirectMenus) {
|
||||||
|
console.log(data.indirectMenus)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜单权限改变事件
|
* 菜单权限改变事件
|
||||||
* @param row 触发的项
|
* @param row 触发的项
|
||||||
|
@ -306,7 +320,9 @@ function menuChange(
|
||||||
row: tableItemType,
|
row: tableItemType,
|
||||||
setButtonBool: boolean = true,
|
setButtonBool: boolean = true,
|
||||||
): undefined {
|
): undefined {
|
||||||
|
console.log('menuChange', row)
|
||||||
// 判断是否需要对子菜单及操作权限进行选择
|
// 判断是否需要对子菜单及操作权限进行选择
|
||||||
|
hasIndirectMenus(row)
|
||||||
if (setButtonBool) {
|
if (setButtonBool) {
|
||||||
if (row.buttons && row.buttons.length > 0)
|
if (row.buttons && row.buttons.length > 0)
|
||||||
row.buttons.forEach((button) => {
|
row.buttons.forEach((button) => {
|
||||||
|
@ -358,7 +374,7 @@ function menuChange(
|
||||||
}
|
}
|
||||||
|
|
||||||
emits('update:selectItems', selectList); // 选中的项传回父组件
|
emits('update:selectItems', selectList); // 选中的项传回父组件
|
||||||
treeRef.value.$forceUpdate();
|
proxy?.$forceUpdate?.();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
import type {Ref} from "vue";
|
||||||
|
import {watch} from "vue";
|
||||||
|
|
||||||
|
const handlePermissionsMap = (data: any, map: Map<string, any>, parentId: string[] = []) => {
|
||||||
|
data.forEach((item: any) => {
|
||||||
|
if (item.children) {
|
||||||
|
handlePermissionsMap(item.children,map, parentId.concat(item.id) )
|
||||||
|
} else {
|
||||||
|
map.set(item.id, {
|
||||||
|
parentIds: parentId,
|
||||||
|
name: item.name
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export const useIndirectMenusMap = (tableData: Ref<any[]>) => {
|
||||||
|
const PermissionsMap = ref<Map<string, any>>(new Map())
|
||||||
|
|
||||||
|
watch(() => tableData.value, () => {
|
||||||
|
PermissionsMap.value.clear()
|
||||||
|
if (tableData.value?.length) {
|
||||||
|
handlePermissionsMap(tableData.value, PermissionsMap.value)
|
||||||
|
}
|
||||||
|
}, { immediate: true})
|
||||||
|
|
||||||
|
return {
|
||||||
|
PermissionsMap
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue