From 522f40a3c2085643878cd4e789310de62e1da0b7 Mon Sep 17 00:00:00 2001 From: wangfq Date: Fri, 5 Jun 2026 10:47:48 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=BB=9F=E4=B8=80=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E4=B8=BA=20yyyy-MM-dd=20HH:mm:ss=EF=BC=8C?= =?UTF-8?q?=E5=8E=BB=E6=8E=89=E6=AF=AB=E7=A7=92=E9=83=A8=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- edc-web/app/static/js/test_data.js | 12 +++++++++--- edc-web/app/static/js/test_op.js | 11 ++++++++--- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/edc-web/app/static/js/test_data.js b/edc-web/app/static/js/test_data.js index eb00ffb..98fdd99 100644 --- a/edc-web/app/static/js/test_data.js +++ b/edc-web/app/static/js/test_data.js @@ -20,7 +20,7 @@ const VIEWS = { { key: 'exit_dist', title: '离开距离' }, { key: 'remain_count', title: '剩余次数' }, { key: 'curr_dist', title: '当前距离' }, - { key: 'create_time', title: '时间' }, + { key: 'create_time', title: '时间', render: r => fmtTime(r.create_time) }, ], }, b2: { @@ -44,7 +44,7 @@ const VIEWS = { { key: 'exit_dist', title: '离开距离' }, { key: 'enter_speed', title: '进入速度', render: r => toSpeed(r.enter_speed) }, { key: 'exit_speed', title: '离开速度', render: r => toSpeed(r.exit_speed) }, - { key: 'create_time', title: '时间' }, + { key: 'create_time', title: '时间', render: r => fmtTime(r.create_time) }, ], }, b4: { @@ -63,7 +63,7 @@ const VIEWS = { { key: 'b4_enter_dist', title: '进入高度(mm)' }, { key: 'b4_leave_dist', title: '离开高度(mm)' }, { key: 'relay_out', title: '继电器' }, - { key: 'create_time', title: '时间' }, + { key: 'create_time', title: '时间', render: r => fmtTime(r.create_time) }, ], }, }; @@ -79,6 +79,12 @@ function toSpeed(v) { return (parseFloat(v) / 10).toFixed(1); } +function fmtTime(v) { + if (!v) return '-'; + // MySQL datetime: '2026-06-01 14:30:25' 或 '2026-06-01T14:30:25' + return String(v).replace('T', ' ').replace(/\.\d+/, '').substring(0, 19); +} + // ─── 视图切换 ──────────────────────────────────── function switchView(view) { diff --git a/edc-web/app/static/js/test_op.js b/edc-web/app/static/js/test_op.js index c39b0d6..3336746 100644 --- a/edc-web/app/static/js/test_op.js +++ b/edc-web/app/static/js/test_op.js @@ -278,6 +278,11 @@ function toSpeed(v) { return (parseFloat(v) / 10).toFixed(1); } +function fmtTime(v) { + if (!v) return '-'; + return String(v).replace('T', ' ').replace(/\.\d+/, '').substring(0, 19); +} + // ─── 显示最新结果 ────────────────────────────── function renderLatest(data) { @@ -295,7 +300,7 @@ function renderLatest(data) {

离开速度:${toSpeed(data.exit_speed)} m/s

是否完成:${data.iffinish === '1' ? '是' : '否'}

故障信息:${data.fault_info || '无'}

-

时间:${data.create_time || '-'}

+

时间:${fmtTime(data.create_time)}

`; } @@ -336,7 +341,7 @@ function renderLatestWave(data) {

进入高度 (B4):${data.b4_enter_dist || '-'} mm

离开高度 (B4):${data.b4_leave_dist || '-'} mm

继电器:${data.relay_out || '无'}

-

时间:${data.create_time || '-'}

+

时间:${fmtTime(data.create_time)}

`; } @@ -364,7 +369,7 @@ function renderRecords(records) { ${r.enter_dist || '-'} ${r.exit_dist || '-'} ${toSpeed(r.enter_speed)} - ${r.create_time || '-'} + ${fmtTime(r.create_time)} `).join(""); }