mirror of
https://gitee.com/xiongmao1988/rax-medical.git
synced 2026-06-12 19:31:52 +08:00
Compare commits
2 Commits
68601dda67
...
003fd7881c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
003fd7881c | ||
|
|
ddc2b28726 |
|
|
@ -67,8 +67,14 @@ export const useRemoteWsStore = defineStore("remoteWs", {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setCurrentTaskIndex(i: number) {
|
setCurrentTaskIndex(i: number) {
|
||||||
this.currentTaskIndex = i
|
// this.currentTaskIndex = i
|
||||||
Session.set("currentTaskIndex", i)
|
// Session.set("currentTaskIndex", i)
|
||||||
|
// 切换前清除旧任务的重连定时器
|
||||||
|
if (this.currentTaskIndex !== -1) {
|
||||||
|
this.clearReconnectTimer(this.currentTaskIndex);
|
||||||
|
}
|
||||||
|
this.currentTaskIndex = i;
|
||||||
|
Session.set("currentTaskIndex", i);
|
||||||
},
|
},
|
||||||
getCurrentTaskIndex() {
|
getCurrentTaskIndex() {
|
||||||
if (Session.get("currentTaskIndex") > -1) {
|
if (Session.get("currentTaskIndex") > -1) {
|
||||||
|
|
@ -215,29 +221,88 @@ export const useRemoteWsStore = defineStore("remoteWs", {
|
||||||
}
|
}
|
||||||
},*/
|
},*/
|
||||||
|
|
||||||
|
// 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]
|
||||||
|
// },
|
||||||
disconnect(name: string, id: string, date: string, index: number) {
|
disconnect(name: string, id: string, date: string, index: number) {
|
||||||
this.disconnectChat(name, id, date, index)
|
this.disconnectChat(name, id, date, index);
|
||||||
this.disconnectVital(name, id, date, index)
|
this.disconnectVital(name, id, date, index);
|
||||||
delete this.patient[name + id + date + index]
|
const patientKey = `${name}${id}${date}${index}`;
|
||||||
|
delete this.patient[patientKey];
|
||||||
|
this.setActiveDisconnect(index, true); // 确保标记主动断开
|
||||||
|
this.clearReconnectTimer(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 + 1) + ",生命体征数据连接成功")
|
||||||
|
// 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']
|
||||||
|
// }
|
||||||
|
// },
|
||||||
createVital(name: string, id: string, date: string, index: number) {
|
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] = {}
|
const patientKey = `${name}${id}${date}${index}`;
|
||||||
|
const patient = this.patient[patientKey] ? this.patient[patientKey] : this.patient[patientKey] = {};
|
||||||
|
// 新增:若已主动断开,直接返回不创建连接
|
||||||
|
if (this.isActiveDisconnect(index)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (patient && !patient['vitalWS']) {
|
if (patient && !patient['vitalWS']) {
|
||||||
patient['vitalWS'] = new WebSocket(vitalUrl)
|
patient['vitalWS'] = new WebSocket(vitalUrl);
|
||||||
patient['vitalWS'].onopen = function () {
|
patient['vitalWS'].onopen = () => {
|
||||||
ElMessage.info("远程查看" + (index + 1) + ",生命体征数据连接成功")
|
if (index === this.currentTaskIndex) {
|
||||||
|
ElMessage.info("远程查看,生命体征数据连接成功");
|
||||||
|
}
|
||||||
patient['vitalWS'].send(JSON.stringify({
|
patient['vitalWS'].send(JSON.stringify({
|
||||||
patientName: name,
|
patientName: name,
|
||||||
idNum: id,
|
idNum: id,
|
||||||
date: date,
|
date: date,
|
||||||
msgType: "msg"
|
msgType: "msg"
|
||||||
}))
|
}));
|
||||||
}
|
this.clearReconnectTimer(index);
|
||||||
|
};
|
||||||
|
|
||||||
patient['vitalWS'].onerror = () => {
|
patient['vitalWS'].onerror = () => {
|
||||||
ElMessage.error("远程管理" + (index + 1) + "生命体征数据出错")
|
if (index === this.currentTaskIndex) {
|
||||||
|
ElMessage.error("远程管理,生命体征数据出错");
|
||||||
}
|
}
|
||||||
delete this.closeStatus[name + id + date + index + 'vitalWS']
|
};
|
||||||
|
|
||||||
|
patient['vitalWS'].onclose = () => {
|
||||||
|
// 新增:若已主动断开,不触发重连
|
||||||
|
if (this.isActiveDisconnect(index)) {
|
||||||
|
delete patient.vitalWS;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (index === this.currentTaskIndex) {
|
||||||
|
ElMessage.warning("远程查看,生命体征连接断开,正在重连...");
|
||||||
|
this.clearReconnectTimer(index);
|
||||||
|
const timerId = window.setTimeout(() => {
|
||||||
|
// 重连前再次检查是否已主动断开
|
||||||
|
if (!this.isActiveDisconnect(index)) {
|
||||||
|
this.createVital(name, id, date, index);
|
||||||
|
}
|
||||||
|
}, 3000);
|
||||||
|
this.setReconnectTimer(index, timerId);
|
||||||
|
}
|
||||||
|
delete patient.vitalWS;
|
||||||
|
};
|
||||||
|
|
||||||
|
delete this.closeStatus[`${patientKey}vitalWS`];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
subscribeVital(name: string, id: string, date: string, index: number, cb: any) {
|
subscribeVital(name: string, id: string, date: string, index: number, cb: any) {
|
||||||
|
|
@ -313,38 +378,108 @@ 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']
|
||||||
|
// }
|
||||||
|
// },
|
||||||
disconnectVital(name: string, id: string, date: string, index: number) {
|
disconnectVital(name: string, id: string, date: string, index: number) {
|
||||||
const patient: any = this.patient[name + id + date + index]
|
const patientKey = `${name}${id}${date}${index}`;
|
||||||
|
const patient: any = this.patient[patientKey];
|
||||||
if (patient && patient.vitalWS) {
|
if (patient && patient.vitalWS) {
|
||||||
this.closeStatus[name + id + date + index + 'vitalWS'] = true
|
this.closeStatus[`${patientKey}vitalWS`] = true;
|
||||||
patient.vitalWS.close()
|
this.setActiveDisconnect(index, true); // 标记为主动断开
|
||||||
delete patient['vitalWS']
|
patient.vitalWS.close();
|
||||||
|
delete patient.vitalWS;
|
||||||
|
this.clearReconnectTimer(index); // 强制清除重连定时器
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
// 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 + 1) + ",通讯连接成功")
|
||||||
|
// patient['chatWS'].send(JSON.stringify({
|
||||||
|
// patientName: name,
|
||||||
|
// idNum: id,
|
||||||
|
// date: date,
|
||||||
|
// msgType: "init"
|
||||||
|
// }))
|
||||||
|
// patient['chatWS'].send(JSON.stringify({
|
||||||
|
// patientName: name,
|
||||||
|
// idNum: id,
|
||||||
|
// date: date,
|
||||||
|
// msgType: "historyChat"
|
||||||
|
// }))
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// patient['chatWS'].onerror = () => {
|
||||||
|
// ElMessage.error("远程查看" + (index + 1) + "通讯出错")
|
||||||
|
// }
|
||||||
|
// delete this.closeStatus[name + id + date + index + 'chatWS']
|
||||||
|
// }
|
||||||
|
// },
|
||||||
createChat(name: string, id: string, date: string, index: number) {
|
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] = {}
|
const patientKey = `${name}${id}${date}${index}`;
|
||||||
|
const patient = this.patient[patientKey] ? this.patient[patientKey] : this.patient[patientKey] = {};
|
||||||
|
// 新增:若已主动断开,直接返回不创建连接
|
||||||
|
if (this.isActiveDisconnect(index)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (patient && !patient['chatWS']) {
|
if (patient && !patient['chatWS']) {
|
||||||
patient['chatWS'] = new WebSocket(chatUrl)
|
patient['chatWS'] = new WebSocket(chatUrl);
|
||||||
patient['chatWS'].onopen = function () {
|
patient['chatWS'].onopen = () => {
|
||||||
ElMessage.info("远程查看" + (index + 1) + ",通讯连接成功")
|
if (index === this.currentTaskIndex) {
|
||||||
|
ElMessage.info("远程查看,通讯连接成功");
|
||||||
|
}
|
||||||
patient['chatWS'].send(JSON.stringify({
|
patient['chatWS'].send(JSON.stringify({
|
||||||
patientName: name,
|
patientName: name,
|
||||||
idNum: id,
|
idNum: id,
|
||||||
date: date,
|
date: date,
|
||||||
msgType: "init"
|
msgType: "init"
|
||||||
}))
|
}));
|
||||||
patient['chatWS'].send(JSON.stringify({
|
patient['chatWS'].send(JSON.stringify({
|
||||||
patientName: name,
|
patientName: name,
|
||||||
idNum: id,
|
idNum: id,
|
||||||
date: date,
|
date: date,
|
||||||
msgType: "historyChat"
|
msgType: "historyChat"
|
||||||
}))
|
}));
|
||||||
}
|
this.clearReconnectTimer(index);
|
||||||
|
};
|
||||||
|
|
||||||
patient['chatWS'].onerror = () => {
|
patient['chatWS'].onerror = () => {
|
||||||
ElMessage.error("远程查看" + (index + 1) + "通讯出错")
|
if (index === this.currentTaskIndex) {
|
||||||
|
ElMessage.error("远程查看,通讯出错");
|
||||||
}
|
}
|
||||||
delete this.closeStatus[name + id + date + index + 'chatWS']
|
};
|
||||||
|
|
||||||
|
patient['chatWS'].onclose = () => {
|
||||||
|
// 新增:若已主动断开,不触发重连
|
||||||
|
if (this.isActiveDisconnect(index)) {
|
||||||
|
delete patient.chatWS;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (index === this.currentTaskIndex) {
|
||||||
|
ElMessage.warning("远程查看,通讯连接断开,正在重连...");
|
||||||
|
this.clearReconnectTimer(index);
|
||||||
|
const timerId = window.setTimeout(() => {
|
||||||
|
// 重连前再次检查是否已主动断开
|
||||||
|
if (!this.isActiveDisconnect(index)) {
|
||||||
|
this.createChat(name, id, date, index);
|
||||||
|
}
|
||||||
|
}, 3000);
|
||||||
|
this.setReconnectTimer(index, timerId);
|
||||||
|
}
|
||||||
|
delete patient.chatWS;
|
||||||
|
};
|
||||||
|
|
||||||
|
delete this.closeStatus[`${patientKey}chatWS`];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
subscribeChat(name: string, id: string, date: string, index: number, cb: any) {
|
subscribeChat(name: string, id: string, date: string, index: number, cb: any) {
|
||||||
|
|
@ -383,12 +518,23 @@ export const useRemoteWsStore = defineStore("remoteWs", {
|
||||||
const patient: any = this.patient[name + id + date + index]
|
const patient: any = this.patient[name + id + date + index]
|
||||||
patient.chatWS.onmessage = 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']
|
||||||
|
// }
|
||||||
|
// },
|
||||||
disconnectChat(name: string, id: string, date: string, index: number) {
|
disconnectChat(name: string, id: string, date: string, index: number) {
|
||||||
const patient: any = this.patient[name + id + date + index]
|
const patientKey = `${name}${id}${date}${index}`;
|
||||||
|
const patient: any = this.patient[patientKey];
|
||||||
if (patient && patient.chatWS) {
|
if (patient && patient.chatWS) {
|
||||||
this.closeStatus[name + id + date + index + 'chatWS'] = true
|
this.closeStatus[`${patientKey}chatWS`] = true;
|
||||||
patient.chatWS.close()
|
this.setActiveDisconnect(index, true); // 标记为主动断开
|
||||||
delete patient['chatWS']
|
patient.chatWS.close();
|
||||||
|
delete patient.chatWS;
|
||||||
|
this.clearReconnectTimer(index); // 强制清除重连定时器
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
sendMedicine(args: {
|
sendMedicine(args: {
|
||||||
|
|
|
||||||
|
|
@ -138,7 +138,8 @@ function subscribeVital() {
|
||||||
function wsClose() {
|
function wsClose() {
|
||||||
remoteWsStore.vitalOnclose(remoteTask.value.patient, remoteTask.value.patientId, remoteTask.value.date, props.index, () => {
|
remoteWsStore.vitalOnclose(remoteTask.value.patient, remoteTask.value.patientId, remoteTask.value.date, props.index, () => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
ElMessage.info('远程查看' + (props.index + 1) + ', 生命体征数据连接断开,正在尝试重连……')
|
// ElMessage.info('远程查看' + (props.index + 1) + ', 生命体征数据连接断开,正在尝试重连……')
|
||||||
|
ElMessage.info('远程查看,生命体征数据连接断开,正在尝试重连……')
|
||||||
initData()
|
initData()
|
||||||
}, 3000)
|
}, 3000)
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -221,7 +221,8 @@ function initData() {
|
||||||
}
|
}
|
||||||
// 创建定时器并保存到store
|
// 创建定时器并保存到store
|
||||||
const timerId = setTimeout(() => {
|
const timerId = setTimeout(() => {
|
||||||
ElMessage.info(`远程查看${currentIndex + 1},生命体征数据连接断开,正在尝试重连……`)
|
// ElMessage.info(`远程查看${currentIndex + 1},生命体征数据连接断开,正在尝试重连……`)
|
||||||
|
ElMessage.info(`远程查看,生命体征数据连接断开,正在尝试重连……`)
|
||||||
remoteWsStore.createVital(
|
remoteWsStore.createVital(
|
||||||
remoteItem.value.patient,
|
remoteItem.value.patient,
|
||||||
remoteItem.value.patientId,
|
remoteItem.value.patientId,
|
||||||
|
|
|
||||||
|
|
@ -376,7 +376,8 @@ const subscribeChat = () => {
|
||||||
messageList.value = msg.history;
|
messageList.value = msg.history;
|
||||||
}
|
}
|
||||||
if (msg.msgType == "destroy") {
|
if (msg.msgType == "destroy") {
|
||||||
ElMessageBox.confirm('远程查看' + (currentIndex + 1) + '已断开与手术室连接', '提示', {
|
// ElMessageBox.confirm('远程查看' + (currentIndex + 1) + '已断开与手术室连接', '提示', {
|
||||||
|
ElMessageBox.confirm('远程查看' + '已断开与手术室连接', '提示', {
|
||||||
confirmButtonText: '确认',
|
confirmButtonText: '确认',
|
||||||
type: 'info'
|
type: 'info'
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
|
|
@ -386,7 +387,8 @@ const subscribeChat = () => {
|
||||||
})
|
})
|
||||||
remoteWsStore.chatOnclose(currentRemote.value.patient, currentRemote.value.patientId, currentRemote.value.date, currentIndex, () => {
|
remoteWsStore.chatOnclose(currentRemote.value.patient, currentRemote.value.patientId, currentRemote.value.date, currentIndex, () => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
ElMessage.info('远程查看' + (currentIndex + 1) + ', 通讯连接断开,正在尝试重连……')
|
// ElMessage.info('远程查看' + (currentIndex + 1) + ', 通讯连接断开,正在尝试重连……')
|
||||||
|
ElMessage.info('远程查看, 通讯连接断开,正在尝试重连……')
|
||||||
subscribeChat()
|
subscribeChat()
|
||||||
}, 3000)
|
}, 3000)
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user