79 lines
2.2 KiB
TypeScript
Raw Normal View History

2025-06-27 16:42:11 +08:00
import {
MyButtons,
MyColumns,
MyPageContainer,
MyProTableProps,
2025-07-25 16:42:54 +08:00
usePageTabs,
2025-06-27 16:42:11 +08:00
} from '@/common';
import { Apis } from '@/gen/Apis';
import { ProTable } from '@ant-design/pro-components';
import { Space, Tag } from 'antd';
import Create from './modals/Create';
import EditPermissions from './modals/EditPermissions';
import Update from './modals/Update';
export default function Index({ title = '角色' }) {
2025-07-25 16:42:54 +08:00
// 注册当前页面为标签页
usePageTabs({
tabKey: 'system-roles',
tabLabel: title,
});
2025-06-27 16:42:11 +08:00
return (
<MyPageContainer
2025-07-25 16:42:54 +08:00
title={title}
enableTabs={true}
tabKey="system-roles"
tabLabel={title}
>
2025-06-27 16:42:11 +08:00
<ProTable
{...MyProTableProps.props}
search={false}
request={async (params, sort) =>
2025-06-27 17:15:50 +08:00
MyProTableProps.request(params, sort, Apis.Permission.SysRoles.List)
2025-06-27 16:42:11 +08:00
}
toolBarRender={(action) => [
<Create key="Create" reload={action?.reload} title={title} />,
]}
columns={[
MyColumns.ID(),
{ dataIndex: 'guard_name', title: 'guard_name', search: false },
{ dataIndex: 'name', title: '名称' },
{
title: '颜色',
dataIndex: 'color',
hideInSearch: true,
renderText: (color) => <Tag color={color as string}>{color}</Tag>,
},
{
title: '配置角色权限',
hideInSearch: true,
render: (_, item, index, action) => (
<EditPermissions
item={item}
title="配置角色权限"
reload={action?.reload}
/>
),
},
MyColumns.CreatedAt(),
MyColumns.Option({
render: (_, item: any, index, action) => (
<Space key={index}>
<Update item={item} reload={action?.reload} title={title} />
<MyButtons.Delete
onConfirm={() =>
2025-06-27 17:15:50 +08:00
Apis.Permission.SysRoles.Delete({ id: item.id }).then(() =>
2025-06-27 16:42:11 +08:00
action?.reload(),
)
}
/>
</Space>
),
}),
]}
/>
</MyPageContainer>
);
}