import { PageTemplateView, TabsTemplateView } from '@/pages/frame/view/template';
import { RouterView } from '@/layout';

export const globalRoutes = [
    {
        path: '/login',
        name: '登录页',
        component: () => import('@/pages/frame/view/login'),
    },
    {
        path: '/403',
        name: '403',
        component: () => import('@/pages/frame/view/exception/403'),
    },
    {
        path: '/500',
        name: '500',
        component: () => import('@/pages/frame/view/exception/500'),
    },
];

const hasAuthorityRoutes = [
    {
        path: '/',
        component: TabsTemplateView,
        redirect: '/home',
        children: [
            {
                path: 'home',
                name: '首页',
                meta: { icon: 'home' },
                component: () => import('@/pages/home/index.vue'),
            },
            {
                path: 'dashboard',
                name: 'Dashboard',
                meta: {
                    icon: 'dashboard',
                },
                children: [
                    {
                        path: 'workbench',
                        name: '工作台',
                        meta: {
                            page: {
                                closable: false,
                            },
                        },
                        component: () => import('@/pages/dashboard/workbench'),
                    },
                    {
                        path: 'analysis',
                        name: '分析页',
                        component: () => import('@/pages/dashboard/analysis'),
                    },
                ],
            },
            {
                path: 'ranger',
                name: '巡检管理',
                component: PageTemplateView,
                children: [
                    {
                        path: 'basic',
                        name: '基础数据配置',
                        component: RouterView,
                        children: [
                            {
                                path: 'region',
                                name: '地区配置',
                                component: () => import('@/pages/ranger/basic/region'),
                            },
                            {
                                path: 'place',
                                name: '地点配置',
                                component: () => import('@/pages/ranger/basic/place'),
                            },
                            {
                                path: 'unit',
                                name: '单元配置',
                                component: () => import('@/pages/ranger/basic/unit'),
                            },
                            {

                                path: 'major',
                                name: '专业配置',
                                component: () => import('@/pages/ranger/basic/major'),
                            },
                            {

                                path: 'item',
                                name: '项目配置',
                                component: () => import('@/pages/ranger/basic/item'),
                            },
                            {
                                path: 'line',
                                name: '线路配置',
                                component: () => import('@/pages/ranger/basic/line'),
                            },
                            {
                                path: 'exemption',
                                name: '免检配置',
                                component: () => import('@/pages/ranger/basic/exemption'),
                            },
                        ],
                    },
                    {
                        path: 'task',
                        name: '任务管理',
                        component: RouterView,
                        children: [
                            {
                                path: 'center',
                                name: '任务中心',
                                component: () => import('@/pages/ranger/task_managment/center'),
                            },
                        ],
                    },
                    {
                        path: 'report',
                        name: '报表中心',
                        component: RouterView,
                        children: [
                            {
                                path: 'week',
                                name: '巡检周报',
                                component: () => import('@/pages/ranger/report/weekly'),
                            },
                            {
                                path: 'month',
                                name: '巡检月报',
                                component: () => import('@/pages/ranger/report/month'),
                            },
                        ],
                    },
                ],
            },
            {
                path: 'system',
                name: '系统管理',
                component: PageTemplateView,
                children: [
                    {
                        path: 'menu',
                        name: '菜单管理',
                        component: () => import('@/pages/system/menu'),
                    },
                    {
                        path: 'organization',
                        name: '组织管理',
                        component: RouterView,
                        children: [
                            {
                                path: 'job',
                                name: '岗位管理',
                                component: () =>
                                    import('@/pages/system/organization/jobsmanagement/Jobs.vue'),
                            },
                            {
                                path: 'user',
                                name: '用户管理',
                                component: () =>
                                    import('@/pages/system/organization/usermanagement/User.vue'),
                            },
                            {
                                path: 'org',
                                name: '机构管理',
                                component: () => import('@/pages/system/organization/orgmanagement/Org.vue'),
                            },
                        ],
                    },
                    {
                        path: 'role',
                        name: '角色管理',
                        component: () => import('@/pages/system/role'),
                    },
                    {
                        path: 'parameter',
                        name: '参数管理',
                        component: RouterView,
                        children: [
                            {
                                path: 'business',
                                name: '业务参数',
                                component: () => import('@/pages/system/parameter/business/index.vue'),
                            },
                            {
                                path: 'operation',
                                name: '运维参数',
                                component: () => import('@/pages/system/parameter/operation/index.vue'),
                            },
                        ],
                    },
                    {
                        path: 'log',
                        name: '日志管理',
                        component: RouterView,
                        children: [
                            {
                                path: 'login',
                                name: '登录日志',
                                component: () => import('@/pages/system/log/login_log'),
                            },
                            {
                                path: 'operation',
                                name: '操作日志',
                                component: () => import('@/pages/system/log/operation/index.vue'),
                            },
                        ],
                    },
                    {
                        path: 'task',
                        name: '任务',
                        component: () => import('@/pages/system/task/index.vue'),
                    },
                ],
            },
            {
                path: 'oceanus',
                name: '设备管理',
                meta: {
                    icon: 'control',
                },
                component: PageTemplateView,
                children: [
                    {
                        path: 'category',
                        name: '分类配置',
                        component: () => import('@/pages/oceanus/category/index.vue'),
                    },
                    {
                        path: 'equipment',
                        name: '设备台账',
                        component: () => import('@/pages/oceanus/equipment/index.vue'),
                    },
                ],
            },
            {
                path: 'user',
                name: '个人中心',
                meta: { icon: 'user' },
                component: () => import('@/pages/user/index.vue'),
            },
        ],
    },
];

// 路由配置
const options = {
    mode: 'history',
    routes: [...globalRoutes, ...hasAuthorityRoutes],
};

export default options;
