-
+
-
+
-
-
+
+ {{ currentRemote.taskName }}
-{{ currentRemote.taskName }}
+
-
+ diff --git a/src/api/log-manage.ts b/src/api/log-manage.ts index e9182a0..72ad062 100644 --- a/src/api/log-manage.ts +++ b/src/api/log-manage.ts @@ -22,7 +22,7 @@ export function getMonthlyLogCount(startTime: string, endTime: string) { }) } -export function getPage(current: number, size: number, condition: {timeInterval: string, logType: string}) { +export function getPage(current: number, size: number, condition?: {timeInterval: string, logType: string}) { return new Promise((resolve, reject) => { request.get(getPageUrl, { params: { diff --git a/src/components/Websocket/index.vue b/src/components/Websocket/index.vue deleted file mode 100644 index 6b2ed61..0000000 --- a/src/components/Websocket/index.vue +++ /dev/null @@ -1,159 +0,0 @@ - - - - diff --git a/src/stores/remote-ws-store.ts b/src/stores/remote-ws-store.ts index fd5153b..b1bb55d 100644 --- a/src/stores/remote-ws-store.ts +++ b/src/stores/remote-ws-store.ts @@ -1,214 +1,384 @@ import {defineStore} from "pinia"; import {Session} from "@/utils/storage"; +import {ElMessage} from "element-plus"; -const vitalUrl = "ws://localhost:5173/socket.io/admin/rax/vitalSignsMedicine?token=" + Session.getToken() -const medicineUrl = "ws://localhost:5173/socket.io/admin/rax/addMedicine?token=" + Session.getToken() -const chatUrl = "ws://localhost:5173/socket.io/admin/rax/chatRoom?token=" + Session.getToken() +const vitalUrl = "ws://" + window.location.host + "/socket.io/admin/rax/vitalSignsMedicine?token=" + Session.getToken() +const medicineUrl = "ws://" + window.location.host + "/socket.io/admin/rax/addMedicine?token=" + Session.getToken() +const chatUrl = "ws://" + window.location.host + "/socket.io/admin/rax/chatRoom?token=" + Session.getToken() export const useRemoteWsStore = defineStore("remoteWs", { - state: () => { - return { - patient: {} as any, - remoteTasks: [] as any, - remoteTasksCap: 10, - currentTaskIndex: 0, - varMedicine: ["丙泊酚", "舒芬太尼", "瑞芬太尼", "顺阿曲库胺"], - fixedMedicine: ["尼卡地平", "艾司洛尔", "麻黄素", "阿托品"], - exceptionType: ["BIS_except", "DBP_except", "EtCO2_except", "HR_except", "SBP_except", "ST_except"], - exceptionMsg: { - "BIS_except": "脑电双频指数异常", "DBP_except": "舒张压异常", "EtCO2_except": "呼气末二氧化碳异常", - "HR_except": "心率异常", "SBP_except": "收缩压异常", "ST_except": "ST异常" - } as any, - } - }, - actions: { - initRemoteTask() { - if (this.remoteTasks.length <= 0) { - for (let i = 0; i < 10; i++) { - this.remoteTasks.push({ - isRemote: false, - isException: false, - taskName: "", - server: "", - serverun: "", - serverps: "", - patient: "", - patientId: "", - date: "", - log: [], - index: i - }) - } - } - return this.remoteTasks - }, - resetRemoteTask(i: number) { - this.remoteTasks[i] = Object.assign(this.remoteTasks[i], { - isRemote: false, - isException: false, - taskName: "", - server: "", - serverun: "", - serverps: "", - patient: "", - patientId: "", - date: "", - log: [], - index: i, - message: [] - }) - }, - getActiveRemoteTask() { - for (let i = 0; i < this.remoteTasks.length; i++) { - if (this.remoteTasks[i].isRemote) return i - } - }, - setRemoteLog(log: any, i: number) { - this.remoteTasks[i].log.push(log) - }, - createConnect(name: string, id: string, date: string) { - if (!this.patient[name + id + date]) { - const vitalWS = new WebSocket(vitalUrl) - const medicineWS = new WebSocket(medicineUrl) - const chatWS = new WebSocket(chatUrl) - vitalWS.onopen = function () { - vitalWS.send(JSON.stringify({ - patientName: name, - idNum: id, - date: date - })) - } - medicineWS.onopen = function () { - medicineWS.send(JSON.stringify({ - patientName: name, - idNum: id, - date: date - })) - } - chatWS.onopen = function () { - chatWS.send(JSON.stringify({ - patientName: name, - idNum: id, - date: date - })) - } - this.patient[name + id + date] = { - vitalWS, - medicineWS, - chatWS - } - } - }, - disconnect(name: string, id: string, date: string) { - const patient: any = this.patient[name + id + date] - if (patient) { - patient.vitalWS.close() - patient.medicineWS.close() - patient.chatWS.close() - delete this.patient[name + id + date] - } - }, - subscribeVital(name: string, id: string, date: string, cb: any) { - const patient: any = this.patient[name + id + date] - if (patient) { - patient.vitalWS.onmessage = cb - patient.vitalCB = cb - } else { - cb({ - status: 1, - msg: "已断开连接" - }) - } - }, - unsubscribeVital(name: string, id: string, date: string) { - const patient: any = this.patient[name + id + date] - if (patient && patient.vitalWS) { - patient.vitalWS.onmessage = undefined; - patient.vitalCB = undefined; - } - }, - sendMsg(name: string, id: string, date: string, msg: string, cb: any) { - const patient: any = this.patient[name + id + date] - if (patient) { - const params = { - patientName: name, - idNum: id, - date: date, - msg - } - patient.chatWS.send(JSON.stringify(params)) - cb({ - status: 0 - }) - } else { - cb({ - status: 1, - msg: "已断开连接" - }) - } - }, - subscribeChat(name: string, id: string, date: string, cb: any) { - const patient: any = this.patient[name + id + date] - if (patient) { - patient.chatCB = cb - patient.chatWS.onmessage = cb - } else { - cb({ - status: 1, - msg: "已断开连接" - }) - } - }, - unsubscribeChat(name: string, id: string, date: string) { - const patient: any = this.patient[name + id + date] - patient.chatCB = undefined; - patient.chatWS.onmessage = undefined; - }, - sendMedicine(args: { - name: string, - id: string, - date: string, - flag: string, - medicine: string, - value: string - }, cb: any) { - const patient: any = this.patient[args.name + args.id + args.date] - if (patient) { - const params = { - patientName: args.name, - idNum: args.id, - date: args.date, - flag: args.flag, - medicine: args.medicine, - value: args.value - } - patient.medicineWS.send(JSON.stringify(params)) - cb({ - status: 0 - }) - } else { - cb({ - status: 1, - msg: "已断开连接" - }) - } - }, - subscribeMedicine(name: string, id: string, date: string, cb: any) { - const patient = this.patient[name + id + date] - if (patient) { - patient.medicineCB = cb - patient.medicineWS.onmessage = cb - } else { - cb({ - status: 1, - msg: "已断开连接" - }) - } - }, - unsubscribeMedicine(name: string, id: string, date: string) { - const patient: any = this.patient[name + id + date] - patient.medicineCB = undefined; - patient.medicineWS.onmessage = undefined; - } - } + state: () => { + return { + patient: {} as any, + remoteTasks: [] as any, + remoteTasksCap: 10, + currentTaskIndex: 0, + varMedicine: ["丙泊酚", "舒芬太尼", "瑞芬太尼", "顺阿曲库胺"], + fixedMedicine: ["尼卡地平", "艾司洛尔", "麻黄素", "阿托品"], + exceptionType: ["BIS_except", "DBP_except", "EtCO2_except", "HR_except", "SBP_except", "ST_except"], + exceptionMsg: { + "BIS_except": "脑电双频指数异常", "DBP_except": "舒张压异常", "EtCO2_except": "呼气末二氧化碳异常", + "HR_except": "心率异常", "SBP_except": "收缩压异常", "ST_except": "ST异常" + } as any, + exceptions: {} as any, + closeStatus: {} as any + } + }, + actions: { + setCurrentTaskIndex(i: number) { + this.currentTaskIndex = i + Session.set("currentTaskIndex", i) + }, + getCurrentTaskIndex() { + if (Session.get("currentTaskIndex") && Session.get("currentTaskIndex") > -1) { + this.currentTaskIndex = Session.get("currentTaskIndex") + } + return this.currentTaskIndex + }, + setExceptions(i: number, e: any) { + this.exceptions[i] = e + }, + getExceptions() { + return this.exceptions + }, + getCloseStatus() { + return this.closeStatus + }, + setRemoteTask() { + Session.set("remoteTasks", this.remoteTasks) + }, + getRemoteTask() { + if (Session.get("remoteTasks") && !this.remoteTasks) { + this.remoteTasks = Session.get("remoteTasks") + } + return this.remoteTasks + }, + initRemoteTask() { + if (Session.get("remoteTasks") && !this.remoteTasks) { + this.remoteTasks = Session.get("remoteTasks") + } + if (this.remoteTasks.length <= 0) { + for (let i = 0; i < 10; i++) { + this.remoteTasks.push({ + isRemote: false, + isException: false, + taskName: "", + server: "", + serverun: "", + serverps: "", + patient: "", + patientId: "", + date: "", + log: [], + index: i + }) + } + } + return this.remoteTasks + }, + resetRemoteTask(i: number) { + this.remoteTasks[i] = Object.assign(this.remoteTasks[i], { + isRemote: false, + isException: false, + taskName: "", + server: "", + serverun: "", + serverps: "", + patient: "", + patientId: "", + date: "", + log: [], + index: i, + message: [] + }) + Session.set("remoteTasks", this.remoteTasks) + }, + getActiveRemoteTask() { + let index = 0 + for (let i = 0; i < this.remoteTasks.length; i++) { + if (this.remoteTasks[i].isRemote) index = i + } + return index + }, + setRemoteLog(log: any, i: number) { + this.remoteTasks[i].log.push(log) + }, + disconnect(name: string, id: string, date: string) { + this.disconnectVital(name, id, date) + this.disconnectChat(name, id, date) + this.disconnectMedicine(name, id, date) + delete this.patient[name + id + date] + }, + createVitalConnect(name: string, id: string, date: string) { + if (!this.patient[name + id + date]) this.patient[name + id + date] = {} + const patient = this.patient[name + id + date] + if (!patient['vitalWS']) { + patient['vitalWS'] = new WebSocket(vitalUrl) + patient.vitalWS.onopen = () => { + patient.vitalWS.send(JSON.stringify({ + patientName: name, + idNum: id, + date: date, + msgType: "msg" + })) + } + } + }, + subscribeVital(name: string, id: string, date: string, cb: any) { + const patient = this.patient[name + id + date] + if (patient.vitalWS) { + patient.vitalWS.onmessage = (e: any) => { + if (e && e.data) { + const data = JSON.parse(e.data); + if (data.msgType == "msg") { + cb(e) + } else { + patient.vitalWS.send(JSON.stringify({msgType: "heartbeat"})) + } + } + } + } else { + cb({ + status: 1, + msg: "已断开连接" + }) + } + }, + vitalOnclose(name: string, id: string, date: string, cb: any) { + const patient = this.patient[name + id + date] + if (patient.vitalWS) { + patient.vitalWS.onclose = cb + } else { + cb({ + status: 1, + msg: "已断开连接" + }) + } + }, + vitalOnerror(name: string, id: string, date: string, cb: any) { + const patient = this.patient[name + id + date] + if (patient.vitalWS) { + patient.vitalWS.onerror = cb + } else { + cb({ + status: 1, + msg: "已断开连接" + }) + } + }, + unsubscribeVital(name: string, id: string, date: string) { + const patient: any = this.patient[name + id + date] + if (patient) { + patient.vitalWS.onmessage = undefined + patient.vitalWS.onclose = undefined + patient.vitalWS.onerror = undefined + } + }, + disconnectVital(name: string, id: string, date: string) { + const patient: any = this.patient[name + id + date] + if (patient && patient.vitalWS) { + this.closeStatus[name + id + date + 'vitalWS'] = true + patient.vitalWS.close() + delete patient['vitalWS'] + delete this.closeStatus[name + id + date + 'vitalWS'] + } + }, + createChatConnect(name: string, id: string, date: string) { + if (!this.patient[name + id + date]) this.patient[name + id + date] = {} + const patient = this.patient[name + id + date] + if (!patient['chatWS']) { + patient['chatWS'] = new WebSocket(chatUrl) + patient.chatWS.onopen = function () { + patient.chatWS.send(JSON.stringify({ + patientName: name, + idNum: id, + date: date, + msgType: "msg" + })) + } + } + }, + subscribeChat(name: string, id: string, date: string, cb: any) { + const patient = this.patient[name + id + date] + if (patient.chatWS) { + patient.chatWS.onmessage = (e: any) => { + if (e && e.data) { + const data = JSON.parse(e.data); + if (data.msgType == "msg") { + cb(e) + } else { + patient.chatWS.send(JSON.stringify({msgType: "heartbeat"})) + } + } + } + } else { + cb({ + status: 1, + msg: "已断开连接" + }) + } + }, + chatOnclose(name: string, id: string, date: string, cb: any) { + const patient = this.patient[name + id + date] + if (patient.chatWS) { + patient.chatWS.onclose = cb + } else { + cb({ + status: 1, + msg: "已断开连接" + }) + } + }, + chatOnerror(name: string, id: string, date: string, cb: any) { + const patient = this.patient[name + id + date] + if (patient.chatWS) { + patient.chatWS.onerror = cb + } else { + cb({ + status: 1, + msg: "已断开连接" + }) + } + }, + unsubscribeChat(name: string, id: string, date: string) { + const patient: any = this.patient[name + id + date] + if (patient) { + patient.chatWS.onmessage = undefined + patient.chatWS.onclose = undefined + patient.chatWS.onerror = undefined + } + }, + sendMsg(name: string, id: string, date: string, msg: string, cb: any) { + const patient: any = this.patient[name + id + date] + if (patient) { + const params = { + patientName: name, + idNum: id, + date: date, + msg + } + patient.chatWS.send(JSON.stringify(params)) + cb({ + status: 0 + }) + } else { + cb({ + status: 1, + msg: "已断开连接" + }) + } + }, + disconnectChat(name: string, id: string, date: string) { + const patient: any = this.patient[name + id + date] + if (patient && patient.chatWS) { + this.closeStatus[name + id + date + 'chatWS'] = true + patient.chatWS.close() + delete patient['chatWS'] + delete this.closeStatus[name + id + date + 'chatWS'] + } + }, + createMedicineConnect(name: string, id: string, date: string) { + if (!this.patient[name + id + date]) this.patient[name + id + date] = {} + const patient = this.patient[name + id + date] + if (!patient['medicineWS']) { + patient['medicineWS'] = new WebSocket(medicineUrl) + patient.medicineWS.onopen = function () { + patient.medicineWS.send(JSON.stringify({ + patientName: name, + idNum: id, + date: date, + msgType: "msg" + })) + } + } + }, + subscribeMedicine(name: string, id: string, date: string, cb: any) { + const patient = this.patient[name + id + date] + if (patient) { + patient.medicineWS.onmessage = (e: any) => { + if (e && e.data) { + const data = JSON.parse(e.data); + if (data.msgType == "msg") { + cb(e) + } else { + patient.medicineWS.send(JSON.stringify({msgType: "heartbeat"})) + } + } + } + } else { + cb({ + status: 1, + msg: "已断开连接" + }) + } + }, + medicineOnclose(name: string, id: string, date: string, cb: any) { + const patient = this.patient[name + id + date] + if (patient.medicineWS) { + patient.medicineWS.onclose = cb + } else { + cb({ + status: 1, + msg: "已断开连接" + }) + } + }, + medicineOnerror(name: string, id: string, date: string, cb: any) { + const patient = this.patient[name + id + date] + if (patient.medicineWS) { + patient.medicineWS.onerror = cb + } else { + cb({ + status: 1, + msg: "已断开连接" + }) + } + }, + unsubscribeMedicine(name: string, id: string, date: string) { + const patient: any = this.patient[name + id + date] + if (patient) { + patient.medicineWS.onmessage = undefined + patient.medicineWS.onclose = undefined + patient.medicineWS.onerror = undefined + } + }, + sendMedicine(args: { + name: string, + id: string, + date: string, + flag: string, + medicine: string, + value: string + }, cb: any) { + const patient: any = this.patient[args.name + args.id + args.date] + if (patient) { + const params = { + patientName: args.name, + idNum: args.id, + date: args.date, + flag: args.flag, + medicine: args.medicine, + value: args.value + } + patient.medicineWS.send(JSON.stringify(params)) + cb({ + status: 0 + }) + } else { + cb({ + status: 1, + msg: "已断开连接" + }) + } + }, + disconnectMedicine(name: string, id: string, date: string) { + const patient: any = this.patient[name + id + date] + if (patient && patient.medicineWS) { + this.closeStatus[name + id + date + 'medicineWS'] = true + patient.medicineWS.close() + delete patient['medicineWS'] + delete this.closeStatus[name + id + date + 'medicineWS'] + } + }, + } }) \ No newline at end of file diff --git a/src/utils/request.ts b/src/utils/request.ts index d461504..911565c 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -79,7 +79,7 @@ function handleResponse(response: any) { axiosInstance.interceptors.response.use(handleResponse, error => { const code = error.response.status || 200 - if (code == 424 || code == 401) { + if (code == 424) { ElMessageBox.confirm('令牌状态已过期,请点击重新登录', "系统提示", { confirmButtonText: "确定", cancelButtonText: "取消", diff --git a/src/views/home/index.vue b/src/views/home/index.vue index d52818c..0255e99 100644 --- a/src/views/home/index.vue +++ b/src/views/home/index.vue @@ -12,8 +12,8 @@
-
+
-
+
-
-
+
+
-
+