index.js 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. import { createWebHistory, createRouter } from 'vue-router'
  2. /* Layout */
  3. import Layout from '@/layout'
  4. /**
  5. * Note: 路由配置项
  6. *
  7. * hidden: true // 当设置 true 的时候该路由不会再侧边栏出现 如401,login等页面,或者如一些编辑页面/edit/1
  8. * alwaysShow: true // 当你一个路由下面的 children 声明的路由大于1个时,自动会变成嵌套的模式--如组件页面
  9. * // 只有一个时,会将那个子路由当做根路由显示在侧边栏--如引导页面
  10. * // 若你想不管路由下面的 children 声明的个数都显示你的根路由
  11. * // 你可以设置 alwaysShow: true,这样它就会忽略之前定义的规则,一直显示根路由
  12. * redirect: noRedirect // 当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
  13. * name:'router-name' // 设定路由的名字,一定要填写不然使用<keep-alive>时会出现各种问题
  14. * query: '{"id": 1, "name": "ry"}' // 访问路由的默认传递参数
  15. * roles: ['admin', 'common'] // 访问路由的角色权限
  16. * permissions: ['a:a:a', 'b:b:b'] // 访问路由的菜单权限
  17. * meta : {
  18. noCache: true // 如果设置为true,则不会被 <keep-alive> 缓存(默认 false)
  19. title: 'title' // 设置该路由在侧边栏和面包屑中展示的名字
  20. icon: 'svg-name' // 设置该路由的图标,对应路径src/assets/icons/svg
  21. breadcrumb: false // 如果设置为false,则不会在breadcrumb面包屑中显示
  22. activeMenu: '/system/user' // 当路由设置了该属性,则会高亮相对应的侧边栏。
  23. }
  24. */
  25. // 公共路由
  26. export const constantRoutes = [
  27. {
  28. path: '/redirect',
  29. component: Layout,
  30. hidden: true,
  31. children: [
  32. {
  33. path: '/redirect/:path(.*)',
  34. component: () => import('@/views/redirect/index.vue')
  35. }
  36. ]
  37. },
  38. {
  39. path: '/login',
  40. component: () => import('@/views/login'),
  41. hidden: true
  42. },
  43. {
  44. path: '/register',
  45. component: () => import('@/views/register'),
  46. hidden: true
  47. },
  48. {
  49. path: '/:pathMatch(.*)*',
  50. component: () => import('@/views/error/404'),
  51. hidden: true
  52. },
  53. {
  54. path: '/401',
  55. component: () => import('@/views/error/401'),
  56. hidden: true
  57. },
  58. {
  59. path: '',
  60. component: Layout,
  61. redirect: '/index',
  62. children: [
  63. {
  64. path: '/index',
  65. component: () => import('@/views/index'),
  66. name: 'Index',
  67. meta: {
  68. title: '首页',
  69. icon: 'dashboard',
  70. affix: true
  71. }
  72. }
  73. ]
  74. },
  75. {
  76. path: '/user',
  77. component: Layout,
  78. hidden: true,
  79. redirect: 'noredirect',
  80. children: [
  81. {
  82. path: 'profile',
  83. component: () => import('@/views/system/user/profile/index'),
  84. name: 'Profile',
  85. meta: {
  86. title: '个人中心',
  87. icon: 'user'
  88. }
  89. }
  90. ]
  91. }
  92. ]
  93. // 动态路由,基于用户权限动态去加载
  94. export const dynamicRoutes = [
  95. {
  96. path: '/system/user-auth',
  97. component: Layout,
  98. hidden: true,
  99. permissions: ['system:user:edit'],
  100. children: [
  101. {
  102. path: 'role/:userId(\\d+)',
  103. component: () => import('@/views/system/user/authRole'),
  104. name: 'AuthRole',
  105. meta: {
  106. title: '分配角色',
  107. activeMenu: '/system/user'
  108. }
  109. }
  110. ]
  111. },
  112. {
  113. path: '/system/role-auth',
  114. component: Layout,
  115. hidden: true,
  116. permissions: ['system:role:edit'],
  117. children: [
  118. {
  119. path: 'user/:roleId(\\d+)',
  120. component: () => import('@/views/system/role/authUser'),
  121. name: 'AuthUser',
  122. meta: {
  123. title: '分配用户',
  124. activeMenu: '/system/role'
  125. }
  126. }
  127. ]
  128. },
  129. {
  130. path: '/system/dict-data',
  131. component: Layout,
  132. hidden: true,
  133. permissions: ['system:dict:list'],
  134. children: [
  135. {
  136. path: 'index/:dictId(\\d+)',
  137. component: () => import('@/views/system/dict/data'),
  138. name: 'Data',
  139. meta: {
  140. title: '字典数据',
  141. activeMenu: '/system/dict'
  142. }
  143. }
  144. ]
  145. },
  146. {
  147. path: '/monitor/job-log',
  148. component: Layout,
  149. hidden: true,
  150. permissions: ['monitor:job:list'],
  151. children: [
  152. {
  153. path: 'index/:jobId(\\d+)',
  154. component: () => import('@/views/monitor/job/log'),
  155. name: 'JobLog',
  156. meta: {
  157. title: '调度日志',
  158. activeMenu: '/monitor/job'
  159. }
  160. }
  161. ]
  162. },
  163. {
  164. path: '/tool/gen-edit',
  165. component: Layout,
  166. hidden: true,
  167. permissions: ['tool:gen:edit'],
  168. children: [
  169. {
  170. path: 'index/:tableId(\\d+)',
  171. component: () => import('@/views/tool/gen/editTable'),
  172. name: 'GenEdit',
  173. meta: {
  174. title: '修改生成配置',
  175. activeMenu: '/tool/gen'
  176. }
  177. }
  178. ]
  179. },
  180. {
  181. path: '/reviseBath',
  182. component: Layout,
  183. hidden: true,
  184. permissions: ['business:productionPlan:query'],
  185. children: [
  186. {
  187. path: 'lotFormParticulars/:lotCode(.*)',
  188. component: () => import('@/views/business/reviseBath/lotFormParticulars'),
  189. name: 'LotProductionPlan',
  190. meta: {
  191. title: '批次详情'
  192. }
  193. }
  194. ]
  195. },
  196. {
  197. path: '/drawing',
  198. component: Layout,
  199. hidden: true,
  200. permissions: ['business:electronicDrawings:query'],
  201. children: [
  202. {
  203. // 假设您要传递的三个参数
  204. path: 'drawingDetail/:productId/:productVersion/:processCode',
  205. component: () => import('@/views/business/drawing/drawingDetail'),
  206. name: 'drawingDetails',
  207. meta: {
  208. title: '产品图纸'
  209. }
  210. }
  211. ]
  212. },
  213. {
  214. path: '/standards',
  215. component: Layout,
  216. hidden: true,
  217. permissions: ['business:standards:list'],
  218. children: [
  219. {
  220. // 假设您要传递的三个参数
  221. path: 'detail/:productId/:productVersion/:processCode',
  222. component: () => import('@/views/business/standards/detail'),
  223. name: 'detail',
  224. meta: {
  225. title: '产品检查标准'
  226. }
  227. }
  228. ]
  229. },
  230. // {
  231. // path: '/drawing',
  232. // component: Layout,
  233. // hidden: true,
  234. // permissions: ['business:drawing:query'],
  235. // children: [
  236. // {
  237. // path: 'drawingDetail/:currentProduct(.*)',
  238. // component: () => import('@/views/business/drawing/drawingDetail'),
  239. // name: 'drawingDetails',
  240. // meta: {
  241. // title: '产品图纸'
  242. // }
  243. // }
  244. // ]
  245. // },
  246. {
  247. path: '/Production',
  248. component: Layout,
  249. hidden: true,
  250. permissions: ['business:productionPlan:query'],
  251. children: [
  252. {
  253. path: 'lot/:productionPlanNo(.*)/:lineNumber(.*)',
  254. component: () => import('@/views/business/lot/index'),
  255. name: 'lotInfo',
  256. meta: {
  257. title: '计划查询'
  258. }
  259. }
  260. ]
  261. }
  262. ]
  263. const router = createRouter({
  264. history: createWebHistory(),
  265. routes: constantRoutes,
  266. scrollBehavior(to, from, savedPosition) {
  267. if (savedPosition) {
  268. return savedPosition
  269. } else {
  270. return {
  271. top: 0
  272. }
  273. }
  274. }
  275. })
  276. export default router