{{ record.studentName }}
+{{ record.studentName }} +
{{ record.statusName }} @@ -52,7 +30,7 @@预约: - {{ record.visitDate }} + {{ formatDate(record.visitDate) }}
院校: @@ -70,70 +48,71 @@
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 @@
预约: - {{ record.visitDate }} + {{ formatDate(record.visitDate) }}
院校: @@ -70,70 +48,71 @@