index.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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: "/groupView",
  89. component: () => import("@/views/groupView/groupView"),
  90. meta: {
  91. title: "班组人员",
  92. keepAlive: false
  93. }
  94. },
  95. {
  96. path: "/MemberInfo",
  97. component: () => import("@/views/groupView/info"),
  98. meta: {
  99. title: "通讯录",
  100. keepAlive: false
  101. }
  102. },
  103. {
  104. // path: "/workView",
  105. path: "/report",
  106. component: () => import("@/views/workView/workView"),
  107. meta: {
  108. title: "报工",
  109. keepAlive: false
  110. }
  111. },
  112. {
  113. path: "/fillReport",
  114. component: () => import("@/views/workView/fillReport"),
  115. meta: {
  116. title: "报工",
  117. keepAlive: false
  118. }
  119. },
  120. {
  121. path: "/test",
  122. meta: {
  123. title: "测试页面"
  124. },
  125. component: () => import("@/views/test/index")
  126. },
  127. {
  128. path: "/tests",
  129. meta: {
  130. title: "测试页面2"
  131. },
  132. component: () => import("@/views/test/list")
  133. },
  134. {
  135. path: "/clearStorage",
  136. meta: {
  137. title: "清空存储"
  138. },
  139. component: () => import("@/views/test/clearStorage")
  140. },
  141. {
  142. path: "/my",
  143. component: () => import("@/views/my/index"),
  144. redirect: "/my/center",
  145. children: [
  146. {
  147. path: "center",
  148. meta: {
  149. title: "个人中心"
  150. },
  151. component: () => import("@/views/my/children/center")
  152. },
  153. {
  154. path: "set",
  155. meta: {
  156. title: "修改密码"
  157. },
  158. component: () => import("@/views/my/children/set")
  159. }
  160. ]
  161. },
  162. {
  163. path: "/pdf",
  164. meta: {
  165. title: "PDF"
  166. },
  167. component: () => import("@/views/pdf/ppd")
  168. },
  169. {
  170. path: "*",
  171. component: () => import("@/components/NotFound")
  172. }
  173. ]
  174. });
  175. // 解决编程式路由往同一地址跳转时会报错的情况
  176. const originalPush = Router.prototype.push;
  177. const originalReplace = Router.prototype.replace;
  178. Router.prototype.push = function push(location, onResolve, onReject) {
  179. if (onResolve || onReject)
  180. return originalPush.call(this, location, onResolve, onReject);
  181. return originalPush.call(this, location).catch(err => err);
  182. };
  183. Router.prototype.replace = function push(location, onResolve, onReject) {
  184. if (onResolve || onReject)
  185. return originalReplace.call(this, location, onResolve, onReject);
  186. return originalReplace.call(this, location).catch(err => err);
  187. };
  188. router.beforeEach((to, from, next) => {
  189. let { title, needLogin } = to.meta;
  190. let { isLogin } = store.state;
  191. document.title = title;
  192. if (needLogin && !isLogin) {
  193. next({
  194. path: "/login"
  195. });
  196. } else {
  197. next();
  198. }
  199. });
  200. export default router;