From 861bdb519592f9b31ca3fea88fc9c6992776ee35 Mon Sep 17 00:00:00 2001 From: xjs Date: Thu, 6 Aug 2026 13:59:08 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/format.ts | 11 +- src/views/reception/ReceptionTask.vue | 8 +- src/views/teacher/InvitationData.vue | 151 +++++++++++--------------- 3 files changed, 75 insertions(+), 95 deletions(-) diff --git a/src/utils/format.ts b/src/utils/format.ts index 52b14b7..946c59c 100644 --- a/src/utils/format.ts +++ b/src/utils/format.ts @@ -1,10 +1,13 @@ // 通用格式化 / 校验纯函数(无状态,供 composable 与页面复用)。 /** Date → `YYYY-MM-DD` */ -export const formatDate = (date: Date): string => { - const year = date.getFullYear(); - const month = String(date.getMonth() + 1).padStart(2, "0"); - const day = String(date.getDate()).padStart(2, "0"); +export const formatDate = (date: Date | string): string => { + const transformedDate = typeof date === "string" ? new Date(date) : date; + if (Number.isNaN(transformedDate.getTime())) return ""; + + const year = transformedDate.getFullYear(); + const month = String(transformedDate.getMonth() + 1).padStart(2, "0"); + const day = String(transformedDate.getDate()).padStart(2, "0"); return `${year}-${month}-${day}`; }; diff --git a/src/views/reception/ReceptionTask.vue b/src/views/reception/ReceptionTask.vue index ab0a09f..3474ba2 100644 --- a/src/views/reception/ReceptionTask.vue +++ b/src/views/reception/ReceptionTask.vue @@ -32,7 +32,7 @@
{{ item.studentName || "-" }} - 签到:{{ formatCheckinTime(item.checkinTime) }} + 签到:{{ formatDate(item.checkinTime) }} = [ { label: "待接待", value: "available" }, @@ -99,10 +100,7 @@ const router = useRouter(); const { activeTab, tasks, loading, finished, error, claimingTaskId, showEmpty, emptyText, loadNextPage, claimTask } = useReceptionTasks(20); - const formatCheckinTime = (value: string): string => { - const normalized = value.replace("T", " "); - return normalized.length >= 16 ? normalized.slice(5, 16) : normalized || "-"; - }; + const formatDateOnly = (value: string): string => value.split(/[T ]/, 1)[0] || "-"; diff --git a/src/views/teacher/InvitationData.vue b/src/views/teacher/InvitationData.vue index 21111a0..50eb71e 100644 --- a/src/views/teacher/InvitationData.vue +++ b/src/views/teacher/InvitationData.vue @@ -1,49 +1,27 @@