index.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  1. import Vue from 'vue';
  2. import Router from 'vue-router';
  3. import store from '../store'
  4. import menu from '../menu/menu.js'
  5. import { getToken } from '@/utils/auth'; // get token from cookie
  6. Vue.use(Router);
  7. /* Layout */
  8. import Layout from '@/layout';
  9. import AppMain from '@/layout/components/AppMain.vue';
  10. /**
  11. * Note: sub-menu only appear when route children.length >= 1
  12. * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
  13. *
  14. * hidden: true if set true, item will not show in the sidebar(default is false)
  15. * alwaysShow: true if set true, will always show the root menu
  16. * if not set alwaysShow, when item has more than one children route,
  17. * it will becomes nested mode, otherwise not show the root menu
  18. * redirect: noRedirect if set noRedirect will no redirect in the breadcrumb
  19. * name:'router-name' the name is used by <keep-alive> (must set!!!)
  20. * meta : {
  21. roles: ['admin','editor'] control the page roles (you can set multiple roles)
  22. title: 'title' the name show in sidebar and breadcrumb (recommend set)
  23. icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
  24. breadcrumb: false if set false, the item will hidden in breadcrumb(default is true)
  25. activeMenu: '/example/list' if set path, the sidebar will highlight the path you set
  26. }
  27. */
  28. /**
  29. * constantRoutes
  30. * a base page that does not have permission requirements
  31. * all roles can be accessed
  32. */
  33. export const constantRoutes = [
  34. {
  35. path: '/login',
  36. component: () => import('@/views/login/index'),
  37. hidden: true,
  38. },
  39. {
  40. path: '/404',
  41. component: () => import('@/views/404'),
  42. hidden: true,
  43. },
  44. {
  45. path: '/',
  46. component: Layout,
  47. redirect: '/dashboard',
  48. children: [
  49. {
  50. path: 'dashboard',
  51. name: 'Dashboard',
  52. component: () => import('@/views/dashboard/index'),
  53. meta: { title: '病案首页质量分析', icon: 'dashboard' },
  54. },
  55. //全病历质控
  56. {
  57. path: '/caseNumber',
  58. name: 'caseNumber',
  59. component: () => import('@/views/allcase/caseNumber'),
  60. hidden: true, //不在导航栏展示
  61. meta: { title: '病案数量' },
  62. },
  63. {
  64. path: '/defectNumber',
  65. name: 'defectNumber',
  66. component: () => import('@/views/allcase/defectNumber'),
  67. hidden: true,//不在导航栏展示
  68. meta: { title: '缺陷病案'},
  69. },
  70. {
  71. path: '/homePage',
  72. name: 'homePage',
  73. component: () => import('@/views/allcase/homePage'),
  74. hidden: true,//不在导航栏展示
  75. meta: { title: '出院记录'},
  76. },
  77. {
  78. path: '/caseViews',
  79. name: 'caseViews',
  80. component: () => import('@/views/allcase/caseViews'),
  81. hidden: true,//不在导航栏展示
  82. meta: { title: '出院记录'},
  83. },
  84. //首页数据质控
  85. {
  86. path: '/defectList',
  87. name: 'defectList',
  88. component: () => import('@/views/data/medicalRecords/defectList'),
  89. hidden: true,//不在导航栏展示
  90. meta: { title: '质量分析缺陷病案', keepAlive:true }
  91. },
  92. {
  93. path: '/medicalRecords',
  94. name: 'medicalRecords',
  95. component: () => import('@/views/data/medicalRecords'),
  96. hidden: true, //不在导航栏展示
  97. meta: { title: '质量分析病案数量',keepAlive:true }
  98. },
  99. {
  100. path: '/errorList',
  101. name: 'errorList',
  102. component: () => import('@/views/data/medicalRecords/errorList'),
  103. hidden: true, //不在导航栏展示
  104. meta: { title: '病案数' }
  105. },
  106. {
  107. path: '/department',
  108. name: 'department',
  109. component: () => import('@/views/data/medicalRecords/department'),
  110. hidden: true, //不在导航栏展示
  111. meta: { title: '总缺陷'}
  112. },
  113. {
  114. path: '/TotalRankingList',
  115. name: 'TotalRankingList',
  116. component: () => import('@/views/data/frontHome/TotalRankingList'),
  117. hidden: true, //不在导航栏展示
  118. meta: { title: '总排名' },
  119. },
  120. {
  121. path: '/codeList',
  122. name: 'codeList',
  123. component: () => import('@/views/data/medicalRecords/codeList'),
  124. hidden: true, //不在导航栏展示
  125. meta: { title: '编码员' }
  126. },
  127. {
  128. path: '/details',
  129. name: 'details',
  130. component: () => import('@/views/data/query/details'),
  131. hidden: true, //不在导航栏展示
  132. meta: { title: '病案首页质控详情' }
  133. },
  134. {
  135. path: '/ChargeDetails',
  136. name: 'ChargeDetails',
  137. hidden: true, //不在导航栏展示
  138. component: () => import('@/views/data/query/ChargeDetails'),
  139. meta: { title: '费用明细' }
  140. },
  141. {
  142. path: '/StatementList',
  143. name: 'StatementList',
  144. component: () => import('@/views/SettlementList/StatementList'),
  145. hidden: true,//不在导航栏展示
  146. meta: { title: '结算清单数量'}
  147. },
  148. // 医保结算清单
  149. {
  150. path: '/SetDetails',
  151. name: 'SetDetails',
  152. component: () => import('@/views/SettlementList/SetDetails'),
  153. hidden: true,//不在导航栏展示
  154. meta: { title: '医保结算单病案数量' }
  155. },
  156. {
  157. path: '/StatementListquery',
  158. name: 'StatementListquery',
  159. component: () => import('@/views/SettlementList/StatementListquery'),
  160. hidden: true,//不在导航栏展示
  161. meta: { title: '医保结算单病案数量'}
  162. },
  163. {
  164. path: '/defectStatementList',
  165. name: 'defectStatementList',
  166. hidden: true,//不在导航栏展示
  167. component: () => import('@/views/SettlementList/defectStatementList'),
  168. meta: { title: '缺陷结算清单数量'}
  169. },
  170. {
  171. path: '/caseIndex',
  172. name: 'caseIndex',
  173. component: () => import('@/views/allcase/caseIndex'),
  174. hidden: true,
  175. meta: { title: '病案管理质量控制指标', keepAlive:true},
  176. },
  177. {
  178. path: '/caseIndexList',
  179. name: 'caseIndexList',
  180. component: () => import('@/views/allcase/caseIndexList'),
  181. hidden: true,
  182. meta: { title: '病案管理质量控制指标列表', keepAlive:true },
  183. },
  184. {
  185. path: '/caseIndexAnalysis',
  186. name: 'CaseIndexAnalysis',
  187. component: () => import('@/views/allcase/caseIndexAnalysis'),
  188. hidden: true,
  189. meta: { title: '评审评价指标分析', keepAlive:true },
  190. },
  191. {
  192. path: '/caseIndexAnalysisList',
  193. name: 'CaseIndexAnalysisList',
  194. component: () => import('@/views/allcase/caseIndexAnalysisList'),
  195. meta: { title: '评审评价指标分析-科室病案' },
  196. hidden: true,
  197. },
  198. {
  199. path: '/searchSystem',
  200. name: 'SearchSystem',
  201. component: () => import('@/views/searchSystem/index'),
  202. hidden: true,
  203. meta: { title: '医院大数据自助查询系统', keepAlive:true, icon: 'dashboard' },
  204. },
  205. {
  206. path: '/outpatientCase',
  207. name: 'OutpatientCase',
  208. component: () => import('@/views/outpatient/case'),
  209. meta: { title: '门诊病历查询' },
  210. hidden: true,
  211. },
  212. {
  213. path: '/outpatientControl',
  214. name: 'OutpatientControl',
  215. component: () => import('@/views/outpatient/control'),
  216. meta: { title: '门诊病历质控' },
  217. hidden: true,
  218. },
  219. {
  220. path: '/outpatientMedicalRecordDefectNumber',
  221. name: 'OutpatientMedicalRecordDefectNumber',
  222. component: () => import('@/views/outpatient/control/defectNumber'),
  223. meta: { title: '门诊病历', keepAlive: true },
  224. hidden: true,
  225. },
  226. {
  227. path: '/outpatientMedicalShouldDefectNumber',
  228. name: 'OutpatientMedicalShouldDefectNumber',
  229. component: () => import('@/views/outpatient/control/shouldDefectNumber'),
  230. meta: { title: '门诊应有病历', keepAlive: true },
  231. hidden: true,
  232. },
  233. {
  234. path: '/outpatientMedicalRecordDetail',
  235. name: 'OutpatientMedicalRecordDetail',
  236. component: () => import('@/views/outpatient/control/detail'),
  237. meta: { title: '门诊病历详情' },
  238. hidden: true,
  239. },
  240. {
  241. path: '/reviewIndicators',
  242. name: 'reviewIndicators',
  243. component: () => import('@/views/allcase/reviewIndicators.vue'),
  244. hidden: true,
  245. meta: { title: '评审指标', keepAlive:true},
  246. },
  247. {
  248. path: '/reviewIndicatorsList',
  249. name: 'reviewIndicatorsList',
  250. component: () => import('@/views/allcase/reviewIndicatorsList.vue'),
  251. hidden: true,
  252. meta: { title: '指标列表', keepAlive:false },
  253. },
  254. {
  255. path: '/yypsIndexAnalysis',
  256. name: 'YypsIndexAnalysis',
  257. component: () => import('@/views/yyps/analysis/index.vue'),
  258. hidden: true,
  259. meta: { title: '指标分析', keepAlive:true },
  260. },
  261. {
  262. path: '/yypsIndex',
  263. name: 'yypsIndex',
  264. component: () => import('@/views/yyps/index/index.vue'),
  265. hidden: true,
  266. meta: { title: '评审指标', keepAlive:true},
  267. },
  268. ],
  269. },
  270. // 医院大数据自助查询系统
  271. {
  272. path: '/hospital',
  273. component: AppMain,
  274. redirect: '/hospital-search',
  275. children: [
  276. {
  277. path: '/hospital-search',
  278. name: 'HospitalSearch',
  279. component: () => import('@/views/searchSystem/index'),
  280. meta: { keepAlive:true },
  281. hidden: true
  282. },
  283. {
  284. path: '/hospital-caseViews',
  285. name: 'HospitalCaseViews',
  286. component: () => import('@/views/allcase/caseViews'),
  287. hidden: true
  288. },
  289. {
  290. path: '/hospital-details',
  291. name: 'HospitalDetails',
  292. component: () => import('@/views/data/query/details'),
  293. hidden: true
  294. },
  295. {
  296. path: '/hospital-chargeDetails',
  297. name: 'HospitalChargeDetails',
  298. hidden: true,
  299. component: () => import('@/views/data/query/ChargeDetails')
  300. },
  301. ]
  302. },
  303. {
  304. path: '/embedIndex',
  305. component: AppMain,
  306. redirect: '/embedIndex-home',
  307. children: [
  308. {
  309. path: '/embedIndex-home',
  310. name: 'EmbedIndexHome',
  311. component: () => import('@/views/embedIndex/index'),
  312. meta: { keepAlive: true },
  313. hidden: true
  314. },
  315. {
  316. path: '/embedIndex-caseIndexAnalysisList',
  317. name: 'EmbedIndexCaseIndexAnalysisList',
  318. component: () => import('@/views/allcase/caseIndexAnalysisList'),
  319. hidden: true
  320. },
  321. {
  322. path: '/embedIndex-caseIndexList',
  323. name: 'EmbedIndexCaseIndexList',
  324. component: () => import('@/views/allcase/caseIndexList'),
  325. hidden: true,
  326. },
  327. {
  328. path: '/embedIndex-caseViews',
  329. name: 'EmbedIndexCaseViews',
  330. component: () => import('@/views/allcase/caseViews'),
  331. hidden: true
  332. },
  333. {
  334. path: '/embedIndex-chargeDetails',
  335. name: 'EmbedIndexChargeDetails',
  336. hidden: true,
  337. component: () => import('@/views/data/query/ChargeDetails')
  338. }
  339. ]
  340. },
  341. {
  342. path: '/whitelist',
  343. component: AppMain,
  344. redirect: '/whitelist-search',
  345. children: [
  346. {
  347. path: '/whitelist-search',
  348. name: 'WhitelistSearch',
  349. component: () => import('@/views/searchSystem/index'),
  350. meta: { keepAlive:true },
  351. hidden: true
  352. },
  353. {
  354. path: '/whitelist-caseViews',
  355. name: 'WhitelistCaseViews',
  356. component: () => import('@/views/allcase/caseViews'),
  357. hidden: true
  358. },
  359. {
  360. path: '/whitelist-chargeDetails',
  361. name: 'WhitelistChargeDetails',
  362. hidden: true,
  363. component: () => import('@/views/data/query/ChargeDetails')
  364. },
  365. {
  366. path: '/whitelist-details',
  367. name: 'WhitelistDetails',
  368. component: () => import('@/views/data/query/details'),
  369. hidden: true
  370. },
  371. ]
  372. }
  373. ];
  374. const createRouter = () =>
  375. new Router({
  376. // mode: 'history', // require service support
  377. scrollBehavior: () => ({ y: 0 }),
  378. routes: constantRoutes,
  379. });
  380. const router = createRouter();
  381. const whiteList = ['/login','/404', '/whitelist-search', '/whitelist-caseViews', '/whitelist-chargeDetails', '/whitelist-details']; // 添加路由白名单
  382. //路由判断
  383. router.beforeEach(async (to, from, next) => {
  384. const hasToken = getToken();
  385. if(hasToken){
  386. if (!store.state.user.menu.length) {
  387. // 判断当前用户是否已拉取完权限菜单信息
  388. // 如果本地不存在权限菜单,则获取权限菜单,生成菜单列表
  389. if(!sessionStorage.getItem("route")){
  390. //获取路由菜单
  391. menu.getMenu().then(response =>{
  392. //保险起见,组装一次数据
  393. menu.parseRoute(JSON.parse(sessionStorage.getItem("route")),[]).then(res =>{
  394. //添加路由并进行跳转
  395. menu.addMenu(res).then(e =>{
  396. next({ ...to, replace: true }) // hack方法 确保addRoutes已完成
  397. })
  398. })
  399. }).catch(err =>{//失败则直接跳转登录页面
  400. next(`/login?redirect=${to.path}`);
  401. })
  402. }else{//从缓存中读取用户权限列表,并添加菜单到侧边栏和路由元
  403. menu.parseRoute(JSON.parse(sessionStorage.getItem("route")),[]).then(res =>{
  404. menu.addMenu(res).then(e =>{
  405. next({ ...to, replace: true }) // hack方法 确保addRoutes已完成
  406. })
  407. })
  408. }
  409. }else{
  410. // 有路由表直接放行
  411. next();
  412. }
  413. }else{
  414. if (whiteList.indexOf(to.path) !== -1) {
  415. // 在白名单内直接放行
  416. next();
  417. } else {
  418. // 其他没有访问权限的页面将被重定向到登录页面。
  419. next(`/login?redirect=${to.path}`);
  420. }
  421. }
  422. if(to.path == from.path ){
  423. // 让 列表页 即不缓存,刷新
  424. to.meta.keepAlive = false;
  425. }
  426. next()
  427. })
  428. // Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
  429. export function resetRouter() {
  430. const newRouter = createRouter();
  431. router.matcher = newRouter.matcher; // reset router
  432. }
  433. export default router;