fix: UI 标签优化、继电器着色、工装配置概览面板
- fixture.js: FarTol/NearTol/StepTol 容差字段去掉 ×10 换算 - test_data.js: relay_out 列增加 fmtRelay() 着色渲染 - test_op.js: 新增工装配置概览面板 (renderConfigOverview + toggleConfig);新增 fmtRelay();renderLatest 继电器着色 - fixture.html: 标签文本优化 — 触发距离/释放距离/mm/V 单位标注 - test_op.html: 新增配置概览面板 HTML,隐藏旧 test-mode-indicator - vehicle_base_test.html: 标签文本统一(触发/释放距离 + 单位) - .gitignore: 新增,排除 __pycache__/*.pyc/.venv
This commit is contained in:
@@ -279,6 +279,7 @@ async function loadTestMode() {
|
||||
const param = await resp.json();
|
||||
if (param && param.dnt_id) {
|
||||
updateTestModeUI(param.TestMode);
|
||||
renderConfigOverview(param);
|
||||
} else {
|
||||
// 没有工装参数时,尝试从最新测试数据获取
|
||||
const r2 = await fetch(`/api/automation/${DNT_ID}/progress`);
|
||||
@@ -292,17 +293,81 @@ async function loadTestMode() {
|
||||
|
||||
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';
|
||||
}
|
||||
}
|
||||
|
||||
function renderConfigOverview(param) {
|
||||
const panel = document.getElementById("config-overview");
|
||||
if (!panel) return;
|
||||
panel.style.display = '';
|
||||
|
||||
// 测试模式
|
||||
const modeEl = document.getElementById("cfg-test-mode");
|
||||
if (param.TestMode === 1) {
|
||||
modeEl.innerHTML = '<strong style="color:#e67e22;">波动测试</strong>';
|
||||
} else {
|
||||
modeEl.innerHTML = '<strong style="color:#2980b9;">灵敏度测试</strong>';
|
||||
}
|
||||
|
||||
// 型号
|
||||
const devTypeMap = {0: '未知', 1: 'PD132', 2: 'DLD110'};
|
||||
document.getElementById("cfg-dev-type").textContent = devTypeMap[param.DevType] || `0x${(param.DevType||0).toString(16)}`;
|
||||
|
||||
// 距离 (DB cm → 显示 mm)
|
||||
document.getElementById("cfg-reset-dis").textContent = param.RestDis != null ? param.RestDis * 10 : '-';
|
||||
document.getElementById("cfg-minus-dis").textContent = param.MinusDis != null ? param.MinusDis * 10 : '-';
|
||||
|
||||
// 触发和释放范围 (SensMin ~ SensMax)
|
||||
document.getElementById("cfg-sens-range").textContent =
|
||||
(param.SensMin != null && param.SensMax != null) ? `${param.SensMin} ~ ${param.SensMax}` : '-';
|
||||
|
||||
// 频率范围 (配置值 ×10 = 实际 Hz)
|
||||
if (param.FreMin != null && param.FreMax != null) {
|
||||
document.getElementById("cfg-fre-range").textContent = `${param.FreMin * 10} ~ ${param.FreMax * 10}`;
|
||||
} else {
|
||||
document.getElementById("cfg-fre-range").textContent = '-';
|
||||
}
|
||||
|
||||
// 线圈信息
|
||||
const coil = [param.coil_num, param.coil_name].filter(Boolean).join(' ');
|
||||
document.getElementById("cfg-coil").textContent = coil || '-';
|
||||
|
||||
// 模拟车辆信息
|
||||
const car = [param.simulate_num, param.car_name].filter(Boolean).join(' ');
|
||||
document.getElementById("cfg-car").textContent = car || '-';
|
||||
|
||||
// 波动参数
|
||||
const waveParams = document.getElementById("cfg-wave-params");
|
||||
if (param.TestMode === 1) {
|
||||
waveParams.style.display = '';
|
||||
document.getElementById("cfg-near-tol").textContent = param.NearTol ?? '-';
|
||||
document.getElementById("cfg-far-tol").textContent = param.FarTol ?? '-';
|
||||
document.getElementById("cfg-step-tol").textContent = param.StepTol ?? '-';
|
||||
document.getElementById("cfg-back-forth").textContent = param.BackForth ?? '-';
|
||||
document.getElementById("cfg-near-stay").textContent = param.NearStay ?? '-';
|
||||
document.getElementById("cfg-far-stay").textContent = param.FarStay ?? '-';
|
||||
} else {
|
||||
waveParams.style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
function toggleConfig() {
|
||||
const body = document.getElementById("config-body");
|
||||
const toggle = document.getElementById("config-toggle");
|
||||
if (body.style.display === 'none') {
|
||||
body.style.display = '';
|
||||
toggle.textContent = '收起 ▲';
|
||||
} else {
|
||||
body.style.display = 'none';
|
||||
toggle.textContent = '展开 ▼';
|
||||
}
|
||||
}
|
||||
|
||||
async function loadInitialData() {
|
||||
await loadTestMode();
|
||||
refreshDeviceStatus();
|
||||
@@ -399,6 +464,13 @@ function decodeRelay(v) {
|
||||
return RELAY_MAP[parseInt(v)] || `0x${parseInt(v).toString(16).toUpperCase().padStart(2, '0')}`;
|
||||
}
|
||||
|
||||
function fmtRelay(s) {
|
||||
if (!s) return '-';
|
||||
return s
|
||||
.replace(/继电器有输出/g, '<span style="color:#22c55e;font-weight:600">✅有输出</span>')
|
||||
.replace(/继电器无输出/g, '<span style="color:#ef4444;font-weight:600">❌无输出</span>');
|
||||
}
|
||||
|
||||
// ─── 显示最新结果 ──────────────────────────────
|
||||
|
||||
function renderLatest(data) {
|
||||
@@ -416,7 +488,7 @@ function renderLatest(data) {
|
||||
<p>离开速度:${toSpeed(data.exit_speed)} m/s</p>
|
||||
<p>是否完成:${data.iffinish === '1' ? '是' : '否'}</p>
|
||||
<p>故障信息:${data.fault_info || '无'}</p>
|
||||
<p>继电器:${data.relay_out || decodeRelay(data.relay_code)}</p>
|
||||
<p>继电器:${fmtRelay(data.relay_out) || decodeRelay(data.relay_code)}</p>
|
||||
<p>时间:${fmtTime(data.create_time)}</p>
|
||||
`;
|
||||
}
|
||||
@@ -457,7 +529,7 @@ function renderLatestWave(data) {
|
||||
<p>最远距离:${data.far_dist || '-'} mm</p>
|
||||
<p>进入高度 (B4):${data.b4_enter_dist || '-'} mm</p>
|
||||
<p>离开高度 (B4):${data.b4_leave_dist || '-'} mm</p>
|
||||
<p>继电器:${data.relay_out || decodeRelay(data.relay_code)}</p>
|
||||
<p>继电器:${fmtRelay(data.relay_out) || decodeRelay(data.relay_code)}</p>
|
||||
<p>时间:${fmtTime(data.create_time)}</p>
|
||||
`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user