fix(components): 修复菜单树选择组件
This commit is contained in:
parent
94f183e7b5
commit
bbda803e90
@ -90,16 +90,23 @@ function handleCheckedTreeNodeAll(checked: boolean) {
|
|||||||
checkedKeys.value = [];
|
checkedKeys.value = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCheckedMenuIds() {
|
function getCheckedMenuIds(isCascade: boolean = false) {
|
||||||
const menuIds = menuTreeRef.value?.getCheckedData()?.keys as string[];
|
const menuIds = menuTreeRef.value?.getCheckedData()?.keys as string[];
|
||||||
const indeterminateData = menuTreeRef.value?.getIndeterminateData();
|
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[];
|
const parentIds: string[] = indeterminateData?.keys.filter(item => !menuIds?.includes(String(item))) as string[];
|
||||||
menuIds?.push(...parentIds);
|
menuIds?.push(...parentIds);
|
||||||
}
|
}
|
||||||
return menuIds;
|
return menuIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
watch(cascade, () => {
|
||||||
|
if (cascade.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
checkedKeys.value = getCheckedMenuIds(true);
|
||||||
|
});
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
getCheckedMenuIds,
|
getCheckedMenuIds,
|
||||||
refresh: getMenuList
|
refresh: getMenuList
|
||||||
@ -121,6 +128,7 @@ defineExpose({
|
|||||||
<NCheckbox v-model:checked="cascade" :checked-value="true" :unchecked-value="false">父子联动</NCheckbox>
|
<NCheckbox v-model:checked="cascade" :checked-value="true" :unchecked-value="false">父子联动</NCheckbox>
|
||||||
</div>
|
</div>
|
||||||
<NSpin class="resource h-full w-full py-6px pl-3px" content-class="h-full" :show="loading">
|
<NSpin class="resource h-full w-full py-6px pl-3px" content-class="h-full" :show="loading">
|
||||||
|
{{ checkedKeys }}
|
||||||
<NTree
|
<NTree
|
||||||
ref="menuTreeRef"
|
ref="menuTreeRef"
|
||||||
v-model:checked-keys="checkedKeys"
|
v-model:checked-keys="checkedKeys"
|
||||||
|
@ -82,7 +82,7 @@ const {
|
|||||||
key: 'dataScope',
|
key: 'dataScope',
|
||||||
title: '数据范围',
|
title: '数据范围',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
minWidth: 120,
|
minWidth: 180,
|
||||||
render: row => {
|
render: row => {
|
||||||
return <NTag type="info">{dataScopeRecord[row.dataScope]}</NTag>;
|
return <NTag type="info">{dataScopeRecord[row.dataScope]}</NTag>;
|
||||||
}
|
}
|
||||||
@ -113,7 +113,7 @@ const {
|
|||||||
key: 'operate',
|
key: 'operate',
|
||||||
title: $t('common.operate'),
|
title: $t('common.operate'),
|
||||||
align: 'center',
|
align: 'center',
|
||||||
width: 220,
|
width: 230,
|
||||||
render: row => {
|
render: row => {
|
||||||
if (row.roleId === 1) return null;
|
if (row.roleId === 1) return null;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user