123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513 |
- import {
- AppstoreOutlined,
- ContainerOutlined,
- DesktopOutlined,
- MailOutlined,
- MenuFoldOutlined,
- MenuUnfoldOutlined,
- PieChartOutlined,
- } from "@ant-design/icons";
- import { Navigate } from "react-router-dom";
- import AuthLayout from "@/layouts/AuthLayout";
- import Container from "@/layouts/Container";
- import Login from "@/pages/login";
- import Page404 from "@/pages/404";
- import Home from "@/pages/sample/home";
- import BasicForm from "@/pages/sample/form";
- import BasicTable from "@/pages/sample/table";
- import GuaranteeTaskList from "@/pages/guaranteeTask";
- import GuaranteeTaskEdit from "@/pages/guaranteeTask/Edit";
- import GuaranteeTaskPrint from "@/pages/guaranteeTask/print";
- import GuaranteeTaskEvaluate from "@/pages/evaluate";
- import GuaranteeTaskEvaluateList from "@/pages/evaluate/evaluateList";
- import DishList from "@/pages/dish/list";
- import DishEdit from "@/pages/dish/edit";
- import PackageList from "@/pages/package";
- import StockList from "@/pages/stock/list";
- import StockEdit from "@/pages/stock/edit";
- import StockInOut from "@/pages/stock/outAndIn";
- import StockLog from "@/pages/stock/stockLog";
- import StockClassificationList from "@/pages/stockClassification/list";
- import StockClassificationEdit from "@/pages/stockClassification/edit";
- import RotationChartList from "@/pages/rotationChart/list";
- import RotationChartEdit from "@/pages/rotationChart/edit";
- import RotationChartIntroduction from "@/pages/rotationChart/introduction";
- import RotationChartIntroductionEdit from "@/pages/rotationChart/introduction/edit";
- import RotationChartDetail from "@/pages/rotationChart/detail";
- import Roles from "@/pages/roles/index";
- import RegulationList from "@/regulation";
- import RegulationEdit from "@/regulation/edit";
- import UserList from "@/pages/user";
- import UserEdit from "@/pages/user/Edit";
- import PurchasePlanList from "@/pages/purchase/plan/list";
- import PurchasePlanEdit from "@/pages/purchase/plan/edit";
- import PurchaseBillEdit from "@/pages/purchase/bill/edit";
- import PurchaseInStoreEdit from "@/pages/purchase/inStore/edit";
- import EmergencyPlanList from "@/pages/cms/emergencyPlan/list";
- import EmergencyPlanEdit from "@/pages/cms/emergencyPlan/edit";
- import EmergencyPlanDetail from "@/pages/cms/emergencyPlan/detail";
- import FilesList from "@/pages/cms/files/list";
- import MessageList from "@/pages/message";
- import MessageDetail from "@/pages/message/detail";
- import StatisCharts from "@/pages/statis/charts";
-
- /**
- * meta 用来扩展自定义数据数据
- * {
- * title: 用于页面或者菜单的标题, 没有此字段, 菜单不会显示
- * hideInMenu: 布尔值, 如果为 false, 菜单不会显示
- * noLayout: 布尔值, 如果为 true, 将不会使用默认布局
- * noSiderBar: 布尔值, 如果为 true, 将没有左侧菜单栏
- * noFooter: 布尔值, 如果为 true, 将没有底部 footer
- * target: 字符串, 如果为 _blank, 将在新窗口打开
- * permission: 对应服务器端权限名称
- * }
- */
-
- export const authRoutes = [
- {
- path: "static",
- element: <StatisCharts />,
- meta: {
- title: "数据分析",
- noSiderBar: true,
- noFooter: true,
- permission: 'static',
- },
- },
- {
- path: "task",
- element: <Container />,
- meta: {
- title: "军供任务",
- permission: 'task',
- },
- children: [
- {
- index: true,
- element: <Navigate to="guaranteeTask" replace />,
- },
- {
- path: "guaranteeTask",
- element: <GuaranteeTaskList />,
- meta: {
- title: "军供通报",
- permission: 'guaranteeTask',
- },
- },
- {
- path: "guaranteeTask/edit",
- element: <GuaranteeTaskEdit />,
- meta: {
- title: "任务配置",
- permission: 'guaranteeTask.edit',
- },
- },
- {
- path: "guaranteeTask/print",
- element: <GuaranteeTaskPrint />,
- meta: {
- hideInMenu: true,
- noLayout: true,
- target: "_blank",
- title: "任务执行",
- permission: 'guaranteeTask.print',
- },
- },
- {
- path: "evaluate",
- element: <GuaranteeTaskEvaluate />,
- meta: {
- title: "任务评价",
- permission: 'guaranteeTask.evaluate',
- },
- },
- {
- path: "evaluate/list",
- element: <GuaranteeTaskEvaluateList />,
- meta: {
- title: "任务评价",
- hideInMenu: true,
- permission: 'guaranteeTask.evaluate.list',
- },
- },
- ],
- },
- {
- path: "stock",
- element: <Container />,
- meta: {
- title: "库存物资",
- permission: 'stock',
- },
- children: [
- {
- index: true,
- element: <Navigate to="dish/list" replace />,
- },
- {
- path: "dish/list",
- element: <DishList />,
- meta: {
- title: "菜肴管理",
- permission: 'dish',
- },
- },
- {
- path: "dish/edit",
- element: <DishEdit />,
- meta: {
- hideInMenu: true,
- title: "菜肴维护",
- permission: 'dish.edit',
- },
- },
- {
- path: "package/list",
- element: <PackageList />,
- meta: {
- title: "套餐管理",
- permission: 'package',
- },
- },
- {
- path: "list",
- element: <StockList />,
- meta: {
- title: "库存列表",
- permission: 'stock.list',
- },
- },
- {
- path: "add",
- element: <StockEdit />,
- meta: {
- title: "库存维护",
- permission: 'stock.edit',
- },
- },
- ],
- },
- {
- path: "purchase",
- element: <Container />,
- meta: {
- title: "采购管理",
- permission: 'purchase',
- },
- children: [
- {
- index: true,
- element: <Navigate to="plan/list" replace />,
- },
- {
- path: "plan/list",
- element: <PurchasePlanList type="plan" />,
- meta: {
- title: "采购计划",
- permission: 'purchase.plan',
- },
- },
- {
- path: "plan/edit",
- element: <PurchasePlanEdit />,
- meta: {
- title: "采购计划维护",
- hideInMenu: true,
- permission: 'purchase.plan.edit',
- },
- },
- {
- path: "bill/list",
- element: <PurchasePlanList type="bill" />,
- meta: {
- title: "采购账单",
- permission: 'purchase.bill',
- },
- },
- {
- path: "bill/edit",
- element: <PurchaseBillEdit />,
- meta: {
- title: "采购账单维护",
- hideInMenu: true,
- permission: 'purchase.bill.edit',
- },
- },
- {
- path: "inStore/list",
- element: <PurchasePlanList type="inStore" />,
- meta: {
- title: "采购入库",
- permission: 'purchase.instore',
- },
- },
- {
- path: "inStore/edit",
- element: <PurchaseInStoreEdit />,
- meta: {
- title: "采购详情",
- permission: 'purchase.detail',
- hideInMenu: true,
- },
- },
- ],
- },
- {
- path: "cms",
- element: <Container />,
- meta: {
- title: "公告文件",
- permission: 'cms',
- },
- children: [
- {
- index: true,
- element: <Navigate to="rotationChart/list" replace />,
- },
- {
- path: "rotationChart/introduction",
- element: <RotationChartIntroductionEdit />,
- meta: {
- title: "本站信息",
- permission: 'station',
- },
- },
- {
- path: "rotationChart/list",
- element: <RotationChartList />,
- meta: {
- title: "公告管理",
- permission: 'rotationChart',
- },
- },
- {
- path: "rotationChart/add",
- element: <RotationChartEdit />,
- meta: {
- title: "公告维护",
- hideInMenu: true,
- permission: 'rotationChart.edit',
- },
- },
- {
- path: "rotationChart/detail",
- element: <RotationChartDetail />,
- meta: {
- title: "公告详情",
- hideInMenu: true,
- permission: 'rotationChart.detail',
- },
- },
- {
- path: "regulation",
- element: <RegulationList />,
- meta: {
- title: "规章制度",
- permission: 'regulation',
- },
- },
- {
- path: "regulation/add",
- element: <RegulationEdit />,
- meta: {
- hideInMenu: true,
- title: "规章制度维护",
- permission: 'regulation.edit',
- },
- },
- {
- path: "emergency-plan",
- element: <EmergencyPlanList />,
- meta: {
- title: "应急预案",
- permission: 'emergency-plan',
- },
- },
- {
- path: "emergency-plan/edit",
- element: <EmergencyPlanEdit />,
- meta: {
- title: "应急预案维护",
- hideInMenu: true,
- permission: 'emergency-plan.edit',
- },
- },
- {
- path: "emergency-plan/detail",
- element: <EmergencyPlanDetail />,
- meta: {
- title: "应急预案详情",
- hideInMenu: true,
- permission: 'emergency-plan.detail',
- },
- },
-
- {
- path: "files",
- element: <FilesList />,
- meta: {
- title: "文件管理",
- permission: 'files',
- },
- },
- ],
- },
- {
- path: "system",
- element: <Container />,
- meta: {
- title: "系统管理",
- permission: 'system',
- },
- children: [
- {
- index: true,
- element: <Navigate to="stockClassification/list" replace />,
- },
- {
- path: DH_MONITOR,
- element: null,
- meta: {
- title: "大华监控",
- },
- },
- {
- path: DH_MONITOR,
- element: null,
- meta: {
- title: "海康监控",
- },
- },
- {
- path: "stockClassification/list",
- element: <StockClassificationList />,
- meta: {
- title: "库存分类",
- permission: 'stockClassification',
- },
- },
- {
- path: "stockClassification/edit",
- element: <StockClassificationEdit />,
- meta: {
- title: "库存分类维护",
- hideInMenu: true,
- permission: 'stockClassification.edit',
- },
- },
- {
- path: "log",
- element: <StockLog />,
- meta: {
- title: "库存日志",
- permission: 'stock.log',
- },
- },
- {
- path: "roles",
- element: <Roles />,
- meta: {
- title: "角色管理",
- permission: 'role',
- },
- },
- {
- path: "user",
- element: <UserList />,
- meta: {
- title: "用户管理",
- permission: 'user',
- },
- },
- {
- path: "user/edit",
- element: <UserEdit />,
- meta: {
- hideInMenu: true,
- title: "系统用户编辑",
- permission: 'user.edit',
- },
- },
- {
- path: "message",
- element: <MessageList />,
- meta: {
- title: "消息列表",
- permission: 'message',
- },
- },
- {
- path: "foo",
- element: null,
- meta: {
- title: "操作手册",
- },
- },
- ],
- },
- ];
-
- export const defaultRoutes = [
- {
- path: "/",
- element: <AuthLayout />,
- children: [
- {
- index: true,
- element: <Navigate to="home" replace />,
- },
- {
- path: "home",
- element: <Home />,
- meta: {
- title: "首页",
- icon: <DesktopOutlined />,
- noSiderBar: true,
- noFooter: true,
- },
- },
- {
- path: "*",
- element: <Page404 />,
- },
- ],
- },
- {
- path: "/login",
- element: <Login />,
- },
- {
- path: "*",
- element: <Page404 />,
- },
- ];
-
- export function mergeAuthRoutes (r1, r2) {
- const r = r1.slice();
- const children = r1[0].children.slice();
- r[0].children = children.concat(r2);
- return r;
- }
-
- // 全部路由
- export const routes = mergeAuthRoutes(defaultRoutes, authRoutes);
- function getPath (parent = "/", current = "") {
- if (current.indexOf("/") === 0 || current.indexOf("http") === 0)
- return current;
- return `${parent}/${current}`.replace(/\/\//g, "/");
- }
-
- // 路由数组, 一维数组
- export const routeArr = (() => {
- const flatten = (routes, parentPath = "/") => {
- return routes.reduce((acc, route) => {
- const path = getPath(parentPath, route.path);
- const children = route.children ? flatten(route.children, path) : [];
-
- return acc.concat([{ ...route, path }].concat(children));
- }, []);
- };
-
- return flatten(routes);
- })();
|