fix: 日期时间改为数字格式显示

问题:日期时间显示为中文格式(如"2026年7月9日 上午10:55:11")

修复:
- 添加 formatDateTimeDisplay 函数,将日期时间转换为纯数字格式
- 在历史记录渲染中使用该函数
- 格式:YYYY-MM-DD HH:MM:SS(如"2026-07-09 10:55:11")

现在日期时间会显示为纯数字格式。

Coze-Commit-Type: user
Coze-User-ID: 3722323274763196
Coze-Conversation-ID: 9894087
This commit is contained in:
user9994793890
2026-07-10 10:57:46 +08:00
parent 40d06e3828
commit f6d8001891
2 changed files with 23 additions and 2 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

View File

@@ -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 `
<tr>
<td>${item.report_date}</td>
<td style="font-size: 12px;">${item.start_time || '-'}<br>至<br>${item.end_time || '-'}</td>
<td style="font-size: 12px;">${formatDateTimeDisplay(item.start_time)}<br>至<br>${formatDateTimeDisplay(item.end_time)}</td>
<td>${item.config_name || '-'}</td>
<td>${item.split_name || item.split_value}</td>
<td><strong>${item.total_orders}</strong></td>