From 8da4829da3014b1a93720c0700c5963a3298b63a Mon Sep 17 00:00:00 2001 From: 80937518651731347 Date: Mon, 29 Jun 2026 13:21:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=88=AA=E6=AC=A1=E7=99=BB?= =?UTF-8?q?=E8=AE=B0=E9=A1=B5=E9=9D=A2=20voyageReg?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/dataTransfer/voyageReg.vue | 44 ++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/src/views/dataTransfer/voyageReg.vue b/src/views/dataTransfer/voyageReg.vue index af3d4e7..f70ff6b 100644 --- a/src/views/dataTransfer/voyageReg.vue +++ b/src/views/dataTransfer/voyageReg.vue @@ -320,7 +320,7 @@ @@ -719,20 +719,38 @@ export default { this.paramsPeople.limit = val this.getPeopleList() }, - formatAge(birthDateString) { - if (birthDateString) { - const today = new Date() - const birthDate = new Date(birthDateString) - let age = today.getFullYear() - birthDate.getFullYear() - // 检查是否已过今年的生日 - const m = today.getMonth() - birthDate.getMonth() - if (m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) { - age-- - } - return age - } else { + /** + * 格式化出生日期显示 + * @param {string|null|undefined} birthDateString - 出生日期 + * @returns {string} + */ + formatBirthday(birthDateString) { + if (!birthDateString || !String(birthDateString).trim()) { return '' } + return String(birthDateString).slice(0, 10) + }, + /** + * 根据出生日期计算年龄,出生信息为空时不计算 + * @param {string|null|undefined} birthDateString - 出生日期 + * @returns {string|number} + */ + formatAge(birthDateString) { + if (!birthDateString || !String(birthDateString).trim()) { + return '' + } + const birthDate = new Date(birthDateString) + if (isNaN(birthDate.getTime())) { + return '' + } + const today = new Date() + let age = today.getFullYear() - birthDate.getFullYear() + // 检查是否已过今年的生日 + const m = today.getMonth() - birthDate.getMonth() + if (m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) { + age-- + } + return age }, cancelPeople() { this.openPeople = false