From 3003dd79b2175037b54c1e7f641fa1379424a616 Mon Sep 17 00:00:00 2001 From: newPeter7 Date: Thu, 18 May 2023 10:34:09 +0800 Subject: [PATCH] peter --- .../360View/commonForm/eyesVision.vue | 2 +- .../360View/commonForm/optometryForm-copy.vue | 2 +- .../360View/commonForm/optometryForm.vue | 607 ++++++++++-------- .../360View/commonForm/threeVision.vue | 2 +- src/components/360View/special/index.vue | 2 +- src/i18n/zh-CN.js | 2 +- src/page-subspecialty/router/index.js | 6 + src/page-subspecialty/router/index.js.bak | 318 +++++++++ src/page-subspecialty/views/main-navbar.vue | 2 +- .../scientificManagement/search/index.vue | 14 +- .../scientificManagement/sys/project.vue | 50 +- .../systemManagement/team/edit-password.vue | 2 +- .../modules/systemManagement/team/index.vue | 2 +- src/page-subspecialty/views/pages/login.vue | 2 +- .../views/pages/subjectManage/index.vue | 56 ++ 15 files changed, 760 insertions(+), 309 deletions(-) create mode 100644 src/page-subspecialty/router/index.js.bak create mode 100644 src/page-subspecialty/views/pages/subjectManage/index.vue diff --git a/src/components/360View/commonForm/eyesVision.vue b/src/components/360View/commonForm/eyesVision.vue index 7e7d063..46efe44 100644 --- a/src/components/360View/commonForm/eyesVision.vue +++ b/src/components/360View/commonForm/eyesVision.vue @@ -832,7 +832,7 @@ export default { methods: { // 获取签名 setSign() { - const userData = window.sessionStorage.getItem('qg-userData') + const userData = JSON.parse(window.sessionStorage.getItem('qg-userData')) const date = this.$moment().format('YYYY-MM-DD') const mzName = window.sessionStorage.getItem('mzDoctorName') this.formData.ygsSign = userData.signImgBase diff --git a/src/components/360View/commonForm/optometryForm-copy.vue b/src/components/360View/commonForm/optometryForm-copy.vue index 66d3b9e..f559695 100644 --- a/src/components/360View/commonForm/optometryForm-copy.vue +++ b/src/components/360View/commonForm/optometryForm-copy.vue @@ -578,7 +578,7 @@ export default { methods: { // 设置签名 setSign() { - const userData = window.sessionStorage.getItem('qg-userData') + const userData = JSON.parse(window.sessionStorage.getItem('qg-userData')) const date = this.$moment().format('YYYY-MM-DD') const mzName = window.sessionStorage.getItem('mzDoctorName') this.dataForm.tongk = '正常瞳孔' diff --git a/src/components/360View/commonForm/optometryForm.vue b/src/components/360View/commonForm/optometryForm.vue index 95d25d7..5d8a979 100644 --- a/src/components/360View/commonForm/optometryForm.vue +++ b/src/components/360View/commonForm/optometryForm.vue @@ -1,9 +1,21 @@ @@ -166,22 +178,22 @@
- +
- +
- +
- +
@@ -190,7 +202,7 @@ @@ -248,22 +260,22 @@
- +
- +
- +
- +
@@ -272,7 +284,7 @@ @@ -311,22 +323,22 @@
- +
- +
- +
- +
@@ -335,22 +347,22 @@
视光师: - +
- +
日期: + />
-

说明:1.持本报告但配镜仅供参考。 2.本报告单有效期3个月

+

说明:1.持本报告单配镜仅供参考。 2.本报告单有效期3个月

@@ -366,9 +378,13 @@ export default { type: String, default: '' }, - formContent: { - type: Object, - default: () => { } + caseId: { + type: String, + default: '' + }, + isPlatform: { + type: Boolean, + default: true }, onlyRead: { type: Boolean, @@ -377,6 +393,7 @@ export default { }, data() { return { + connectFlag: false, // 连接 ws: null, // 建立的连接 lockReconnect: false, // 是否真正建立连接 timeout: 28 * 1000, // 30秒一次心跳 @@ -384,14 +401,46 @@ export default { serverTimeoutObj: null, // 心跳倒计时 timeoutnum: null, // 断开 重连倒计时 dataForm: { + id: '', + jzNumber: '', + idList: [], patientId: '', patientName: '', patientSex: '', patientAge: '', - file: '', - optometrist: '', - physician: '', - date: '' + qgFyda: '', // 屈光发育档案 + ygsSign: '', // 视光师 + ysSign: '', // 医师 + riQi: '', // 日期 + slType: '', // 视力类型 + slOs: '', // 左眼视力 + slOd: '', // 右眼视力 + tongk: '', // 瞳孔 + jianchaFangfa: '', + ygjcDsOd: '', + ygjcDsOs: '', + ygjcDcOd: '', + ygjcDcOs: '', + ygjcAOd: '', + ygjcAOs: '', + ygjcVaOd: '', + ygjcVaOs: '', + ygjcAddOd: '', + ygjcAddOs: '', + zzcfAOd: '', + zzcfAOs: '', + zzcfAddOd: '', + zzcfAddOs: '', + zzcfDcOd: '', + zzcfDcOs: '', + zzcfDsOd: '', + zzcfDsOs: '', + zzcfVaOs: '', + zzcfVaOd: '', + zzcfCheck: '', + pjyjCheck: '', // 配镜建议 + pjyjQt: '', // 配镜建议-其他 + beiZhu: '' // 备注 }, fileList: [ { @@ -412,35 +461,28 @@ export default { pupil: [ { name: '正常瞳孔', - id: '1', - isSelect: false + id: '1' }, { name: '复方托吡卡胺', - id: '2', - isSelect: false + id: '2' }, { name: '美多丽', - id: '3', - isSelect: false + id: '3' }, { name: '赛飞杰', - id: '4', - isSelect: false + id: '4' }, { name: '阿托品', - id: '5', - isSelect: false + id: '5' } ], examine: [ { name: '检影', - id: '1', - isSelect: false + id: '1' }, { name: '综合', - id: '2', - isSelect: false + id: '2' } ], remoteUse: [ @@ -484,164 +526,110 @@ export default { originTableData: [], tableData: [ { - name: '基本信息', - vision: '1', - od: '', // 右眼 - os: '' // 左眼 + name: '基本信息' }, { - name: '1', - value: '', // 瞳孔状态 - examValue: '' // 检查方法 + name: '1' }, { name: '验光检查' }, { - name: '3', // 验光检查 右眼 - a: '', // 球镜(DS) - b: '', // 柱镜(DC) - c: '', // 轴位(A) - d: '', // 矫正视力(VA) - e: '' // 下加光(ADD) + name: '3' }, { - name: '4', // 验光检查 左眼 - a: '', - b: '', - c: '', - d: '', - e: '' + name: '4' }, { - name: '最终处方', // 最终处方 右眼 - a: '', - b: '', - c: '', - d: '', - e: '' + name: '最终处方' }, { - name: '5', // 最终处方 右眼 - a: '', - b: '', - c: '', - d: '', - e: '' + name: '5' }, { - name: '配镜建议', - value: '' // 其他 + name: '配镜建议' }, { - name: '备注', - value: '' // 备注 + name: '备注' }], print: { id: 'optomeFunc' } } }, + watch: { + caseId: { + handler: function(newV, oldV) { + this.queryForm() + if (this.isSearch === '3') { + this.initWebSoket() + } + } + } + }, destroyed() { - this.ws.close() + if (this.isSearch === '3') { + this.connectFlag = false + clearTimeout(this.timeoutnum) + clearTimeout(this.timeoutObj) + clearTimeout(this.serverTimeoutObj) + this.ws.close() + } }, mounted() { - this.originTableData = JSON.parse(JSON.stringify(this.tableData)) - this.setSign() - this.initWebSoket() + this.queryForm() this.getPatientData() - this.setVision() + if (this.isSearch === '3') { + this.initWebSoket() + } }, methods: { + // 设置签名 setSign() { - const userData = window.sessionStorage.getItem('qg-userData') + const userData = JSON.parse(window.sessionStorage.getItem('qg-userData')) const date = this.$moment().format('YYYY-MM-DD') const mzName = window.sessionStorage.getItem('mzDoctorName') - this.dataForm.optometrist = userData.signImgBase - this.dataForm.physician = mzName - this.dataForm.date = date - }, - setData() { - this.dataForm = this.formContent.a - this.tableData = this.formContent.b - this.setSign() - this.getPatientData() - }, - reSet() { - this.dataForm = { - patientId: '', - patientName: '', - patientSex: '', - patientAge: '', - file: '', - optometrist: '', - physician: '', - date: '' - } - this.tableData = Object.assign([], this.originTableData) - this.setSign() - this.setVision() - this.getPatientData() + this.dataForm.tongk = '正常瞳孔' + this.dataForm.jianchaFangfa = '综合' + this.dataForm.ygsSign = userData.signImgBase + this.dataForm.ysSign = mzName + this.dataForm.riQi = date }, setVision() { const data = window.sessionStorage.getItem('shili') ? JSON.parse(window.sessionStorage.getItem('shili')) : [] - if (data.length) { - const one = data[0].odVan - const two = data[0].odVag - if (one) { - this.tableData[0].vision = '1' - this.selectVision('1') - } else if (two && !one) { - this.tableData[0].vision = '2' - this.selectVision('2') - } else { - this.tableData[0].vision = '1' - this.selectVision('1') - } + const one = data.length ? data[0].odVan : '' + const two = data.length ? data[0].odVag : '' + if (two && !one) { + this.dataForm.slType = '2' + this.selectVision('2') + } else { + this.dataForm.slType = '1' + this.selectVision('1') } }, selectVision(id) { + const data = window.sessionStorage.getItem('shili') ? JSON.parse(window.sessionStorage.getItem('shili')) : [] if (id === '1') { // 裸眼视力 - const data = window.sessionStorage.getItem('shili') ? JSON.parse(window.sessionStorage.getItem('shili')) : [] - if (data.length) { - this.tableData[0].od = data[0].odVan - this.tableData[0].os = data[0].osVan - } else { - this.tableData[0].od = '' - this.tableData[0].os = '' - } + this.dataForm.slOd = data.length ? data[0].odVan : '' + this.dataForm.slOs = data.length ? data[0].osVan : '' } else { - const data = window.sessionStorage.getItem('shili') ? JSON.parse(window.sessionStorage.getItem('shili')) : [] - if (data.length) { - this.tableData[0].od = data[0].odVag - this.tableData[0].os = data[0].osVag - } else { - this.tableData[0].od = '' - this.tableData[0].os = '' - } + this.dataForm.slOd = data.length ? data[0].odVag : '' + this.dataForm.slOs = data.length ? data[0].osVag : '' } }, copyData() { - const ods = this.tableData.filter(item => item.name === '3') - const oss = this.tableData.filter(item => item.name === '4') - this.tableData.forEach(item => { - if (item.name === '最终处方') { - item.a = ods[0].a - item.b = ods[0].b - item.c = ods[0].c - item.d = ods[0].d - item.e = ods[0].e - } - if (item.name === '5') { - item.a = oss[0].a - item.b = oss[0].b - item.c = oss[0].c - item.d = oss[0].d - item.e = oss[0].e - } - }) + this.dataForm.zzcfDsOd = this.dataForm.ygjcDsOd + this.dataForm.zzcfDcOd = this.dataForm.ygjcDcOd + this.dataForm.zzcfAOd = this.dataForm.ygjcAOd + this.dataForm.zzcfVaOd = this.dataForm.ygjcVaOd + this.dataForm.zzcfAddOd = this.dataForm.ygjcAddOd + this.dataForm.zzcfDsOs = this.dataForm.ygjcDsOs + this.dataForm.zzcfDcOs = this.dataForm.ygjcDcOs + this.dataForm.zzcfAOs = this.dataForm.ygjcAOs + this.dataForm.zzcfVaOs = this.dataForm.ygjcVaOs + this.dataForm.zzcfAddOs = this.dataForm.ygjcAddOs }, async getPatientData() { const { data: res } = await this.$http.get( - '/patient/view/getPatientData', - { - params: { - patientId: this.patientId + '/patient/view/getPatientData', + { + params: { + patientId: this.patientId + } } - } ) if (res.code === 0) { const data = res.data @@ -653,6 +641,58 @@ export default { this.$message.error(res.msg) } }, + async queryForm() { + const { data: res } = await this.$http.get( + '/ygbgd/getYgbgdInfo', + { + params: { + patientId: this.patientId, + caseId: this.caseId + } + } + ) + if (res.code === 0) { + this.dataForm = res.data + if (!this.dataForm.id) { + await this.queryProject() + this.setVision() + this.setSign() + } + this.dataForm.jzNumber = window.sessionStorage.getItem('jzNumber') + this.handleStr(this.dataForm.pjyjCheck, this.suggest) + this.handleStr(this.dataForm.zzcfCheck, this.remoteUse) + } else { + this.$message.error(res.msg) + } + }, + // 获取报告单id + async queryProject() { + const project = window.sessionStorage.getItem('projectItem') ? JSON.parse(window.sessionStorage.getItem('projectItem')) : [] + const { data: res } = await this.$http.get( + '/patient/getZlItemDict', + { + params: { + caseName: '验光报告单' + } + } + ) + if (res.code === 0) { + const data = res.data || [] + const list = [] + if (data.length) { + for (let i = 0; i < data.length; i++) { + for (let j = 0; j < project.length; j++) { + if (data[i].itemId === project[j].porjectCode) { + list.push(project[j].id) + } + } + } + this.dataForm.idList = list + } + } else { + this.$message.error(res.msg) + } + }, reconnect() { // 重新连接 const that = this if (that.lockReconnect) { @@ -696,53 +736,114 @@ export default { // wss://127.0.0.1:8030/data // const url = 'ws://47.110.224.240:8036/xiangan-crf/websocket/0071' // const url = 'ws://192.168.0.167:8036/xiangan-crf/websocket/0071' - const url = 'ws://127.0.0.1:8030/data' - const self = this - this.ws = new WebSocket(url) - this.ws.onopen = function() { - console.log('连接成功') - self.start() - } - this.ws.onclose = function() { - // console.log('连接关闭') - self.reconnect() + try { + const url = 'ws://127.0.0.1:8030/data' + const self = this + this.ws = new WebSocket(url) + this.ws.onopen = function() { + console.log('连接成功') + self.connectFlag = true + self.start() + } + this.ws.onclose = function() { + self.connectFlag = false + self.reconnect() + } + this.ws.onerror = function() { + self.connectFlag = false + self.reconnect() + } + this.ws.onmessage = function(msg) { + const message = JSON.parse(msg.data) + // const data = JSON.parse(msg.data) + // const message = JSON.parse(data.msgTxt) + self.dataForm.ygjcDsOd = message.RData.DS + self.dataForm.ygjcDcOd = message.RData.DC + self.dataForm.ygjcAOd = message.RData.AXIS + self.dataForm.ygjcVaOd = message.RData.VA + self.dataForm.ygjcAddOd = message.RData.ADD + self.dataForm.ygjcDsOs = message.LData.DS + self.dataForm.ygjcDcOs = message.LData.DC + self.dataForm.ygjcAOs = message.LData.AXIS + self.dataForm.ygjcVaOs = message.LData.VA + self.dataForm.ygjcAddOs = message.LData.ADD + self.resetHeart() + } + } catch (e) { + console.log(e) } - this.ws.onerror = function() { - // console.log('连接失败') - self.reconnect() + }, + // 处理字符串 + handleStr(string, array) { + if (string) { + const data = string.split(',') + array.forEach(item => { + data.forEach(row => { + if (item.name === row) { + item.isSelect = true + } + }) + }) + } else { + array.forEach(item => { + item.isSelect = false + }) } - this.ws.onmessage = function(msg) { - const message = JSON.parse(msg.data) - // const data = JSON.parse(msg.data) - // const message = JSON.parse(data.msgTxt) - console.log(message) - self.tableData.forEach(item => { - if (item.name == '3') { - item.a = message.RData.DS - item.b = message.RData.DC - item.c = message.RData.AXIS - item.d = message.RData.VA - item.e = message.RData.ADD - } else if (item.name == '4') { - item.a = message.LData.DS - item.b = message.LData.DC - item.c = message.LData.AXIS - item.d = message.LData.VA - item.e = message.LData.ADD + return array + }, + // 处理数组 + handleCheck(array) { + if (array && array.length) { + const temp = [] + array.forEach(item => { + if (item.isSelect) { + temp.push(item.name) } }) - self.resetHeart() + return temp.join(',') } }, handleSaveTable() { - const data = { - a: this.dataForm, - b: this.tableData - } - this.$emit('save', data) + this.dataForm.pjyjCheck = this.handleCheck(this.suggest) + this.dataForm.zzcfCheck = this.handleCheck(this.remoteUse) + this.$http.post('/ygbgd/saveYgbgd', this.dataForm).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: () => { + this.queryForm() + } + }) + }).catch(() => {}) }, handleDelete() { - this.$emit('del') + const params = { + id: this.caseId + } + this.$confirmFun('你确定要删除吗?').then(async() => { + await this.deleteNewForm() + const { data: res } = await this.$http.post('/case/delete', params) + if (res.code === 0) { + this.$message.success('删除成功') + await this.$parent.getFormList() + } else { + this.$message.error(res.msg) + } + }) + }, + async deleteNewForm() { + const params = { + id: this.caseId + } + const { data: res } = await this.$http.post('/ygbgd/delYgbgdInfo', params) + if (res.code === 0) { + } else { + this.$message.error(res.msg) + } }, objectSpanMethod({ row, column, rowIndex, columnIndex }) { if (columnIndex === 0) { @@ -922,18 +1023,6 @@ export default { .el-date-editor.el-input__inner { width: 140px; } - //.el-checkbox__input.is-checked + .el-checkbox__label { - // color: #606266; - //} - //.el-checkbox__input.is-checked .el-checkbox__inner, - //.el-checkbox__input.is-indeterminate .el-checkbox__inner { - // background: #767676; - // border-color: #767676; - //} - //.el-checkbox__inner:hover, - //.el-checkbox__inner { - // border-color: #767676; - //} .el-table--enable-row-hover .el-table__body tr:hover>td.el-table__cell { background: none !important; } @@ -963,6 +1052,21 @@ export default { margin-right: 5px; } } + .el-input__inner { + padding: 0; + border: none; + text-align: center; + border-radius: 0; + border-bottom: 1px solid #8e8c8c; + } + .operation-record-table{ + .el-input__inner { + padding: 0; + border: none; + text-align: center; + border-radius: 0; + } + } .bold{ font-weight: 700; } @@ -987,6 +1091,9 @@ export default { border: none; } .el-input__suffix-inner{ + //display: none; + } + .el-icon-arrow-up{ display: none; } } diff --git a/src/components/360View/commonForm/threeVision.vue b/src/components/360View/commonForm/threeVision.vue index 15238b7..e3ad1bd 100644 --- a/src/components/360View/commonForm/threeVision.vue +++ b/src/components/360View/commonForm/threeVision.vue @@ -1245,7 +1245,7 @@ export default { setSign() { const userData = window.sessionStorage.getItem('qg-userData') const date = this.$moment().format('YYYY-MM-DD') - this.dataForm.sgsSign = userData.signImgBase + this.dataForm.sgsSign = JSON.parse(userData).signImgBase this.dataForm.riQi = date }, async getPatientData() { diff --git a/src/components/360View/special/index.vue b/src/components/360View/special/index.vue index c9caf10..eecf766 100644 --- a/src/components/360View/special/index.vue +++ b/src/components/360View/special/index.vue @@ -123,7 +123,7 @@ export default { } }, mounted() { - const user = window.sessionStorage.getItem('qg-userData') + const user = JSON.parse(window.sessionStorage.getItem('qg-userData')) this.employeeId = user.employeeId this.getPatientData() this.getSpecialItem() diff --git a/src/i18n/zh-CN.js b/src/i18n/zh-CN.js index c32cebf..a0c7398 100644 --- a/src/i18n/zh-CN.js +++ b/src/i18n/zh-CN.js @@ -3,7 +3,7 @@ const t = {} t.loading = '加载中...' t.brand = {} -t.brand.lg = '眼科电子病历&科研' +t.brand.lg = '眼科工作平台' t.brand.mini = '屈光' t.add = '新增' diff --git a/src/page-subspecialty/router/index.js b/src/page-subspecialty/router/index.js index 2ca8de6..6462192 100644 --- a/src/page-subspecialty/router/index.js +++ b/src/page-subspecialty/router/index.js @@ -47,6 +47,12 @@ export const pageRoutes = [ component: () => import('@/page-subspecialty/views/pages/pacs/index'), name: 'pacs', meta: { title: 'pacs浏览器', isTab: true } + }, + { + path: '/subjectMgt', + component: () => import('@/page-subspecialty/views/pages/subjectManage/index'), + name: 'subjectMgt', + meta: { title: '课题管理', isTab: true } } ] diff --git a/src/page-subspecialty/router/index.js.bak b/src/page-subspecialty/router/index.js.bak new file mode 100644 index 0000000..2ca8de6 --- /dev/null +++ b/src/page-subspecialty/router/index.js.bak @@ -0,0 +1,318 @@ +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: '/pacsManage', + component: () => import('@/page-subspecialty/views/pages/pacsManage/index'), + name: 'pacsManage', + meta: { title: 'pacs浏览器', isTab: true } + }, + { + path: '/pacs', + component: () => import('@/page-subspecialty/views/pages/pacs/index'), + name: 'pacs', + meta: { title: 'pacs浏览器', isTab: true } + } + +] + +// 模块路由(基于主入口布局页面)*8 +export const moduleRoutes = { + path: '/', + component: () => import('@/page-subspecialty/views/main'), + name: 'main', + redirect: { name: 'outpatientManagement' }, + meta: { title: '首页' }, + children: [ + { + path: '/outpatientManagement', + component: () => import('@/page-subspecialty/views/modules/outpatientManagement/call'), + name: 'outpatientManagement', + 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') + }, + { + path: '/360view', + name: '360view', + component: () => import('@/components/360View/index1.vue') + } + ] +} + +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 if (to.name === '360view' && to.query.doctorId) { + loginByDocId(to.query.doctorId, next, to.fullPath) + } 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) + fnAddDynamicMenuRoutes(JSON.parse(JSON.stringify(res.data)), menuListChild.length) + + next({ ...to, replace: true }) + }).catch(() => { + // console.log(123) + return next({ name: 'login' }) + }) + } +}) +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.sessionStorage.setItem('xa-token', res.data.token) + window.sessionStorage.setItem('qg-userData', JSON.stringify(res.data.currentUser)) + getNavList(next) + muneList(next) + + return next() + }).catch(() => { }) +} + +/** + * 判断当前路由是否为页面路由 + * @param {*} route 当前路由 + * @param {*} pageRoutes 页面路由 + */ +function fnCurrentRouteIsPageRoute(route, pageRoutes = []) { + let temp = [] + for (let 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 + 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组件,父级路由必须有占位符 + // 其孩子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) + } + }) + // 此处一定要加判断,因为此方法在递归,要等到递归完成后再执行下面的内容 + // 坑!!!如果不加此判断,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 diff --git a/src/page-subspecialty/views/main-navbar.vue b/src/page-subspecialty/views/main-navbar.vue index e2c27d4..42b29e7 100644 --- a/src/page-subspecialty/views/main-navbar.vue +++ b/src/page-subspecialty/views/main-navbar.vue @@ -5,7 +5,7 @@

-
眼科电子病历&科研
+
眼科工作平台

diff --git a/src/page-subspecialty/views/modules/scientificManagement/search/index.vue b/src/page-subspecialty/views/modules/scientificManagement/search/index.vue index a47b684..565a3f8 100644 --- a/src/page-subspecialty/views/modules/scientificManagement/search/index.vue +++ b/src/page-subspecialty/views/modules/scientificManagement/search/index.vue @@ -2,13 +2,13 @@ + + +