mirror of
https://gitee.com/xiongmao1988/rax-medical.git
synced 2025-08-24 04:54:58 +08:00
11111
This commit is contained in:
parent
2881c819b6
commit
269ee1c120
|
@ -1,5 +1,5 @@
|
|||
import {defineStore} from "pinia";
|
||||
import {Session} from "@/utils/storage";
|
||||
import { defineStore } from "pinia";
|
||||
import { Local, Session } from "@/utils/storage";
|
||||
|
||||
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()
|
||||
|
@ -22,7 +22,29 @@ export const useRemoteWsStore = defineStore("remoteWs", {
|
|||
}
|
||||
},
|
||||
actions: {
|
||||
setCurrentTaskIndex(i: number) {
|
||||
this.currentTaskIndex = i
|
||||
Local.set("currentTaskIndex", i)
|
||||
},
|
||||
getCurrentTaskIndex() {
|
||||
if (Local.get("currentTaskIndex")) {
|
||||
this.currentTaskIndex = Local.get("currentTaskIndex")
|
||||
}
|
||||
return this.currentTaskIndex
|
||||
},
|
||||
setRemoteTask() {
|
||||
Local.set("remoteTasks", this.remoteTasks)
|
||||
},
|
||||
getRemoteTask() {
|
||||
if (Local.get("remoteTasks")) {
|
||||
this.remoteTasks = Local.get("remoteTasks")
|
||||
}
|
||||
return this.remoteTasks
|
||||
},
|
||||
initRemoteTask() {
|
||||
if (Local.get("remoteTasks")) {
|
||||
this.remoteTasks = Local.get("remoteTasks")
|
||||
}
|
||||
if (this.remoteTasks.length <= 0) {
|
||||
for (let i = 0; i < 10; i++) {
|
||||
this.remoteTasks.push({
|
||||
|
@ -57,6 +79,7 @@ export const useRemoteWsStore = defineStore("remoteWs", {
|
|||
index: i,
|
||||
message: []
|
||||
})
|
||||
Local.set("remoteTasks", this.remoteTasks)
|
||||
},
|
||||
getActiveRemoteTask() {
|
||||
for (let i = 0; i < this.remoteTasks.length; i++) {
|
||||
|
@ -114,10 +137,9 @@ export const useRemoteWsStore = defineStore("remoteWs", {
|
|||
patient.vitalWS.onmessage = cb
|
||||
patient.vitalCB = cb
|
||||
} else {
|
||||
cb({
|
||||
status: 1,
|
||||
msg: "已断开连接"
|
||||
})
|
||||
this.createConnect(name, id, date)
|
||||
this.patient[name + id + date].vitalWS.onmessage = cb
|
||||
this.patient[name + id + date].vitalCB = cb
|
||||
}
|
||||
},
|
||||
unsubscribeVital(name: string, id: string, date: string) {
|
||||
|
|
|
@ -8,23 +8,18 @@ import Cookies from 'js-cookie';
|
|||
* @method clear 移除全部永久缓存
|
||||
*/
|
||||
export const Local = {
|
||||
// 查看 v2.4.3版本更新日志
|
||||
setKey(key: string) {
|
||||
// @ts-ignore
|
||||
return `${__NEXT_NAME__}:${key}`;
|
||||
},
|
||||
// 设置永久缓存
|
||||
set<T>(key: string, val: T) {
|
||||
window.localStorage.setItem(Local.setKey(key), JSON.stringify(val));
|
||||
window.localStorage.setItem(key, JSON.stringify(val));
|
||||
},
|
||||
// 获取永久缓存
|
||||
get(key: string) {
|
||||
let json = <string>window.localStorage.getItem(Local.setKey(key));
|
||||
let json = <string>window.localStorage.getItem(key);
|
||||
return JSON.parse(json);
|
||||
},
|
||||
// 移除永久缓存
|
||||
remove(key: string) {
|
||||
window.localStorage.removeItem(Local.setKey(key));
|
||||
window.localStorage.removeItem(key);
|
||||
},
|
||||
// 移除全部永久缓存
|
||||
clear() {
|
||||
|
|
|
@ -66,7 +66,8 @@ const confirmRemote = () => {
|
|||
patientInfo.value.taskName = '远程控制' + (patientInfo.value.index + 1)
|
||||
patientInfo.value.date = dateFormater("yyyyMMdd", patientInfo.value.date)
|
||||
unsubscribeLastTask();
|
||||
remoteWsStore.$patch({currentTaskIndex: patientInfo.value.index})
|
||||
remoteWsStore.setCurrentTaskIndex(patientInfo.value.index)
|
||||
remoteWsStore.setRemoteTask()
|
||||
remoteWsStore.setRemoteLog({
|
||||
time: new Date(),
|
||||
taskName: patientInfo.value.taskName,
|
||||
|
|
|
@ -117,7 +117,7 @@
|
|||
</template>
|
||||
|
||||
<script lang='ts' setup>
|
||||
import {onUnmounted, ref} from 'vue'
|
||||
import {onMounted, onUnmounted, ref} from 'vue'
|
||||
import {useRemoteWsStore} from "@/stores/remote-ws-store";
|
||||
|
||||
const emit = defineEmits(['addLogAfter', 'breakRemote'])
|
||||
|
@ -134,6 +134,10 @@ window.addEventListener('resize', () => {
|
|||
mediaMini800.value = Boolean(window.innerWidth < 801)
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
initData();
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
remoteWsStore.unsubscribeVital(remoteItem.value.patient, remoteItem.value.patientId, remoteItem.value.date);
|
||||
})
|
||||
|
@ -150,7 +154,8 @@ function showData(i: any) {
|
|||
}
|
||||
|
||||
function initData() {
|
||||
remoteItem.value = remoteWsStore.remoteTasks[remoteWsStore.currentTaskIndex]
|
||||
const remoteTasks = remoteWsStore.getRemoteTask();
|
||||
remoteItem.value = remoteTasks[remoteWsStore.currentTaskIndex]
|
||||
remoteWsStore.createConnect(remoteItem.value.patient, remoteItem.value.patientId, remoteItem.value.date)
|
||||
getData()
|
||||
}
|
||||
|
|
|
@ -222,7 +222,7 @@ const medicineCustom: any[] = [
|
|||
{ name: '罗库溴铵', plus: 0.1, total: 10 }
|
||||
]
|
||||
const remoteWsStore = useRemoteWsStore()
|
||||
const currentRemote = ref(remoteWsStore.remoteTasks[remoteWsStore.currentTaskIndex])
|
||||
const currentRemote = ref(remoteWsStore.getRemoteTask()[remoteWsStore.getCurrentTaskIndex()])
|
||||
const userInfo = useUserStore()
|
||||
|
||||
const chartDom1 = ref(),
|
||||
|
|
|
@ -39,7 +39,7 @@ const remoteTask = ref([] as any);
|
|||
const remoteWsStore = useRemoteWsStore();
|
||||
|
||||
onMounted(() => {
|
||||
remoteTask.value = remoteWsStore.remoteTasks;
|
||||
remoteTask.value = remoteWsStore.getRemoteTask();
|
||||
})
|
||||
|
||||
const openRemote = (params: any) => {
|
||||
|
|
Loading…
Reference in New Issue
Block a user