index.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. import Vue from "vue";
  2. import Router from "vue-router";
  3. import store from "../store/index";
  4. Vue.use(Router);
  5. const router = new Router({
  6. routes: [
  7. {
  8. path: "/",
  9. redirect: "/login"
  10. },
  11. {
  12. path: "/login",
  13. component: () => import("@/views/login/index"),
  14. meta: {
  15. title: "登陆"
  16. }
  17. },
  18. {
  19. path: "/expire",
  20. component: () => import("@/views/expire/index"),
  21. meta: {
  22. title: "到期"
  23. }
  24. },
  25. {
  26. path: "/index",
  27. component: () => import("@/views/index/index"),
  28. meta: {
  29. title: "车间生产管家",
  30. keepAlive: true
  31. }
  32. },
  33. {
  34. // path: "/todayPlan",
  35. path: "/plan/today",
  36. component: () => import("@/views/planView/todayPlan/todayPlan"),
  37. meta: {
  38. title: "今日计划",
  39. keepAlive: false
  40. }
  41. },
  42. {
  43. path: "/distribution",
  44. name: "distribution",
  45. component: () => import("@/views/planView/todayPlan/distribution"),
  46. meta: {
  47. title: "计划详情",
  48. keepAlive: false
  49. }
  50. },
  51. {
  52. // path: "/tomorrowPlan",
  53. path: "/plan/tomorrow",
  54. component: () => import("@/views/planView/tomorrowPlan/tomorrowPlan"),
  55. meta: {
  56. title: "明日计划",
  57. keepAlive: false
  58. }
  59. },
  60. {
  61. // path: "/InsertionPlan",
  62. path: "/plan/orderInsert",
  63. component: () => import("@/views/planView/InsertionPlan/InsertionPlan"),
  64. meta: {
  65. title: "插单计划",
  66. keepAlive: false
  67. }
  68. },
  69. {
  70. path: "/InsertionPlanAdd",
  71. name: '计划新增',
  72. component: () => import("@/views/planView/InsertionPlan/InsertionPlanAdd"),
  73. meta: {
  74. title: "计划新增",
  75. keepAlive: false
  76. }
  77. },
  78. {
  79. path: "/statisticsView",
  80. // path: "/statistic",
  81. component: () => import("@/views/statisticsView/statisticsView"),
  82. meta: {
  83. title: "数据统计",
  84. keepAlive: false
  85. }
  86. },
  87. {
  88. path: "/statisticsDetail",
  89. // path: "/statistic",
  90. component: () => import("@/views/statisticsView/statisticsDetail"),
  91. meta: {
  92. title: "数据统计",
  93. keepAlive: false
  94. }
  95. },
  96. {
  97. path: "/groupView",
  98. component: () => import("@/views/groupView/groupView"),
  99. meta: {
  100. title: "班组人员",
  101. keepAlive: false
  102. }
  103. },
  104. {
  105. path: "/MemberInfo",
  106. component: () => import("@/views/groupView/info"),
  107. meta: {
  108. title: "通讯录",
  109. keepAlive: false
  110. }
  111. },
  112. {
  113. // path: "/workView",
  114. path: "/report",
  115. component: () => import("@/views/workView/workView"),
  116. meta: {
  117. title: "报工",
  118. keepAlive: false
  119. }
  120. },
  121. {
  122. path: "/fillReport",
  123. component: () => import("@/views/workView/fillReport"),
  124. meta: {
  125. title: "报工",
  126. keepAlive: false
  127. }
  128. },
  129. {
  130. path: "/test",
  131. meta: {
  132. title: "测试页面"
  133. },
  134. component: () => import("@/views/test/index")
  135. },
  136. {
  137. path: "/tests",
  138. meta: {
  139. title: "测试页面2"
  140. },
  141. component: () => import("@/views/test/list")
  142. },
  143. {
  144. path: "/clearStorage",
  145. meta: {
  146. title: "清空存储"
  147. },
  148. component: () => import("@/views/test/clearStorage")
  149. },
  150. {
  151. path: "/my",
  152. component: () => import("@/views/my/index"),
  153. redirect: "/my/center",
  154. children: [
  155. {
  156. path: "center",
  157. meta: {
  158. title: "个人中心"
  159. },
  160. component: () => import("@/views/my/children/center")
  161. },
  162. {
  163. path: "set",
  164. meta: {
  165. title: "修改密码"
  166. },
  167. component: () => import("@/views/my/children/set")
  168. }
  169. ]
  170. },
  171. {
  172. path: "/pdf",
  173. meta: {
  174. title: "PDF"
  175. },
  176. component: () => import("@/views/pdf/ppd")
  177. },
  178. {
  179. path: "*",
  180. component: () => import("@/components/NotFound")
  181. }
  182. ]
  183. });
  184. // 解决编程式路由往同一地址跳转时会报错的情况
  185. const originalPush = Router.prototype.push;
  186. const originalReplace = Router.prototype.replace;
  187. Router.prototype.push = function push(location, onResolve, onReject) {
  188. if (onResolve || onReject)
  189. return originalPush.call(this, location, onResolve, onReject);
  190. return originalPush.call(this, location).catch(err => err);
  191. };
  192. Router.prototype.replace = function push(location, onResolve, onReject) {
  193. if (onResolve || onReject)
  194. return originalReplace.call(this, location, onResolve, onReject);
  195. return originalReplace.call(this, location).catch(err => err);
  196. };
  197. router.beforeEach((to, from, next) => {
  198. let { title, needLogin } = to.meta;
  199. let { isLogin } = store.state;
  200. document.title = title;
  201. if (needLogin && !isLogin) {
  202. next({
  203. path: "/login"
  204. });
  205. } else {
  206. next();
  207. }
  208. });
  209. export default router;