|
|
@ -2,6 +2,7 @@ import Vue from 'vue' |
|
|
|
import Router from 'vue-router' |
|
|
|
import http from '../utils/request' |
|
|
|
import { isURL } from '@/utils/validate' |
|
|
|
import Cookies from 'js-cookie' |
|
|
|
|
|
|
|
Vue.use(Router) |
|
|
|
|
|
|
@ -146,6 +147,9 @@ router.beforeEach((to, from, next) => { |
|
|
|
} |
|
|
|
if (to.name === 'login' || to.path === '/login' || to.path === 'satusScreen' || to.name === 'satusScreen') { |
|
|
|
next() |
|
|
|
} else if (to.name === '360view' && to.query.doctorId) { |
|
|
|
loginByDocId(to.query.doctorId, next, to.fullPath) |
|
|
|
|
|
|
|
} else { |
|
|
|
// 获取字典列表, 添加并全局变量保存
|
|
|
|
// http.get('/sys/dict/type/all').then(({ data: res }) => {
|
|
|
@ -154,7 +158,6 @@ router.beforeEach((to, from, next) => { |
|
|
|
// }
|
|
|
|
// window.SITE_CONFIG['dictList'] = res.data
|
|
|
|
// }).catch(() => {})
|
|
|
|
|
|
|
|
// 获取左侧菜单列表,添加并全局变量保存
|
|
|
|
http.get('/sys/menu/nav').then(({ data: res }) => { |
|
|
|
if (res.code !== 0) { |
|
|
@ -178,7 +181,6 @@ router.beforeEach((to, from, next) => { |
|
|
|
} |
|
|
|
// window.SITE_CONFIG['menuList'] = res.data
|
|
|
|
const menuListChild = res.data.filter(item => item.children.length > 0) |
|
|
|
// this.$store.commit('activeIndexFun', menuListChild[0].children[0].id)
|
|
|
|
fnAddDynamicMenuRoutes(JSON.parse(JSON.stringify(res.data)), menuListChild.length) |
|
|
|
|
|
|
|
next({ ...to, replace: true }) |
|
|
@ -186,69 +188,62 @@ router.beforeEach((to, from, next) => { |
|
|
|
// console.log(123)
|
|
|
|
return next({ name: 'login' }) |
|
|
|
}) |
|
|
|
// 获取【字段字典表】, 添加并全局变量保存
|
|
|
|
// http.get('/sys/table/dict/getList', { params: { type: 1 }}).then(({ data: res }) => {
|
|
|
|
// window.SITE_CONFIG['dict_colSearch'] = res.data
|
|
|
|
// })
|
|
|
|
getInitData() |
|
|
|
} |
|
|
|
}) |
|
|
|
function getInitData() { |
|
|
|
// 获取字典列表, 添加并全局变量保存
|
|
|
|
// http.get('/sys/dict/type/all').then(({ data: res }) => {
|
|
|
|
// if (res.code !== 0) { return }
|
|
|
|
// window.SITE_CONFIG['dictList'] = res.data
|
|
|
|
// })
|
|
|
|
|
|
|
|
// 获取【字段字典表】, 添加并全局变量保存
|
|
|
|
// http.get('/table/dict/optionsColumn').then(({ data: res }) => {
|
|
|
|
// window.SITE_CONFIG['dict_colAll'] = res.data
|
|
|
|
// })
|
|
|
|
//
|
|
|
|
// // 获取【字段字典表】, 添加并全局变量保存
|
|
|
|
// http.get('/table/dict/optionsColumn', { params: { type: 1 }}).then(({ data: res }) => {
|
|
|
|
// window.SITE_CONFIG['dict_colSearch'] = res.data
|
|
|
|
// })
|
|
|
|
//
|
|
|
|
// // 获取【字段字典表】, 添加并全局变量保存
|
|
|
|
// http.get('/table/dict/optionsColumn', { params: { type: 2 }}).then(({ data: res }) => {
|
|
|
|
// window.SITE_CONFIG['dict_colChart'] = res.data
|
|
|
|
// })
|
|
|
|
//
|
|
|
|
// // 获取【字段字典表】, 添加并全局变量保存
|
|
|
|
// http.get('/table/dict/optionsColumn', { params: { type: 3 }}).then(({ data: res }) => {
|
|
|
|
// window.SITE_CONFIG['dict_colCrf'] = res.data
|
|
|
|
// })
|
|
|
|
//
|
|
|
|
// // 获取【字段字典表】, 添加并全局变量保存
|
|
|
|
// http.get('/table/dict/optionsColumn', { params: { type: 4 }}).then(({ data: res }) => {
|
|
|
|
// window.SITE_CONFIG['dict_colExport'] = res.data
|
|
|
|
// })
|
|
|
|
|
|
|
|
// 获取【检查项目字典】, 添加并全局变量保存
|
|
|
|
// http.get('/table/dict/examItem').then(({ data: res }) => {
|
|
|
|
// sortChinese(res.data, 'itemName')
|
|
|
|
// window.SITE_CONFIG['dict_examItem'] = res.data
|
|
|
|
// })
|
|
|
|
|
|
|
|
// 获取【设备信息字典】, 添加并全局变量保存
|
|
|
|
// http.get('/device/getData2RelDeviceList').then(({ data: res }) => {
|
|
|
|
// window.SITE_CONFIG['dict_device'] = res.data
|
|
|
|
// })
|
|
|
|
function getNavList(next) { |
|
|
|
http.get('/sys/menu/nav').then(({ data: res }) => { |
|
|
|
if (res.code !== 0) { |
|
|
|
Vue.prototype.$message.error(res.msg) |
|
|
|
return next() |
|
|
|
} |
|
|
|
window.SITE_CONFIG['menuList'] = res.data |
|
|
|
}).catch(() => { |
|
|
|
return next({ name: 'login' }) |
|
|
|
}) |
|
|
|
} |
|
|
|
function muneList(next) { |
|
|
|
http.get('/sys/menu/list', { |
|
|
|
params: { |
|
|
|
type: 0 |
|
|
|
} |
|
|
|
}).then(({ data: res }) => { |
|
|
|
if (res.code !== 0) { |
|
|
|
Vue.prototype.$message.error(res.msg) |
|
|
|
return next({ name: 'login' }) |
|
|
|
} |
|
|
|
// window.SITE_CONFIG['menuList'] = res.data
|
|
|
|
const menuListChild = res.data.filter(item => item.children.length > 0) |
|
|
|
fnAddDynamicMenuRoutes(JSON.parse(JSON.stringify(res.data)), menuListChild.length) |
|
|
|
}).catch(() => { |
|
|
|
return next({ name: 'login' }) |
|
|
|
}) |
|
|
|
} |
|
|
|
function loginByDocId(doctorId, next) { |
|
|
|
const params = { |
|
|
|
doctorId: doctorId |
|
|
|
} |
|
|
|
http.post('/loginByDid', params).then(({ data: res }) => { |
|
|
|
if (res.code !== 0) { |
|
|
|
return this.$message.error(res.msg) |
|
|
|
} |
|
|
|
console.log(res) |
|
|
|
Cookies.set('xa-token', res.data.token) |
|
|
|
window.localStorage.setItem('qg-userData', JSON.stringify(res.data.currentUser)) |
|
|
|
getNavList(next) |
|
|
|
muneList(next) |
|
|
|
|
|
|
|
// 获取【设备与检查项目字典】, 添加并全局变量保存
|
|
|
|
// http.get('/device/getData2RelDeviceItemList').then(({ data: res }) => {
|
|
|
|
// window.SITE_CONFIG['dict_device_item'] = res.data
|
|
|
|
// })
|
|
|
|
return next() |
|
|
|
}).catch(() => { }) |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 判断当前路由是否为页面路由 |
|
|
|
* @param {*} route 当前路由 |
|
|
|
* @param {*} pageRoutes 页面路由 |
|
|
|
*/ |
|
|
|
function fnCurrentRouteIsPageRoute(route, pageRoutes = []) { |
|
|
|
var temp = [] |
|
|
|
for (var i = 0; i < pageRoutes.length; i++) { |
|
|
|
let temp = [] |
|
|
|
for (let i = 0; i < pageRoutes.length; i++) { |
|
|
|
if (route.path === pageRoutes[i].path) { |
|
|
|
return true |
|
|
|
} |
|
|
|