From 3b0a3594129453e4fb8d19f9ba8d3efc1a8f3771 Mon Sep 17 00:00:00 2001 From: chenqi Date: Fri, 3 Apr 2026 11:02:58 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=97=A5=E6=9C=9F?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=8C=96=E5=87=BD=E6=95=B0=EF=BC=8C=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E4=B8=8D=E5=B8=A6=E5=89=8D=E5=AF=BC=E9=9B=B6=E7=9A=84?= =?UTF-8?q?=20M/D=20=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改 formatDateStr 函数,添加对 M/ 和 /D 格式的支持 - 确保生成的日期格式与后端期望的 yyyy/M/d HH:mm:ss 格式匹配 --- openhis-ui-vue3/src/utils/index.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/openhis-ui-vue3/src/utils/index.js b/openhis-ui-vue3/src/utils/index.js index e04e2643..8009d14c 100644 --- a/openhis-ui-vue3/src/utils/index.js +++ b/openhis-ui-vue3/src/utils/index.js @@ -28,11 +28,18 @@ export function formatDateStr(cellValue, format = 'YYYY-MM-DD HH:mm:ss') { const hours = String(date.getHours()).padStart(2, '0'); const minutes = String(date.getMinutes()).padStart(2, '0'); const seconds = String(date.getSeconds()).padStart(2, '0'); + + // 支持不带前导零的格式 + const monthNoPad = String(date.getMonth() + 1); + const dayNoPad = String(date.getDate()); return format .replace('YYYY', year) .replace('MM', month) .replace('DD', day) + .replace('M/', monthNoPad + '/') // 支持 M/ 格式 + .replace('D ', dayNoPad + ' ') // 支持 D 格式(后跟空格) + .replace('/D', '/' + dayNoPad) // 支持 /D 格式 .replace('HH', hours) .replace('mm', minutes) .replace('ss', seconds);