From aa69fcab6c564969e4fc16e0829a774e4c979422 Mon Sep 17 00:00:00 2001 From: yy <11@11.com> Date: Thu, 30 May 2024 14:57:25 +0800 Subject: [PATCH] =?UTF-8?q?=E9=94=99=E8=AF=AF=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/log-manage.ts | 2 +- src/components/SliderVerify/index.vue | 1040 +++++++++--------- src/components/Websocket/index.vue | 159 --- src/stores/remote-ws-store.ts | 530 ++++----- src/utils/other.ts | 6 + src/views/remote-manage/chart/chart-ecg.vue | 8 +- src/views/remote-manage/chart/chart-line.vue | 10 +- src/views/remote-manage/part/remote-part.vue | 706 ++++++------ vite.config.ts | 2 +- 9 files changed, 1158 insertions(+), 1305 deletions(-) delete mode 100644 src/components/Websocket/index.vue 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/SliderVerify/index.vue b/src/components/SliderVerify/index.vue index 95eb848..e8dc572 100644 --- a/src/components/SliderVerify/index.vue +++ b/src/components/SliderVerify/index.vue @@ -1,20 +1,21 @@ 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 8ace883..43540b6 100644 --- a/src/stores/remote-ws-store.ts +++ b/src/stores/remote-ws-store.ts @@ -1,278 +1,278 @@ -import { defineStore } from "pinia"; -import { Session } from "@/utils/storage"; -import { ElMessage } from "element-plus"; +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: -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, - } - }, - 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 - })) - } + 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, + } + }, + 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 + })) + } - vitalWS.onclose = () => { - ElMessage.info("远程管理" + (index + 1) + "已断开") - } + vitalWS.onclose = () => { + ElMessage.info("远程管理" + (index + 1) + "已断开") + } - vitalWS.onerror = () => { - ElMessage.error("远程管理" + (index + 1) + "出错") - } + vitalWS.onerror = () => { + ElMessage.error("远程管理" + (index + 1) + "出错") + } - medicineWS.onopen = function () { - medicineWS.send(JSON.stringify({ - patientName: name, - idNum: id, - date: date - })) - } + medicineWS.onopen = function () { + medicineWS.send(JSON.stringify({ + patientName: name, + idNum: id, + date: date + })) + } - medicineWS.onclose = () => { - ElMessage.info("远程管理" + (index + 1) + "给药已断开") - } + medicineWS.onclose = () => { + ElMessage.info("远程管理" + (index + 1) + "给药已断开") + } - medicineWS.onerror = () => { - ElMessage.error("远程管理" + (index + 1) + "给药出错") - } + medicineWS.onerror = () => { + ElMessage.error("远程管理" + (index + 1) + "给药出错") + } - chatWS.onopen = function () { - chatWS.send(JSON.stringify({ - patientName: name, - idNum: id, - date: date - })) - } + chatWS.onopen = function () { + chatWS.send(JSON.stringify({ + patientName: name, + idNum: id, + date: date + })) + } - chatWS.onclose = () => { - ElMessage.info("远程管理" + (index + 1) + "通讯已断开") - } + chatWS.onclose = () => { + ElMessage.info("远程管理" + (index + 1) + "通讯已断开") + } - chatWS.onerror = () => { - ElMessage.error("远程管理" + (index + 1) + "通讯出错") - } + chatWS.onerror = () => { + ElMessage.error("远程管理" + (index + 1) + "通讯出错") + } - 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 = cb - patient.vitalCB = cb - } else { - this.createConnect(name, id, date, index) - this.patient[name + id + date + index].vitalWS.onmessage = cb - 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 - } - 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 = cb - } 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 - } - 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 = cb - } 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; - } - } + 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 = cb + patient.vitalCB = cb + } else { + this.createConnect(name, id, date, index) + this.patient[name + id + date + index].vitalWS.onmessage = cb + 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 + } + 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 = cb + } 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 + } + 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 = cb + } 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/utils/other.ts b/src/utils/other.ts index b4ccede..8f5e811 100644 --- a/src/utils/other.ts +++ b/src/utils/other.ts @@ -68,4 +68,10 @@ function rgbToHex(r: number, g: number, b: number) { function componentToHex(c: number) { const hex = c.toString(16); return hex.length == 1 ? "0" + hex : hex; +} + + +// 获取assets静态资源 +export const getAssetsFile = (url: string) => { + return new URL(`../assets/${url}`, import.meta.url).href } \ No newline at end of file diff --git a/src/views/remote-manage/chart/chart-ecg.vue b/src/views/remote-manage/chart/chart-ecg.vue index 9484df1..0612552 100644 --- a/src/views/remote-manage/chart/chart-ecg.vue +++ b/src/views/remote-manage/chart/chart-ecg.vue @@ -11,7 +11,7 @@ import {dateFormater} from '@/utils/date-util'; import {useRemoteWsStore} from "@/stores/remote-ws-store"; const chartDom = ref(); -const props = withDefaults(defineProps<{ names?: string[] }>(), { +const props = withDefaults(defineProps<{ names?: any }>(), { names: ['CH1', 'CH2'] }); defineExpose({ @@ -67,7 +67,7 @@ function chartInit() { formatter: (params: any) => { let str = params[0].axisValue; str += `
`; - props.names.forEach((item, index) => { + props.names.forEach((item: any, index: any) => { str += params[index].marker; str += params[index].seriesName + ' '; str += `${params[index].value} HZ`; @@ -124,8 +124,8 @@ function getXData() { } function getSeries() { - props.names.forEach((name, index) => { - const serie = { + props.names.forEach((name: any, index: any) => { + const serie: any = { name, type: 'line', symbol: 'none', diff --git a/src/views/remote-manage/chart/chart-line.vue b/src/views/remote-manage/chart/chart-line.vue index 20ff8af..c4fe8b5 100644 --- a/src/views/remote-manage/chart/chart-line.vue +++ b/src/views/remote-manage/chart/chart-line.vue @@ -12,7 +12,7 @@ import {useRemoteWsStore} from "@/stores/remote-ws-store"; const chartDom = ref(); const props = withDefaults(defineProps<{ - names: string[] + names: any }>(), { names: ['BIS', 'HR'] }); @@ -76,7 +76,7 @@ function chartInit() { let str = ''; str += params[0].axisValue; str += '
'; - props.names.forEach((item, index) => { + props.names.forEach((item: any, index: any) => { str += params[index].marker; str += params[index].seriesName + ' '; switch (item) { @@ -121,7 +121,7 @@ function chartInit() { lineHeight: 30, }, formatter: (params: string) => { - const index = props.names.findIndex((item) => item === params); + const index = props.names.findIndex((item: any) => item === params); let str = params + ' '; switch (params) { case 'BIS': @@ -186,7 +186,7 @@ function chartInit() { } function getSeries() { - props.names.forEach(name => { + props.names.forEach((name: any) => { const serie = { name, type: 'line', @@ -208,7 +208,7 @@ function getXData() { } function getLegendData() { - props.names.forEach((name, index) => { + props.names.forEach((name: any, index: any) => { legendData.push({ name, textStyle: {color: colors[index]}, diff --git a/src/views/remote-manage/part/remote-part.vue b/src/views/remote-manage/part/remote-part.vue index 697fc22..7eb600c 100644 --- a/src/views/remote-manage/part/remote-part.vue +++ b/src/views/remote-manage/part/remote-part.vue @@ -1,124 +1,124 @@ diff --git a/vite.config.ts b/vite.config.ts index e314f4a..462cf5e 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -6,7 +6,7 @@ import vue from '@vitejs/plugin-vue' // https://vitejs.dev/config/ export default defineConfig({ - base: '/medical/', + // base: '/medical/', plugins: [vue()], resolve: { alias: {