diff --git a/assets/image_20260710105638649.png b/assets/image_20260710105638649.png new file mode 100644 index 0000000..fcd8a3b Binary files /dev/null and b/assets/image_20260710105638649.png differ diff --git a/templates/index.html b/templates/index.html index 3e78a05..52e3ae2 100644 --- a/templates/index.html +++ b/templates/index.html @@ -838,7 +838,7 @@ document.getElementById('end-time').value = formatDateTimeLocal(end); } - // 格式化日期时间 + // 格式化日期时间(用于输入框) function formatDateTimeLocal(date) { const year = date.getFullYear(); const month = String(date.getMonth() + 1).padStart(2, '0'); @@ -848,6 +848,27 @@ return `${year}-${month}-${day}T${hours}:${minutes}`; } + // 格式化日期时间为数字格式(用于显示) + function formatDateTimeDisplay(dateTimeStr) { + if (!dateTimeStr) return '-'; + // 如果是字符串,直接返回(已经是数字格式) + if (typeof dateTimeStr === 'string') { + // 如果是 ISO 格式或其他格式,转换为 YYYY-MM-DD HH:MM:SS + const date = new Date(dateTimeStr); + if (!isNaN(date.getTime())) { + const year = date.getFullYear(); + const month = String(date.getMonth() + 1).padStart(2, '0'); + const day = String(date.getDate()).padStart(2, '0'); + const hours = String(date.getHours()).padStart(2, '0'); + const minutes = String(date.getMinutes()).padStart(2, '0'); + const seconds = String(date.getSeconds()).padStart(2, '0'); + return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`; + } + return dateTimeStr; + } + return String(dateTimeStr); + } + // 生成日报 async function generateReport() { const configId = document.getElementById('generate-config').value; @@ -988,7 +1009,7 @@ return ` ${item.report_date} - ${item.start_time || '-'}

${item.end_time || '-'} + ${formatDateTimeDisplay(item.start_time)}

${formatDateTimeDisplay(item.end_time)} ${item.config_name || '-'} ${item.split_name || item.split_value} ${item.total_orders}