diff --git a/src/stores/remote-ws-store.ts b/src/stores/remote-ws-store.ts index fe9dc93..8ace883 100644 --- a/src/stores/remote-ws-store.ts +++ b/src/stores/remote-ws-store.ts @@ -172,6 +172,10 @@ export const useRemoteWsStore = defineStore("remoteWs", { 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) { @@ -211,6 +215,10 @@ export const useRemoteWsStore = defineStore("remoteWs", { }) } }, + 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; @@ -257,6 +265,10 @@ export const useRemoteWsStore = defineStore("remoteWs", { }) } }, + 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; diff --git a/src/views/remote-manage/part/remote-item-part.vue b/src/views/remote-manage/part/remote-item-part.vue index fe471ed..8480587 100644 --- a/src/views/remote-manage/part/remote-item-part.vue +++ b/src/views/remote-manage/part/remote-item-part.vue @@ -69,6 +69,7 @@ const emit = defineEmits(['addLogAfter']) const remoteWsStore = useRemoteWsStore(); const remoteTask = ref(remoteWsStore.remoteTasks[props.index]); const patientInfo = ref({} as any) +let reconnectTime = 0 onMounted(() => { // 连接成功执行查询 @@ -81,7 +82,8 @@ onUnmounted(() => { }) function initData() { - subscribeVital(); + subscribeVital() + wsClose() } function subscribeVital() { @@ -98,6 +100,19 @@ function subscribeVital() { } +function wsClose() { + remoteWsStore.vitalOnclose(remoteTask.value.patient, remoteTask.value.patientId, remoteTask.value.date, props.index, () => { + if (reconnectTime < 3) { + remoteWsStore.createConnect(remoteTask.value.patient, remoteTask.value.patientId, remoteTask.value.date, props.index) + subscribeVital() + wsClose() + } else { + reconnectTime = 0 + } + }) + +} + function setLog(data: any, index: number) { remoteWsStore.exceptionType.forEach((item: any) => { if (data[item]) { diff --git a/src/views/remote-manage/part/remote-part.vue b/src/views/remote-manage/part/remote-part.vue index 09deb11..fd15062 100644 --- a/src/views/remote-manage/part/remote-part.vue +++ b/src/views/remote-manage/part/remote-part.vue @@ -166,7 +166,7 @@ function initData() { } function getData() { - if (currentIndex > -1 && remoteItem.value.patient) { + 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) {