refactor: menu
This commit is contained in:
parent
1a10f30de3
commit
0644c46d21
@ -6,7 +6,7 @@ import { $t } from '@vben/locales';
|
|||||||
import { addFullName, getPopupContainer, listToTree } from '@vben/utils';
|
import { addFullName, getPopupContainer, listToTree } from '@vben/utils';
|
||||||
|
|
||||||
import { useVbenForm } from '#/adapter';
|
import { useVbenForm } from '#/adapter';
|
||||||
import { menuAdd, menuList, menuUpdate } from '#/api/system/menu';
|
import { menuAdd, menuInfo, menuList, menuUpdate } from '#/api/system/menu';
|
||||||
|
|
||||||
import { drawerSchema } from './data';
|
import { drawerSchema } from './data';
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ const emit = defineEmits<{ reload: [] }>();
|
|||||||
|
|
||||||
interface DrawerProps {
|
interface DrawerProps {
|
||||||
update: boolean;
|
update: boolean;
|
||||||
record?: any;
|
id?: number | string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const isUpdate = ref(false);
|
const isUpdate = ref(false);
|
||||||
@ -81,13 +81,14 @@ const [BasicDrawer, drawerApi] = useVbenDrawer({
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
drawerApi.drawerLoading(true);
|
drawerApi.drawerLoading(true);
|
||||||
const { record, update } = drawerApi.getData() as DrawerProps;
|
const { id, update } = drawerApi.getData() as DrawerProps;
|
||||||
isUpdate.value = update;
|
isUpdate.value = update;
|
||||||
// 加载菜单树选择
|
// 加载菜单树选择
|
||||||
await setupMenuSelect();
|
await setupMenuSelect();
|
||||||
if (update && record) {
|
if (update && id) {
|
||||||
|
const record = await menuInfo(id);
|
||||||
for (const key in record) {
|
for (const key in record) {
|
||||||
await formApi.setFieldValue(key, record[key]);
|
await formApi.setFieldValue(key, record[key as keyof typeof record]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
drawerApi.drawerLoading(false);
|
drawerApi.drawerLoading(false);
|
||||||
@ -102,7 +103,6 @@ async function handleConfirm() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const data = await formApi.getValues();
|
const data = await formApi.getValues();
|
||||||
console.log(data);
|
|
||||||
await (isUpdate.value ? menuUpdate(data) : menuAdd(data));
|
await (isUpdate.value ? menuUpdate(data) : menuAdd(data));
|
||||||
emit('reload');
|
emit('reload');
|
||||||
await handleCancel();
|
await handleCancel();
|
||||||
|
Loading…
Reference in New Issue
Block a user