feat: 整合动态路由

This commit is contained in:
xlsea
2024-09-03 15:27:10 +08:00
parent 8ab7ee2268
commit 0130688265
6 changed files with 71 additions and 15 deletions

View File

@ -49,14 +49,15 @@ const getMeunTree = async () => {
getMeunTree();
async function handleSubmitted() {
getMeunTree();
async function handleSubmitted(menuType?: Api.System.MenuType) {
if (menuType === 'F') {
await getBtnMenuList();
return;
}
await getMeunTree();
if (operateType.value === 'edit') {
currentMenu.value = menuTreeRef.value?.getCheckedData().options[0] as Api.System.Menu;
}
if (createType.value === 'F') {
getBtnMenuList();
}
}
function handleAddMenu(pid: CommonType.IdType) {
@ -83,7 +84,7 @@ async function handleDeleteMenu(id?: CommonType.IdType) {
expandedKeys.value.filter(item => !checkedKeys.value.includes(item));
currentMenu.value = undefined;
checkedKeys.value = [];
getBtnMenuList();
getMeunTree();
}
function renderPrefix({ option }: { option: TreeOption }) {
@ -339,7 +340,7 @@ const btnColumns: DataTableColumns<Api.System.Menu> = [
</NButton>
<NPopconfirm @positive-click="() => handleDeleteMenu()">
<template #trigger>
<NButton size="small" ghost type="error">
<NButton size="small" ghost type="error" :disabled="btnData.length > 0 || btnLoading">
<template #icon>
<icon-ic-round-delete />
</template>

View File

@ -30,7 +30,7 @@ interface Props {
const props = defineProps<Props>();
interface Emits {
(e: 'submitted'): void;
(e: 'submitted', menuType?: Api.System.MenuType): void;
}
const emit = defineEmits<Emits>();
@ -136,7 +136,10 @@ async function handleSubmit() {
remark
} = model;
const path = !model.path?.startsWith('/') ? `/${model.path}` : model.path;
let path = model.path;
if (model.isFrame === '1') {
path = !model.path?.startsWith('/') ? `/${model.path}` : model.path;
}
let icon;
if (model.icon) {
@ -206,7 +209,7 @@ async function handleSubmit() {
}
closeDrawer();
emit('submitted');
emit('submitted', menuType);
}
watch(visible, () => {
@ -265,7 +268,13 @@ const FormTipComponent = defineComponent({
</NFormItemGi>
<NFormItemGi v-if="menuType !== 'F'" :span="24" label="菜单类型" path="menuType">
<NRadioGroup v-model:value="model.menuType">
<NRadioButton v-for="item in menuTypeOptions" :key="item.value" :value="item.value" :label="item.label" />
<NRadioButton
v-for="item in menuTypeOptions"
v-show="item.value !== 'F'"
:key="item.value"
:value="item.value"
:label="item.label"
/>
</NRadioGroup>
</NFormItemGi>
<NFormItemGi :span="24" label="菜单名称" path="menuName">