From fa9fc60fc6691c92c8696dae2ff3415e2e8fffd9 Mon Sep 17 00:00:00 2001
From: zhangchen <1652267879@qq.com>
Date: 星期六, 26 七月 2025 11:39:04 +0800
Subject: [PATCH] ID1625-修改头部字体大小
---
src/store/bedsideAuxiliaryScreen.ts | 73 ++++++++++++++++++++++++++++++++++--
1 files changed, 68 insertions(+), 5 deletions(-)
diff --git a/src/store/bedsideAuxiliaryScreen.ts b/src/store/bedsideAuxiliaryScreen.ts
index 4f07588..b93d6cc 100644
--- a/src/store/bedsideAuxiliaryScreen.ts
+++ b/src/store/bedsideAuxiliaryScreen.ts
@@ -1,8 +1,10 @@
import { defineStore } from "pinia";
import { ref } from "vue";
+import dayjs from "dayjs";
import cache from "../utils/cache";
import { EventSourcePolyfill } from "event-source-polyfill";
-import type { BedsideAuxiliaryScreen } from "./type/bedsideAuxiliaryScreen.type";
+import type { BedsideAuxiliaryScreen, SseMsgData } from "./type/bedsideAuxiliaryScreen.type";
+import type { Task } from "./type/task.type";
import {
defaultDeviceData,
defaultconsumablesCollection,
@@ -19,6 +21,9 @@
/** 设备信息数据 */
const deviceData = ref<BedsideAuxiliaryScreen>(defaultDeviceData());
+ /** 任务列表 */
+ const taskData = ref<Task[]>([]);
+
/**
* 设置设备编号
* @param code
@@ -26,6 +31,47 @@
const setDeviceCode = (code: string) => {
deviceCode.value = code;
cache.set("devcieCode", code);
+ };
+
+ /**
+ * 清除设备信息
+ */
+ const clearDevice = () => {
+ deviceData.value = defaultDeviceData();
+ };
+
+ /**
+ * 追加定时任务
+ * @param taskItem
+ */
+ const pushTask = (taskItem: Task) => {
+ taskData.value.push(taskItem);
+ };
+
+ /**
+ * 是否将当前任务设置为已过期
+ * @param i
+ */
+ // const deleteTask = (i: number) => {
+ // const task = taskData.value[i];
+ // if (task) {
+ // // 二次判断,判断任务时间是否早于或等于当前时间
+ // const taskTime = dayjs(task.taskDate).second(0).millisecond(0);
+ // const now = dayjs().second(0).millisecond(0); // 秒和毫秒都去掉
+ // if (!taskTime.isAfter(now)) {
+ // taskData.value[i].overdue = true
+ // }
+ // }
+ // };
+
+ /** 设置当前定时任务 */
+ const setSyncTask = (taskItem: Task) => {
+ taskData.value = [taskItem];
+ };
+
+ /** 清除当前定时任务 */
+ const clearTask = () => {
+ taskData.value = [];
};
// SSE 相关状态
@@ -64,7 +110,7 @@
if (retryCount < maxRetryCount) {
const delay = baseRetryDelay * Math.pow(2, retryCount); // 指数退避
retryCount++;
- console.log(`[SSE] 第${retryCount}次重连,延迟${delay}ms`);
+ console.log(`[SSE] 第${retryCount}次重连,延迟${baseRetryDelay}ms`);
ElMessage.warning(
`链接服务失败, 第${retryCount}次重连,请耐心等待重连。。`
);
@@ -85,13 +131,24 @@
let end = msg.length - 1;
if (beng !== -1 && end !== -1 && dif !== -1) {
const datax = msg.slice(beng, end + 1);
- const dataBody = JSON.parse(datax);
+ const dataBody = JSON.parse(datax) as SseMsgData;
console.log("dataBody: ", dataBody);
// 倒计时提示文本
- if (dataBody.倒计时?.提示文本) {
+ if (dataBody.倒计时?.提醒文本) {
+ const taskTime = dayjs(dataBody.倒计时?.当前服务器时间).add(dataBody.倒计时?.设定提醒倒计时, 'minute')
+ setSyncTask({
+ deviceCode: dataBody.IOT信息.设备唯一编号,
+ recordCode: dataBody.透析状态?.透析单编号,
+ taskDate: taskTime.format('YYYY-MM-DD HH:mm'),
+ taskName: dataBody.倒计时?.提醒文本,
+ overdue: false,
+ countdown: dataBody.倒计时?.设定提醒倒计时
+ })
+ } else {
+ clearTask();
}
- deviceData.value = formatDeviceData(dataBody);
+ deviceData.value = formatDeviceData(deviceData.value, dataBody);
}
};
};
@@ -104,6 +161,8 @@
source.value.close();
source.value = null;
isConnected.value = false;
+ clearDevice();
+ clearTask();
console.log("[SSE] 连接已关闭");
}
};
@@ -125,6 +184,10 @@
connect,
close,
refresh,
+ taskData,
+ pushTask,
+ setSyncTask,
+ clearTask,
};
}
);
--
Gitblit v1.8.0