From 7998f56025eac6be7dc1cf9c694ab0fc18b68bca Mon Sep 17 00:00:00 2001
From: zhangchen <1652267879@qq.com>
Date: 星期五, 25 七月 2025 14:55:54 +0800
Subject: [PATCH] Merge branch 'ID1825-床旁副屏改版' into test

---
 src/views/mobile/bedsideAuxiliaryScreen/components/ScheduledTask.vue |   56 ++++++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 50 insertions(+), 6 deletions(-)

diff --git a/src/views/mobile/bedsideAuxiliaryScreen/components/ScheduledTask.vue b/src/views/mobile/bedsideAuxiliaryScreen/components/ScheduledTask.vue
index 96a2c1a..34328e5 100644
--- a/src/views/mobile/bedsideAuxiliaryScreen/components/ScheduledTask.vue
+++ b/src/views/mobile/bedsideAuxiliaryScreen/components/ScheduledTask.vue
@@ -8,6 +8,8 @@
       :show-close="false"
       class="scheduled-task-dialog"
       top="0"
+      :destroy-on-close="true"
+      :close-on-click-modal="false"
     >
       <template #header>
         <div class="scheduled-task-header">
@@ -38,7 +40,7 @@
           <div class="content-left-stereotyped-writing">
             <div class="stereotyped-writing">
               <input
-                v-model="taskName"
+                v-model.trim="taskName"
                 type="text"
                 :disabled="isInpDisabled"
                 class="stereotyped-writing-input"
@@ -70,6 +72,10 @@
 
 <script lang="ts" setup>
 import { computed, ref } from "vue";
+import dayjs from "dayjs";
+import { setTimeoutAlert } from "@/utils/httpApi";
+import { useBedsideAuxiliaryScreenStore } from "@/store/bedsideAuxiliaryScreen";
+
 // @ts-ignore
 import TimePicker from "./TimePicker.vue";
 
@@ -81,6 +87,7 @@
 import tdddbaojing from "@/assets/tzddd.mp3";
 import tzxllbaojing from "@/assets/tzxll.mp3";
 import cgbaojing from "@/assets/cg.mp3";
+import { ElMessage } from "element-plus";
 
 interface TaskItem {
   label: string;
@@ -94,14 +101,18 @@
   value: number;
 }
 
+const bedsideAuxiliaryScreenStore = useBedsideAuxiliaryScreenStore();
+
 const isShow = ref(false);
 
 const taskName = ref(""); // 任务名称
 const isInpDisabled = ref(false); // 输入框是否禁用
 
-const timeValue = ref("19:16");
+const timeValue = ref("");
 
 const detaCheck = ref<number | null>(); // 这个是判断时间按钮的
+
+const loading = ref(false);
 
 const taskOptions = ref<TaskItem[]>([
   {
@@ -155,6 +166,8 @@
 
 const openDialog = () => {
   isShow.value = true;
+  const time = dayjs();
+  timeValue.value = time.format("HH:mm");
 };
 
 const onStereotypedWritingClick = (item: TaskItem) => {
@@ -197,7 +210,38 @@
   isShow.value = false;
 };
 
-const handleConfirm = () => {};
+const handleConfirm = async () => {
+  const today = dayjs().format("YYYY-MM-DD");
+  const fullDateTime = dayjs(`${today} ${timeValue.value}`).second(0).millisecond(0); // 秒和毫秒都去掉,要不然间隔短了就是0分钟
+
+  const now = dayjs().second(0).millisecond(0);; // 秒和毫秒都去掉
+  if (!fullDateTime.isAfter(now))
+    return ElMessage.warning("任务提醒时间不能早于或等于当前时间");
+  if (!taskName.value) return ElMessage.warning("任务内容不能为空");
+  loading.value = true;
+  try {
+    const diffMinutes = fullDateTime.diff(now, "minute");
+    const params = {
+      deviceCode: bedsideAuxiliaryScreenStore.deviceData.deviceCode,
+      minutes: diffMinutes,
+      alertText: taskName.value,
+    }
+    const recordCode = bedsideAuxiliaryScreenStore.deviceData.recordCode;
+    const { data, message } = await setTimeoutAlert(params);
+    if (data !== "OK") return ElMessage.warning(message);
+    ElMessage.success('操作成功');
+    bedsideAuxiliaryScreenStore.setSyncTask({
+        deviceCode: params.deviceCode,
+        recordCode: recordCode,
+        taskDate: dayjs(fullDateTime).format("YYYY-MM-DD HH:mm"),
+        taskName: params.alertText,
+        overdue: false
+    });
+    handleCancel();
+  } finally {
+    loading.value = false;
+  }
+};
 
 defineExpose({
   openDialog,
@@ -285,9 +329,9 @@
           .date {
             margin-left: 0;
             padding: 0;
-            width: 50px;
-            height: 23px;
-            line-height: 23px;
+            width: 44px;
+            height: 18px;
+            line-height: 18px;
             text-align: center;
             font-size: 11px;
             background-color: #769aff;

--
Gitblit v1.8.0