Compare commits

..

No commits in common. "003fd7881c44704648733aca202ea3a19d057c8b" and "68601dda6741bbaa0d461ddf56cbbb81c994be21" have entirely different histories.

4 changed files with 36 additions and 186 deletions

View File

@ -67,14 +67,8 @@ 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) {
@ -221,88 +215,29 @@ 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)
const patientKey = `${name}${id}${date}${index}`; delete this.patient[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 patientKey = `${name}${id}${date}${index}`; const patient = this.patient[name + id + date + index] ? this.patient[name + id + date + index] : this.patient[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 = () => { patient['vitalWS'].onopen = function () {
if (index === this.currentTaskIndex) { ElMessage.info("远程查看" + (index + 1) + ",生命体征数据连接成功")
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 = () => {
if (index === this.currentTaskIndex) { ElMessage.error("远程管理" + (index + 1) + "生命体征数据出错")
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) {
@ -378,108 +313,38 @@ 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 patientKey = `${name}${id}${date}${index}`; const patient: any = this.patient[name + id + date + index]
const patient: any = this.patient[patientKey];
if (patient && patient.vitalWS) { if (patient && patient.vitalWS) {
this.closeStatus[`${patientKey}vitalWS`] = true; this.closeStatus[name + id + date + index + 'vitalWS'] = true
this.setActiveDisconnect(index, true); // 标记为主动断开 patient.vitalWS.close()
patient.vitalWS.close(); delete patient['vitalWS']
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 patientKey = `${name}${id}${date}${index}`; const patient = this.patient[name + id + date + index] ? this.patient[name + id + date + index] : this.patient[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 = () => { patient['chatWS'].onopen = function () {
if (index === this.currentTaskIndex) { ElMessage.info("远程查看" + (index + 1) + ",通讯连接成功")
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 = () => {
if (index === this.currentTaskIndex) { ElMessage.error("远程查看" + (index + 1) + "通讯出错")
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) {
@ -518,23 +383,12 @@ 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 patientKey = `${name}${id}${date}${index}`; const patient: any = this.patient[name + id + date + index]
const patient: any = this.patient[patientKey];
if (patient && patient.chatWS) { if (patient && patient.chatWS) {
this.closeStatus[`${patientKey}chatWS`] = true; this.closeStatus[name + id + date + index + 'chatWS'] = true
this.setActiveDisconnect(index, true); // 标记为主动断开 patient.chatWS.close()
patient.chatWS.close(); delete patient['chatWS']
delete patient.chatWS;
this.clearReconnectTimer(index); // 强制清除重连定时器
} }
}, },
sendMedicine(args: { sendMedicine(args: {

View File

@ -138,8 +138,7 @@ 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)
}) })

View File

@ -221,8 +221,7 @@ 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,

View File

@ -376,8 +376,7 @@ 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(() => {
@ -387,8 +386,7 @@ 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)
}) })