diff --git a/edc-web/app/static/js/test_op.js b/edc-web/app/static/js/test_op.js index bd52a56..5a90659 100644 --- a/edc-web/app/static/js/test_op.js +++ b/edc-web/app/static/js/test_op.js @@ -7,6 +7,7 @@ let autoFailed = 0; let autoRemaining = 0; let autoStartTime = ""; let localSinceStr = ""; +let currentTestMode = null; // 0=灵敏度, 1=波动, null=未加载 let pollInterval = null; let nextCmdTimer = null; // 间隔等待定时器 @@ -256,7 +257,39 @@ async function pollProgress() { } // ─── 页面加载时获取初始数据 ────────────────────── + +async function loadTestMode() { + try { + const resp = await fetch(`/api/fixture/param/${DNT_ID}`); + const param = await resp.json(); + if (param && param.dnt_id) { + updateTestModeUI(param.TestMode); + } else { + // 没有工装参数时,尝试从最新测试数据获取 + const r2 = await fetch(`/api/automation/${DNT_ID}/progress`); + const d2 = await r2.json(); + if (d2.latest && d2.latest.test_mode !== undefined) { + updateTestModeUI(d2.latest.test_mode); + } + } + } catch (e) { /* 静默 */ } +} + +function updateTestModeUI(mode) { + currentTestMode = mode; + const indicator = document.getElementById("test-mode-indicator"); + const waveSection = document.getElementById("wave-section"); + if (mode === 1) { + indicator.innerHTML = '当前测试模式:波动测试'; + waveSection.style.display = ''; + } else { + indicator.innerHTML = '当前测试模式:灵敏度测试'; + waveSection.style.display = 'none'; + } +} + async function loadInitialData() { + await loadTestMode(); try { const resp = await fetch(`/api/automation/${DNT_ID}/progress`); const data = await resp.json(); @@ -321,6 +354,9 @@ function decodeRelay(v) { // ─── 显示最新结果 ────────────────────────────── function renderLatest(data) { + if (data.test_mode !== undefined && data.test_mode !== currentTestMode) { + updateTestModeUI(data.test_mode); + } const div = document.getElementById("latest-result"); div.innerHTML = `

设备型号:${data.str_type || '-'}

diff --git a/edc-web/app/templates/test_op.html b/edc-web/app/templates/test_op.html index 4253e02..e70433b 100644 --- a/edc-web/app/templates/test_op.html +++ b/edc-web/app/templates/test_op.html @@ -6,6 +6,7 @@
← 返回设备列表

测试操作 — {{ device.serial }} ({{ device.name or '未命名' }})

+
加载中…
@@ -58,10 +59,12 @@

等待设备上报...

+

波动测试数据

暂无波动数据...

+

自动化平均值