fix: 修复历史记录日期格式和配置名称显示问题

Coze-Commit-Type: user
Coze-User-ID: 3722323274763196
Coze-Conversation-ID: 9894087
This commit is contained in:
user9994793890
2026-07-13 14:55:08 +08:00
parent aaa5ba887a
commit b3f5918dff
2 changed files with 82 additions and 27 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@@ -2218,41 +2218,96 @@
return; return;
} }
// 解析日期字符串(支持多种格式)
const parseDate = (dateStr) => {
if (!dateStr) return null;
// 尝试匹配 "2026-07-12" 格式
let match = dateStr.match(/(\d{4})-(\d{1,2})-(\d{1,2})/);
if (match) {
return {
year: parseInt(match[1]),
month: parseInt(match[2]),
day: parseInt(match[3])
};
}
// 尝试匹配 "Sun, 12 Jul 2026 00:00:00 GMT" 格式
match = dateStr.match(/(\d{1,2})\s+(\w+)\s+(\d{4})/);
if (match) {
const months = {
'Jan': 1, 'Feb': 2, 'Mar': 3, 'Apr': 4, 'May': 5, 'Jun': 6,
'Jul': 7, 'Aug': 8, 'Sep': 9, 'Oct': 10, 'Nov': 11, 'Dec': 12
};
return {
year: parseInt(match[3]),
month: months[match[2]] || 1,
day: parseInt(match[1])
};
}
return null;
};
// 解析时间字符串(支持多种格式)
const parseTime = (timeStr) => {
if (!timeStr) return null;
// 尝试匹配 "2026-07-12 08:00:00" 格式
let match = timeStr.match(/(\d{4})-(\d{1,2})-(\d{1,2})\s+(\d{1,2}):(\d{1,2}):(\d{1,2})/);
if (match) {
return {
year: match[1],
month: match[2].padStart(2, '0'),
day: match[3].padStart(2, '0'),
hour: match[4].padStart(2, '0'),
minute: match[5].padStart(2, '0'),
second: match[6].padStart(2, '0')
};
}
// 尝试匹配 "Sun, 12 Jul 2026 08:00:00 GMT" 格式
match = timeStr.match(/(\d{1,2})\s+(\w+)\s+(\d{4})\s+(\d{1,2}):(\d{1,2}):(\d{1,2})/);
if (match) {
const months = {
'Jan': '01', 'Feb': '02', 'Mar': '03', 'Apr': '04', 'May': '05', 'Jun': '06',
'Jul': '07', 'Aug': '08', 'Sep': '09', 'Oct': '10', 'Nov': '11', 'Dec': '12'
};
return {
year: match[3],
month: months[match[2]] || '01',
day: match[1].padStart(2, '0'),
hour: match[4].padStart(2, '0'),
minute: match[5].padStart(2, '0'),
second: match[6].padStart(2, '0')
};
}
return null;
};
tbody.innerHTML = list.map(item => { tbody.innerHTML = list.map(item => {
const statusText = item.status === 1 ? '成功' : '失败'; const statusText = item.status === 1 ? '成功' : '失败';
const statusClass = item.status === 1 ? 'status-success' : 'status-failed'; const statusClass = item.status === 1 ? 'status-success' : 'status-failed';
// 格式化报表日期为中文(直接解析字符串格式 '2026-07-12' // 格式化报表日期为中文
let reportDate = '-'; let reportDate = '-';
if (item.report_date) { const dateObj = parseDate(item.report_date);
const match = item.report_date.match(/(\d{4})-(\d{1,2})-(\d{1,2})/); if (dateObj) {
if (match) { reportDate = `${dateObj.year}${dateObj.month}${dateObj.day}`;
const year = parseInt(match[1]); } else if (item.report_date) {
const month = parseInt(match[2]); reportDate = item.report_date;
const day = parseInt(match[3]);
reportDate = `${year}${month}${day}`;
} else {
reportDate = item.report_date;
}
} }
// 格式化时间范围(直接解析字符串格式 '2026-07-12 08:00:00' // 格式化时间范围
let timeRange = '-'; let timeRange = '-';
if (item.start_time && item.end_time) { const startObj = parseTime(item.start_time);
const formatTimeStr = (timeStr) => { const endObj = parseTime(item.end_time);
const match = timeStr.match(/(\d{4})-(\d{1,2})-(\d{1,2})\s+(\d{1,2}):(\d{1,2}):(\d{1,2})/); if (startObj && endObj) {
if (match) { const formatTimeObj = (obj) => `${obj.year}-${obj.month}-${obj.day} ${obj.hour}:${obj.minute}:${obj.second}`;
const year = match[1]; timeRange = `${formatTimeObj(startObj)}${formatTimeObj(endObj)}`;
const month = match[2].padStart(2, '0'); } else if (item.start_time && item.end_time) {
const day = match[3].padStart(2, '0'); timeRange = `${item.start_time}${item.end_time}`;
const hour = match[4].padStart(2, '0');
const minute = match[5].padStart(2, '0');
const second = match[6].padStart(2, '0');
return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
}
return timeStr;
};
timeRange = `${formatTimeStr(item.start_time)}${formatTimeStr(item.end_time)}`;
} }
const configName = item.config_name || '-'; const configName = item.config_name || '-';