dynamicMuen.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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: '/patrolStandard',
  80. component: () => import(/* webpackChunkName: "404" */ '@views/patrolManagement/patrolStandard.vue')
  81. },
  82. {
  83. path: '/employeeServices',
  84. component: () => import(/* webpackChunkName: "404" */ '@views/workOrders/employeeServices/index.vue')
  85. },
  86. {
  87. path: '*',
  88. redirect: '/404'
  89. }
  90. ];
  91. //路由格式
  92. // 自定义路由文件
  93. const setListMunt = (arrList, item) => {
  94. let newOb = {};
  95. newOb = {
  96. path: `/${item.linkPath}`,
  97. component: () => import(`@/views/${item.linkPath}.vue`),
  98. meta: { title: item.name },
  99. name: `${item.linkPath}`
  100. };
  101. arrList.push(newOb);
  102. };
  103. const dimension = (arrList, arr) => {
  104. arr.forEach((item, index) => {
  105. //默认去掉第一个添加路由
  106. // if (item.linkPath !== 'workbench/index') {
  107. // if (!!item.children) {
  108. // dimension(arrList, item.children);
  109. // } else {
  110. // setListMunt(arrList, item);
  111. // }
  112. // }
  113. if (!!item.children) {
  114. dimension(arrList, item.children);
  115. } else {
  116. setListMunt(arrList, item);
  117. }
  118. });
  119. };
  120. //添加路由
  121. const AddRt = (router, dynamicMuenList) => {
  122. let NEWdynamicMuenList = [...dynamicMuenList, ...staticMuen];
  123. if (NEWdynamicMuenList.length !== 0) {
  124. NEWdynamicMuenList.forEach((item) => {
  125. router.options.routes[0].children.push(item);
  126. });
  127. router.addRoutes(router.options.routes);
  128. }
  129. };
  130. export const funcRouter = (arr, data, router) => {
  131. dimension(arr, data);
  132. store.commit('setMenuList', data);
  133. AddRt(router, arr);
  134. };