From e023de9fa3fcfc8c6e62470a4688c1e549062f6f Mon Sep 17 00:00:00 2001
From: "1747191978@qq.com" <1942943850@qq.com>
Date: Wed, 19 Mar 2025 10:23:48 +0800
Subject: [PATCH] =?UTF-8?q?=E8=AE=A1=E7=AE=97=E8=AE=A1=E7=AE=97=E7=9D=A1?=
=?UTF-8?q?=E7=9C=A0=E6=95=88=E7=8E=87?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
acupuncture-前台/src/views/screening/h5.vue | 59 +++++++++++++++------
1 file changed, 43 insertions(+), 16 deletions(-)
diff --git a/acupuncture-前台/src/views/screening/h5.vue b/acupuncture-前台/src/views/screening/h5.vue
index 6280b3ee..a9a1a19d 100644
--- a/acupuncture-前台/src/views/screening/h5.vue
+++ b/acupuncture-前台/src/views/screening/h5.vue
@@ -101,7 +101,7 @@
-
+
疾病风险选择
@@ -426,10 +436,11 @@ export default {
"SCWJ-BMI": "",
"SCWJ-JL": "",
"SCWJ-ZLFS": [],
- "SCWJ-SCSJ": "",
- "SCWJ-RSSJ": "",
- "SCWJ-SXSJ": "",
- "SCWJ-SMXL": "",
+ "SCWJ-SCSJ": "22:00",
+ "SCWJ-RSSJ": "22:30",
+ "SCWJ-SXSJ": "06:30",
+ "SCWJ-QCSJ": "07:00",
+ "SCWJ-SMXL": "", // 睡眠效率
"SCWJ-XBS": [],
"SCWJ-XBS-QT": "",
// "SCWJ-NAME": "测试患者2",
@@ -536,22 +547,26 @@ export default {
console.log("this.tenantId", this.tenantId);
localStorage.setItem("tenantId", this.tenantId);
this.getQueryHospitalNoToken(); // 组织id获取组织名称
+ this.calculateSleepTime(); //计算睡眠效率
},
methods: {
// 计算睡眠效率
// 上床睡觉时间、入睡时间、睡醒时间、起床时间,自动计算睡眠效率(睡眠时间/在床上时间)
- // 睡眠时间 = 入睡时间 - 起床时间
- // 在床上时间 = 上床睡觉时间 - 入睡时间
+ // 睡眠时间 = 睡醒时间 - 入睡时间
+ // 在床上时间 = 起床时间 - 上床时间
// 睡眠效率 = 睡眠时间 / 在床上时间
-
+ // 注:
+ // 睡醒时间 小于 入睡时间则表示是第二天的时间
+ // 起床时间 小于 上床则表示是第二天的时间
calculateSleepTime() {
// 获取时间值
const bedTime = this.form["SCWJ-SCSJ"]; // 上床睡觉时间
const sleepTime = this.form["SCWJ-RSSJ"]; // 入睡时间
const wakeTime = this.form["SCWJ-SXSJ"]; // 睡醒时间
+ const wakeBedTime = this.form["SCWJ-QCSJ"]; // 起床时间
// 如果缺少任一时间,直接返回
- if (!bedTime || !sleepTime || !wakeTime) return;
+ if (!bedTime || !sleepTime || !wakeTime || !wakeBedTime) return;
// 将时间字符串转换为分钟数
const toMinutes = (timeStr) => {
@@ -559,12 +574,24 @@ export default {
return parseInt(hour) * 60 + parseInt(minute);
};
- // 计算在床上时间(入睡时间 - 上床睡觉时间)
- const inBedMinutes = toMinutes(sleepTime) - toMinutes(bedTime);
+ // 计算在床上时间和睡眠时间
+ // 在床上时间 = 上床睡觉时间 - 入睡时间
+ // 睡眠时间 = 入睡时间 - 起床时间
+ let inBedMinutes = toMinutes(wakeBedTime) - toMinutes(bedTime); // 在床上时间
+ let sleepMinutes = toMinutes(wakeTime) - toMinutes(sleepTime); // 睡眠时间
- // 计算睡眠时间(睡醒时间 - 入睡时间)
- const sleepMinutes = toMinutes(wakeTime) - toMinutes(sleepTime);
+ // 处理跨天情况
+ // 如果入睡时间小于上床时间,说明跨天,加上24小时
+ if (inBedMinutes < 0) {
+ inBedMinutes += 24 * 60;
+ }
+ // 如果睡醒时间小于入睡时间,说明跨天,加上24小时
+ if (sleepMinutes < 0) {
+ sleepMinutes += 24 * 60;
+ }
+ console.log("inBedMinutes", inBedMinutes);
+ console.log("sleepMinutes", sleepMinutes);
// 计算睡眠效率(睡眠时间 / 在床上时间)
const sleepEfficiency = (sleepMinutes / inBedMinutes) * 100;