index.js 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  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: '/webViewer/:code(\\d+)',
  47. component: () => import('@/views/webViewer'),
  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: 'index',
  69. children: [
  70. {
  71. path: 'index',
  72. component: () => import('@/views/index'),
  73. name: 'Index',
  74. meta: { title: '首页', icon: 'dashboard', affix: true }
  75. }
  76. ]
  77. },
  78. {
  79. path: '/user',
  80. component: Layout,
  81. hidden: true,
  82. redirect: 'noredirect',
  83. children: [
  84. {
  85. path: 'profile',
  86. component: () => import('@/views/system/user/profile/index'),
  87. name: 'Profile',
  88. meta: { title: '个人中心', icon: 'user' }
  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: { title: '分配角色', activeMenu: '/system/user' }
  106. }
  107. ]
  108. },
  109. {
  110. path: '/system/role-auth',
  111. component: Layout,
  112. hidden: true,
  113. permissions: ['system:role:edit'],
  114. children: [
  115. {
  116. path: 'user/:roleId(\\d+)',
  117. component: () => import('@/views/system/role/authUser'),
  118. name: 'AuthUser',
  119. meta: { title: '分配用户', activeMenu: '/system/role' }
  120. }
  121. ]
  122. },
  123. {
  124. path: '/system/dict-data',
  125. component: Layout,
  126. hidden: true,
  127. permissions: ['system:dict:list'],
  128. children: [
  129. {
  130. path: 'index/:dictId(\\d+)',
  131. component: () => import('@/views/system/dict/data'),
  132. name: 'Data',
  133. meta: { title: '字典数据', activeMenu: '/system/dict' }
  134. }
  135. ]
  136. },
  137. {
  138. path: '/monitor/job-log',
  139. component: Layout,
  140. hidden: true,
  141. permissions: ['monitor:job:list'],
  142. children: [
  143. {
  144. path: 'index',
  145. component: () => import('@/views/monitor/job/log'),
  146. name: 'JobLog',
  147. meta: { title: '调度日志', activeMenu: '/monitor/job' }
  148. }
  149. ]
  150. },
  151. {
  152. path: '/tool/gen-edit',
  153. component: Layout,
  154. hidden: true,
  155. permissions: ['tool:gen:edit'],
  156. children: [
  157. {
  158. path: 'index/:tableId(\\d+)',
  159. component: () => import('@/views/tool/gen/editTable'),
  160. name: 'GenEdit',
  161. meta: { title: '修改生成配置', activeMenu: '/tool/gen' }
  162. }
  163. ]
  164. },
  165. // {
  166. // path: '/tool/gen-form',
  167. // component: Layout,
  168. // hidden: true,
  169. // permissions: ['tool:gen:edit'],
  170. // children: [
  171. // {
  172. // path: 'index/:tableId(\\d+)',
  173. // component: () => import('@/views/tool/build/index'),
  174. // name: 'GenEdit',
  175. // meta: { title: '修改生成配置', activeMenu: '/tool/gen' }
  176. // }
  177. // ]
  178. // },
  179. {
  180. path: '/cloth',
  181. component: Layout,
  182. hidden: true,
  183. permissions: ['cloth:price:list'],
  184. children: [
  185. {
  186. path: 'setPrice/:clothId(\\d+)',
  187. component: () => import('@/views/cloth/clothItem/setPrice.vue'),
  188. name: 'SetClothPrice',
  189. meta: { title: '设置价格' }
  190. }
  191. ]
  192. },
  193. {
  194. path: '/goods',
  195. component: Layout,
  196. hidden: true,
  197. permissions: ['goods:commonGoods:list'],
  198. children: [
  199. {
  200. path: 'setSku/:goodsId(\\d+)',
  201. component: () => import('@/views/goods/commonGoods/setSku.vue'),
  202. name: 'setGoodsSku',
  203. meta: { title: '设置价格' }
  204. }
  205. ]
  206. },
  207. {
  208. path: '/goods',
  209. component: Layout,
  210. hidden: true,
  211. permissions: ['goods:commonGoods:list'],
  212. children: [
  213. {
  214. path: 'stockRecord/:goodsSkuId(\\d+)',
  215. component: () => import('@/views/goods/commonGoods/stockRecord.vue'),
  216. name: 'stockRecord',
  217. meta: { title: '库存记录' }
  218. }
  219. ]
  220. },
  221. {
  222. path: '/recharge',
  223. component: Layout,
  224. hidden: true,
  225. permissions: ['recharge:batchRecord:edit'],
  226. children: [
  227. {
  228. path: 'useRecord/:batchNo(\\d+)',
  229. component: () => import('@/views/recharge/batchRecord/useRecord.vue'),
  230. name: 'useRecord',
  231. meta: { title: '使用记录' }
  232. }
  233. ]
  234. },
  235. {
  236. path: '/recharge',
  237. component: Layout,
  238. hidden: true,
  239. permissions: ['recharge:batchRecord:edit'],
  240. children: [
  241. {
  242. path: 'cardDetail/:batchNo(\\d+)',
  243. component: () => import('@/views/recharge/batchRecord/cardDetail.vue'),
  244. name: 'useRecord',
  245. meta: { title: '明细详情' }
  246. }
  247. ]
  248. },
  249. {
  250. path: '/hanger',
  251. component: Layout,
  252. hidden: true,
  253. permissions: ['cloth:hanger:list'],
  254. children: [
  255. {
  256. path: 'detail/:hangerId(\\d+)',
  257. component: () => import('@/views/cloth/hanger/detail.vue'),
  258. name: 'Detail',
  259. meta: { title: '位置详情' }
  260. }
  261. ]
  262. },
  263. {
  264. path: '/activity',
  265. component: Layout,
  266. hidden: true,
  267. permissions: ['activity:couponInfo:list','activity:groupInfo:list'],
  268. children: [
  269. {
  270. path: 'couponItem/:activityId(\\d+)',
  271. component: () => import('@/views/activity/couponItem/index.vue'),
  272. name: 'ActivityCouponItem',
  273. meta: { title: '设置优惠券' }
  274. }
  275. ]
  276. },
  277. {
  278. path: '/activity',
  279. component: Layout,
  280. hidden: true,
  281. permissions: ['activity:recharge:list'],
  282. children: [
  283. {
  284. path: 'rechargeItem/:activityId(\\d+)',
  285. component: () => import('@/views/activity/rechargeItem/index.vue'),
  286. name: 'ActivityRechargeItem',
  287. meta: { title: '设置充值规则' }
  288. }
  289. ]
  290. },
  291. {
  292. path: '/activity',
  293. component: Layout,
  294. hidden: true,
  295. permissions: ['activity:clothInfo:list'],
  296. children: [
  297. {
  298. path: 'clothItem/:activityId(\\d+)',
  299. component: () => import('@/views/activity/clothItem/index.vue'),
  300. name: 'ActivityClothItem',
  301. meta: { title: '设置充值规则' }
  302. }
  303. ]
  304. },
  305. {
  306. path: '/coupon',
  307. component: Layout,
  308. hidden: true,
  309. permissions: ['coupon:type:list'],
  310. children: [
  311. {
  312. path: 'typeApplyCloth/:couponTypeId(\\d+)',
  313. component: () => import('@/views/coupon/typeApplyCloth/index.vue'),
  314. name: 'CouponTypeApplyClothItem',
  315. meta: { title: '设置优惠券适用衣服' }
  316. }
  317. ]
  318. },
  319. {
  320. path: '/settlement',
  321. component: Layout,
  322. hidden: true,
  323. permissions: ['settlement:bill:list'],
  324. children: [
  325. {
  326. path: 'factory/:billId(\\d+)',
  327. component: () => import('@/views/settlement/bill/factorySettlement.vue'),
  328. name: 'factorySettlement',
  329. meta: { title: '工厂结算详情明细' }
  330. }
  331. ]
  332. },
  333. {
  334. path: '/settlement',
  335. component: Layout,
  336. hidden: true,
  337. permissions: ['settlement:bill:list'],
  338. children: [
  339. {
  340. path: 'store/:billId(\\d+)',
  341. component: () => import('@/views/settlement/bill/storeSettlement.vue'),
  342. name: 'storeSettlement',
  343. meta: { title: '门店结算详情明细' }
  344. }
  345. ]
  346. },
  347. ]
  348. // 防止连续点击多次路由报错
  349. let routerPush = Router.prototype.push;
  350. Router.prototype.push = function push(location) {
  351. return routerPush.call(this, location).catch(err => err)
  352. }
  353. export default new Router({
  354. mode: 'history', // 去掉url中的#
  355. scrollBehavior: () => ({ y: 0 }),
  356. routes: constantRoutes
  357. })