feat: RBAC权限管理

This commit is contained in:
2025-03-10 23:55:10 +08:00
parent cbd06dcf54
commit e7bd916cae
13 changed files with 142 additions and 110 deletions

View File

@@ -27,8 +27,8 @@ export function getColumns(callback: (type: TableOptions, record: any) => Promis
align: 'center',
},
{
title: '菜单url',
dataIndex: 'url',
title: '菜单path',
dataIndex: 'path',
align: 'center',
},
{

View File

@@ -88,8 +88,8 @@ export default function FormComponent(props: Props) {
<Form.Item label="菜单名称" field="name" rules={[{required: true}]}>
<Input placeholder="请输入菜单名称"/>
</Form.Item>
<Form.Item label="菜单url" field="url" rules={[{required: true}]}>
<Input placeholder="请输入菜单url"/>
<Form.Item label="菜单path" field="path" rules={[{required: true}]}>
<Input placeholder="请输入菜单path"/>
</Form.Item>
<Form.Item label="排序" field="sort">
<InputNumber placeholder="请输入排序"/>

View File

@@ -20,7 +20,7 @@ function GrantPermission(props: Props) {
try {
setConfirmLoading(true);
const values = await form.validate();
await grantPermission(values.id, checkedKeys.map(item=>Number(item)));
await grantPermission(values.id, checkedKeys);
Message.success(`操作成功!`);
handleConfirm();
} catch (e) {
@@ -41,13 +41,12 @@ function GrantPermission(props: Props) {
const [handleFinished, setHandleFinished] = useState(false);
const handleMenuAndKeys = (menu, menuIds) => {
let newMenuIds = menuIds.map((menuId) => menuId.toString());
let newMenuIds = menuIds.map((menuId) => menuId);
function handleMenu(_menu) {
_menu.forEach((item) => {
// 组件需要的key必须为string
item.id = item.id.toString();
item.parentId = item.id.toString();
item.parentId = item.id;
if (item.children?.length > 0) {
if (item.children.some(child => !newMenuIds.includes(child.id))) {

View File

@@ -15,7 +15,7 @@ export type IRoute = AuthParams & {
const generatorMenu = (data, parentId = '-') => {
const menu = [];
for (const item of data) {
item.key = item.url;
item.key = item.path;
if ((item.parentId || '-') === parentId) {
const children = generatorMenu(data, item.id);
if (children.length) {