feat: 添加子菜单
This commit is contained in:
parent
93912efc67
commit
3551292619
@ -131,7 +131,7 @@ export const columns: VxeGridProps['columns'] = [
|
|||||||
fixed: 'right',
|
fixed: 'right',
|
||||||
slots: { default: 'action' },
|
slots: { default: 'action' },
|
||||||
title: '操作',
|
title: '操作',
|
||||||
width: 180,
|
width: 200,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -100,6 +100,12 @@ function handleAdd() {
|
|||||||
drawerApi.open();
|
drawerApi.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleSubAdd(row: Recordable<any>) {
|
||||||
|
const { menuId } = row;
|
||||||
|
drawerApi.setData({ id: menuId, update: false });
|
||||||
|
drawerApi.open();
|
||||||
|
}
|
||||||
|
|
||||||
async function handleEdit(record: Recordable<any>) {
|
async function handleEdit(record: Recordable<any>) {
|
||||||
drawerApi.setData({ id: record.menuId });
|
drawerApi.setData({ id: record.menuId });
|
||||||
drawerApi.open();
|
drawerApi.open();
|
||||||
@ -165,6 +171,15 @@ const isAdmin = computed(() => {
|
|||||||
>
|
>
|
||||||
{{ $t('pages.common.edit') }}
|
{{ $t('pages.common.edit') }}
|
||||||
</ghost-button>
|
</ghost-button>
|
||||||
|
<!-- '按钮类型'无法再添加子菜单 -->
|
||||||
|
<ghost-button
|
||||||
|
v-if="row.menuType !== 'F'"
|
||||||
|
class="btn-add"
|
||||||
|
v-access:code="['system:menu:add']"
|
||||||
|
@click="handleSubAdd(row)"
|
||||||
|
>
|
||||||
|
{{ $t('pages.common.add') }}
|
||||||
|
</ghost-button>
|
||||||
<Popconfirm
|
<Popconfirm
|
||||||
:get-popup-container="getPopupContainer"
|
:get-popup-container="getPopupContainer"
|
||||||
placement="left"
|
placement="left"
|
||||||
@ -186,3 +201,15 @@ const isAdmin = computed(() => {
|
|||||||
</Page>
|
</Page>
|
||||||
<Fallback v-else description="您没有菜单管理的访问权限" status="403" />
|
<Fallback v-else description="您没有菜单管理的访问权限" status="403" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.btn-add {
|
||||||
|
color: hsl(var(--success)) !important;
|
||||||
|
border-color: hsl(var(--success)) !important;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
color: hsl(var(--success) / 50%) !important;
|
||||||
|
border-color: hsl(var(--success) / 50%) !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
@ -15,6 +15,11 @@ import { menuAdd, menuInfo, menuList, menuUpdate } from '#/api/system/menu';
|
|||||||
|
|
||||||
import { drawerSchema } from './data';
|
import { drawerSchema } from './data';
|
||||||
|
|
||||||
|
interface ModalProps {
|
||||||
|
id?: number | string;
|
||||||
|
update: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
const emit = defineEmits<{ reload: [] }>();
|
const emit = defineEmits<{ reload: [] }>();
|
||||||
|
|
||||||
const isUpdate = ref(false);
|
const isUpdate = ref(false);
|
||||||
@ -28,6 +33,7 @@ const [BasicForm, formApi] = useVbenForm({
|
|||||||
class: 'w-full',
|
class: 'w-full',
|
||||||
},
|
},
|
||||||
formItemClass: 'col-span-2',
|
formItemClass: 'col-span-2',
|
||||||
|
labelWidth: 90,
|
||||||
},
|
},
|
||||||
schema: drawerSchema(),
|
schema: drawerSchema(),
|
||||||
showDefaultActions: false,
|
showDefaultActions: false,
|
||||||
@ -81,13 +87,17 @@ const [BasicDrawer, drawerApi] = useVbenDrawer({
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
drawerApi.drawerLoading(true);
|
drawerApi.drawerLoading(true);
|
||||||
const { id } = drawerApi.getData() as { id?: number | string };
|
const { id, update } = drawerApi.getData() as ModalProps;
|
||||||
isUpdate.value = !!id;
|
isUpdate.value = update;
|
||||||
|
|
||||||
// 加载菜单树选择
|
// 加载菜单树选择
|
||||||
await setupMenuSelect();
|
await setupMenuSelect();
|
||||||
if (isUpdate.value && id) {
|
if (id) {
|
||||||
const record = await menuInfo(id);
|
await formApi.setFieldValue('parentId', id);
|
||||||
await formApi.setValues(record);
|
if (update) {
|
||||||
|
const record = await menuInfo(id);
|
||||||
|
await formApi.setValues(record);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
drawerApi.drawerLoading(false);
|
drawerApi.drawerLoading(false);
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user