审查视图

src/routes.js 5.0 KB
朱兆平 authored
1 2 3 4
import Login from './views/Login.vue'
import NotFound from './views/404.vue'
import Home from './views/Home.vue'
import Main from './views/Main.vue'
5 6
import Role from './views/nav1/role.vue'
import Perm from './views/nav1/perm.vue'
7
import LOG from './views/nav1/Log.vue'
shenhailong authored
8 9
import Company from './views/nav1/company.vue'
import Department from './views/nav1/department.vue'
10
import Group from './views/nav1/groupcompany.vue'
朱兆平 authored
11 12
import Process from './views/hqpt/Process.vue'
import Job from './views/hqpt/Job.vue'
13 14

import User from './views/nav1/user.vue'
朱兆平 authored
15 16
import Page6 from './views/nav3/Page6.vue'
import echarts from './views/charts/echarts.vue'
17 18 19
import SecrityInspection from './views/staff/security_inspection.vue'
import Key from './views/staff/key.vue'
import Maintain from './views/staff/maintain.vue'
朱兆平 authored
20
import Location from './views/empt/Location.vue'
shenhailong authored
21 22
import QueryOrder from './views/empt/QueryOrder.vue'
import PayOrder from './views/empt/PayOrder.vue'
23
import userPayOrder from './views/empt/userPayOrder.vue'
朱兆平 authored
24 25 26 27 28

let routes = [
    {
        path: '/login',
        component: Login,
29
        name: '登录',
朱兆平 authored
30 31 32 33 34
        hidden: true
    },
    {
        path: '/404',
        component: NotFound,
35
        name: '错误',
朱兆平 authored
36 37 38 39 40
        hidden: true
    },
    {
        path: '/',
        component: Home,
41
        name: '主页',
42 43
        leaf: true,
        iconCls: 'el-icon-menu',
朱兆平 authored
44
        children: [
45
            { path: '/main', component: Main, name: '首页'},
46 47 48 49
        ]
    },
    // { path: '/test', component: Main },
    {
50
        path: '/admin',
51
        component: Home,
52
        name: '系统设置',
53 54 55
        iconCls: 'el-icon-setting',//图标样式class
        children: [
            { path: '/user', component: User, name: '用户管理' },
shenhailong authored
56
            { path: '/role', component: Role, name: '组织机构' },
57
            { path: '/perm', component: Perm, name: '权限管理' },
58
            { path: '/log', component: LOG, name: '系统日志' },
shenhailong authored
59 60
            { path: '/department', component: Department, name: '部门管理' },
            { path: '/company', component: Company, name: '公司管理'},
61
            { path: '/group', component: Group, name: '集团管理'}
朱兆平 authored
62 63 64
        ]
    },
    {
朱兆平 authored
65 66 67 68 69 70 71 72 73 74
        path: '/guestService',
        component: Home,
        name: '客服系统',
        iconCls: 'fa fa-id-card-o',
        children: [
            { path: '/process', component: Process, name: '工单管理' },
            { path: '/job', component: Job, name: '任务管理' }
        ]
    },
    {
朱兆平 authored
75 76 77 78 79 80
        path: '/empt',
        component: Home,
        name: '能源管理',
        iconCls: 'fa fa-id-card-o',
        children: [
            { path: '/location', component: Location, name: '能源缴费' },
shenhailong authored
81
            { path: '/PayOrder', component: PayOrder, name: '缴水电费订单' },
82
            { path: '/userPayOrder', component: userPayOrder, name: '用户水电缴费' },
shenhailong authored
83
            { path: '/QueryOrder', component: QueryOrder, name: '订单查询' },
朱兆平 authored
84 85 86
        ]
    },
    {
87
        path: '/satff',
朱兆平 authored
88
        component: Home,
89
        name: '生活保障部门',
朱兆平 authored
90 91
        iconCls: 'fa fa-id-card-o',
        children: [
92 93 94
            { path: '/security_inspection', component: SecrityInspection, name: '职工公寓安全巡视管理' },
            { path: '/key', component: Key, name: '职工公寓备用钥匙使用登记管理' },
            { path: '/maintain', component: Maintain, name: '职工公寓设施设备维修记录管理' },
朱兆平 authored
95 96 97 98 99
        ]
    },
    {
        path: '/',
        component: Home,
100
        name: '导航三',
朱兆平 authored
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
        iconCls: 'fa fa-address-card',
        leaf: true,//只有一个节点
        children: [
            { path: '/page6', component: Page6, name: '导航三' }
        ]
    },
    {
        path: '/',
        component: Home,
        name: 'Charts',
        iconCls: 'fa fa-bar-chart',
        children: [
            { path: '/echarts', component: echarts, name: 'echarts' }
        ]
    },
    {
        path: '*',
        hidden: true,
        redirect: { path: '/404' }
    }
];
122
let initRouters = routes.concat();
123 124
let setUserMenus = function (list) {
    routes = list;
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
}
/**
 * 处理登陆后的账号对应的菜单
 * @param menuList
 */
let handleMenuList = function (router,menu) {
    var _self = this;
    var routerName = "";
    router.forEach(function (v_router) {
        routerName = v_router.name;
        menu.forEach(function (v_menu) {
            //查找返回的目录列表是否包含路由名称,有就返回匹配到的元素,没有就移除
            let result = menu.find(item => {
                return item.name === routerName;
            });

            //匹配到继续判断是否子元素,有子元素继续递归
            if (result) {
                if(v_router.children) {
                    _self.handleMenuList(v_router.children,result.children);
                }
                //没有则可以移除
            }else {
                router.splice(router.findIndex(itm => itm.name === routerName ),1);
            }
        })
    });
152 153
}
export default {
154
    routes,setUserMenus,handleMenuList,initRouters
155
};