Merge 301008d876
into 38db7196c7
commit
84e68e0357
|
@ -0,0 +1,14 @@
|
||||||
|
export function filterTree<T extends { children: T[] | undefined }>(tree: T[], iterate: (item: T, index: number) => boolean): T[] {
|
||||||
|
function filter(tree: T[]): T[] {
|
||||||
|
return tree.filter((item, index) => {
|
||||||
|
if (!iterate(item, index)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (item.children && item.children.length > 0) {
|
||||||
|
item.children = filter(item.children);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return filter(tree);
|
||||||
|
}
|
|
@ -10,6 +10,8 @@
|
||||||
import {BasicDrawer, useDrawerInner} from '/@/components/Drawer';
|
import {BasicDrawer, useDrawerInner} from '/@/components/Drawer';
|
||||||
import {list, saveOrUpdateMenu} from './menu.api';
|
import {list, saveOrUpdateMenu} from './menu.api';
|
||||||
import { useAdapt } from '/@/hooks/system/useAutoAdapt.ts';
|
import { useAdapt } from '/@/hooks/system/useAutoAdapt.ts';
|
||||||
|
import { filterTree } from '/@/utils/tree';
|
||||||
|
|
||||||
// 声明Emits
|
// 声明Emits
|
||||||
const emit = defineEmits(['success', 'register']);
|
const emit = defineEmits(['success', 'register']);
|
||||||
const {width}= useAdapt();
|
const {width}= useAdapt();
|
||||||
|
@ -36,8 +38,15 @@
|
||||||
isUpdate.value = !!data?.isUpdate;
|
isUpdate.value = !!data?.isUpdate;
|
||||||
menuType.value = data?.record?.menuType;
|
menuType.value = data?.record?.menuType;
|
||||||
|
|
||||||
|
// 获取当前 record 的 id
|
||||||
|
const currentId = data?.record?.id;
|
||||||
|
|
||||||
//获取下拉树信息
|
//获取下拉树信息
|
||||||
const treeData = await list();
|
let treeData = await list();
|
||||||
|
if (currentId) {
|
||||||
|
treeData = filterTree(treeData, (item: any) => item.id !== currentId);
|
||||||
|
}
|
||||||
|
|
||||||
updateSchema([{
|
updateSchema([{
|
||||||
field: 'parentId',
|
field: 'parentId',
|
||||||
componentProps: {treeData},
|
componentProps: {treeData},
|
||||||
|
|
Loading…
Reference in New Issue