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);