华西海圻ELN前端工程
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

315 lines
8.5 KiB

  1. import Vue from 'vue'
  2. import Router from 'vue-router'
  3. Vue.use(Router)
  4. /* Layout */
  5. import Layout from '@/layout'
  6. /**
  7. * Note: 路由配置项
  8. *
  9. * hidden: true // 当设置 true 的时候该路由不会再侧边栏出现 如401,login等页面,或者如一些编辑页面/edit/1
  10. * alwaysShow: true // 当你一个路由下面的 children 声明的路由大于1个时,自动会变成嵌套的模式--如组件页面
  11. * // 只有一个时,会将那个子路由当做根路由显示在侧边栏--如引导页面
  12. * // 若你想不管路由下面的 children 声明的个数都显示你的根路由
  13. * // 你可以设置 alwaysShow: true,这样它就会忽略之前定义的规则,一直显示根路由
  14. * redirect: noRedirect // 当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
  15. * name:'router-name' // 设定路由的名字,一定要填写不然使用<keep-alive>时会出现各种问题
  16. * query: '{"id": 1, "name": "ry"}' // 访问路由的默认传递参数
  17. * roles: ['admin', 'common'] // 访问路由的角色权限
  18. * permissions: ['a:a:a', 'b:b:b'] // 访问路由的菜单权限
  19. * meta : {
  20. noCache: true // 如果设置为true,则不会被 <keep-alive> 缓存(默认 false)
  21. title: 'title' // 设置该路由在侧边栏和面包屑中展示的名字
  22. icon: 'svg-name' // 设置该路由的图标,对应路径src/assets/icons/svg
  23. breadcrumb: false // 如果设置为false,则不会在breadcrumb面包屑中显示
  24. activeMenu: '/system/user' // 当路由设置了该属性,则会高亮相对应的侧边栏。
  25. }
  26. */
  27. // 公共路由
  28. export const constantRoutes = [
  29. {
  30. path: '/redirect',
  31. component: Layout,
  32. hidden: true,
  33. children: [
  34. {
  35. path: '/redirect/:path(.*)',
  36. component: () => import('@/views/redirect')
  37. }
  38. ]
  39. },
  40. {
  41. path: '/login',
  42. component: () => import('@/views/login'),
  43. hidden: true
  44. },
  45. {
  46. path: '/lblh',
  47. component: () => import('@/views/lblh/index'),
  48. hidden: true
  49. },
  50. {
  51. path: '/register',
  52. component: () => import('@/views/register'),
  53. hidden: true
  54. },
  55. {
  56. path: '/404',
  57. component: () => import('@/views/error/404'),
  58. hidden: true
  59. },
  60. {
  61. path: '/401',
  62. component: () => import('@/views/error/401'),
  63. hidden: true
  64. },
  65. {
  66. path: '',
  67. component: Layout,
  68. redirect: '/user/work',
  69. children: [
  70. {
  71. path: 'index',
  72. component: () => import('@/views/index'),
  73. name: 'Index',
  74. meta: { title: '首页', icon: 'dashboard', affix: true }
  75. }
  76. ],
  77. hidden: true
  78. },
  79. {
  80. path: '/user',
  81. component: Layout,
  82. hidden: true,
  83. redirect: 'noredirect',
  84. children: [
  85. {
  86. path: 'profile',
  87. component: () => import('@/views/system/user/profile/index'),
  88. name: 'Profile',
  89. meta: { title: '个人中心', icon: 'user' }
  90. }
  91. ]
  92. }
  93. ]
  94. // 动态路由,基于用户权限动态去加载
  95. export const dynamicRoutes = [
  96. {
  97. path: '/system/user-auth',
  98. component: Layout,
  99. hidden: true,
  100. permissions: ['system:user:edit'],
  101. children: [
  102. {
  103. path: 'role/:userId(\\d+)',
  104. component: () => import('@/views/system/user/authRole'),
  105. name: 'AuthRole',
  106. meta: { title: '分配角色', activeMenu: '/system/user' }
  107. }
  108. ]
  109. },
  110. {
  111. path: '/system/role-auth',
  112. component: Layout,
  113. hidden: true,
  114. permissions: ['system:role:edit'],
  115. children: [
  116. {
  117. path: 'user/:roleId(\\d+)',
  118. component: () => import('@/views/system/role/authUser'),
  119. name: 'AuthUser',
  120. meta: { title: '分配用户', activeMenu: '/system/role' }
  121. }
  122. ]
  123. },
  124. {
  125. path: '/system/dict-data',
  126. component: Layout,
  127. hidden: true,
  128. permissions: ['system:dict:list'],
  129. children: [
  130. {
  131. path: 'index/:dictId(\\d+)',
  132. component: () => import('@/views/system/dict/data'),
  133. name: 'Data',
  134. meta: { title: '字典数据', activeMenu: '/system/dict' }
  135. }
  136. ]
  137. },
  138. {
  139. path: '/monitor/job-log',
  140. component: Layout,
  141. hidden: true,
  142. permissions: ['monitor:job:list'],
  143. children: [
  144. {
  145. path: 'index/:jobId(\\d+)',
  146. component: () => import('@/views/monitor/job/log'),
  147. name: 'JobLog',
  148. meta: { title: '调度日志', activeMenu: '/monitor/job' }
  149. }
  150. ]
  151. },
  152. {
  153. path: '/tool/gen-edit',
  154. component: Layout,
  155. hidden: true,
  156. permissions: ['tool:gen:edit'],
  157. children: [
  158. {
  159. path: 'index/:tableId(\\d+)',
  160. component: () => import('@/views/tool/gen/editTable'),
  161. name: 'GenEdit',
  162. meta: { title: '修改生成配置', activeMenu: '/tool/gen' }
  163. }
  164. ]
  165. },
  166. {
  167. path: '/study/enter',
  168. component: Layout,
  169. hidden: true,
  170. permissions: ['business:study:enter'],
  171. children: [
  172. {
  173. path: ':studyId(\\d+)/:tab',
  174. component: () => import('@/views/business/study/comp/enter'),
  175. name: 'StudyEnter',
  176. meta: { title: '', activeMenu: '/trial/list' }
  177. }
  178. ]
  179. },
  180. {
  181. path: '/nonTrial/enter',
  182. component: Layout,
  183. hidden: true,
  184. permissions: ['business:form:nonTrial:enter'],
  185. children: [
  186. {
  187. path: ':studyId(\\d+)/:tab',
  188. component: () => import('@/views/business/form/nonTrial/comp/enter'),
  189. name: 'NonTrialEnter',
  190. meta: { title: '', activeMenu: '/form/nonTrial' }
  191. }
  192. ]
  193. },
  194. {
  195. path: '/drug/enter',
  196. component: Layout,
  197. hidden: true,
  198. permissions: ['business:form:drug:enter'],
  199. children: [
  200. {
  201. path: ':studyId(\\d+)/:tab',
  202. component: () => import('@/views/business/form/drug/comp/enter'),
  203. name: 'DrugEnter',
  204. meta: { title: '', activeMenu: '/form/drug' }
  205. }
  206. ]
  207. },
  208. {
  209. path: '/study/formFillBj',
  210. component: Layout,
  211. hidden: true,
  212. permissions: ['business:studyFormFill:bj'],
  213. children: [
  214. {
  215. path: ':key',
  216. component: () => import('@/views/business/study/comp/tbbd/Bj'),
  217. name: 'studyFormFillBj',
  218. meta: { title: '', activeMenu: '/trial/list' }
  219. }
  220. ]
  221. },
  222. {
  223. path: '/nonTrial/formFillBj',
  224. component: Layout,
  225. hidden: true,
  226. permissions: ['business:nonTrialFormFill:bj'],
  227. children: [
  228. {
  229. path: ':key',
  230. component: () => import('@/views/business/study/comp/tbbd/Bj'),
  231. name: 'nonTrialFormFillBj',
  232. meta: { title: '', activeMenu: '/form/nonTrial' }
  233. }
  234. ]
  235. },
  236. {
  237. path: '/drug/formFillBj',
  238. component: Layout,
  239. hidden: true,
  240. permissions: ['business:drugFormFill:bj'],
  241. children: [
  242. {
  243. path: ':key',
  244. component: () => import('@/views/business/study/comp/tbbd/Bj'),
  245. name: 'drugFormFillBj',
  246. meta: { title: '', activeMenu: '/form/drug' }
  247. }
  248. ]
  249. },
  250. {
  251. path: '/resource/mjy',
  252. component: Layout,
  253. hidden: true,
  254. permissions: ['business:resource:mjy:list'],
  255. children: [
  256. {
  257. path: ':tab',
  258. component: () => import('@/views/business/resource/mjy/index'),
  259. name: 'Mjy',
  260. meta: { title: '麻精药管理', activeMenu: '/resource/mjy/mjyList' }
  261. }
  262. ]
  263. },
  264. {
  265. path: '/resource/gyzj',
  266. component: Layout,
  267. hidden: true,
  268. permissions: ['business:resource:gyzj:list'],
  269. children: [
  270. {
  271. path: ':tab',
  272. component: () => import('@/views/business/resource/gyzj/index'),
  273. name: 'Gyzj',
  274. meta: { title: '给药制剂管理', activeMenu: '/resource/gyzj/gyzjList' }
  275. }
  276. ]
  277. },
  278. {
  279. path: '/resource/specimen',
  280. component: Layout,
  281. hidden: true,
  282. permissions: ['business:resource:gsp:list'],
  283. children: [
  284. {
  285. path: ':tab',
  286. component: () => import('@/views/business/resource/gsp/index'),
  287. name: 'Gsp',
  288. meta: { title: '供试品管理', activeMenu: '/resource/gsp/gspList' }
  289. }
  290. ]
  291. }
  292. ]
  293. // 防止连续点击多次路由报错
  294. let routerPush = Router.prototype.push
  295. let routerReplace = Router.prototype.replace
  296. // push
  297. Router.prototype.push = function push(location) {
  298. return routerPush.call(this, location).catch((err) => err)
  299. }
  300. // replace
  301. Router.prototype.replace = function push(location) {
  302. return routerReplace.call(this, location).catch((err) => err)
  303. }
  304. export default new Router({
  305. mode: 'history', // 去掉url中的#
  306. scrollBehavior: () => ({ y: 0 }),
  307. routes: constantRoutes
  308. })