index.js 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  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: "/audit",
  13. meta: {
  14. title: "导入日报审核"
  15. },
  16. component: () => import("@/views/audit/audit")
  17. },
  18. {
  19. path: "/login",
  20. component: () => import("@/views/login/index"),
  21. meta: {
  22. title: "登陆"
  23. }
  24. },
  25. {
  26. path: "/register",
  27. component: () => import("@/views/register/index"),
  28. meta: {
  29. title: "注册"
  30. }
  31. },
  32. {
  33. path: "/expire",
  34. component: () => import("@/views/expire/index"),
  35. meta: {
  36. title: "到期"
  37. }
  38. },
  39. {
  40. path: "/index",
  41. component: () => import("@/views/index/index"),
  42. meta: {
  43. title: "工时管家",
  44. keepAlive: true
  45. }
  46. },
  47. {
  48. path: "/view",
  49. meta: {
  50. title: "查看日报"
  51. },
  52. component: () => import("@/views/view/index")
  53. },
  54. {
  55. path: "/calendar",
  56. meta: {
  57. title: "查看日报"
  58. },
  59. component: () => import("@/views/view/calendar")
  60. },
  61. {
  62. path: "/edit",
  63. meta: {
  64. title: "填写日报"
  65. },
  66. component: () => import("@/views/edit/index")
  67. },
  68. {
  69. path: "/weekedit",
  70. meta: {
  71. title: "按周填报"
  72. },
  73. component: () => import("@/views/edit/weekEdit")
  74. },
  75. {
  76. path: "/task",
  77. meta: {
  78. title: "待办任务"
  79. },
  80. component: () => import("@/views/task/index")
  81. },
  82. {
  83. path: "/expense",
  84. meta: {
  85. title: "费用报销"
  86. },
  87. component: () => import("@/views/expense/index")
  88. },
  89. {
  90. path: "/expenseDetails",
  91. name: "expenseDetails",
  92. meta: {
  93. title: "单据编辑"
  94. },
  95. component: () => import("@/views/expense/details")
  96. },
  97. {
  98. path: "/customizedDetail",
  99. name: "customizedDetail",
  100. meta: {
  101. title: "单据编辑"
  102. },
  103. component: () => import("@/views/expense/customizedDetail")
  104. },
  105. {
  106. path: "/projectInside",
  107. name: "projectInside",
  108. meta: {
  109. title: "项目详情"
  110. },
  111. component: () => import("@/views/project/projectInside")
  112. },
  113. {
  114. path: "/editProject",
  115. meta: {
  116. title: "编辑项目"
  117. },
  118. component: () => import("@/views/project/edit")
  119. },
  120. {
  121. path: "/editask",
  122. name: "editask",
  123. meta: {
  124. title: "编辑任务"
  125. },
  126. component: () => import("@/views/task/editask")
  127. },
  128. {
  129. path: "/search",
  130. meta: {
  131. title: "选择项目"
  132. },
  133. component: () => import("@/views/edit/search")
  134. },
  135. {
  136. path: "/review",
  137. meta: {
  138. title: "审核日报"
  139. },
  140. component: () => import("@/views/review/index")
  141. },
  142. {
  143. path: "/profession_review",
  144. meta: {
  145. title: "专业审核"
  146. },
  147. component: () => import("@/views/review/profession_list")
  148. },
  149. {
  150. path: "/department_review",
  151. meta: {
  152. title: "部门审核"
  153. },
  154. component: () => import("@/views/review/department_list")
  155. },
  156. {
  157. path: "/msg",
  158. meta: {
  159. title: "消息记录"
  160. },
  161. component: () => import("@/views/msg/index")
  162. },
  163. {
  164. path: "/project",
  165. meta: {
  166. title: "项目管理"
  167. },
  168. component: () => import("@/views/project/index")
  169. },
  170. {
  171. path: "/error",
  172. meta: {
  173. title: "错误提示"
  174. },
  175. component: () => import("@/views/error/index")
  176. },
  177. {
  178. path: "/test",
  179. meta: {
  180. title: "测试页面"
  181. },
  182. component: () => import("@/views/test/index")
  183. },
  184. {
  185. path: "/tests",
  186. meta: {
  187. title: "测试页面2"
  188. },
  189. component: () => import("@/views/test/list")
  190. },
  191. // {
  192. // path: "/timetool",
  193. // meta: {
  194. // title: "自动计时"
  195. // },
  196. // component: () => import("@/views/timetool/timetool")
  197. // },
  198. {
  199. path: "/exaLeave",
  200. meta: {
  201. title: "请假审批"
  202. },
  203. component: () => import("@/views/exaLeave/exaLeave")
  204. },
  205. {
  206. path: "/applyLeave",
  207. meta: {
  208. title: "请假申请"
  209. },
  210. component: () => import("@/views/exaLeave/applyLeave")
  211. },
  212. {
  213. path: "/awayOffice",
  214. meta: {
  215. title: "出差申请"
  216. },
  217. component: () => import("@/views/exaLeave/awayOffice")
  218. },
  219. {
  220. path: "/editPerfect",
  221. meta: {
  222. title: "完善工号"
  223. },
  224. component: () => import("@/views/editPerfect/editPerfect")
  225. },
  226. {
  227. path: "/clearStorage",
  228. meta: {
  229. title: "清空存储"
  230. },
  231. component: () => import("@/views/test/clearStorage")
  232. },
  233. {
  234. path: "/my",
  235. component: () => import("@/views/my/index"),
  236. redirect: "/my/center",
  237. children: [
  238. {
  239. path: "center",
  240. meta: {
  241. title: "个人中心"
  242. },
  243. component: () => import("@/views/my/children/center")
  244. },
  245. {
  246. path: "set",
  247. meta: {
  248. title: "修改密码"
  249. },
  250. component: () => import("@/views/my/children/set")
  251. }
  252. ]
  253. },
  254. {
  255. path: "/count",
  256. component: () => import("@/views/count/count"),
  257. meta: {
  258. title: "填报统计"
  259. }
  260. },
  261. {
  262. path: "/cost",
  263. component: () => import("@/views/cost/cost"),
  264. meta: {
  265. title: "成本"
  266. }
  267. },
  268. {
  269. path: "/useRegistration",
  270. component: () => import("@/views/deviceManagement/useRegistration"),
  271. meta: {
  272. title: "设备使用登记"
  273. }
  274. },
  275. {
  276. path: "/usageHistory",
  277. component: () => import("@/views/deviceManagement/usageHistory"),
  278. meta: {
  279. title: "设备使用记录"
  280. }
  281. },
  282. {
  283. path: "/pdf",
  284. meta: {
  285. title: "PDF"
  286. },
  287. component: () => import("@/views/pdf/ppd")
  288. },
  289. {
  290. path: "*",
  291. component: () => import("@/components/NotFound")
  292. }
  293. ]
  294. });
  295. // 解决编程式路由往同一地址跳转时会报错的情况
  296. const originalPush = Router.prototype.push;
  297. const originalReplace = Router.prototype.replace;
  298. Router.prototype.push = function push(location, onResolve, onReject) {
  299. if (onResolve || onReject)
  300. return originalPush.call(this, location, onResolve, onReject);
  301. return originalPush.call(this, location).catch(err => err);
  302. };
  303. Router.prototype.replace = function push(location, onResolve, onReject) {
  304. if (onResolve || onReject)
  305. return originalReplace.call(this, location, onResolve, onReject);
  306. return originalReplace.call(this, location).catch(err => err);
  307. };
  308. router.beforeEach((to, from, next) => {
  309. let { title, needLogin } = to.meta;
  310. let { isLogin } = store.state;
  311. document.title = title;
  312. if (needLogin && !isLogin) {
  313. next({
  314. path: "/login"
  315. });
  316. } else {
  317. next();
  318. }
  319. });
  320. export default router;