From 6ecaed01cf576560a31ae960d0cdf1473e03c6b8 Mon Sep 17 00:00:00 2001
From: zhangchen <1652267879@qq.com>
Date: 星期一, 11 八月 2025 15:40:26 +0800
Subject: [PATCH] ID1975-自动更新流程zancun
---
src/store/bedsideAuxiliaryScreen.ts | 43 ++++++++++++++++++++++---------------------
1 files changed, 22 insertions(+), 21 deletions(-)
diff --git a/src/store/bedsideAuxiliaryScreen.ts b/src/store/bedsideAuxiliaryScreen.ts
index b93d6cc..fbcd79c 100644
--- a/src/store/bedsideAuxiliaryScreen.ts
+++ b/src/store/bedsideAuxiliaryScreen.ts
@@ -1,7 +1,6 @@
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, SseMsgData } from "./type/bedsideAuxiliaryScreen.type";
import type { Task } from "./type/task.type";
@@ -11,12 +10,16 @@
formatDeviceData,
} from "./type/bedsideAuxiliaryScreen.type";
import { ElMessage } from "element-plus/es";
+import { Local } from "@/utils/storage";
export const useBedsideAuxiliaryScreenStore = defineStore(
"bedsideAuxiliaryScreen",
() => {
/** 设备编号 */
- const deviceCode = ref<string>(cache.get("devcieCode") || "");
+ const deviceCode = ref<string>(Local.get("devcieCode") || "");
+
+ /** 副屏版本号 */
+ const version = ref<string>(Local.get("version") || "0.0.0");
/** 设备信息数据 */
const deviceData = ref<BedsideAuxiliaryScreen>(defaultDeviceData());
@@ -24,13 +27,19 @@
/** 任务列表 */
const taskData = ref<Task[]>([]);
+ /** 设置副屏版本号 */
+ const setVersion = (val: string) => {
+ version.value = val;
+ Local.set("version", val);
+ }
+
/**
* 设置设备编号
* @param code
*/
const setDeviceCode = (code: string) => {
deviceCode.value = code;
- cache.set("devcieCode", code);
+ Local.set("devcieCode", code);
};
/**
@@ -47,22 +56,6 @@
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) => {
@@ -134,14 +127,19 @@
const dataBody = JSON.parse(datax) as SseMsgData;
console.log("dataBody: ", dataBody);
// 倒计时提示文本
- if (dataBody.倒计时?.提醒文本) {
- const taskTime = dayjs(dataBody.倒计时?.当前服务器时间).add(dataBody.倒计时?.设定提醒倒计时, 'minute')
+ if (dataBody.倒计时?.提醒文本 && Number(dataBody.倒计时?.设定提醒倒计时 > 0)) {
+ const serverTimeRaw = dataBody.倒计时?.当前服务器时间;
+ const reminderMinutes = Number(dataBody.倒计时?.设定提醒倒计时 ?? 0);
+ const serverTimeFormatted = serverTimeRaw.replace(' ', 'T');
+
+ const taskTime = dayjs(serverTimeFormatted).add(reminderMinutes, 'second');
setSyncTask({
deviceCode: dataBody.IOT信息.设备唯一编号,
recordCode: dataBody.透析状态?.透析单编号,
taskDate: taskTime.format('YYYY-MM-DD HH:mm'),
taskName: dataBody.倒计时?.提醒文本,
overdue: false,
+ sync: true,
countdown: dataBody.倒计时?.设定提醒倒计时
})
} else {
@@ -149,6 +147,7 @@
}
deviceData.value = formatDeviceData(deviceData.value, dataBody);
+ setDeviceCode(dataBody.服务端版本号);
}
};
};
@@ -175,6 +174,7 @@
};
return {
+ version,
deviceCode,
deviceData,
setDeviceCode,
@@ -188,6 +188,7 @@
pushTask,
setSyncTask,
clearTask,
+ setVersion,
};
}
);
--
Gitblit v1.8.0