fix(frontend): 修复角色菜单回显时父节点级联勾选所有子节点

This commit is contained in:
wcg
2026-05-06 12:27:08 +08:00
parent 4e61f18d8c
commit b8802e7d20
@@ -13,7 +13,7 @@ import type { MenuOption } from '#/api/system/menu/model';
import { nextTick, onMounted, ref, shallowRef, watch } from 'vue'; import { nextTick, onMounted, ref, shallowRef, watch } from 'vue';
import { cloneDeep, findGroupParentIds } from '@vben/utils'; import { cloneDeep } from '@vben/utils';
import { Alert, Checkbox, RadioGroup, Space } from 'ant-design-vue'; import { Alert, Checkbox, RadioGroup, Space } from 'ant-design-vue';
import { uniq } from 'lodash-es'; import { uniq } from 'lodash-es';
@@ -320,15 +320,7 @@ function getCheckedKeys() {
const records = tableApi?.grid?.getCheckboxRecords?.(true) ?? []; const records = tableApi?.grid?.getCheckboxRecords?.(true) ?? [];
// 子节点 // 子节点
const nodeKeys = getKeys(records, true); const nodeKeys = getKeys(records, true);
// 所有父节点 return uniq(nodeKeys);
// Note: findGroupParentIds is typed for number[] but works with strings at runtime
const parentIds = findGroupParentIds(
props.menus,
nodeKeys as any,
) as (string | number)[];
// 拼接 去重
const realKeys = uniq([...parentIds, ...nodeKeys]);
return realKeys;
} }
// 节点独立 // 节点独立