feat: 菜单改造

This commit is contained in:
leiqiaochu 2023-09-20 16:37:40 +08:00
parent 03db286aab
commit 47fc37fffe
2 changed files with 7 additions and 6 deletions

View File

@ -128,21 +128,21 @@ const getProvidersFn = async () => {
} }
} }
getProvidersFn(); getProvidersFn();
function filterTree(nodes: Array<any>, selectedKeys: Array<any>) { function filterTree(nodes: Array<any>, selectedKeys: Array<any>,parentId?:string) {
const filtered = []; const filtered = [];
for (let i = 0; i < nodes.length; i++) { for (let i = 0; i < nodes.length; i++) {
const node = nodes[i]; const node = nodes[i];
if (!node.code) { if (!node.code) {
continue; continue;
} }
node.parentId = parentId ? undefined : parentId
if (selectedKeys.indexOf(node.code) !== -1) { if (selectedKeys.indexOf(node.code) !== -1) {
filtered.push(node); filtered.push(node);
if (node.children) { if (node.children) {
node.children = filterTree(node.children, selectedKeys); node.children = filterTree(node.children, selectedKeys,node.id);
} }
} else if (node.children) { } else if (node.children) {
node.children = filterTree(node.children, selectedKeys); node.children = filterTree(node.children, selectedKeys,node.id);
if (node.children.length > 0) { if (node.children.length > 0) {
filtered.push(node); filtered.push(node);
} }
@ -155,6 +155,7 @@ const handleOk = async () => {
const _dataArr = filterTree(cloneDeep(treeData.value), selectedKeys.value); const _dataArr = filterTree(cloneDeep(treeData.value), selectedKeys.value);
const _dataSorts = handleSorts(_dataArr) const _dataSorts = handleSorts(_dataArr)
loading.value = true; loading.value = true;
console.log(_dataSorts)
const res = await updateMenus(_dataSorts).catch(() => {}); const res = await updateMenus(_dataSorts).catch(() => {});
if (res?.status === 200) { if (res?.status === 200) {
onlyMessage('操作成功', 'success'); onlyMessage('操作成功', 'success');

View File

@ -53,8 +53,8 @@
<PermissionButton <PermissionButton
type="link" type="link"
:hasPermission="`${permission}:add`" :hasPermission="`${permission}:add`"
:tooltip="{ title: '新增子菜单' }" :tooltip="{ title: slotProps?.options?.LowCode ? '低码创建的菜单不支持编辑' : slotProps.level >= 3 ? '仅支持3级菜单' : '新增子菜单' }"
:disabled="slotProps.level >= 3" :disabled="slotProps.level >= 3 || slotProps?.options?.LowCode"
@click="table.addChildren(slotProps)" @click="table.addChildren(slotProps)"
> >
<AIcon type="PlusCircleOutlined" /> <AIcon type="PlusCircleOutlined" />