From 375fd80a3145ff56330ff7b976ad77aa4fb4539e Mon Sep 17 00:00:00 2001 From: yy <11@11.com> Date: Wed, 5 Jun 2024 14:09:09 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=9C=E7=A8=8B=E9=87=8D=E8=BF=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/user-info.vue | 6 +- src/stores/remote-ws-store.ts | 664 +++++++++--------- src/views/login/login.vue | 6 +- .../permissions-manage/form/doctor-form.vue | 6 +- .../remote-manage/part/remote-item-part.vue | 12 +- src/views/remote-manage/part/remote-part.vue | 14 +- src/views/remote-manage/remote-control.vue | 76 +- 7 files changed, 425 insertions(+), 359 deletions(-) diff --git a/src/components/user-info.vue b/src/components/user-info.vue index 7f82ef7..72ad1c7 100644 --- a/src/components/user-info.vue +++ b/src/components/user-info.vue @@ -35,15 +35,15 @@ diff --git a/src/stores/remote-ws-store.ts b/src/stores/remote-ws-store.ts index 890d970..76a824d 100644 --- a/src/stores/remote-ws-store.ts +++ b/src/stores/remote-ws-store.ts @@ -7,322 +7,352 @@ const medicineUrl = "ws://" + window.location.host + "/socket.io/admin/rax/addMe 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: -1, - 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, + state: () => { + return { + patient: {} as any, + remoteTasks: [] as any, + remoteTasksCap: 10, + currentTaskIndex: -1, + 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, + closeStatus: {} as any + } + }, + actions: { + setCurrentTaskIndex(i: number) { + this.currentTaskIndex = i + Session.set("currentTaskIndex", i) + }, + getCurrentTaskIndex() { + if (Session.get("currentTaskIndex") > -1) { + this.currentTaskIndex = Session.get("currentTaskIndex") + } + return this.currentTaskIndex + }, + setRemoteTask() { + Session.set("remoteTasks", this.remoteTasks) + }, + getRemoteTask() { + if (Session.get("remoteTasks")) { + this.remoteTasks = Session.get("remoteTasks") + } + return this.remoteTasks + }, + initRemoteTask() { + if (Session.get("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) + }, + getCloseStatus() { + return this.closeStatus + }, + /*createConnect(name: string, id: string, date: string, index: number) { + if (!this.patient[name + id + date + index]) { + 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, + msgType: "msg" + })) + } + + vitalWS.onerror = () => { + ElMessage.error("远程管理" + (index + 1) + "出错") + } + + vitalWS.onmessage = (e: any) => { + if (e && e.data) { + const data = JSON.parse(e.data); + if (data.msgType == "heartbeat") { + vitalWS.send(JSON.stringify({msgType: "heartbeat"})) + } + } + } + + /!* medicineWS.onopen = function () { + medicineWS.send(JSON.stringify({ + patientName: name, + idNum: id, + date: date + })) + } + + medicineWS.onclose = () => { + ElMessage.info("远程管理" + (index + 1) + "给药已断开") + } + + medicineWS.onerror = () => { + ElMessage.error("远程管理" + (index + 1) + "给药出错") + }*!/ + + chatWS.onopen = function () { + chatWS.send(JSON.stringify({ + patientName: name, + idNum: id, + date: date, + msgType: "msg" + })) + } + + chatWS.onerror = () => { + ElMessage.error("远程管理" + (index + 1) + "通讯出错") + } + + chatWS.onmessage = (e: any) => { + if (e && e.data) { + const data = JSON.parse(e.data); + if (data.msgType == "heartbeat") { + chatWS.send(JSON.stringify({msgType: "heartbeat"})) + } + } + } + + this.patient[name + id + date + index] = { + vitalWS, + // medicineWS, + chatWS + } + } + },*/ + disconnect(name: string, id: string, date: string, index: number) { + this.disconnectChat(name, id, date, index) + this.disconnectVital(name, id, date, index) + delete this.patient[name + id + date + index] + }, + createVital(name: string, id: string, date: string, index: number) { + const patient = this.patient[name + id + date + index] ? this.patient[name + id + date + index] : this.patient[name + id + date + index] = {} + if (patient && !patient['vitalWS']) { + patient['vitalWS'] = new WebSocket(vitalUrl) + patient['vitalWS'].onopen = function () { + ElMessage.info("远程控制" + index + ",生命体征数据连接成功") + patient['vitalWS'].send(JSON.stringify({ + patientName: name, + idNum: id, + date: date, + msgType: "msg" + })) + } + + patient['vitalWS'].onerror = () => { + ElMessage.error("远程管理" + (index + 1) + "出错") + } + delete this.closeStatus[name + id + date + index + 'vitalWS'] + } + }, + subscribeVital(name: string, id: string, date: string, index: number, cb: any) { + const patient: any = this.patient[name + id + date + index] + 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"})) + } + } + } + }, + vitalOnclose(name: string, id: string, date: string, index: number, cb: any) { + const patient: any = this.patient[name + id + date + index] + patient.vitalWS.onclose = cb + }, + unsubscribeVital(name: string, id: string, date: string, index: number) { + const patient: any = this.patient[name + id + date + index] + if (patient && patient.vitalWS) { + patient.vitalWS.onmessage = undefined; + } + }, + sendMsg(name: string, id: string, date: string, msg: string, index: number, cb: any) { + const patient: any = this.patient[name + id + date + index] + if (patient) { + const params = { + patientName: name, + idNum: id, + date: date, + msg, + msgType: "msg" + } + patient.chatWS.send(JSON.stringify(params)) + cb({ + status: 0 + }) + } else { + cb({ + status: 1, + msg: "已断开连接" + }) + } + }, + disconnectVital(name: string, id: string, date: string, index: number) { + const patient: any = this.patient[name + id + date + index] + if (patient && patient.vitalWS) { + this.closeStatus[name + id + date + index + 'vitalWS'] = true + patient.vitalWS.close() + delete patient['vitalWS'] + } + }, + createChat(name: string, id: string, date: string, index: number) { + const patient = this.patient[name + id + date + index] ? this.patient[name + id + date + index] : this.patient[name + id + date + index] = {} + if (patient && !patient['chatWS']) { + patient['chatWS'] = new WebSocket(chatUrl) + patient['chatWS'].onopen = function () { + ElMessage.info("远程控制" + index + ",通讯连接成功") + patient['chatWS'].send(JSON.stringify({ + patientName: name, + idNum: id, + date: date, + msgType: "msg" + })) + } + + patient['chatWS'].onerror = () => { + ElMessage.error("远程管理" + (index + 1) + "出错") + } + delete this.closeStatus[name + id + date + index + 'chatWS'] + } + }, + subscribeChat(name: string, id: string, date: string, index: number, cb: any) { + const patient: any = this.patient[name + id + date + index] + 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"})) + } + } + } + }, + chatOnclose(name: string, id: string, date: string, index: number, cb: any) { + const patient: any = this.patient[name + id + date + index] + patient.chatWS.onclose = cb + }, + unsubscribeChat(name: string, id: string, date: string, index: number) { + const patient: any = this.patient[name + id + date + index] + patient.chatWS.onmessage = undefined; + }, + disconnectChat(name: string, id: string, date: string, index: number) { + const patient: any = this.patient[name + id + date + index] + if (patient && patient.chatWS) { + this.closeStatus[name + id + date + index + 'chatWS'] = true + patient.chatWS.close() + delete patient['chatWS'] + } + }, + sendMedicine(args: { + name: string, + id: string, + date: string, + flag: string, + medicine: string, + value: string + }, index: number, cb: any) { + const patient: any = this.patient[args.name + args.id + args.date + index] + if (patient) { + const params = { + patientName: args.name, + idNum: args.id, + date: args.date, + flag: args.flag, + medicine: args.medicine, + value: args.value, + msgType: "msg" + } + patient.medicineWS.send(JSON.stringify(params)) + cb({ + status: 0 + }) + } else { + cb({ + status: 1, + msg: "已断开连接" + }) + } + }, + subscribeMedicine(name: string, id: string, date: string, index: number, cb: any) { + const patient = this.patient[name + id + date + index] + if (patient) { + patient.medicineCB = cb + 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, index: number, cb: any) { + const patient: any = this.patient[name + id + date + index] + patient.medicineWS.onclose = cb + }, + unsubscribeMedicine(name: string, id: string, date: string, index: number) { + const patient: any = this.patient[name + id + date + index] + patient.medicineCB = undefined; + patient.medicineWS.onmessage = undefined; + } } - }, - actions: { - setCurrentTaskIndex(i: number) { - this.currentTaskIndex = i - Session.set("currentTaskIndex", i) - }, - getCurrentTaskIndex() { - if (Session.get("currentTaskIndex") > -1) { - this.currentTaskIndex = Session.get("currentTaskIndex") - } - return this.currentTaskIndex - }, - setRemoteTask() { - Session.set("remoteTasks", this.remoteTasks) - }, - getRemoteTask() { - if (Session.get("remoteTasks")) { - this.remoteTasks = Session.get("remoteTasks") - } - return this.remoteTasks - }, - initRemoteTask() { - if (Session.get("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) - }, - createConnect(name: string, id: string, date: string, index: number) { - if (!this.patient[name + id + date + index]) { - 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, - msgType: "msg" - })) - } - - vitalWS.onerror = () => { - ElMessage.error("远程管理" + (index + 1) + "出错") - } - - vitalWS.onmessage = (e: any) => { - if (e && e.data) { - const data = JSON.parse(e.data); - if (data.msgType == "heartbeat") { - vitalWS.send(JSON.stringify({msgType: "heartbeat"})) - } - } - } - -/* medicineWS.onopen = function () { - medicineWS.send(JSON.stringify({ - patientName: name, - idNum: id, - date: date - })) - } - - medicineWS.onclose = () => { - ElMessage.info("远程管理" + (index + 1) + "给药已断开") - } - - medicineWS.onerror = () => { - ElMessage.error("远程管理" + (index + 1) + "给药出错") - }*/ - - chatWS.onopen = function () { - chatWS.send(JSON.stringify({ - patientName: name, - idNum: id, - date: date, - msgType: "msg" - })) - } - - chatWS.onerror = () => { - ElMessage.error("远程管理" + (index + 1) + "通讯出错") - } - - chatWS.onmessage = (e: any) => { - if (e && e.data) { - const data = JSON.parse(e.data); - if (data.msgType == "heartbeat") { - chatWS.send(JSON.stringify({msgType: "heartbeat"})) - } - } - } - - this.patient[name + id + date + index] = { - vitalWS, - // medicineWS, - chatWS - } - } - }, - disconnect(name: string, id: string, date: string, index: number) { - const patient: any = this.patient[name + id + date + index] - if (patient) { - patient.vitalWS.close() - // patient.medicineWS.close() - patient.chatWS.close() - delete this.patient[name + id + date + index] - } - }, - subscribeVital(name: string, id: string, date: string, index: number, cb: any) { - const patient: any = this.patient[name + id + date + index] - if (patient) { - 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"})) - } - } - } - patient.vitalCB = cb - } else { - this.createConnect(name, id, date, index) - this.patient[name + id + date + index].vitalWS.onmessage = (e: any) => { - if (e && e.data) { - const data = JSON.parse(e.data); - if (data.msgType == "msg") { - cb(e) - } else { - this.patient[name + id + date + index].vitalWS.send(JSON.stringify({msgType: "heartbeat"})) - } - } - } - this.patient[name + id + date + index].vitalCB = cb - } - }, - vitalOnclose(name: string, id: string, date: string, index: number, cb: any) { - const patient: any = this.patient[name + id + date + index] - patient.vitalWS.onclose = cb - }, - unsubscribeVital(name: string, id: string, date: string, index: number) { - const patient: any = this.patient[name + id + date + index] - if (patient && patient.vitalWS) { - patient.vitalWS.onmessage = undefined; - patient.vitalCB = undefined; - } - }, - sendMsg(name: string, id: string, date: string, msg: string, index: number, cb: any) { - const patient: any = this.patient[name + id + date + index] - if (patient) { - const params = { - patientName: name, - idNum: id, - date: date, - msg, - msgType: "msg" - } - patient.chatWS.send(JSON.stringify(params)) - cb({ - status: 0 - }) - } else { - cb({ - status: 1, - msg: "已断开连接" - }) - } - }, - subscribeChat(name: string, id: string, date: string, index: number, cb: any) { - const patient: any = this.patient[name + id + date + index] - if (patient) { - patient.chatCB = cb - 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, index: number, cb: any) { - const patient: any = this.patient[name + id + date + index] - patient.chatWS.onclose = cb - }, - unsubscribeChat(name: string, id: string, date: string, index: number) { - const patient: any = this.patient[name + id + date + index] - patient.chatCB = undefined; - patient.chatWS.onmessage = undefined; - }, - sendMedicine(args: { - name: string, - id: string, - date: string, - flag: string, - medicine: string, - value: string - }, index: number, cb: any) { - const patient: any = this.patient[args.name + args.id + args.date + index] - if (patient) { - const params = { - patientName: args.name, - idNum: args.id, - date: args.date, - flag: args.flag, - medicine: args.medicine, - value: args.value, - msgType: "msg" - } - patient.medicineWS.send(JSON.stringify(params)) - cb({ - status: 0 - }) - } else { - cb({ - status: 1, - msg: "已断开连接" - }) - } - }, - subscribeMedicine(name: string, id: string, date: string, index: number, cb: any) { - const patient = this.patient[name + id + date + index] - if (patient) { - patient.medicineCB = cb - 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, index: number, cb: any) { - const patient: any = this.patient[name + id + date + index] - patient.medicineWS.onclose = cb - }, - unsubscribeMedicine(name: string, id: string, date: string, index: number) { - const patient: any = this.patient[name + id + date + index] - patient.medicineCB = undefined; - patient.medicineWS.onmessage = undefined; - } - } }) \ No newline at end of file diff --git a/src/views/login/login.vue b/src/views/login/login.vue index 8f5ff38..5bc384d 100644 --- a/src/views/login/login.vue +++ b/src/views/login/login.vue @@ -83,15 +83,15 @@ + placeholder="2~16位字母或数字(区分大小写)"> + placeholder="8~16位字母或数字(区分大小写)"> + placeholder="确认密码"> diff --git a/src/views/permissions-manage/form/doctor-form.vue b/src/views/permissions-manage/form/doctor-form.vue index 6ef3ecc..e568ba0 100644 --- a/src/views/permissions-manage/form/doctor-form.vue +++ b/src/views/permissions-manage/form/doctor-form.vue @@ -3,7 +3,7 @@ - @@ -46,13 +46,13 @@ - - diff --git a/src/views/remote-manage/part/remote-item-part.vue b/src/views/remote-manage/part/remote-item-part.vue index 698b614..5291a35 100644 --- a/src/views/remote-manage/part/remote-item-part.vue +++ b/src/views/remote-manage/part/remote-item-part.vue @@ -61,6 +61,7 @@