断开提示

This commit is contained in:
yy 2024-05-29 17:09:56 +08:00
parent 66dab4b687
commit 78aaffe4e1
4 changed files with 35 additions and 3 deletions

View File

@ -1,5 +1,6 @@
import { defineStore } from "pinia"; import { defineStore } from "pinia";
import { Session } from "@/utils/storage"; import { Session } from "@/utils/storage";
import { ElMessage } from "element-plus";
const vitalUrl = "ws://localhost:5173/socket.io/admin/rax/vitalSignsMedicine?token=" + Session.getToken() const vitalUrl = "ws://localhost:5173/socket.io/admin/rax/vitalSignsMedicine?token=" + Session.getToken()
const medicineUrl = "ws://localhost:5173/socket.io/admin/rax/addMedicine?token=" + Session.getToken() const medicineUrl = "ws://localhost:5173/socket.io/admin/rax/addMedicine?token=" + Session.getToken()
@ -27,7 +28,7 @@ export const useRemoteWsStore = defineStore("remoteWs", {
Session.set("currentTaskIndex", i) Session.set("currentTaskIndex", i)
}, },
getCurrentTaskIndex() { getCurrentTaskIndex() {
if (Session.get("currentTaskIndex")) { if (Session.get("currentTaskIndex") > -1) {
this.currentTaskIndex = Session.get("currentTaskIndex") this.currentTaskIndex = Session.get("currentTaskIndex")
} }
return this.currentTaskIndex return this.currentTaskIndex
@ -84,7 +85,7 @@ export const useRemoteWsStore = defineStore("remoteWs", {
getActiveRemoteTask() { getActiveRemoteTask() {
let index = 0; let index = 0;
for (let i = 0; i < this.remoteTasks.length; i++) { for (let i = 0; i < this.remoteTasks.length; i++) {
if (this.remoteTasks[i].isRemote)index = i if (this.remoteTasks[i].isRemote) index = i
} }
return index return index
}, },
@ -103,6 +104,15 @@ export const useRemoteWsStore = defineStore("remoteWs", {
date: date date: date
})) }))
} }
vitalWS.onclose = () => {
ElMessage.info("远程管理" + (index + 1) + "已断开")
}
vitalWS.onerror = () => {
ElMessage.error("远程管理" + (index + 1) + "出错")
}
medicineWS.onopen = function () { medicineWS.onopen = function () {
medicineWS.send(JSON.stringify({ medicineWS.send(JSON.stringify({
patientName: name, patientName: name,
@ -110,6 +120,15 @@ export const useRemoteWsStore = defineStore("remoteWs", {
date: date date: date
})) }))
} }
medicineWS.onclose = () => {
ElMessage.info("远程管理" + (index + 1) + "给药已断开")
}
medicineWS.onerror = () => {
ElMessage.error("远程管理" + (index + 1) + "给药出错")
}
chatWS.onopen = function () { chatWS.onopen = function () {
chatWS.send(JSON.stringify({ chatWS.send(JSON.stringify({
patientName: name, patientName: name,
@ -117,6 +136,15 @@ export const useRemoteWsStore = defineStore("remoteWs", {
date: date date: date
})) }))
} }
chatWS.onclose = () => {
ElMessage.info("远程管理" + (index + 1) + "通讯已断开")
}
chatWS.onerror = () => {
ElMessage.error("远程管理" + (index + 1) + "通讯出错")
}
this.patient[name + id + date + index] = { this.patient[name + id + date + index] = {
vitalWS, vitalWS,
medicineWS, medicineWS,

View File

@ -95,6 +95,7 @@ function subscribeVital() {
emit('addLogAfter', props.index) emit('addLogAfter', props.index)
} }
}) })
} }
function setLog(data: any, index: number) { function setLog(data: any, index: number) {

View File

@ -180,6 +180,7 @@ function getData() {
} }
} }
}) })
} }
} }

View File

@ -218,7 +218,7 @@ const medicineCustom: any[] = [
{ name: '罗库溴铵', plus: 0.1, total: 10 } { name: '罗库溴铵', plus: 0.1, total: 10 }
] ]
const remoteWsStore = useRemoteWsStore() const remoteWsStore = useRemoteWsStore()
const currentRemote = ref(remoteWsStore.getRemoteTask()[remoteWsStore.getCurrentTaskIndex()]) const currentRemote = ref()
const userInfo = useUserStore() const userInfo = useUserStore()
const chartDom1 = ref(), const chartDom1 = ref(),
@ -254,6 +254,7 @@ let currentDocMedicine: any;
const medicineSpeedTemp: any = {}; const medicineSpeedTemp: any = {};
onMounted(() => { onMounted(() => {
currentRemote.value = remoteWsStore.getRemoteTask()[remoteWsStore.getCurrentTaskIndex()]
if (!currentRemote.value.isRemote) { if (!currentRemote.value.isRemote) {
router.replace('/remote-manage/remote-manage'); router.replace('/remote-manage/remote-manage');
return; return;
@ -300,6 +301,7 @@ function subscribeWS() {
ElMessage.error(data.msg) ElMessage.error(data.msg)
} }
}) })
} }
function initData() { function initData() {