mirror of
https://gitee.com/xiongmao1988/rax-medical.git
synced 2025-08-24 13:04:57 +08:00
远程重连
This commit is contained in:
parent
0f7622a264
commit
375fd80a31
|
@ -35,15 +35,15 @@
|
|||
<template v-else>
|
||||
<el-form-item label="密码" prop="password" label-width="100">
|
||||
<el-input v-model="formData.password" type="password" show-password
|
||||
placeholder="请输入密码"></el-input>
|
||||
placeholder="8~16位字母或数字(区分大小写)"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="新密码" prop="newPassword" label-width="100">
|
||||
<el-input v-model="formData.newPassword" type="password" show-password
|
||||
placeholder="请输入新密码"></el-input>
|
||||
placeholder="8~16位字母或数字(区分大小写)"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="确认密码" prop="confirmPassword" label-width="100">
|
||||
<el-input v-model="formData.confirmPassword" type="password" show-password
|
||||
placeholder="请输入新密码"></el-input>
|
||||
placeholder="确认密码"></el-input>
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-form>
|
||||
|
|
|
@ -20,6 +20,7 @@ export const useRemoteWsStore = defineStore("remoteWs", {
|
|||
"BIS_except": "脑电双频指数异常", "DBP_except": "舒张压异常", "EtCO2_except": "呼气末二氧化碳异常",
|
||||
"HR_except": "心率异常", "SBP_except": "收缩压异常", "ST_except": "ST异常"
|
||||
} as any,
|
||||
closeStatus: {} as any
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
|
@ -92,7 +93,10 @@ export const useRemoteWsStore = defineStore("remoteWs", {
|
|||
setRemoteLog(log: any, i: number) {
|
||||
this.remoteTasks[i].log.push(log)
|
||||
},
|
||||
createConnect(name: string, id: string, date: string, index: number) {
|
||||
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)
|
||||
|
@ -119,7 +123,7 @@ export const useRemoteWsStore = defineStore("remoteWs", {
|
|||
}
|
||||
}
|
||||
|
||||
/* medicineWS.onopen = function () {
|
||||
/!* medicineWS.onopen = function () {
|
||||
medicineWS.send(JSON.stringify({
|
||||
patientName: name,
|
||||
idNum: id,
|
||||
|
@ -133,7 +137,7 @@ export const useRemoteWsStore = defineStore("remoteWs", {
|
|||
|
||||
medicineWS.onerror = () => {
|
||||
ElMessage.error("远程管理" + (index + 1) + "给药出错")
|
||||
}*/
|
||||
}*!/
|
||||
|
||||
chatWS.onopen = function () {
|
||||
chatWS.send(JSON.stringify({
|
||||
|
@ -163,19 +167,34 @@ export const useRemoteWsStore = defineStore("remoteWs", {
|
|||
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()
|
||||
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]
|
||||
if (patient) {
|
||||
patient.vitalWS.onmessage = (e: any) => {
|
||||
if (e && e.data) {
|
||||
const data = JSON.parse(e.data);
|
||||
|
@ -186,21 +205,6 @@ export const useRemoteWsStore = defineStore("remoteWs", {
|
|||
}
|
||||
}
|
||||
}
|
||||
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]
|
||||
|
@ -210,7 +214,6 @@ export const useRemoteWsStore = defineStore("remoteWs", {
|
|||
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) {
|
||||
|
@ -234,10 +237,36 @@ export const useRemoteWsStore = defineStore("remoteWs", {
|
|||
})
|
||||
}
|
||||
},
|
||||
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]
|
||||
if (patient) {
|
||||
patient.chatCB = cb
|
||||
patient.chatWS.onmessage = (e: any) => {
|
||||
if (e && e.data) {
|
||||
const data = JSON.parse(e.data);
|
||||
|
@ -248,12 +277,6 @@ export const useRemoteWsStore = defineStore("remoteWs", {
|
|||
}
|
||||
}
|
||||
}
|
||||
} 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]
|
||||
|
@ -261,9 +284,16 @@ export const useRemoteWsStore = defineStore("remoteWs", {
|
|||
},
|
||||
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;
|
||||
},
|
||||
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,
|
||||
|
|
|
@ -83,15 +83,15 @@
|
|||
<el-form ref="registerFormRef" :model="registerParams" :rules="registerRules" label-width="100">
|
||||
<el-form-item label="用户名" prop="username">
|
||||
<el-input v-model="registerParams.username"
|
||||
placeholder="请输入用户名2~16位字母或数字(区分大小写)"></el-input>
|
||||
placeholder="2~16位字母或数字(区分大小写)"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="密码" prop="password">
|
||||
<el-input v-model="registerParams.password" type="password" show-password
|
||||
placeholder="请输入密码8~16位字母或数字(区分大小写)"></el-input>
|
||||
placeholder="8~16位字母或数字(区分大小写)"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="确认密码" prop="confirmPassword">
|
||||
<el-input v-model="registerParams.confirmPassword" type="password" show-password
|
||||
placeholder="请输入密码8~16位字母或数字(区分大小写)"></el-input>
|
||||
placeholder="确认密码"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="姓名" prop="name">
|
||||
<el-input v-model="registerParams.name" placeholder="请输入姓名"></el-input>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="用户名" prop="username">
|
||||
<el-input v-model="formData.username" placeholder="请输入用户名2~16位字母或数字(区分大小写)"
|
||||
<el-input v-model="formData.username" placeholder="2~16位字母或数字(区分大小写)"
|
||||
:disabled="type === 'edit'"></el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
@ -46,13 +46,13 @@
|
|||
<el-row v-if="type != 'edit'">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="密码" prop="password">
|
||||
<el-input v-model="formData.password" placeholder="请输入密码8~16位字母或数字(区分大小写)"
|
||||
<el-input v-model="formData.password" placeholder="8~16位字母或数字(区分大小写)"
|
||||
:disabled="type === 'edit'" type="password" show-password></el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="确认密码" prop="confirmPassword">
|
||||
<el-input v-model="formData.confirmPassword" placeholder="请输入密码8~16位字母或数字(区分大小写)"
|
||||
<el-input v-model="formData.confirmPassword" placeholder="确认密码"
|
||||
:disabled="type === 'edit'" type="password" show-password></el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
|
|
@ -61,6 +61,7 @@
|
|||
<script lang='ts' setup>
|
||||
import {onMounted, onUnmounted, ref} from 'vue'
|
||||
import {useRemoteWsStore} from "@/stores/remote-ws-store";
|
||||
import {ElMessage} from "element-plus";
|
||||
|
||||
const props = withDefaults(defineProps<{ index: number }>(), {
|
||||
index: () => 0
|
||||
|
@ -69,7 +70,6 @@ const emit = defineEmits(['addLogAfter'])
|
|||
const remoteWsStore = useRemoteWsStore();
|
||||
const remoteTask = ref(remoteWsStore.remoteTasks[props.index]);
|
||||
const patientInfo = ref({} as any)
|
||||
let reconnectTime = 0
|
||||
let currentException: any = {}
|
||||
|
||||
onMounted(() => {
|
||||
|
@ -83,6 +83,7 @@ onUnmounted(() => {
|
|||
})
|
||||
|
||||
function initData() {
|
||||
remoteWsStore.createVital(remoteTask.value.patient, remoteTask.value.patientId, remoteTask.value.date, props.index)
|
||||
subscribeVital()
|
||||
wsClose()
|
||||
}
|
||||
|
@ -103,13 +104,12 @@ 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)
|
||||
const status = remoteWsStore.getCloseStatus()
|
||||
if (remoteTask.value.patient && !status[remoteTask.value.patient + remoteTask.value.patientId + remoteTask.value.date + props.index + 'vitalWS']) {
|
||||
setTimeout(() => {
|
||||
subscribeVital()
|
||||
wsClose()
|
||||
ElMessage.info('远程控制' + props.index + ', 生命体征数据连接断开,正在尝试重连……')
|
||||
initData()
|
||||
}, 3000)
|
||||
reconnectTime++
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
@ -119,6 +119,7 @@
|
|||
<script lang='ts' setup>
|
||||
import {onMounted, onUnmounted, ref} from 'vue'
|
||||
import {useRemoteWsStore} from "@/stores/remote-ws-store";
|
||||
import {ElMessage} from "element-plus";
|
||||
|
||||
const emit = defineEmits(['addLogAfter', 'breakRemote'])
|
||||
const mediaMini800 = ref(false)
|
||||
|
@ -163,7 +164,17 @@ function initData() {
|
|||
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)
|
||||
remoteWsStore.createVital(remoteItem.value.patient, remoteItem.value.patientId, remoteItem.value.date, currentIndex)
|
||||
remoteWsStore.vitalOnclose(remoteItem.value.patient, remoteItem.value.patientId, remoteItem.value.date, currentIndex, () => {
|
||||
const status = remoteWsStore.getCloseStatus()
|
||||
if (remoteItem.value.patient && !status[remoteItem.value.patient + remoteItem.value.patientId + remoteItem.value.date + currentIndex + 'vitalWS']) {
|
||||
setTimeout(() => {
|
||||
ElMessage.info('远程控制' + currentIndex + ', 生命体征数据连接断开,正在尝试重连……')
|
||||
remoteWsStore.createVital(remoteItem.value.patient, remoteItem.value.patientId, remoteItem.value.date, currentIndex)
|
||||
initData()
|
||||
}, 3000)
|
||||
}
|
||||
})
|
||||
getData()
|
||||
}
|
||||
}
|
||||
|
@ -183,7 +194,6 @@ function getData() {
|
|||
}
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -220,6 +220,7 @@ const medicineCustom: any[] = [
|
|||
const remoteWsStore = useRemoteWsStore()
|
||||
const currentRemote = ref()
|
||||
const userInfoStore = useUserStore()
|
||||
const currentIndex = remoteWsStore.getCurrentTaskIndex()
|
||||
|
||||
const chartDom1 = ref(),
|
||||
chartDom2 = ref(),
|
||||
|
@ -266,35 +267,15 @@ onMounted(() => {
|
|||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
const index = remoteWsStore.getCurrentTaskIndex()
|
||||
remoteWsStore.unsubscribeChat(currentRemote.value.patient, currentRemote.value.patientId, currentRemote.value.date, index);
|
||||
remoteWsStore.unsubscribeChat(currentRemote.value.patient, currentRemote.value.patientId, currentRemote.value.date, currentIndex);
|
||||
// remoteWsStore.unsubscribeMedicine(currentRemote.value.patient, currentRemote.value.patientId, currentRemote.value.date, index);
|
||||
remoteWsStore.unsubscribeVital(currentRemote.value.patient, currentRemote.value.patientId, currentRemote.value.date, index);
|
||||
remoteWsStore.unsubscribeVital(currentRemote.value.patient, currentRemote.value.patientId, currentRemote.value.date, currentIndex);
|
||||
remoteWsStore.disconnectChat(currentRemote.value.patient, currentRemote.value.patientId, currentRemote.value.date, currentIndex)
|
||||
})
|
||||
|
||||
function subscribeWS() {
|
||||
const index = remoteWsStore.getCurrentTaskIndex()
|
||||
remoteWsStore.subscribeVital(currentRemote.value.patient, currentRemote.value.patientId, currentRemote.value.date, index,
|
||||
function (res: any) {
|
||||
const data = JSON.parse(res.data);
|
||||
chartDom1.value.updateChartData(data.vitalSignsList);
|
||||
chartDom2.value.updateChartData(data.vitalSignsList);
|
||||
chartDom3.value.updateChartData(data.vitalSignsList);
|
||||
// chartDom4.value.updateChartData(data.vitalSignsList);
|
||||
// updateMedicineTable(data.aiMedicineList[0], data.docMedicineList[0]);
|
||||
updateMedicineTable(data.aiMedicineList[0], undefined);
|
||||
})
|
||||
|
||||
remoteWsStore.subscribeChat(currentRemote.value.patient, currentRemote.value.patientId, currentRemote.value.date, index,
|
||||
function (res: any) {
|
||||
const chatObj = JSON.parse(res.data);
|
||||
if (chatObj.history) {
|
||||
mssageList.value = chatObj.history;
|
||||
} else {
|
||||
mssageList.value.push(JSON.parse(res.data));
|
||||
}
|
||||
})
|
||||
|
||||
subscribeVital()
|
||||
subscribeChat()
|
||||
/*remoteWsStore.subscribeMedicine(currentRemote.value.patient, currentRemote.value.patientId, currentRemote.value.date, index,
|
||||
function (res: any) {
|
||||
const data = JSON.parse(res.data);
|
||||
|
@ -310,6 +291,51 @@ function subscribeWS() {
|
|||
|
||||
}
|
||||
|
||||
const subscribeVital = () => {
|
||||
remoteWsStore.createVital(currentRemote.value.patient, currentRemote.value.patientId, currentRemote.value.date, currentIndex)
|
||||
remoteWsStore.subscribeVital(currentRemote.value.patient, currentRemote.value.patientId, currentRemote.value.date, currentIndex,
|
||||
function (res: any) {
|
||||
const data = JSON.parse(res.data);
|
||||
chartDom1.value.updateChartData(data.vitalSignsList);
|
||||
chartDom2.value.updateChartData(data.vitalSignsList);
|
||||
chartDom3.value.updateChartData(data.vitalSignsList);
|
||||
// chartDom4.value.updateChartData(data.vitalSignsList);
|
||||
// updateMedicineTable(data.aiMedicineList[0], data.docMedicineList[0]);
|
||||
updateMedicineTable(data.aiMedicineList[0], undefined);
|
||||
})
|
||||
remoteWsStore.vitalOnclose(currentRemote.value.patient, currentRemote.value.patientId, currentRemote.value.date, currentIndex, () => {
|
||||
const status = remoteWsStore.getCloseStatus()
|
||||
if (currentRemote.value.patient && !status[currentRemote.value.patient + currentRemote.value.patientId + currentRemote.value.date + currentIndex + 'vitalWS']) {
|
||||
setTimeout(() => {
|
||||
ElMessage.info('远程控制' + currentIndex + ', 生命体征数据连接断开,正在尝试重连……')
|
||||
subscribeVital()
|
||||
}, 3000)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const subscribeChat = () => {
|
||||
remoteWsStore.createChat(currentRemote.value.patient, currentRemote.value.patientId, currentRemote.value.date, currentIndex)
|
||||
remoteWsStore.subscribeChat(currentRemote.value.patient, currentRemote.value.patientId, currentRemote.value.date, currentIndex,
|
||||
function (res: any) {
|
||||
const chatObj = JSON.parse(res.data);
|
||||
if (chatObj.history) {
|
||||
mssageList.value = chatObj.history;
|
||||
} else {
|
||||
mssageList.value.push(JSON.parse(res.data));
|
||||
}
|
||||
})
|
||||
remoteWsStore.chatOnclose(currentRemote.value.patient, currentRemote.value.patientId, currentRemote.value.date, currentIndex, () => {
|
||||
const status = remoteWsStore.getCloseStatus()
|
||||
if (!status[currentRemote.value.patient + currentRemote.value.patientId + currentRemote.value.date + currentIndex + 'chatWS']) {
|
||||
setTimeout(() => {
|
||||
ElMessage.info('远程控制' + currentIndex + ', 通讯连接断开,正在尝试重连……')
|
||||
subscribeChat()
|
||||
}, 3000)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function initData() {
|
||||
lungAlarm.value = false;
|
||||
heartAlarm.value = false;
|
||||
|
|
Loading…
Reference in New Issue
Block a user