123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465 |
- 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/List';
- 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 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, 将在新窗口打开
- * }
- */
-
- export const authRoutes = [
- {
- path: "task",
- element: <Container />,
- meta: {
- title: "军供任务",
- icon: <AppstoreOutlined />,
- },
- children: [
- {
- index: true,
- element: <Navigate to="guaranteeTask" replace />,
- },
- {
- path: "guaranteeTask",
- element: <GuaranteeTaskList />,
- meta: {
- title: "任务通报",
- },
- },
- {
- path: "guaranteeTask/edit",
- element: <GuaranteeTaskEdit />,
- meta: {
- title: "任务配置",
- },
- },
- {
- path: "guaranteeTask/print",
- element: <GuaranteeTaskPrint />,
- meta: {
- hideInMenu: true,
- noLayout: true,
- target: "_blank",
- title: "任务执行",
- },
- },
- {
- path: "evaluate",
- element: <GuaranteeTaskEvaluate />,
- meta: {
- title: "任务评价",
- },
- },
- {
- path: "evaluate/list",
- element: <GuaranteeTaskEvaluateList />,
- meta: {
- title: "任务评价",
- hideInMenu: true,
- },
- },
- ],
- },
- {
- path: "material",
- element: <Container />,
- meta: {
- title: "物资管理",
- icon: <AppstoreOutlined />,
- },
- children: [
- {
- index: true,
- element: <Navigate to="dish/list" replace />,
- },
- {
- path: "dish/list",
- element: <DishList />,
- meta: {
- title: "菜肴管理",
- },
- },
- {
- path: "dish/edit",
- element: <DishEdit />,
- meta: {
- hideInMenu: true,
- title: "菜肴维护",
- },
- },
- {
- path: "package/list",
- element: <PackageList />,
- meta: {
- title: "套餐管理",
- },
- },
- ],
- },
- {
- path: "stock",
- element: <Container />,
- meta: {
- title: "库存管理",
- icon: <AppstoreOutlined />,
- },
- children: [
- {
- index: true,
- element: <Navigate to="list" replace />,
- },
- {
- path: "list",
- element: <StockList />,
- meta: {
- title: "库存列表",
- },
- },
- {
- path: "add",
- element: <StockEdit />,
- meta: {
- title: "库存维护",
- },
- },
- ],
- },
- {
- path: "cms",
- element: <Container />,
- meta: {
- title: "公告文件",
- },
- children: [
- {
- index: true,
- element: <Navigate to="rotationChart/list" replace />,
- },
- {
- path: "rotationChart/introduction",
- element: <RotationChartIntroductionEdit />,
- meta: {
- title: "本站信息",
- },
- },
- {
- path: "rotationChart/list",
- element: <RotationChartList />,
- meta: {
- title: "公告内容",
- },
- },
- {
- path: "rotationChart/add",
- element: <RotationChartEdit />,
- meta: {
- title: "公告维护",
- },
- },
-
- {
- path: 'regulation',
- element: <RegulationList />,
- meta: {
- title: "规章制度",
- },
- },
- {
- path: 'regulation/add',
- element: <RegulationEdit />,
- meta: {
- hideInMenu: true,
- title: '规章制度维护',
- },
- },
- {
- path: "emergency-plan",
- element: <EmergencyPlanList />,
- meta: {
- title: "应急预案",
- },
- },
- {
- path: "emergency-plan/edit",
- element: <EmergencyPlanEdit />,
- meta: {
- title: "应急预案维护",
- hideInMenu: true,
- },
- },
- {
- path: "emergency-plan/detail",
- element: <EmergencyPlanDetail />,
- meta: {
- title: "应急预案详情",
- hideInMenu: true,
- },
- },
-
- {
- path: "files",
- element: <FilesList />,
- meta: {
- title: "文件管理",
- },
- },
- ],
- },
- {
- path: 'static',
- element: <StatisCharts />,
- meta: {
- title: '数据分析',
- noSiderBar: true,
- noFooter: true,
- },
- },
- {
- path: "system",
- element: <Container />,
- meta: {
- title: "系统管理",
- },
- children: [
- {
- index: true,
- element: <Navigate to="stockClassification/list" replace />,
- },
- {
- path: "stockClassification/list",
- element: <StockClassificationList />,
- meta: {
- title: "库存分类",
- },
- },
- {
- path: "stockClassification/edit",
- element: <StockClassificationEdit />,
- meta: {
- title: "库存分类维护",
- hideInMenu: true,
- },
- },
- {
- path: "log",
- element: <StockLog />,
- meta: {
- title: "操作日志",
- },
- },
- {
- path: "roles",
- element: <Roles />,
- meta: {
- title: "角色管理",
- },
- },
- {
- path: "user",
- element: <UserList />,
- meta: {
- title: "用户管理",
- },
- },
- {
- path: "user/edit",
- element: <UserEdit />,
- meta: {
- hideInMenu: true,
- title: "系统用户编辑",
- },
- },
- {
- path: "message",
- element: <MessageList />,
- meta: {
- title: "消息列表",
- },
- },
- {
- path: "message/detail",
- element: <MessageDetail />,
- meta: {
- title: "消息详情",
- hideInMenu: true,
- },
- },
- ],
- },
- {
- path: "purchase",
- element: <Container />,
- meta: {
- title: "采购管理",
- },
- children: [
- {
- index: true,
- element: <Navigate to="plan/list" replace />,
- },
- {
- path: "plan/list",
- element: <PurchasePlanList type="plan" />,
- meta: {
- title: "采购计划",
- },
- },
- {
- path: "plan/edit",
- element: <PurchasePlanEdit />,
- meta: {
- title: "采购计划维护",
- hideInMenu: true,
- },
- },
- {
- path: "bill/list",
- element: <PurchasePlanList type="bill" />,
- meta: {
- title: "采购账单",
- },
- },
- {
- path: "bill/edit",
- element: <PurchaseBillEdit />,
- meta: {
- title: "采购账单维护",
- hideInMenu: true,
- },
- },
- {
- path: "inStore/list",
- element: <PurchasePlanList type="inStore" />,
- meta: {
- title: "采购入库",
- },
- },
- {
- path: "inStore/edit",
- element: <PurchaseInStoreEdit />,
- meta: {
- title: "采购入库维护",
- hideInMenu: true,
- },
- },
- ],
- },
- ];
-
- export const defaultRoutes = [
- {
- path: "/",
- element: <AuthLayout />,
- children: [
- {
- index: true,
- element: <Home />,
- },
- {
- path: "home",
- element: <Home />,
- meta: {
- title: "首页",
- icon: <DesktopOutlined />,
- },
- },
- {
- 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);
- })();
|