feat: 开放设备预约和我的预约页面给团队负责人和设备管理员,添加菜单栏排序功能
This commit is contained in:
parent
31146a7b6b
commit
09534937dc
@ -1,5 +1,6 @@
|
||||
import {
|
||||
ApartmentOutlined,
|
||||
ContainerOutlined,
|
||||
DesktopOutlined,
|
||||
ExperimentOutlined,
|
||||
FileDoneOutlined,
|
||||
@ -14,13 +15,15 @@ const menuConfig = [
|
||||
path: "/user/reserve",
|
||||
label: "设备预约",
|
||||
icon: DesktopOutlined,
|
||||
roles: ["USER"],
|
||||
roles: ["USER", "LEADER", "DEVICE_ADMIN"],
|
||||
order: 4,
|
||||
},
|
||||
{
|
||||
path: "/user/my-reservation",
|
||||
label: "我的预约",
|
||||
icon: UnorderedListOutlined,
|
||||
roles: ["USER"],
|
||||
icon: ContainerOutlined,
|
||||
roles: ["USER", "LEADER", "DEVICE_ADMIN"],
|
||||
order: 5,
|
||||
},
|
||||
|
||||
{
|
||||
@ -28,36 +31,43 @@ const menuConfig = [
|
||||
label: "预约审批",
|
||||
icon: FileDoneOutlined,
|
||||
roles: ["LEADER", "DEVICE_ADMIN"],
|
||||
order: 1,
|
||||
},
|
||||
{
|
||||
path: "/my-approval",
|
||||
label: "审批记录",
|
||||
icon: UnorderedListOutlined,
|
||||
roles: ["LEADER", "DEVICE_ADMIN"],
|
||||
order: 2,
|
||||
},
|
||||
{
|
||||
path: "/device-manage",
|
||||
label: "设备管理",
|
||||
icon: ExperimentOutlined,
|
||||
roles: ["DEVICE_ADMIN"],
|
||||
order: 3,
|
||||
},
|
||||
{
|
||||
path: "/admin/user-manage",
|
||||
label: "用户管理",
|
||||
icon: UsergroupAddOutlined,
|
||||
roles: ["ADMIN"],
|
||||
order: 1,
|
||||
},
|
||||
{
|
||||
label: "数据统计",
|
||||
icon: PieChartOutlined,
|
||||
order: 2,
|
||||
children: [
|
||||
{
|
||||
path: "/admin/stats-device",
|
||||
label: "设备统计",
|
||||
order: 1,
|
||||
},
|
||||
{
|
||||
path: "/admin/stats-reservation",
|
||||
label: "使用人统计",
|
||||
order: 2,
|
||||
},
|
||||
],
|
||||
roles: ["ADMIN"],
|
||||
@ -67,12 +77,14 @@ const menuConfig = [
|
||||
icon: ApartmentOutlined,
|
||||
label: "团队管理",
|
||||
roles: ["ADMIN"],
|
||||
order: 3,
|
||||
},
|
||||
{
|
||||
path: "/userdetail",
|
||||
label: "个人信息",
|
||||
icon: UserOutlined,
|
||||
roles: ["USER", "LEADER", "DEVICE_ADMIN", "ADMIN"],
|
||||
order: 999,
|
||||
},
|
||||
];
|
||||
|
||||
|
@ -44,8 +44,18 @@ export default function CommonLayout() {
|
||||
}
|
||||
};
|
||||
|
||||
// 递归排序函数
|
||||
const sortMenu = (menu) => {
|
||||
return [...menu]
|
||||
.sort((a, b) => (a.order ?? 999) - (b.order ?? 999))
|
||||
.map((item) => ({
|
||||
...item,
|
||||
children: item.children ? sortMenu(item.children) : undefined,
|
||||
}));
|
||||
};
|
||||
|
||||
const buildMenuItems = (menu) =>
|
||||
menu.map((item) => {
|
||||
sortMenu(menu).map((item) => {
|
||||
if (item.children) {
|
||||
return {
|
||||
key: item.label, // 可改为 item.path 但注意不冲突
|
||||
|
@ -28,7 +28,9 @@ const router = createBrowserRouter([
|
||||
children: [
|
||||
{
|
||||
path: "user",
|
||||
element: <ProtectedRoute allowedRoles={["USER"]} />,
|
||||
element: (
|
||||
<ProtectedRoute allowedRoles={["USER", "LEADER", "DEVICE_ADMIN"]} />
|
||||
),
|
||||
children: [
|
||||
{
|
||||
path: "reserve",
|
||||
|
Loading…
x
Reference in New Issue
Block a user