diff --git a/app.py b/app.py index e3c6a9a..fa3c747 100644 --- a/app.py +++ b/app.py @@ -173,5 +173,11 @@ def test_port(): except Exception as e: return jsonify({'success': False, 'message': f'测试失败: {str(e)}'}) +@app.route('/clear_signal_data', methods=['POST']) +def clear_signal_data(): + global signal_data + signal_data = [] + return '', 204 + if __name__ == '__main__': app.run(debug=True, host='0.0.0.0', port=5888) diff --git a/static/images/celex_logo.png b/static/images/celex_logo.png new file mode 100644 index 0000000..841bd32 Binary files /dev/null and b/static/images/celex_logo.png differ diff --git a/static/main.js b/static/main.js index 69108f2..58c3e7c 100644 --- a/static/main.js +++ b/static/main.js @@ -85,33 +85,38 @@ function resetCheckList() { function updateTestResult() { const rows = document.querySelectorAll('#resultTable tbody tr'); - rows.forEach(row => { - const checkbox = row.querySelector('.form-check-input'); - const label = row.querySelector('.form-check-label'); - const pendingSpan = label.querySelector('.pending'); - const passSpan = label.querySelector('.pass'); - const failSpan = label.querySelector('.fail'); - - if (allTestsPassed) { - checkbox.disabled = false; - checkbox.checked = true; - pendingSpan.style.display = 'none'; - passSpan.style.display = 'inline'; - failSpan.style.display = 'none'; - row.classList.remove('pending-row'); - row.classList.add('pass-row'); - row.classList.remove('fail-row'); - } else { - checkbox.disabled = true; - checkbox.checked = false; - pendingSpan.style.display = 'inline'; - passSpan.style.display = 'none'; - failSpan.style.display = 'none'; - row.classList.add('pending-row'); - row.classList.remove('pass-row'); - row.classList.remove('fail-row'); - } - }); + const lastRow = rows[rows.length - 1]; + + // 只更新最后一行的状态 + updateRowTestResult(lastRow); +} + +function updateRowTestResult(row) { + const checkbox = row.querySelector('.form-check-input'); + const label = row.querySelector('.form-check-label'); + const pendingSpan = label.querySelector('.pending'); + const passSpan = label.querySelector('.pass'); + const failSpan = label.querySelector('.fail'); + + if (allTestsPassed) { + checkbox.disabled = false; + checkbox.checked = true; + pendingSpan.style.display = 'none'; + passSpan.style.display = 'inline'; + failSpan.style.display = 'none'; + row.classList.remove('pending-row'); + row.classList.add('pass-row'); + row.classList.remove('fail-row'); + } else { + checkbox.disabled = true; + checkbox.checked = false; + pendingSpan.style.display = 'inline'; + passSpan.style.display = 'none'; + failSpan.style.display = 'none'; + row.classList.add('pending-row'); + row.classList.remove('pass-row'); + row.classList.remove('fail-row'); + } } function addNewRow(button) { @@ -124,10 +129,11 @@ function addNewRow(button) { return; } - serialNumberInput.disabled = true; - button.style.display = 'none'; + // 固定当前行状态 + finalizeRowStatus(currentRow); - const newRow = table.insertRow(table.rows.length); + // 创建新行 + const newRow = table.insertRow(); const rowIndex = table.rows.length - 1; const cell1 = newRow.insertCell(0); @@ -137,39 +143,85 @@ function addNewRow(button) { cell1.innerHTML = ''; cell2.innerHTML = `
- +
`; cell3.innerHTML = ''; + // 重置表单和状态 + resetForm(); + + // 聚焦到新的设备序列号输入框 + const newSerialInput = newRow.querySelector('.serial-number'); + newSerialInput.focus(); + + // 清空app.py的信号数据 + clearSignalData(); +} + +function finalizeRowStatus(row) { + const serialNumberInput = row.querySelector('.serial-number'); + const addButton = row.querySelector('.add-row-btn'); + const checkbox = row.querySelector('.form-check-input'); + + serialNumberInput.disabled = true; + addButton.style.display = 'none'; + checkbox.disabled = true; +} + +function resetForm() { + // 重置测试结果为待测试状态 + resetTestResult(); + + // 重置检测状态记录 + resetDetectionStatus(); + + // 重置灯光状态 + resetLightStatus(); +} + +function resetTestResult() { + allTestsPassed = false; updateTestResult(); } -function updateResultStyle(row) { - const checkbox = row.cells[1].querySelector('.form-check-input'); - const serialNumberInput = row.cells[0].querySelector('.serial-number'); - const label = checkbox.nextElementSibling; - const pendingSpan = label.querySelector('.pending'); - const passSpan = label.querySelector('.pass'); - const failSpan = label.querySelector('.fail'); +function resetDetectionStatus() { + lightHistory = { + common: false, + alarm: false, + up: false, + down: false, + emergency_stop: false + }; - checkbox.addEventListener('change', function() { - if (this.checked) { - row.classList.remove('fail-row'); - row.classList.add('pass-row'); - pendingSpan.style.display = 'none'; - passSpan.style.display = 'inline'; - failSpan.style.display = 'none'; - } else { - row.classList.remove('pass-row'); - row.classList.add('fail-row'); - pendingSpan.style.display = 'none'; - passSpan.style.display = 'none'; - failSpan.style.display = 'inline'; + const deviceType = document.getElementById('deviceType').value; + const checkList = document.getElementById(`statusCheckList${deviceType}`); + if (checkList) { + const badges = checkList.querySelectorAll('.badge'); + badges.forEach(badge => { + badge.style.display = 'none'; + }); + } +} + +function resetLightStatus() { + const lights = document.querySelectorAll('.light'); + lights.forEach(light => { + light.classList.remove('on'); + light.classList.add('off'); + }); +} + +function clearSignalData() { + fetch('/clear_signal_data', { + method: 'POST', + }).then(response => { + if (!response.ok) { + console.error('清空信号数据失败'); } }); } diff --git a/templates/index.html b/templates/index.html index d7a3126..7dc97ed 100644 --- a/templates/index.html +++ b/templates/index.html @@ -17,12 +17,15 @@
-

设备测试监控

+
+ Celex +

通力电梯检修手柄功能检测系统

+
-
测试信息
+
基本信息
@@ -93,10 +96,6 @@

公共灯

-
-
-

警铃灯

-

上行灯

@@ -105,6 +104,10 @@

下行灯

+
+
+

警铃灯

+

急停灯

@@ -143,10 +146,6 @@ 公共 -
  • - 警铃 - -
  • 上行 @@ -155,6 +154,10 @@ 下行
  • +
  • + 警铃 + +
  • 急停 @@ -212,10 +215,15 @@ -
    - +
    + +
    + +
  • @@ -237,6 +245,9 @@ locale: "zh", disableMobile: "true" }); + + // 设置当前年份 + document.getElementById('currentYear').textContent = new Date().getFullYear(); });