dynamicMuen.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. import store from '../store/store.js';
  2. const staticMuen = [
  3. {
  4. path: '/msg',
  5. component: () => import(/* webpackChunkName: "messages" */ '@views/messages'),
  6. meta: { title: '消息中心' }
  7. },
  8. {
  9. path: '/403',
  10. component: () => import(/* webpackChunkName: "404" */ '@views/errorPage/403.vue'),
  11. meta: { title: '403' }
  12. },
  13. {
  14. path: '/404',
  15. component: () => import(/* webpackChunkName: "404" */ '@views/errorPage/404.vue'),
  16. meta: { title: '404' }
  17. },
  18. {
  19. path: '/parkingLotAdministration/pageJump/partitionManagement',
  20. component: () => import(/* webpackChunkName: "404" */ '@views/parkingLotAdministration/pageJump/partitionManagement.vue'),
  21. meta: { title: '车库分区管理' }
  22. },
  23. {
  24. path: '/ownerManagement/details',
  25. component: () => import(/* webpackChunkName: "404" */ '@views/ownerManagement/details.vue'),
  26. meta: { title: '住户详情' }
  27. },
  28. {
  29. path: '/housingManagement/details',
  30. component: () => import(/* webpackChunkName: "404" */ '@views/assetManagement/housingManagement/details.vue'),
  31. meta: { title: '房屋详情' },
  32. name: 'housingManagementDetails'
  33. },
  34. {
  35. path: '/shopManagement/details',
  36. component: () => import(/* webpackChunkName: "404" */ '@views/assetManagement/shopManagement/details.vue'),
  37. meta: { title: '商铺详情' },
  38. name: 'shopManagementDetails'
  39. },
  40. {
  41. path: '/invoiceManagement/index',
  42. component: () => import(/* webpackChunkName: "404" */ '@views/payService/invoiceManagement/index.vue'),
  43. meta: { title: '发票管理' }
  44. },
  45. {
  46. path: '/expenseReport/index',
  47. component: () => import(/* webpackChunkName: "404" */ '@views/payService/expenseReport/index.vue'),
  48. meta: { title: '费用报表' },
  49. name: 'expenseReport'
  50. },
  51. {
  52. path: '/shannon-transfer',
  53. component: () => import(/* webpackChunkName: "404" */ '@views/patrolManagement/components/shannon-transfer.vue'),
  54. meta: { title: '测试' },
  55. name: 'shannon-transfer'
  56. },
  57. {
  58. path: '/editWorkbench',
  59. component: () => import(/* webpackChunkName: "404" */ '@views/newWorkBench/editWorkbench.vue'),
  60. meta: { title: '编辑工作台' },
  61. name: 'editWorkbench'
  62. },
  63. // 配置完成需要删除 房东管理
  64. // {
  65. // path: '/landlordManagement',
  66. // component: () => import(/* webpackChunkName: "404" */ '@views/ownerManagement/landlordManagement/index.vue'),
  67. // meta: { title: 'xxxx' },
  68. // name: 'landlordManagement'
  69. // },
  70. // {
  71. // path: '/landlordReview',
  72. // component: () => import(/* webpackChunkName: "404" */ '@views/ownerManagement/landlordReview/index.vue')
  73. // },
  74. // {
  75. // path: '/landlordReview',
  76. // component: () => import(/* webpackChunkName: "404" */ '@views/payService/landlordBill/index.vue')
  77. // },
  78. {
  79. path: '/receivableExamine',
  80. component: () => import(/* webpackChunkName: "404" */ '@views/payService/receivableExamine/index.vue')
  81. },
  82. {
  83. path: '*',
  84. redirect: '/404'
  85. }
  86. ];
  87. //路由格式
  88. // 自定义路由文件
  89. const setListMunt = (arrList, item) => {
  90. let newOb = {};
  91. newOb = {
  92. path: `/${item.linkPath}`,
  93. component: () => import(`@/views/${item.linkPath}.vue`),
  94. meta: { title: item.name },
  95. name: `${item.linkPath}`
  96. };
  97. arrList.push(newOb);
  98. };
  99. const dimension = (arrList, arr) => {
  100. arr.forEach((item, index) => {
  101. //默认去掉第一个添加路由
  102. // if (item.linkPath !== 'workbench/index') {
  103. // if (!!item.children) {
  104. // dimension(arrList, item.children);
  105. // } else {
  106. // setListMunt(arrList, item);
  107. // }
  108. // }
  109. if (!!item.children) {
  110. dimension(arrList, item.children);
  111. } else {
  112. setListMunt(arrList, item);
  113. }
  114. });
  115. };
  116. //添加路由
  117. const AddRt = (router, dynamicMuenList) => {
  118. let NEWdynamicMuenList = [...dynamicMuenList, ...staticMuen];
  119. if (NEWdynamicMuenList.length !== 0) {
  120. NEWdynamicMuenList.forEach((item) => {
  121. router.options.routes[0].children.push(item);
  122. });
  123. router.addRoutes(router.options.routes);
  124. }
  125. };
  126. export const funcRouter = (arr, data, router) => {
  127. dimension(arr, data);
  128. store.commit('setMenuList', data);
  129. AddRt(router, arr);
  130. };