diff --git a/apps/web-antd/src/api/system/menu/index.ts b/apps/web-antd/src/api/system/menu/index.ts new file mode 100644 index 000000000..c5c03d0dc --- /dev/null +++ b/apps/web-antd/src/api/system/menu/index.ts @@ -0,0 +1,52 @@ +import { requestClient } from '#/api/request'; + +export namespace SystemMenuApi { + /** 菜单信息 */ + export interface MenuVO { + id: number; + name: string; + permission: string; + type: number; + sort: number; + parentId: number; + path: string; + icon: string; + component: string; + componentName?: string; + status: number; + visible: boolean; + keepAlive: boolean; + alwaysShow?: boolean; + createTime: Date; + } +} + +/** 查询菜单(精简)列表 */ +export async function getSimpleMenusList() { + return requestClient.get('/system/menu/simple-list'); +} + +/** 查询菜单列表 */ +export async function getMenuList(params?: Record) { + return requestClient.get('/system/menu/list', { params }); +} + +/** 获取菜单详情 */ +export async function getMenu(id: number) { + return requestClient.get(`/system/menu/get?id=${id}`); +} + +/** 新增菜单 */ +export async function createMenu(data: SystemMenuApi.MenuVO) { + return requestClient.post('/system/menu/create', data); +} + +/** 修改菜单 */ +export async function updateMenu(data: SystemMenuApi.MenuVO) { + return requestClient.put('/system/menu/update', data); +} + +/** 删除菜单 */ +export async function deleteMenu(id: number) { + return requestClient.delete(`/system/menu/delete?id=${id}`); +} diff --git a/apps/web-antd/src/views/system/role/data.ts b/apps/web-antd/src/views/system/role/data.ts index 058ac74d5..dacfb8615 100644 --- a/apps/web-antd/src/views/system/role/data.ts +++ b/apps/web-antd/src/views/system/role/data.ts @@ -114,6 +114,44 @@ export function useAssignDataPermissionFormSchema(): VbenFormSchema[] { ]; } +/** 分配菜单的表单 */ +export function useAssignMenuFormSchema(): VbenFormSchema[] { + return [ + { + component: 'Input', + fieldName: 'id', + label: 'id', + dependencies: { + triggerFields: [''], + show: () => false, + }, + }, + { + component: 'Input', + fieldName: 'name', + label: '角色名称', + componentProps: { + disabled: true, + }, + }, + { + component: 'Input', + fieldName: 'code', + label: '角色标识', + componentProps: { + disabled: true, + }, + }, + { + component: 'Input', + fieldName: 'menuIds', + label: '菜单权限', + formItemClass: 'items-start', + modelPropName: 'modelValue', // TODO @芋艿:这个是不是可以去掉哈 + }, + ]; +} + /** 列表的搜索表单 */ export function useGridFormSchema(): VbenFormSchema[] { return [ @@ -214,14 +252,16 @@ export function useGridColumns( code: 'assign-data-permission', text: '数据权限', }, + { + code: 'assign-menu', + text: '菜单权限', + } ], }, field: 'operation', fixed: 'right', title: '操作', - width: 220, + width: 240, }, ]; -} - -// TODO @芋艿:角色分配 +} \ No newline at end of file diff --git a/apps/web-antd/src/views/system/role/index.vue b/apps/web-antd/src/views/system/role/index.vue index eaf0f9d30..b4a78f271 100644 --- a/apps/web-antd/src/views/system/role/index.vue +++ b/apps/web-antd/src/views/system/role/index.vue @@ -16,6 +16,7 @@ import { Plus, Download } from '@vben/icons'; import { useGridColumns, useGridFormSchema } from './data'; import Form from './modules/form.vue'; import AssignDataPermissionForm from './modules/assign-data-permission-form.vue'; +import AssignMenuForm from '#/views/system/role/modules/assign-menu-form.vue'; import { downloadByData } from '#/utils/download'; const [FormModal, formModalApi] = useVbenModal({ @@ -28,6 +29,11 @@ const [AssignDataPermissionFormModel, assignDataPermissionFormApi] = useVbenModa destroyOnClose: true, }); +const [AssignMenuFormModel, assignMenuFormApi] = useVbenModal({ + connectedComponent: AssignMenuForm, + destroyOnClose: true, +}) + /** 编辑角色 */ function onEdit(row: SystemRoleApi.SystemRole) { formModalApi.setData(row).open(); @@ -62,6 +68,11 @@ function onAssignDataPermission(row: SystemRoleApi.SystemRole) { assignDataPermissionFormApi.setData(row).open(); } +/** 分配角色的菜单权限 */ +function onAssignMenu(row: SystemRoleApi.SystemRole) { + assignMenuFormApi.setData(row).open(); +} + /** 表格操作按钮的回调函数 */ function onActionClick({ code, @@ -80,6 +91,10 @@ function onActionClick({ onAssignDataPermission(row); break; } + case 'assign-menu': { + onAssignMenu(row); + break; + } } } @@ -129,6 +144,7 @@ async function onExport() { +