21 changed files with 1764 additions and 1307 deletions
@ -1,221 +1,188 @@ |
|||||
// import Cookies from 'js-cookie'
|
|
||||
|
|
||||
import qs from "qs"; |
|
||||
|
|
||||
// import qs from 'qs'
|
|
||||
export default { |
|
||||
data() { |
|
||||
/* eslint-disable */ |
|
||||
return { |
|
||||
// 设置属性
|
|
||||
mixinViewModuleOptions: { |
|
||||
createdIsNeed: true, // 此页面是否在创建时,调用查询数据列表接口?
|
|
||||
activatedIsNeed: false, // 此页面是否在激活(进入)时,调用查询数据列表接口?
|
|
||||
getDataListURL: "", // 数据列表接口,API地址
|
|
||||
getDataListIsPage: false, // 数据列表接口,是否需要分页?
|
|
||||
deleteURL: "", // 删除接口,API地址
|
|
||||
deleteIsBatch: false, // 删除接口,是否需要批量?
|
|
||||
deleteIsBatchKey: "id", // 删除接口,批量状态下由那个key进行标记操作?比如:pid,uid...
|
|
||||
exportURL: "", // 导出接口,API地址
|
|
||||
}, |
|
||||
// 默认属性
|
|
||||
dataForm: {}, // 查询条件
|
|
||||
dataList: [], // 数据列表
|
|
||||
order: "", // 排序,asc/desc
|
|
||||
orderField: "", // 排序,字段
|
|
||||
page: 1, // 当前页码
|
|
||||
limit: 10, // 每页数
|
|
||||
total: 0, // 总条数
|
|
||||
dataListLoading: false, // 数据列表,loading状态
|
|
||||
dataListSelections: [], // 数据列表,多选项
|
|
||||
addOrUpdateVisible: false, // 新增/更新,弹窗visible状态
|
|
||||
deleteParams: {}, |
|
||||
}; |
|
||||
/* eslint-enable */ |
|
||||
}, |
|
||||
created() { |
|
||||
if (this.mixinViewModuleOptions.createdIsNeed) { |
|
||||
this.getDataList(); |
|
||||
} |
|
||||
}, |
|
||||
activated() { |
|
||||
if (this.mixinViewModuleOptions.activatedIsNeed) { |
|
||||
this.getDataList(); |
|
||||
} |
|
||||
}, |
|
||||
methods: { |
|
||||
// 获取数据列表
|
|
||||
getDataList() { |
|
||||
this.dataListLoading = true; |
|
||||
let params = { |
|
||||
page: this.mixinViewModuleOptions.getDataListIsPage ? this.page : null, |
|
||||
limit: this.mixinViewModuleOptions.getDataListIsPage |
|
||||
? this.limit |
|
||||
: null, |
|
||||
...this.dataForm, |
|
||||
}; |
|
||||
params = this.dealObjectValue(params); |
|
||||
this.mixinViewModuleOptions.getDataListURL |
|
||||
? this.$http |
|
||||
.get(this.mixinViewModuleOptions.getDataListURL, { |
|
||||
params: params, |
|
||||
}) |
|
||||
.then(({ data: res }) => { |
|
||||
this.dataListLoading = false; |
|
||||
if (res.code !== 0) { |
|
||||
this.dataList = []; |
|
||||
this.total = 0; |
|
||||
return this.$message.error(res.msg); |
|
||||
} |
|
||||
this.dataList = this.mixinViewModuleOptions.getDataListIsPage |
|
||||
? res.data.list |
|
||||
: res.data; |
|
||||
res.data.drgsName ? (this.drgsName = res.data.drgsName) : ""; |
|
||||
this.total = this.mixinViewModuleOptions.getDataListIsPage |
|
||||
? res.data.total |
|
||||
: 0; |
|
||||
}) |
|
||||
.catch(() => { |
|
||||
this.dataListLoading = false; |
|
||||
}) |
|
||||
: ""; |
|
||||
}, |
|
||||
dealObjectValue(obj) { |
|
||||
const param = {}; |
|
||||
if (obj === null || obj === undefined || obj === "") return param; |
|
||||
for (var key in obj) { |
|
||||
if (obj[key] !== null && obj[key] !== undefined && obj[key] !== "") { |
|
||||
param[key] = obj[key]; |
|
||||
} |
|
||||
} |
|
||||
return param; |
|
||||
}, |
|
||||
// 多选
|
|
||||
dataListSelectionChangeHandle(val) { |
|
||||
this.dataListSelections = val; |
|
||||
}, |
|
||||
// 排序
|
|
||||
dataListSortChangeHandle(data) { |
|
||||
if (!data.order || !data.prop) { |
|
||||
this.order = ""; |
|
||||
this.orderField = ""; |
|
||||
return false; |
|
||||
} |
|
||||
this.order = data.order.replace(/ending$/, ""); |
|
||||
this.orderField = data.prop.replace(/([A-Z])/g, "_$1").toLowerCase(); |
|
||||
this.getDataList(); |
|
||||
}, |
|
||||
// 分页, 每页条数
|
|
||||
pageSizeChangeHandle(val) { |
|
||||
this.page = 1; |
|
||||
this.limit = val; |
|
||||
this.getDataList(); |
|
||||
}, |
|
||||
// 分页, 当前页
|
|
||||
pageCurrentChangeHandle(val) { |
|
||||
this.page = val; |
|
||||
this.getDataList(); |
|
||||
}, |
|
||||
// 初始化查询
|
|
||||
getDataListInitial() { |
|
||||
this.page = 1; |
|
||||
this.getDataList(); |
|
||||
}, |
|
||||
// 新增 / 修改
|
|
||||
addOrUpdateHandle(id, params, title, noParams) { |
|
||||
this.addOrUpdateVisible = true; |
|
||||
this.$nextTick(() => { |
|
||||
this.$refs.addOrUpdate.dataForm.id = id; |
|
||||
noParams ? "" : (this.$refs.addOrUpdate.params = params || {}); |
|
||||
this.$refs.addOrUpdate.dataForm.title = title; |
|
||||
// 存在BUG,params无法覆盖,弃用
|
|
||||
// this.$refs.addOrUpdate.dataForm = { id, ...params, title }
|
|
||||
this.$refs.addOrUpdate.init(); |
|
||||
}); |
|
||||
}, |
|
||||
// 分配人员
|
|
||||
assignPeopleHandle(scope) { |
|
||||
this.currentPeopleId = scope.id; |
|
||||
this.dialogVisible = true; |
|
||||
// 添加科研人员时,获取人员列表
|
|
||||
this.getUserList(scope.id); |
|
||||
}, |
|
||||
// 关闭当前窗口
|
|
||||
closeCurrentTab(data) { |
|
||||
var tabName = this.$store.state.contentTabsActiveName; |
|
||||
this.$store.state.contentTabs = this.$store.state.contentTabs.filter( |
|
||||
(item) => item.name !== tabName |
|
||||
); |
|
||||
if (this.$store.state.contentTabs.length <= 0) { |
|
||||
this.$store.state.sidebarMenuActiveName = |
|
||||
this.$store.state.contentTabsActiveName = "home"; |
|
||||
return false; |
|
||||
} |
|
||||
if (tabName === this.$store.state.contentTabsActiveName) { |
|
||||
this.$router.push({ |
|
||||
name: this.$store.state.contentTabs[ |
|
||||
this.$store.state.contentTabs.length - 1 |
|
||||
].name, |
|
||||
}); |
|
||||
} |
|
||||
}, |
|
||||
// 删除
|
|
||||
deleteHandle(id, callback) { |
|
||||
if ( |
|
||||
this.mixinViewModuleOptions.deleteIsBatch && |
|
||||
!id && |
|
||||
this.dataListSelections.length <= 0 |
|
||||
) { |
|
||||
return this.$message({ |
|
||||
message: this.$t("prompt.deleteBatch"), |
|
||||
type: "warning", |
|
||||
duration: 500, |
|
||||
}); |
|
||||
} |
|
||||
this.$confirm( |
|
||||
this.$t("prompt.info", { handle: this.$t("delete") }), |
|
||||
this.$t("prompt.title"), |
|
||||
{ |
|
||||
confirmButtonText: this.$t("confirm"), |
|
||||
cancelButtonText: this.$t("cancel"), |
|
||||
type: "warning", |
|
||||
} |
|
||||
) |
|
||||
.then(() => { |
|
||||
(Array.isArray(id) |
|
||||
? this.$http({ |
|
||||
url: this.mixinViewModuleOptions.deleteURL, |
|
||||
method: "delete", |
|
||||
data: id, |
|
||||
}) |
|
||||
: this.$http.delete( |
|
||||
this.mixinViewModuleOptions.deleteURL + `/${id}` |
|
||||
) |
|
||||
) |
|
||||
.then(({ data: res }) => { |
|
||||
if (res.code !== 0) { |
|
||||
return this.$message.error(res.msg); |
|
||||
} |
|
||||
this.$message({ |
|
||||
message: this.$t("prompt.success"), |
|
||||
type: "success", |
|
||||
duration: 500, |
|
||||
onClose: () => { |
|
||||
callback ? callback() : this.getDataList(); |
|
||||
}, |
|
||||
}); |
|
||||
}) |
|
||||
.catch(() => {}); |
|
||||
}) |
|
||||
.catch(() => {}); |
|
||||
}, |
|
||||
// 导出
|
|
||||
exportHandle() { |
|
||||
// var params = qs.stringify({
|
|
||||
// token: Cookies.get('qg-token'),
|
|
||||
// ...this.dataForm
|
|
||||
// })
|
|
||||
// window.location.href = `${window.SITE_CONFIG.apiURL}${this.mixinViewModuleOptions.exportURL}?${params}`
|
|
||||
}, |
|
||||
}, |
|
||||
}; |
|
||||
|
// import Cookies from 'js-cookie'
|
||||
|
|
||||
|
import qs from 'qs' |
||||
|
|
||||
|
// import qs from 'qs'
|
||||
|
export default { |
||||
|
data() { |
||||
|
/* eslint-disable */ |
||||
|
return { |
||||
|
// 设置属性
|
||||
|
mixinViewModuleOptions: { |
||||
|
createdIsNeed: true, // 此页面是否在创建时,调用查询数据列表接口?
|
||||
|
activatedIsNeed: false, // 此页面是否在激活(进入)时,调用查询数据列表接口?
|
||||
|
getDataListURL: '', // 数据列表接口,API地址
|
||||
|
getDataListIsPage: false, // 数据列表接口,是否需要分页?
|
||||
|
deleteURL: '', // 删除接口,API地址
|
||||
|
deleteIsBatch: false, // 删除接口,是否需要批量?
|
||||
|
deleteIsBatchKey: 'id', // 删除接口,批量状态下由那个key进行标记操作?比如:pid,uid...
|
||||
|
exportURL: '' // 导出接口,API地址
|
||||
|
}, |
||||
|
// 默认属性
|
||||
|
dataForm: {}, // 查询条件
|
||||
|
dataList: [], // 数据列表
|
||||
|
order: '', // 排序,asc/desc
|
||||
|
orderField: '', // 排序,字段
|
||||
|
page: 1, // 当前页码
|
||||
|
limit: 10, // 每页数
|
||||
|
total: 0, // 总条数
|
||||
|
dataListLoading: false, // 数据列表,loading状态
|
||||
|
dataListSelections: [], // 数据列表,多选项
|
||||
|
addOrUpdateVisible: false, // 新增/更新,弹窗visible状态
|
||||
|
deleteParams:{} |
||||
|
} |
||||
|
/* eslint-enable */ |
||||
|
}, |
||||
|
created() { |
||||
|
if (this.mixinViewModuleOptions.createdIsNeed) { |
||||
|
this.getDataList() |
||||
|
} |
||||
|
}, |
||||
|
activated() { |
||||
|
if (this.mixinViewModuleOptions.activatedIsNeed) { |
||||
|
this.getDataList() |
||||
|
} |
||||
|
}, |
||||
|
methods: { |
||||
|
// 获取数据列表
|
||||
|
getDataList() { |
||||
|
this.dataListLoading = true |
||||
|
let params = { |
||||
|
page: this.mixinViewModuleOptions.getDataListIsPage ? this.page : null, |
||||
|
limit: this.mixinViewModuleOptions.getDataListIsPage ? this.limit : null, |
||||
|
...this.dataForm |
||||
|
} |
||||
|
params = this.dealObjectValue(params) |
||||
|
this.mixinViewModuleOptions.getDataListURL ? this.$http.get( |
||||
|
this.mixinViewModuleOptions.getDataListURL, { |
||||
|
params: params |
||||
|
} |
||||
|
).then(({ data: res }) => { |
||||
|
this.dataListLoading = false |
||||
|
if (res.code !== 0) { |
||||
|
this.dataList = [] |
||||
|
this.total = 0 |
||||
|
return this.$message.error(res.msg) |
||||
|
} |
||||
|
this.dataList = this.mixinViewModuleOptions.getDataListIsPage ? res.data.list : res.data |
||||
|
res.data.drgsName ? this.drgsName = res.data.drgsName : '' |
||||
|
this.total = this.mixinViewModuleOptions.getDataListIsPage ? res.data.total : 0 |
||||
|
}).catch(() => { |
||||
|
this.dataListLoading = false |
||||
|
}) : '' |
||||
|
}, |
||||
|
dealObjectValue(obj) { |
||||
|
const param = {} |
||||
|
if (obj === null || obj === undefined || obj === '') return param |
||||
|
for (var key in obj) { |
||||
|
if (obj[key] !== null && obj[key] !== undefined && obj[key] !== '') { |
||||
|
param[key] = obj[key] |
||||
|
} |
||||
|
} |
||||
|
return param |
||||
|
}, |
||||
|
// 多选
|
||||
|
dataListSelectionChangeHandle(val) { |
||||
|
this.dataListSelections = val |
||||
|
}, |
||||
|
// 排序
|
||||
|
dataListSortChangeHandle(data) { |
||||
|
if (!data.order || !data.prop) { |
||||
|
this.order = '' |
||||
|
this.orderField = '' |
||||
|
return false |
||||
|
} |
||||
|
this.order = data.order.replace(/ending$/, '') |
||||
|
this.orderField = data.prop.replace(/([A-Z])/g, '_$1').toLowerCase() |
||||
|
this.getDataList() |
||||
|
}, |
||||
|
// 分页, 每页条数
|
||||
|
pageSizeChangeHandle(val) { |
||||
|
this.page = 1 |
||||
|
this.limit = val |
||||
|
this.getDataList() |
||||
|
}, |
||||
|
// 分页, 当前页
|
||||
|
pageCurrentChangeHandle(val) { |
||||
|
this.page = val |
||||
|
this.getDataList() |
||||
|
}, |
||||
|
// 初始化查询
|
||||
|
getDataListInitial() { |
||||
|
this.page = 1 |
||||
|
this.getDataList() |
||||
|
}, |
||||
|
// 新增 / 修改
|
||||
|
addOrUpdateHandle(id, params, title, noParams) { |
||||
|
this.addOrUpdateVisible = true |
||||
|
this.$nextTick(() => { |
||||
|
this.$refs.addOrUpdate.dataForm.id = id |
||||
|
noParams ? '' : this.$refs.addOrUpdate.params = params || {} |
||||
|
this.$refs.addOrUpdate.dataForm.title = title |
||||
|
// 存在BUG,params无法覆盖,弃用
|
||||
|
// this.$refs.addOrUpdate.dataForm = { id, ...params, title }
|
||||
|
this.$refs.addOrUpdate.init() |
||||
|
}) |
||||
|
}, |
||||
|
// 分配人员
|
||||
|
assignPeopleHandle(scope) { |
||||
|
this.currentPeopleId = scope.id |
||||
|
this.dialogVisible = true |
||||
|
// 添加科研人员时,获取人员列表
|
||||
|
this.getUserList(scope.id) |
||||
|
}, |
||||
|
// 关闭当前窗口
|
||||
|
closeCurrentTab(data) { |
||||
|
var tabName = this.$store.state.contentTabsActiveName |
||||
|
this.$store.state.contentTabs = this.$store.state.contentTabs.filter(item => item.name !== tabName) |
||||
|
if (this.$store.state.contentTabs.length <= 0) { |
||||
|
this.$store.state.sidebarMenuActiveName = this.$store.state.contentTabsActiveName = 'home' |
||||
|
return false |
||||
|
} |
||||
|
if (tabName === this.$store.state.contentTabsActiveName) { |
||||
|
this.$router.push({ name: this.$store.state.contentTabs[this.$store.state.contentTabs.length - 1].name }) |
||||
|
} |
||||
|
}, |
||||
|
// 删除
|
||||
|
deleteHandle(id, callback) { |
||||
|
if (this.mixinViewModuleOptions.deleteIsBatch && !id && this.dataListSelections.length <= 0) { |
||||
|
return this.$message({ |
||||
|
message: this.$t('prompt.deleteBatch'), |
||||
|
type: 'warning', |
||||
|
duration: 500 |
||||
|
}) |
||||
|
} |
||||
|
this.$confirm(this.$t('prompt.info', { handle: this.$t('delete') }), this.$t('prompt.title'), { |
||||
|
confirmButtonText: this.$t('confirm'), |
||||
|
cancelButtonText: this.$t('cancel'), |
||||
|
type: 'warning' |
||||
|
}).then(() => { |
||||
|
(Array.isArray(id) ? this.$http({ |
||||
|
url: this.mixinViewModuleOptions.deleteURL, |
||||
|
method: 'delete', |
||||
|
data: id |
||||
|
}) : this.$http.delete(this.mixinViewModuleOptions.deleteURL + `/${id}`)).then(({ data: res }) => { |
||||
|
if (res.code !== 0) { |
||||
|
return this.$message.error(res.msg) |
||||
|
} |
||||
|
this.$message({ |
||||
|
message: this.$t('prompt.success'), |
||||
|
type: 'success', |
||||
|
duration: 500, |
||||
|
onClose: () => { |
||||
|
callback ? callback() : this.getDataList() |
||||
|
} |
||||
|
}) |
||||
|
}).catch(() => {}) |
||||
|
}).catch(() => {}) |
||||
|
}, |
||||
|
// 导出
|
||||
|
exportHandle() { |
||||
|
// var params = qs.stringify({
|
||||
|
// token: Cookies.get('qg-token'),
|
||||
|
// ...this.dataForm
|
||||
|
// })
|
||||
|
// window.location.href = `${window.SITE_CONFIG.apiURL}${this.mixinViewModuleOptions.exportURL}?${params}`
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
@ -1,118 +1,117 @@ |
|||||
// system入口
|
|
||||
import Vue from "vue"; |
|
||||
import Element from "element-ui"; |
|
||||
// import 'lib-flexible/flexible'
|
|
||||
import App from "./App.vue"; |
|
||||
import router from "./router"; |
|
||||
import store from "./store"; |
|
||||
import http from "./utils/request"; |
|
||||
import jQuery from "jquery"; |
|
||||
import "element-ui/lib/theme-chalk/index.css"; |
|
||||
import "@/icons"; |
|
||||
import "@/assets/scss/aui.scss"; |
|
||||
import "@/assets/scss/reset.scss"; |
|
||||
import i18n from "@/i18n"; |
|
||||
import * as filters from "@/filters"; |
|
||||
import renRadioGroup from "@/components/ren-radio-group"; |
|
||||
import renDeptTree from "@/components/ren-dept-tree"; |
|
||||
import { hasPermission, getDictLabel } from "@/utils"; |
|
||||
import cloneDeep from "lodash/cloneDeep"; |
|
||||
import "xe-utils"; |
|
||||
import VXETable from "vxe-table"; |
|
||||
import "vxe-table/lib/index.css"; |
|
||||
// import echarts from 'echarts'
|
|
||||
import * as echarts from "echarts"; |
|
||||
import moment from "moment"; |
|
||||
import VueChatScroll from "vue-chat-scroll"; |
|
||||
import "default-passive-events"; |
|
||||
|
|
||||
// import jsNSV from '@/utils/js-NSV.js'
|
|
||||
|
|
||||
import Base64 from "@/utils/base64.js"; |
|
||||
Vue.prototype.$Base64 = Base64; |
|
||||
|
|
||||
import Print from "vue-print-nb"; |
|
||||
Vue.use(Print); |
|
||||
|
|
||||
import { confirm } from "@/utils/confirm"; |
|
||||
Vue.prototype.$confirmFun = confirm; |
|
||||
|
|
||||
// import VueDragResize from 'vue-drag-resize'
|
|
||||
// Vue.component('vue-drag-resize', VueDragResize)
|
|
||||
|
|
||||
// 裁切工具
|
|
||||
import VueCropper from "vue-cropper"; |
|
||||
Vue.use(VueCropper); |
|
||||
|
|
||||
import Recorder from "js-audio-recorder"; |
|
||||
const recorder = new Recorder({ |
|
||||
sampleBits: 16, // 采样位数,支持 8 或 16,默认是16
|
|
||||
sampleRate: 16000, // 采样率,支持 11025、16000、22050、24000、44100、48000,根据浏览器默认值,我的chrome是48000
|
|
||||
numChannels: 1, // 声道,支持 1 或 2, 默认是1
|
|
||||
// compiling: false,(0.x版本中生效,1.x增加中) // 是否边录边转换,默认是false
|
|
||||
}); |
|
||||
Vue.prototype.$recorder = recorder; |
|
||||
|
|
||||
// 全局监听DOM元素
|
|
||||
import ElementResizeDetectorMaker from "element-resize-detector"; |
|
||||
Vue.prototype.$erd = ElementResizeDetectorMaker(); |
|
||||
|
|
||||
import animejs from "animejs"; |
|
||||
Vue.prototype.$anime = animejs; |
|
||||
|
|
||||
moment.locale("zh-cn"); // 设置语言 或 moment.lang('zh-cn');
|
|
||||
|
|
||||
Vue.use(Element, { |
|
||||
size: "default", |
|
||||
i18n: (key, value) => i18n.t(key, value), |
|
||||
}); |
|
||||
|
|
||||
Object.keys(filters).forEach((key) => { |
|
||||
Vue.filter(key, filters[key]); |
|
||||
}); |
|
||||
|
|
||||
// 全局组件
|
|
||||
Vue.use(renRadioGroup); |
|
||||
Vue.use(renDeptTree); |
|
||||
Vue.use(VueChatScroll); |
|
||||
Vue.use(VXETable); |
|
||||
|
|
||||
// DICOM
|
|
||||
import cornerstone from "cornerstone-core"; |
|
||||
import cornerstoneMath from "cornerstone-math"; |
|
||||
import cornerstoneTools from "cornerstone-tools"; |
|
||||
import Hammer from "hammerjs"; |
|
||||
import dicomParser from "dicom-parser"; |
|
||||
import cornerstoneWADOImageLoader from "cornerstone-wado-image-loader"; |
|
||||
import cornerstoneWebImageLoader from "cornerstone-web-image-loader"; |
|
||||
|
|
||||
cornerstoneTools.external.cornerstone = cornerstone; |
|
||||
cornerstoneTools.external.Hammer = Hammer; |
|
||||
cornerstoneTools.external.cornerstoneMath = cornerstoneMath; |
|
||||
cornerstoneWADOImageLoader.external.dicomParser = dicomParser; |
|
||||
cornerstoneWADOImageLoader.external.cornerstoneMath = cornerstoneMath; |
|
||||
cornerstoneWADOImageLoader.external.cornerstone = cornerstone; |
|
||||
cornerstoneWebImageLoader.external.cornerstone = cornerstone; |
|
||||
cornerstone.registerImageLoader("http", cornerstoneWADOImageLoader.loadImage); |
|
||||
cornerstone.registerImageLoader("https", cornerstoneWADOImageLoader.loadImage); |
|
||||
cornerstone.registerImageLoader("http", cornerstoneWebImageLoader.loadImage); |
|
||||
Vue.prototype.$cornerstone = cornerstone; |
|
||||
Vue.prototype.$cornerstoneTools = cornerstoneTools; |
|
||||
|
|
||||
// 挂载全局
|
|
||||
Vue.prototype.$http = http; |
|
||||
Vue.prototype.$ = jQuery; |
|
||||
Vue.prototype.$hasPermission = hasPermission; |
|
||||
Vue.prototype.$getDictLabel = getDictLabel; |
|
||||
Vue.prototype.$moment = moment; |
|
||||
Vue.prototype.$echarts = echarts; |
|
||||
|
|
||||
Vue.config.productionTip = false; |
|
||||
// 保存整站vuex本地储存初始状态
|
|
||||
window.SITE_CONFIG.storeState = cloneDeep(store.state); |
|
||||
new Vue({ |
|
||||
i18n, |
|
||||
router, |
|
||||
store, |
|
||||
render: (h) => h(App), |
|
||||
}).$mount("#app"); |
|
||||
|
// system入口
|
||||
|
import Vue from 'vue' |
||||
|
import Element from 'element-ui' |
||||
|
// import 'lib-flexible/flexible'
|
||||
|
import App from './App.vue' |
||||
|
import router from './router' |
||||
|
import store from './store' |
||||
|
import http from './utils/request' |
||||
|
import jQuery from 'jquery' |
||||
|
import 'element-ui/lib/theme-chalk/index.css' |
||||
|
import '@/icons' |
||||
|
import '@/assets/scss/aui.scss' |
||||
|
import '@/assets/scss/reset.scss' |
||||
|
import i18n from '@/i18n' |
||||
|
import * as filters from '@/filters' |
||||
|
import renRadioGroup from '@/components/ren-radio-group' |
||||
|
import renDeptTree from '@/components/ren-dept-tree' |
||||
|
import { hasPermission, getDictLabel } from '@/utils' |
||||
|
import cloneDeep from 'lodash/cloneDeep' |
||||
|
import 'xe-utils' |
||||
|
import VXETable from 'vxe-table' |
||||
|
import 'vxe-table/lib/index.css' |
||||
|
// import echarts from 'echarts'
|
||||
|
import * as echarts from 'echarts' |
||||
|
import moment from 'moment' |
||||
|
import VueChatScroll from 'vue-chat-scroll' |
||||
|
|
||||
|
// import jsNSV from '@/utils/js-NSV.js'
|
||||
|
|
||||
|
import Base64 from '@/utils/base64.js' |
||||
|
Vue.prototype.$Base64 = Base64 |
||||
|
|
||||
|
import Print from 'vue-print-nb' |
||||
|
Vue.use(Print) |
||||
|
|
||||
|
import { confirm } from '@/utils/confirm' |
||||
|
Vue.prototype.$confirmFun = confirm |
||||
|
|
||||
|
// import VueDragResize from 'vue-drag-resize'
|
||||
|
// Vue.component('vue-drag-resize', VueDragResize)
|
||||
|
|
||||
|
// 裁切工具
|
||||
|
import VueCropper from 'vue-cropper' |
||||
|
Vue.use(VueCropper) |
||||
|
|
||||
|
import Recorder from 'js-audio-recorder' |
||||
|
const recorder = new Recorder({ |
||||
|
sampleBits: 16, // 采样位数,支持 8 或 16,默认是16
|
||||
|
sampleRate: 16000, // 采样率,支持 11025、16000、22050、24000、44100、48000,根据浏览器默认值,我的chrome是48000
|
||||
|
numChannels: 1 // 声道,支持 1 或 2, 默认是1
|
||||
|
// compiling: false,(0.x版本中生效,1.x增加中) // 是否边录边转换,默认是false
|
||||
|
}) |
||||
|
Vue.prototype.$recorder = recorder |
||||
|
|
||||
|
// 全局监听DOM元素
|
||||
|
import ElementResizeDetectorMaker from 'element-resize-detector' |
||||
|
Vue.prototype.$erd = ElementResizeDetectorMaker() |
||||
|
|
||||
|
import animejs from 'animejs' |
||||
|
Vue.prototype.$anime = animejs |
||||
|
|
||||
|
moment.locale('zh-cn') // 设置语言 或 moment.lang('zh-cn');
|
||||
|
|
||||
|
Vue.use(Element, { |
||||
|
size: 'default', |
||||
|
i18n: (key, value) => i18n.t(key, value) |
||||
|
}) |
||||
|
|
||||
|
Object.keys(filters).forEach(key => { |
||||
|
Vue.filter(key, filters[key]) |
||||
|
}) |
||||
|
|
||||
|
// 全局组件
|
||||
|
Vue.use(renRadioGroup) |
||||
|
Vue.use(renDeptTree) |
||||
|
Vue.use(VueChatScroll) |
||||
|
Vue.use(VXETable) |
||||
|
|
||||
|
// DICOM
|
||||
|
import cornerstone from 'cornerstone-core' |
||||
|
import cornerstoneMath from 'cornerstone-math' |
||||
|
import cornerstoneTools from 'cornerstone-tools' |
||||
|
import Hammer from 'hammerjs' |
||||
|
import dicomParser from 'dicom-parser' |
||||
|
import cornerstoneWADOImageLoader from 'cornerstone-wado-image-loader' |
||||
|
import cornerstoneWebImageLoader from 'cornerstone-web-image-loader' |
||||
|
|
||||
|
cornerstoneTools.external.cornerstone = cornerstone |
||||
|
cornerstoneTools.external.Hammer = Hammer |
||||
|
cornerstoneTools.external.cornerstoneMath = cornerstoneMath |
||||
|
cornerstoneWADOImageLoader.external.dicomParser = dicomParser |
||||
|
cornerstoneWADOImageLoader.external.cornerstoneMath = cornerstoneMath |
||||
|
cornerstoneWADOImageLoader.external.cornerstone = cornerstone |
||||
|
cornerstoneWebImageLoader.external.cornerstone = cornerstone |
||||
|
cornerstone.registerImageLoader('http', cornerstoneWADOImageLoader.loadImage) |
||||
|
cornerstone.registerImageLoader('https', cornerstoneWADOImageLoader.loadImage) |
||||
|
cornerstone.registerImageLoader('http', cornerstoneWebImageLoader.loadImage) |
||||
|
Vue.prototype.$cornerstone = cornerstone |
||||
|
Vue.prototype.$cornerstoneTools = cornerstoneTools |
||||
|
|
||||
|
// 挂载全局
|
||||
|
Vue.prototype.$http = http |
||||
|
Vue.prototype.$ = jQuery |
||||
|
Vue.prototype.$hasPermission = hasPermission |
||||
|
Vue.prototype.$getDictLabel = getDictLabel |
||||
|
Vue.prototype.$moment = moment |
||||
|
Vue.prototype.$echarts = echarts |
||||
|
|
||||
|
Vue.config.productionTip = false |
||||
|
// 保存整站vuex本地储存初始状态
|
||||
|
window.SITE_CONFIG.storeState = cloneDeep(store.state) |
||||
|
new Vue({ |
||||
|
i18n, |
||||
|
router, |
||||
|
store, |
||||
|
render: h => h(App) |
||||
|
}).$mount('#app') |
||||
|
@ -1,397 +1,358 @@ |
|||||
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); |
|
||||
|
|
||||
// 解决Vue-Router升级导致的Uncaught(in promise) navigation guard问题----------
|
|
||||
const originalPush = Router.prototype.push; |
|
||||
Router.prototype.push = function push(location, onResolve, onReject) { |
|
||||
if (onResolve || onReject) |
|
||||
return originalPush.call(this, location, onResolve, onReject); |
|
||||
return originalPush.call(this, location).catch((err) => err); |
|
||||
}; |
|
||||
// 解决Vue-Router升级导致的Uncaught(in promise) navigation guard问题----------
|
|
||||
|
|
||||
// 页面路由(独立页面)
|
|
||||
export const pageRoutes = [ |
|
||||
{ |
|
||||
path: "/404", |
|
||||
component: () => import("@/page-subspecialty/views/pages/404"), |
|
||||
name: "404", |
|
||||
meta: { title: "404未找到" }, |
|
||||
beforeEnter(to, from, next) { |
|
||||
// 拦截处理特殊业务场景
|
|
||||
// 如果, 重定向路由包含__双下划线, 为临时添加路由
|
|
||||
if (/__.*/.test(to.redirectedFrom)) { |
|
||||
return next(to.redirectedFrom.replace(/__.*/, "")); |
|
||||
} |
|
||||
next(); |
|
||||
}, |
|
||||
}, |
|
||||
{ |
|
||||
path: "/login", |
|
||||
component: () => import("@/page-subspecialty/views/pages/login"), |
|
||||
name: "login", |
|
||||
meta: { title: "登录" }, |
|
||||
}, |
|
||||
{ |
|
||||
path: "/pacs", |
|
||||
component: () => import("@/page-subspecialty/views/pages/pacsManage/index"), |
|
||||
name: "pacs", |
|
||||
meta: { title: "pacs浏览器", isTab: true }, |
|
||||
}, |
|
||||
// 录音
|
|
||||
{ |
|
||||
path: "/luyin", |
|
||||
name: "luyin", |
|
||||
component: () => import("@/page-subspecialty/views/pages/luyin"), |
|
||||
}, |
|
||||
// 日程安排
|
|
||||
{ |
|
||||
path: "/schedule", |
|
||||
name: "schedule", |
|
||||
component: () => import("@/page-subspecialty/views/pages/schedule"), |
|
||||
}, |
|
||||
{ |
|
||||
path: "/question", |
|
||||
name: "question", |
|
||||
component: () => import("@/page-subspecialty/views/pages/question"), |
|
||||
}, |
|
||||
{ |
|
||||
path: "/satusScreen", |
|
||||
name: "satusScreen", |
|
||||
component: () => import("@/page-subspecialty/views/pages/satusScreen"), |
|
||||
}, |
|
||||
{ |
|
||||
path: "/imageEdit", |
|
||||
name: "imageEdit", |
|
||||
component: () => import("@/page-subspecialty/views/pages/imageEdit"), |
|
||||
}, |
|
||||
{ |
|
||||
path: "/articleContent", |
|
||||
name: "articleContent", |
|
||||
component: () => |
|
||||
import( |
|
||||
"@/page-subspecialty/views/modules/articleManagement/articleContent" |
|
||||
), |
|
||||
}, |
|
||||
{ |
|
||||
path: "/transfer", |
|
||||
name: "transfer", |
|
||||
component: () => import("@/page-subspecialty/views/pages/transfer"), |
|
||||
}, |
|
||||
]; |
|
||||
|
|
||||
// 模块路由(基于主入口布局页面)*8
|
|
||||
export const moduleRoutes = { |
|
||||
path: "/", |
|
||||
component: () => import("@/page-subspecialty/views/main"), |
|
||||
name: "main", |
|
||||
redirect: { name: "patientManagement" }, |
|
||||
meta: { title: "首页" }, |
|
||||
children: [ |
|
||||
{ |
|
||||
path: "/patientManagement", |
|
||||
component: () => |
|
||||
import("@/page-subspecialty/views/modules/patientManagement/index"), |
|
||||
name: "patientManagement", |
|
||||
meta: { title: "分诊管理", isTab: true }, |
|
||||
}, |
|
||||
{ |
|
||||
path: "/patientDetail", |
|
||||
component: () => |
|
||||
import("@/page-subspecialty/views/modules/patientDetail"), |
|
||||
name: "patientDetail", |
|
||||
meta: { title: "档案管理", isTab: true }, |
|
||||
}, |
|
||||
// ok镜
|
|
||||
{ |
|
||||
path: "/patientInfo", |
|
||||
name: "patientInfo", |
|
||||
meta: { title: "详情", isTab: true }, |
|
||||
component: () => |
|
||||
import( |
|
||||
"@/page-subspecialty/views/modules/optometryManagement/seeDoctor/index" |
|
||||
), |
|
||||
}, |
|
||||
{ |
|
||||
path: "/iframe", |
|
||||
component: null, |
|
||||
name: "iframe", |
|
||||
meta: { title: "iframe", isTab: true }, |
|
||||
}, |
|
||||
{ |
|
||||
path: "/redirect", |
|
||||
name: "redirect", |
|
||||
component: () => import("@/page-subspecialty/views/redirect"), |
|
||||
}, |
|
||||
], |
|
||||
}; |
|
||||
|
|
||||
export function addDynamicRoute(routeParams, router) { |
|
||||
// 组装路由名称, 并判断是否已添加, 如是: 则直接跳转
|
|
||||
var routeName = routeParams.routeName; |
|
||||
var dynamicRoute = window.SITE_CONFIG["dynamicRoutes"].filter( |
|
||||
(item) => item.name === routeName |
|
||||
)[0]; |
|
||||
if (dynamicRoute) { |
|
||||
return router.push({ name: routeName, params: routeParams.params }); |
|
||||
} |
|
||||
// 否则: 添加并全局变量保存, 再跳转
|
|
||||
dynamicRoute = { |
|
||||
path: routeName, |
|
||||
component: () => |
|
||||
Promise.resolve( |
|
||||
require(`@/page-subspecialty/views/modules/${routeParams.path}`).default |
|
||||
), |
|
||||
// component: () => import(`@/views/modules/${routeParams.path}`),
|
|
||||
name: routeName, |
|
||||
meta: { |
|
||||
...window.SITE_CONFIG["contentTabDefault"], |
|
||||
menuId: routeParams.menuId, |
|
||||
title: `${routeParams.title}`, |
|
||||
}, |
|
||||
}; |
|
||||
router.addRoutes([ |
|
||||
{ |
|
||||
...moduleRoutes, |
|
||||
name: `main-dynamic__${dynamicRoute.name}`, |
|
||||
children: [dynamicRoute], |
|
||||
}, |
|
||||
]); |
|
||||
window.SITE_CONFIG["dynamicRoutes"].push(dynamicRoute); |
|
||||
router.push({ name: dynamicRoute.name, params: routeParams.params }); |
|
||||
} |
|
||||
|
|
||||
const createRouter = () => |
|
||||
new Router({ |
|
||||
mode: "history", |
|
||||
scrollBehavior: () => ({ y: 0 }), |
|
||||
routes: pageRoutes.concat(moduleRoutes), |
|
||||
}); |
|
||||
const router = createRouter(); |
|
||||
|
|
||||
// [vue-router] Duplicate named routes definition 重复的命名路由定义
|
|
||||
// 动态路由退出再登录会出现警告重复路由
|
|
||||
// 解决方案:在退出时调用resetRouter()方法
|
|
||||
export function resetRouter() { |
|
||||
const newRouter = createRouter(); |
|
||||
router.matcher = newRouter.matcher; // reset router
|
|
||||
} |
|
||||
|
|
||||
router.beforeEach((to, from, next) => { |
|
||||
// 添加动态(菜单)路由
|
|
||||
// 已添加或者当前路由为页面路由, 可直接访问
|
|
||||
if ( |
|
||||
window.SITE_CONFIG["dynamicMenuRoutesHasAdded"] || |
|
||||
fnCurrentRouteIsPageRoute(to, pageRoutes) |
|
||||
) { |
|
||||
return next(); |
|
||||
} |
|
||||
if (to.path === from.path) { |
|
||||
return; |
|
||||
} |
|
||||
if ( |
|
||||
to.name === "login" || |
|
||||
to.path === "/login" || |
|
||||
to.path === "satusScreen" || |
|
||||
to.name === "satusScreen" |
|
||||
) { |
|
||||
next(); |
|
||||
} else { |
|
||||
// 获取字典列表, 添加并全局变量保存
|
|
||||
// http.get('/sys/dict/type/all').then(({ data: res }) => {
|
|
||||
// if (res.code !== 0) {
|
|
||||
// return
|
|
||||
// }
|
|
||||
// window.SITE_CONFIG['dictList'] = res.data
|
|
||||
// }).catch(() => {})
|
|
||||
|
|
||||
// 获取左侧菜单列表,添加并全局变量保存
|
|
||||
http |
|
||||
.get("/sys/menu/nav") |
|
||||
.then(({ data: res }) => { |
|
||||
if (res.code !== 0) { |
|
||||
Vue.prototype.$message.error(res.msg); |
|
||||
return next({ name: "login" }); |
|
||||
} |
|
||||
window.SITE_CONFIG["menuList"] = res.data; |
|
||||
}) |
|
||||
.catch(() => { |
|
||||
return next({ name: "login" }); |
|
||||
}); |
|
||||
|
|
||||
// 获取菜单管理菜单列表,并添加动态路由
|
|
||||
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 |
|
||||
); |
|
||||
// console.log(menuListChild)
|
|
||||
fnAddDynamicMenuRoutes( |
|
||||
JSON.parse(JSON.stringify(res.data)), |
|
||||
menuListChild.length |
|
||||
); |
|
||||
|
|
||||
next({ ...to, replace: true }); |
|
||||
}) |
|
||||
.catch(() => { |
|
||||
// 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
|
|
||||
// })
|
|
||||
// 获取【设备与检查项目字典】, 添加并全局变量保存
|
|
||||
// http.get('/device/getData2RelDeviceItemList').then(({ data: res }) => {
|
|
||||
// window.SITE_CONFIG['dict_device_item'] = res.data
|
|
||||
// })
|
|
||||
} |
|
||||
/** |
|
||||
* 判断当前路由是否为页面路由 |
|
||||
* @param {*} route 当前路由 |
|
||||
* @param {*} pageRoutes 页面路由 |
|
||||
*/ |
|
||||
function fnCurrentRouteIsPageRoute(route, pageRoutes = []) { |
|
||||
var temp = []; |
|
||||
for (var i = 0; i < pageRoutes.length; i++) { |
|
||||
if (route.path === pageRoutes[i].path) { |
|
||||
return true; |
|
||||
} |
|
||||
if (pageRoutes[i].children && pageRoutes[i].children.length >= 1) { |
|
||||
temp = temp.concat(pageRoutes[i].children); |
|
||||
} |
|
||||
} |
|
||||
return temp.length >= 1 ? fnCurrentRouteIsPageRoute(route, temp) : false; |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* 添加动态(菜单)路由 |
|
||||
* PH:自上而下遍历,累积平铺 |
|
||||
* @param {*} menuList 菜单列表 |
|
||||
* @param {*} routes 递归创建的动态(菜单)路由 |
|
||||
*/ |
|
||||
function fnAddDynamicMenuRoutes( |
|
||||
menuList = [], |
|
||||
menuListChildLength, |
|
||||
routes = [] |
|
||||
) { |
|
||||
let index = 0; |
|
||||
// console.log(menuList)
|
|
||||
menuList.forEach((item, i) => { |
|
||||
// eslint-disable-next-line
|
|
||||
let URL = (item.url || "").replace(/{{([^}}]+)?}}/g, (s1, s2) => eval(s2)); // URL支持{{ window.xxx }}占位符变量
|
|
||||
item["meta"] = { |
|
||||
...window.SITE_CONFIG["contentTabDefault"], |
|
||||
menuId: item.id, |
|
||||
title: item.name, |
|
||||
}; |
|
||||
if (isURL(URL)) { |
|
||||
item["path"] = item["name"] = `i-${item.id}`; |
|
||||
item["meta"].push({ |
|
||||
iframeURL: URL, |
|
||||
}); |
|
||||
} else { |
|
||||
// console.log(URL)
|
|
||||
URL = URL.replace(/^\//, "").replace(/_/g, "-"); |
|
||||
item["path"] = "/" + URL.replace(/\//g, "-"); |
|
||||
item["name"] = URL.replace(/\//g, "-"); |
|
||||
// 坑!!!父级也必须要有component,父级要有自己的vue组件,父级路由必须有<router-view />占位符
|
|
||||
// 其孩子children才能展示出来,孩子展示在父级占位符的地方
|
|
||||
URL.includes("seeDoctor") ? (URL = "seeDoctor") : ""; // 不同父级有相同子级seeDoctor,防止面包屑冲突,动态路由名字区分设置为seeDoctor、seeDoctorOne,在寻找组件时替换回seeDoctor,可以找到对应组件路径
|
|
||||
item["component"] = () => |
|
||||
Promise.resolve( |
|
||||
require(`@/page-subspecialty/views/modules/${URL}`).default |
|
||||
); |
|
||||
// 如果是父级给父级添加重定向到子菜单第一项
|
|
||||
if (item.children.length > 0 && item.children[0].url) { |
|
||||
// console.log(item)
|
|
||||
// isShow:0显示不菜单 1显示菜单
|
|
||||
item.children[0].isShow === 0 |
|
||||
? "" |
|
||||
: (item["redirect"] = "/" + item.children[0].url.replace(/\//g, "-")); |
|
||||
} |
|
||||
} |
|
||||
if (item.children.length > 0) { |
|
||||
index++; |
|
||||
fnAddDynamicMenuRoutes(item.children); |
|
||||
} |
|
||||
}); |
|
||||
// routes = menuList
|
|
||||
// console.log(routes)
|
|
||||
// 此处一定要加判断,因为此方法在递归,要等到递归完成后再执行下面的内容
|
|
||||
// 坑!!!如果不加此判断,this.$route.matched面包屑的父级就不会展示
|
|
||||
if (menuListChildLength === index) { |
|
||||
routes = menuList; |
|
||||
// PH:底层调用一次
|
|
||||
// 添加路由
|
|
||||
router.addRoutes([ |
|
||||
{ |
|
||||
...moduleRoutes, |
|
||||
name: "main-dynamic-menu", |
|
||||
children: [...routes], |
|
||||
}, |
|
||||
{ path: "*", redirect: { name: "404" } }, |
|
||||
]); |
|
||||
// console.log('----------------------')
|
|
||||
window.SITE_CONFIG["dynamicMenuRoutes"] = routes; |
|
||||
window.SITE_CONFIG["dynamicMenuRoutesHasAdded"] = true; |
|
||||
} |
|
||||
} |
|
||||
export default router; |
|
||||
|
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) |
||||
|
|
||||
|
// 解决Vue-Router升级导致的Uncaught(in promise) navigation guard问题----------
|
||||
|
const originalPush = Router.prototype.push |
||||
|
Router.prototype.push = function push(location, onResolve, onReject) { |
||||
|
if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject) |
||||
|
return originalPush.call(this, location).catch(err => err) |
||||
|
} |
||||
|
// 解决Vue-Router升级导致的Uncaught(in promise) navigation guard问题----------
|
||||
|
|
||||
|
// 页面路由(独立页面)
|
||||
|
export const pageRoutes = [ |
||||
|
{ |
||||
|
path: '/404', |
||||
|
component: () => import('@/page-subspecialty/views/pages/404'), |
||||
|
name: '404', |
||||
|
meta: { title: '404未找到' }, |
||||
|
beforeEnter(to, from, next) { |
||||
|
// 拦截处理特殊业务场景
|
||||
|
// 如果, 重定向路由包含__双下划线, 为临时添加路由
|
||||
|
if (/__.*/.test(to.redirectedFrom)) { |
||||
|
return next(to.redirectedFrom.replace(/__.*/, '')) |
||||
|
} |
||||
|
next() |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
path: '/login', |
||||
|
component: () => import('@/page-subspecialty/views/pages/login'), |
||||
|
name: 'login', |
||||
|
meta: { title: '登录' } |
||||
|
}, |
||||
|
{ |
||||
|
path: '/pacs', |
||||
|
component: () => import('@/page-subspecialty/views/pages/pacsManage/index'), |
||||
|
name: 'pacs', |
||||
|
meta: { title: 'pacs浏览器', isTab: true } |
||||
|
}, |
||||
|
// 录音
|
||||
|
{ |
||||
|
path: '/luyin', |
||||
|
name: 'luyin', |
||||
|
component: () => import('@/page-subspecialty/views/pages/luyin') |
||||
|
}, |
||||
|
// 日程安排
|
||||
|
{ |
||||
|
path: '/schedule', |
||||
|
name: 'schedule', |
||||
|
component: () => import('@/page-subspecialty/views/pages/schedule') |
||||
|
}, |
||||
|
{ |
||||
|
path: '/question', |
||||
|
name: 'question', |
||||
|
component: () => import('@/page-subspecialty/views/pages/question') |
||||
|
}, |
||||
|
{ |
||||
|
path: '/satusScreen', |
||||
|
name: 'satusScreen', |
||||
|
component: () => import('@/page-subspecialty/views/pages/satusScreen') |
||||
|
}, |
||||
|
{ |
||||
|
path: '/imageEdit', |
||||
|
name: 'imageEdit', |
||||
|
component: () => import('@/page-subspecialty/views/pages/imageEdit') |
||||
|
}, |
||||
|
{ |
||||
|
path: '/articleContent', |
||||
|
name: 'articleContent', |
||||
|
component: () => import('@/page-subspecialty/views/modules/articleManagement/articleContent') |
||||
|
}, |
||||
|
{ |
||||
|
path: '/transfer', |
||||
|
name: 'transfer', |
||||
|
component: () => import('@/page-subspecialty/views/pages/transfer') |
||||
|
} |
||||
|
] |
||||
|
|
||||
|
// 模块路由(基于主入口布局页面)*8
|
||||
|
export const moduleRoutes = { |
||||
|
path: '/', |
||||
|
component: () => import('@/page-subspecialty/views/main'), |
||||
|
name: 'main', |
||||
|
redirect: { name: 'patientManagement' }, |
||||
|
meta: { title: '首页' }, |
||||
|
children: [ |
||||
|
{ |
||||
|
path: '/patientManagement', |
||||
|
component: () => import('@/page-subspecialty/views/modules/patientManagement/index'), |
||||
|
name: 'patientManagement', |
||||
|
meta: { title: '分诊管理', isTab: true } |
||||
|
}, |
||||
|
{ |
||||
|
path: '/patientDetail', |
||||
|
component: () => import('@/page-subspecialty/views/modules/patientDetail'), |
||||
|
name: 'patientDetail', |
||||
|
meta: { title: '档案管理', isTab: true } |
||||
|
}, |
||||
|
// ok镜
|
||||
|
{ |
||||
|
path: '/patientInfo', |
||||
|
name: 'patientInfo', |
||||
|
meta: { title: '详情', isTab: true }, |
||||
|
component: () => import('@/page-subspecialty/views/modules/optometryManagement/seeDoctor/index') |
||||
|
}, |
||||
|
{ |
||||
|
path: '/iframe', |
||||
|
component: null, |
||||
|
name: 'iframe', |
||||
|
meta: { title: 'iframe', isTab: true } |
||||
|
}, |
||||
|
{ |
||||
|
path: '/redirect', |
||||
|
name: 'redirect', |
||||
|
component: () => import('@/page-subspecialty/views/redirect') |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
|
||||
|
export function addDynamicRoute(routeParams, router) { |
||||
|
// 组装路由名称, 并判断是否已添加, 如是: 则直接跳转
|
||||
|
var routeName = routeParams.routeName |
||||
|
var dynamicRoute = window.SITE_CONFIG['dynamicRoutes'].filter(item => item.name === routeName)[0] |
||||
|
if (dynamicRoute) { |
||||
|
return router.push({ name: routeName, params: routeParams.params }) |
||||
|
} |
||||
|
// 否则: 添加并全局变量保存, 再跳转
|
||||
|
dynamicRoute = { |
||||
|
path: routeName, |
||||
|
component: () => Promise.resolve(require(`@/page-subspecialty/views/modules/${routeParams.path}`).default), |
||||
|
// component: () => import(`@/views/modules/${routeParams.path}`),
|
||||
|
name: routeName, |
||||
|
meta: { |
||||
|
...window.SITE_CONFIG['contentTabDefault'], |
||||
|
menuId: routeParams.menuId, |
||||
|
title: `${routeParams.title}` |
||||
|
} |
||||
|
} |
||||
|
router.addRoutes([ |
||||
|
{ |
||||
|
...moduleRoutes, |
||||
|
name: `main-dynamic__${dynamicRoute.name}`, |
||||
|
children: [dynamicRoute] |
||||
|
} |
||||
|
]) |
||||
|
window.SITE_CONFIG['dynamicRoutes'].push(dynamicRoute) |
||||
|
router.push({ name: dynamicRoute.name, params: routeParams.params }) |
||||
|
} |
||||
|
|
||||
|
const createRouter = () => new Router({ |
||||
|
mode: 'history', |
||||
|
scrollBehavior: () => ({ y: 0 }), |
||||
|
routes: pageRoutes.concat(moduleRoutes) |
||||
|
}) |
||||
|
const router = createRouter() |
||||
|
|
||||
|
// [vue-router] Duplicate named routes definition 重复的命名路由定义
|
||||
|
// 动态路由退出再登录会出现警告重复路由
|
||||
|
// 解决方案:在退出时调用resetRouter()方法
|
||||
|
export function resetRouter() { |
||||
|
const newRouter = createRouter() |
||||
|
router.matcher = newRouter.matcher // reset router
|
||||
|
} |
||||
|
|
||||
|
router.beforeEach((to, from, next) => { |
||||
|
// 添加动态(菜单)路由
|
||||
|
// 已添加或者当前路由为页面路由, 可直接访问
|
||||
|
if (window.SITE_CONFIG['dynamicMenuRoutesHasAdded'] || fnCurrentRouteIsPageRoute(to, pageRoutes)) { |
||||
|
return next() |
||||
|
} |
||||
|
if (to.path === from.path) { |
||||
|
return |
||||
|
} |
||||
|
if (to.name === 'login' || to.path === '/login' || to.path === 'satusScreen' || to.name === 'satusScreen') { |
||||
|
next() |
||||
|
} else { |
||||
|
// 获取字典列表, 添加并全局变量保存
|
||||
|
// http.get('/sys/dict/type/all').then(({ data: res }) => {
|
||||
|
// if (res.code !== 0) {
|
||||
|
// return
|
||||
|
// }
|
||||
|
// window.SITE_CONFIG['dictList'] = res.data
|
||||
|
// }).catch(() => {})
|
||||
|
|
||||
|
// 获取左侧菜单列表,添加并全局变量保存
|
||||
|
http.get('/sys/menu/nav').then(({ data: res }) => { |
||||
|
if (res.code !== 0) { |
||||
|
Vue.prototype.$message.error(res.msg) |
||||
|
return next({ name: 'login' }) |
||||
|
} |
||||
|
window.SITE_CONFIG['menuList'] = res.data |
||||
|
}).catch(() => { |
||||
|
return next({ name: 'login' }) |
||||
|
}) |
||||
|
|
||||
|
// 获取菜单管理菜单列表,并添加动态路由
|
||||
|
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) |
||||
|
// console.log(menuListChild)
|
||||
|
fnAddDynamicMenuRoutes(JSON.parse(JSON.stringify(res.data)), menuListChild.length) |
||||
|
|
||||
|
next({ ...to, replace: true }) |
||||
|
}).catch(() => { |
||||
|
// 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
|
||||
|
// })
|
||||
|
|
||||
|
// 获取【设备与检查项目字典】, 添加并全局变量保存
|
||||
|
// http.get('/device/getData2RelDeviceItemList').then(({ data: res }) => {
|
||||
|
// window.SITE_CONFIG['dict_device_item'] = res.data
|
||||
|
// })
|
||||
|
} |
||||
|
/** |
||||
|
* 判断当前路由是否为页面路由 |
||||
|
* @param {*} route 当前路由 |
||||
|
* @param {*} pageRoutes 页面路由 |
||||
|
*/ |
||||
|
function fnCurrentRouteIsPageRoute(route, pageRoutes = []) { |
||||
|
var temp = [] |
||||
|
for (var i = 0; i < pageRoutes.length; i++) { |
||||
|
if (route.path === pageRoutes[i].path) { |
||||
|
return true |
||||
|
} |
||||
|
if (pageRoutes[i].children && pageRoutes[i].children.length >= 1) { |
||||
|
temp = temp.concat(pageRoutes[i].children) |
||||
|
} |
||||
|
} |
||||
|
return temp.length >= 1 ? fnCurrentRouteIsPageRoute(route, temp) : false |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 添加动态(菜单)路由 |
||||
|
* PH:自上而下遍历,累积平铺 |
||||
|
* @param {*} menuList 菜单列表 |
||||
|
* @param {*} routes 递归创建的动态(菜单)路由 |
||||
|
*/ |
||||
|
function fnAddDynamicMenuRoutes(menuList = [], menuListChildLength, routes = []) { |
||||
|
let index = 0 |
||||
|
// console.log(menuList)
|
||||
|
menuList.forEach((item, i) => { |
||||
|
// eslint-disable-next-line
|
||||
|
let URL = (item.url || '').replace(/{{([^}}]+)?}}/g, (s1, s2) => eval(s2)) // URL支持{{ window.xxx }}占位符变量
|
||||
|
item['meta'] = { |
||||
|
...window.SITE_CONFIG['contentTabDefault'], |
||||
|
menuId: item.id, |
||||
|
title: item.name |
||||
|
} |
||||
|
if (isURL(URL)) { |
||||
|
item['path'] = item['name'] = `i-${item.id}` |
||||
|
item['meta'].push({ |
||||
|
iframeURL: URL |
||||
|
}) |
||||
|
} else { |
||||
|
// console.log(URL)
|
||||
|
URL = URL.replace(/^\//, '').replace(/_/g, '-') |
||||
|
item['path'] = '/' + URL.replace(/\//g, '-') |
||||
|
item['name'] = URL.replace(/\//g, '-') |
||||
|
// 坑!!!父级也必须要有component,父级要有自己的vue组件,父级路由必须有<router-view />占位符
|
||||
|
// 其孩子children才能展示出来,孩子展示在父级占位符的地方
|
||||
|
URL.includes('seeDoctor') ? URL = 'seeDoctor' : '' // 不同父级有相同子级seeDoctor,防止面包屑冲突,动态路由名字区分设置为seeDoctor、seeDoctorOne,在寻找组件时替换回seeDoctor,可以找到对应组件路径
|
||||
|
item['component'] = () => Promise.resolve(require(`@/page-subspecialty/views/modules/${URL}`).default) |
||||
|
// 如果是父级给父级添加重定向到子菜单第一项
|
||||
|
if (item.children.length > 0 && item.children[0].url) { |
||||
|
// console.log(item)
|
||||
|
// isShow:0显示不菜单 1显示菜单
|
||||
|
item.children[0].isShow === 0 ? '' : item['redirect'] = '/' + item.children[0].url.replace(/\//g, '-') |
||||
|
} |
||||
|
} |
||||
|
if (item.children.length > 0) { |
||||
|
index++ |
||||
|
fnAddDynamicMenuRoutes(item.children) |
||||
|
} |
||||
|
}) |
||||
|
// routes = menuList
|
||||
|
// console.log(routes)
|
||||
|
// 此处一定要加判断,因为此方法在递归,要等到递归完成后再执行下面的内容
|
||||
|
// 坑!!!如果不加此判断,this.$route.matched面包屑的父级就不会展示
|
||||
|
if (menuListChildLength === index) { |
||||
|
routes = menuList |
||||
|
// PH:底层调用一次
|
||||
|
// 添加路由
|
||||
|
router.addRoutes([ |
||||
|
{ |
||||
|
...moduleRoutes, |
||||
|
name: 'main-dynamic-menu', |
||||
|
children: [...routes] |
||||
|
}, |
||||
|
{ path: '*', redirect: { name: '404' }} |
||||
|
]) |
||||
|
// console.log('----------------------')
|
||||
|
window.SITE_CONFIG['dynamicMenuRoutes'] = routes |
||||
|
window.SITE_CONFIG['dynamicMenuRoutesHasAdded'] = true |
||||
|
} |
||||
|
} |
||||
|
export default router |
||||
|
Loading…
Reference in new issue