index.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. import Vue from 'vue'
  2. import Router from 'vue-router'
  3. const _import = require('./_import_' + process.env.NODE_ENV)
  4. // in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
  5. // detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading
  6. Vue.use(Router)
  7. /* Layout */
  8. import Layout from '../views/layout/Layout'
  9. /** note: submenu only apppear when children.length>=1
  10. * detail see https://panjiachen.github.io/vue-element-admin-site/#/router-and-nav?id=sidebar
  11. **/
  12. /**
  13. * hidden: true if `hidden:true` will not show in the sidebar(default is false)
  14. * alwaysShow: true if set true, will always show the root menu, whatever its child routes length
  15. * if not set alwaysShow, only more than one route under the children
  16. * it will becomes nested mode, otherwise not show the root menu
  17. * redirect: noredirect if `redirect:noredirect` will no redirct in the breadcrumb
  18. * name:'router-name' the name is used by <keep-alive> (must set!!!)
  19. * meta : {
  20. roles: ['admin','editor'] will control the page roles (you can set multiple roles)
  21. title: 'title' the name show in submenu and breadcrumb (recommend set)
  22. icon: 'svg-name' the icon show in the sidebar,
  23. noCache: true if fasle ,the page will no be cached(default is false)
  24. }
  25. **/
  26. export const constantRouterMap = [
  27. { path: '/login', component: _import('login/index'), hidden: true },
  28. { path: '/authredirect', component: _import('login/authredirect'), hidden: true },
  29. { path: '/404', component: _import('error/404'), hidden: true },
  30. { path: '/401', component: _import('error/401'), hidden: true },
  31. {
  32. path: '',
  33. component: Layout,
  34. redirect: 'dashboard',
  35. children: [{
  36. path: 'dashboard',
  37. component: _import('dashboard/index'),
  38. name: 'dashboard',
  39. meta: { title: '首页', icon: 'dashboard', noCache: true }
  40. }]
  41. }
  42. ]
  43. export default new Router({
  44. // mode: 'history', // require service support
  45. scrollBehavior: () => ({ y: 0 }),
  46. routes: constantRouterMap
  47. })
  48. export const asyncRouterMap = [
  49. {
  50. path: '/goodsManage',
  51. component: Layout,
  52. redirect: 'noredirect',
  53. name: 'goodsManage',
  54. meta: {
  55. title: '商品管理',
  56. icon: 'shangpin'
  57. },
  58. children: [
  59. { path: 'goodsTypeList', component: _import('goodsManage/goodsTypeList'), name: 'goodsTypeList', meta: { title: '商品类别', noCache: true }},
  60. { path: 'goodsList', component: _import('goodsManage/goodsList'), name: 'goodsList', meta: { title: '商品列表', noCache: true }},
  61. ]
  62. },
  63. {
  64. path: '/stock',
  65. component: Layout,
  66. redirect: 'noredirect',
  67. name: 'stock',
  68. meta: { title: '仓库管理', icon: 'shangpin' },
  69. children: [
  70. { path: 'warehousing', component: _import('stock/warehousing/warehousing'), name: 'warehousing', meta: { title: '入库单', noCache: true }},
  71. { path: 'warehousingAdd', component: _import('stock/warehousing/warehousingAdd'), name: 'warehousingAdd', meta: { title: '新增入库单', noCache: false, hideTag: true, hidden: true }},
  72. { path: 'warehousingEdit/:id', component: _import('stock/warehousing/warehousingAdd'), name: 'warehousingEdit', meta: { title: '编辑入库单', noCache: false, hideTag: true, hidden: true }},
  73. { path: 'warehousingDetail/:id', component: _import('stock/warehousing/warehousingAdd'), name: 'warehousingDetail', meta: { title: '入库单详情', noCache: false, hideTag: true, hidden: true }},
  74. ]
  75. },
  76. {
  77. path: '/dictManage',
  78. component: Layout,
  79. redirect: 'noredirect',
  80. name: 'dictManage',
  81. meta: {
  82. title: '字典管理',
  83. icon: 'zidian'
  84. },
  85. children: [
  86. { path: 'dictList', component: _import('dictManage/dictList'), name: 'dictList', meta: { title: '字典列表', noCache: true }},
  87. { path: 'dictDataList/:id', component: _import('dictManage/dictDataList'), name: 'dictDataList', meta: { title: '字典数据', noCache: false, hideTag: true, hidden: true }},
  88. ]
  89. },
  90. {
  91. path: '/sys',
  92. component: Layout,
  93. redirect: 'noredirect',
  94. name: 'sysManage',
  95. meta: {
  96. title: '系统管理',
  97. icon: 'chart'
  98. },
  99. children: [
  100. { path: 'admin', component: _import('sys/admin'), name: 'admin', meta: { title: '用户管理', noCache: true }},
  101. { path: 'dept', component: _import('sys/dept'), name: 'dept', meta: { title: '部门管理', noCache: true }},
  102. { path: 'role', component: _import('sys/role'), name: 'role', meta: { title: '角色管理', noCache: true }},
  103. ]
  104. },
  105. { path: '*', redirect: '/404', hidden: true }
  106. ]