diff --git a/src/stores/remote-ws-store.ts b/src/stores/remote-ws-store.ts index 763be5b..02307e2 100644 --- a/src/stores/remote-ws-store.ts +++ b/src/stores/remote-ws-store.ts @@ -11,7 +11,7 @@ export const useRemoteWsStore = defineStore("remoteWs", { patient: {} as any, remoteTasks: [] as any, remoteTasksCap: 10, - currentTaskIndex: 0, + currentTaskIndex: -1, varMedicine: ["丙泊酚", "舒芬太尼", "瑞芬太尼", "顺阿曲库胺"], fixedMedicine: ["尼卡地平", "艾司洛尔", "麻黄素", "阿托品"], exceptionType: ["BIS_except", "DBP_except", "EtCO2_except", "HR_except", "SBP_except", "ST_except"], @@ -89,8 +89,8 @@ export const useRemoteWsStore = defineStore("remoteWs", { setRemoteLog(log: any, i: number) { this.remoteTasks[i].log.push(log) }, - createConnect(name: string, id: string, date: string) { - if (!this.patient[name + id + date]) { + 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) @@ -115,42 +115,42 @@ export const useRemoteWsStore = defineStore("remoteWs", { date: date })) } - this.patient[name + id + date] = { + this.patient[name + id + date + index] = { vitalWS, medicineWS, chatWS } } }, - disconnect(name: string, id: string, date: string) { - const patient: any = this.patient[name + id + date] + 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] + delete this.patient[name + id + date + index] } }, - subscribeVital(name: string, id: string, date: string, cb: any) { - const patient: any = this.patient[name + id + date] + 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) - this.patient[name + id + date].vitalWS.onmessage = cb - this.patient[name + id + date].vitalCB = cb + this.createConnect(name, id, date, index) + this.patient[name + id + date + index].vitalWS.onmessage = cb + this.patient[name + id + date + index].vitalCB = cb } }, - unsubscribeVital(name: string, id: string, date: string) { - const patient: any = this.patient[name + id + date] + 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, cb: any) { - const patient: any = this.patient[name + id + date] + 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, @@ -169,8 +169,8 @@ export const useRemoteWsStore = defineStore("remoteWs", { }) } }, - subscribeChat(name: string, id: string, date: string, cb: any) { - const patient: any = this.patient[name + id + date] + 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 @@ -181,8 +181,8 @@ export const useRemoteWsStore = defineStore("remoteWs", { }) } }, - unsubscribeChat(name: string, id: string, date: string) { - const patient: any = this.patient[name + id + date] + 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; }, @@ -193,8 +193,8 @@ export const useRemoteWsStore = defineStore("remoteWs", { flag: string, medicine: string, value: string - }, cb: any) { - const patient: any = this.patient[args.name + args.id + args.date] + }, index: number, cb: any) { + const patient: any = this.patient[args.name + args.id + args.date + index] if (patient) { const params = { patientName: args.name, @@ -215,8 +215,8 @@ export const useRemoteWsStore = defineStore("remoteWs", { }) } }, - subscribeMedicine(name: string, id: string, date: string, cb: any) { - const patient = this.patient[name + id + date] + 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 @@ -227,8 +227,8 @@ export const useRemoteWsStore = defineStore("remoteWs", { }) } }, - unsubscribeMedicine(name: string, id: string, date: string) { - const patient: any = this.patient[name + id + date] + 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; } diff --git a/src/views/remote-manage/part/remote-dialog.vue b/src/views/remote-manage/part/remote-dialog.vue index 774f04d..659caf5 100644 --- a/src/views/remote-manage/part/remote-dialog.vue +++ b/src/views/remote-manage/part/remote-dialog.vue @@ -50,7 +50,8 @@ defineExpose({ }) function open(i: number) { - patientInfo.value = remoteWsStore.remoteTasks[i]; + remoteWsStore.setCurrentTaskIndex(i) + patientInfo.value = remoteWsStore.getRemoteTask()[remoteWsStore.getCurrentTaskIndex()]; patientInfo.value.date = new Date(); dialogVisible.value = true; } @@ -96,7 +97,7 @@ const unsubscribeLastTask = () => { const lastTaskIndex = remoteWsStore.currentTaskIndex; const lastTask: any = remoteWsStore.remoteTasks[lastTaskIndex]; if (lastTask) { - remoteWsStore.unsubscribeVital(lastTask.patient, lastTask.patientId, lastTask.date); + remoteWsStore.unsubscribeVital(lastTask.patient, lastTask.patientId, lastTask.date, lastTaskIndex); } } diff --git a/src/views/remote-manage/part/remote-item-part.vue b/src/views/remote-manage/part/remote-item-part.vue index e3b4785..165404c 100644 --- a/src/views/remote-manage/part/remote-item-part.vue +++ b/src/views/remote-manage/part/remote-item-part.vue @@ -77,7 +77,7 @@ onMounted(() => { } }) onUnmounted(() => { - remoteWsStore.unsubscribeVital(remoteTask.value.patient, remoteTask.value.patientId, remoteTask.value.date); + remoteWsStore.unsubscribeVital(remoteTask.value.patient, remoteTask.value.patientId, remoteTask.value.date, props.index); }) function initData() { @@ -85,7 +85,7 @@ function initData() { } function subscribeVital() { - remoteWsStore.subscribeVital(remoteTask.value.patient, remoteTask.value.patientId, remoteTask.value.date, (res: any) => { + remoteWsStore.subscribeVital(remoteTask.value.patient, remoteTask.value.patientId, remoteTask.value.date, props.index, (res: any) => { const data = JSON.parse(res.data); if (data.vitalSignsList && data.vitalSignsList.length > 0) { Object.assign(patientInfo.value, data.vitalSignsList[0]); diff --git a/src/views/remote-manage/part/remote-part.vue b/src/views/remote-manage/part/remote-part.vue index fae37ed..fe80c30 100644 --- a/src/views/remote-manage/part/remote-part.vue +++ b/src/views/remote-manage/part/remote-part.vue @@ -19,7 +19,7 @@
手术时间 {{ - remoteItem.date + remoteItem?.date }}
@@ -62,11 +62,11 @@
病人名称 - {{ remoteItem.patient }} + {{ remoteItem?.patient }}
住院号 - {{ remoteItem.patientId }} + {{ remoteItem?.patientId }}
@@ -90,7 +90,7 @@
手术时间 {{ - remoteItem.date + remoteItem?.date }}
@@ -123,6 +123,7 @@ import { useRemoteWsStore } from "@/stores/remote-ws-store"; const emit = defineEmits(['addLogAfter', 'breakRemote']) const mediaMini800 = ref(false) const remoteItem = ref({} as any) +let currentIndex = -1; const patientInfo = ref({} as any) const remoteWsStore = useRemoteWsStore() @@ -139,43 +140,47 @@ onMounted(() => { }) onUnmounted(() => { - remoteWsStore.unsubscribeVital(remoteItem.value.patient, remoteItem.value.patientId, remoteItem.value.date); + remoteWsStore.unsubscribeVital(remoteItem.value.patient, remoteItem.value.patientId, remoteItem.value.date, currentIndex); }) function showData(i: any) { - const lastTaskIndex = remoteWsStore.currentTaskIndex; - const lastTask: any = remoteWsStore.remoteTasks[lastTaskIndex]; + const lastTaskIndex = remoteWsStore.getCurrentTaskIndex(); + const lastTask: any = remoteWsStore.getRemoteTask()[lastTaskIndex]; if (lastTask) { - remoteWsStore.unsubscribeVital(lastTask.patient, lastTask.patientId, lastTask.date); + remoteWsStore.unsubscribeVital(lastTask.patient, lastTask.patientId, lastTask.date, lastTaskIndex); } - remoteWsStore.currentTaskIndex = i - remoteItem.value = remoteWsStore.remoteTasks[remoteWsStore.currentTaskIndex] + remoteWsStore.setCurrentTaskIndex(i) + currentIndex = remoteWsStore.getCurrentTaskIndex() + remoteItem.value = remoteWsStore.getRemoteTask()[currentIndex] getData() } function initData() { - const remoteTasks = remoteWsStore.getRemoteTask(); - remoteItem.value = remoteTasks[remoteWsStore.getCurrentTaskIndex()] - if (remoteItem.value) { - remoteWsStore.createConnect(remoteItem.value.patient, remoteItem.value.patientId, remoteItem.value.date) + const remoteTasks = remoteWsStore.getRemoteTask() + currentIndex = remoteWsStore.getCurrentTaskIndex() + remoteItem.value = remoteTasks[currentIndex] + if (remoteItem.value && remoteItem.value.patient) { + remoteWsStore.createConnect(remoteItem.value.patient, remoteItem.value.patientId, remoteItem.value.date, currentIndex) getData() } } function getData() { - remoteWsStore.unsubscribeVital(remoteItem.value.patient, remoteItem.value.patientId, remoteItem.value.date); - remoteWsStore.subscribeVital(remoteItem.value.patient, remoteItem.value.patientId, remoteItem.value.date, (res: any) => { - if (res && res.data) { - const data = JSON.parse(res.data); - if (data.vitalSignsList && data.vitalSignsList.length > 0) { - Object.assign(patientInfo.value, data.vitalSignsList[0]); - patientInfo.value.state = (patientInfo.value.BIS_except || patientInfo.value.SBP_except || - patientInfo.value.DBP_except || patientInfo.value.HR_except); - setLog(patientInfo.value) - emit('addLogAfter') + if (currentIndex > -1 && remoteItem.value.patient) { + remoteWsStore.unsubscribeVital(remoteItem.value.patient, remoteItem.value.patientId, remoteItem.value.date, currentIndex); + remoteWsStore.subscribeVital(remoteItem.value.patient, remoteItem.value.patientId, remoteItem.value.date, currentIndex, (res: any) => { + if (res && res.data) { + const data = JSON.parse(res.data); + if (data.vitalSignsList && data.vitalSignsList.length > 0) { + Object.assign(patientInfo.value, data.vitalSignsList[0]); + patientInfo.value.state = (patientInfo.value.BIS_except || patientInfo.value.SBP_except || + patientInfo.value.DBP_except || patientInfo.value.HR_except); + setLog(patientInfo.value) + emit('addLogAfter') + } } - } - }) + }) + } } function setLog(data: any) { @@ -187,14 +192,15 @@ function setLog(data: any) { taskName: remoteItem.value.taskName, time: new Date(), type: "exception" - }, remoteWsStore.currentTaskIndex); + }, currentIndex); } }) } const breakRemote = () => { - remoteWsStore.disconnect(remoteItem.value.patient, remoteItem.value.patientId, remoteItem.value.date) - remoteWsStore.resetRemoteTask(remoteWsStore.currentTaskIndex) + remoteWsStore.getRemoteTask()[currentIndex] + remoteWsStore.disconnect(remoteItem.value.patient, remoteItem.value.patientId, remoteItem.value.date, currentIndex) + remoteWsStore.resetRemoteTask(currentIndex) if (remoteWsStore.getActiveRemoteTask()) { showData(remoteWsStore.getActiveRemoteTask()) } diff --git a/src/views/remote-manage/remote-control.vue b/src/views/remote-manage/remote-control.vue index 7fada1b..55398fe 100644 --- a/src/views/remote-manage/remote-control.vue +++ b/src/views/remote-manage/remote-control.vue @@ -92,8 +92,8 @@
- - + + + + --> - + -
- - - + + + - +