fix(components): 修复菜单树选择组件

This commit is contained in:
xlsea 2025-06-10 11:05:50 +08:00
parent 94f183e7b5
commit bbda803e90
2 changed files with 12 additions and 4 deletions

View File

@ -90,16 +90,23 @@ function handleCheckedTreeNodeAll(checked: boolean) {
checkedKeys.value = [];
}
function getCheckedMenuIds() {
function getCheckedMenuIds(isCascade: boolean = false) {
const menuIds = menuTreeRef.value?.getCheckedData()?.keys as string[];
const indeterminateData = menuTreeRef.value?.getIndeterminateData();
if (cascade.value) {
if (cascade.value || isCascade) {
const parentIds: string[] = indeterminateData?.keys.filter(item => !menuIds?.includes(String(item))) as string[];
menuIds?.push(...parentIds);
}
return menuIds;
}
watch(cascade, () => {
if (cascade.value) {
return;
}
checkedKeys.value = getCheckedMenuIds(true);
});
defineExpose({
getCheckedMenuIds,
refresh: getMenuList
@ -121,6 +128,7 @@ defineExpose({
<NCheckbox v-model:checked="cascade" :checked-value="true" :unchecked-value="false">父子联动</NCheckbox>
</div>
<NSpin class="resource h-full w-full py-6px pl-3px" content-class="h-full" :show="loading">
{{ checkedKeys }}
<NTree
ref="menuTreeRef"
v-model:checked-keys="checkedKeys"

View File

@ -82,7 +82,7 @@ const {
key: 'dataScope',
title: '数据范围',
align: 'center',
minWidth: 120,
minWidth: 180,
render: row => {
return <NTag type="info">{dataScopeRecord[row.dataScope]}</NTag>;
}
@ -113,7 +113,7 @@ const {
key: 'operate',
title: $t('common.operate'),
align: 'center',
width: 220,
width: 230,
render: row => {
if (row.roleId === 1) return null;