feat: 测试操作页显示当前测试模式,灵敏度模式下隐藏波动数据区
- 页面头部新增测试模式指示器(灵敏度测试/波动测试) - 灵敏度模式时隐藏「波动测试数据」区块 - loadTestMode() 从工装参数获取 TestMode,无参数时回退到最新测试数据 - renderLatest 收到新数据时同步更新模式指示
This commit is contained in:
@@ -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 = '当前测试模式:<strong style="color:#e67e22;">波动测试</strong>';
|
||||
waveSection.style.display = '';
|
||||
} else {
|
||||
indicator.innerHTML = '当前测试模式:<strong style="color:#2980b9;">灵敏度测试</strong>';
|
||||
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 = `
|
||||
<p>设备型号:<strong>${data.str_type || '-'}</strong></p>
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<div class="test-header">
|
||||
<a href="/">← 返回设备列表</a>
|
||||
<h2>测试操作 — {{ device.serial }} ({{ device.name or '未命名' }})</h2>
|
||||
<div id="test-mode-indicator" style="margin-top:4px;font-size:14px;color:#888;">加载中…</div>
|
||||
</div>
|
||||
|
||||
<div class="test-layout">
|
||||
@@ -58,10 +59,12 @@
|
||||
<p class="placeholder">等待设备上报...</p>
|
||||
</div>
|
||||
|
||||
<div id="wave-section">
|
||||
<h3>波动测试数据</h3>
|
||||
<div id="latest-wave">
|
||||
<p class="placeholder">暂无波动数据...</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h3>自动化平均值</h3>
|
||||
<table id="avg-table">
|
||||
|
||||
Reference in New Issue
Block a user