初步完成版,并加上logo和版权

This commit is contained in:
Jay Huang 2024-10-18 23:29:13 +08:00
parent 221c6fc239
commit a35baf7d3d
4 changed files with 136 additions and 67 deletions

6
app.py
View File

@ -173,5 +173,11 @@ def test_port():
except Exception as e: except Exception as e:
return jsonify({'success': False, 'message': f'测试失败: {str(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__': if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0', port=5888) app.run(debug=True, host='0.0.0.0', port=5888)

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

View File

@ -85,33 +85,38 @@ function resetCheckList() {
function updateTestResult() { function updateTestResult() {
const rows = document.querySelectorAll('#resultTable tbody tr'); const rows = document.querySelectorAll('#resultTable tbody tr');
rows.forEach(row => { const lastRow = rows[rows.length - 1];
const checkbox = row.querySelector('.form-check-input');
const label = row.querySelector('.form-check-label'); // 只更新最后一行的状态
const pendingSpan = label.querySelector('.pending'); updateRowTestResult(lastRow);
const passSpan = label.querySelector('.pass'); }
const failSpan = label.querySelector('.fail');
function updateRowTestResult(row) {
if (allTestsPassed) { const checkbox = row.querySelector('.form-check-input');
checkbox.disabled = false; const label = row.querySelector('.form-check-label');
checkbox.checked = true; const pendingSpan = label.querySelector('.pending');
pendingSpan.style.display = 'none'; const passSpan = label.querySelector('.pass');
passSpan.style.display = 'inline'; const failSpan = label.querySelector('.fail');
failSpan.style.display = 'none';
row.classList.remove('pending-row'); if (allTestsPassed) {
row.classList.add('pass-row'); checkbox.disabled = false;
row.classList.remove('fail-row'); checkbox.checked = true;
} else { pendingSpan.style.display = 'none';
checkbox.disabled = true; passSpan.style.display = 'inline';
checkbox.checked = false; failSpan.style.display = 'none';
pendingSpan.style.display = 'inline'; row.classList.remove('pending-row');
passSpan.style.display = 'none'; row.classList.add('pass-row');
failSpan.style.display = 'none'; row.classList.remove('fail-row');
row.classList.add('pending-row'); } else {
row.classList.remove('pass-row'); checkbox.disabled = true;
row.classList.remove('fail-row'); 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) { function addNewRow(button) {
@ -124,10 +129,11 @@ function addNewRow(button) {
return; 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 rowIndex = table.rows.length - 1;
const cell1 = newRow.insertCell(0); const cell1 = newRow.insertCell(0);
@ -137,39 +143,85 @@ function addNewRow(button) {
cell1.innerHTML = '<input type="text" class="form-control serial-number" placeholder="输入设备序列号">'; cell1.innerHTML = '<input type="text" class="form-control serial-number" placeholder="输入设备序列号">';
cell2.innerHTML = ` cell2.innerHTML = `
<div class="form-check form-switch"> <div class="form-check form-switch">
<input class="form-check-input" type="checkbox" id="result-${rowIndex}" ${allTestsPassed ? 'checked' : 'disabled'}> <input class="form-check-input" type="checkbox" id="result-${rowIndex}" disabled>
<label class="form-check-label" for="result-${rowIndex}"> <label class="form-check-label" for="result-${rowIndex}">
<span class="pending" ${allTestsPassed ? 'style="display: none;"' : ''}>待测试</span> <span class="pending">待测试</span>
<span class="pass" ${allTestsPassed ? '' : 'style="display: none;"'}>合格</span> <span class="pass" style="display: none;">合格</span>
<span class="fail" style="display: none;">不合格</span> <span class="fail" style="display: none;">不合格</span>
</label> </label>
</div>`; </div>`;
cell3.innerHTML = '<button class="btn btn-primary add-row-btn" onclick="addNewRow(this)">增加下一条</button>'; cell3.innerHTML = '<button class="btn btn-primary add-row-btn" onclick="addNewRow(this)">增加下一条</button>';
// 重置表单和状态
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(); updateTestResult();
} }
function updateResultStyle(row) { function resetDetectionStatus() {
const checkbox = row.cells[1].querySelector('.form-check-input'); lightHistory = {
const serialNumberInput = row.cells[0].querySelector('.serial-number'); common: false,
const label = checkbox.nextElementSibling; alarm: false,
const pendingSpan = label.querySelector('.pending'); up: false,
const passSpan = label.querySelector('.pass'); down: false,
const failSpan = label.querySelector('.fail'); emergency_stop: false
};
checkbox.addEventListener('change', function() { const deviceType = document.getElementById('deviceType').value;
if (this.checked) { const checkList = document.getElementById(`statusCheckList${deviceType}`);
row.classList.remove('fail-row'); if (checkList) {
row.classList.add('pass-row'); const badges = checkList.querySelectorAll('.badge');
pendingSpan.style.display = 'none'; badges.forEach(badge => {
passSpan.style.display = 'inline'; badge.style.display = 'none';
failSpan.style.display = 'none'; });
} else { }
row.classList.remove('pass-row'); }
row.classList.add('fail-row');
pendingSpan.style.display = 'none'; function resetLightStatus() {
passSpan.style.display = 'none'; const lights = document.querySelectorAll('.light');
failSpan.style.display = 'inline'; 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('清空信号数据失败');
} }
}); });
} }

View File

@ -17,12 +17,15 @@
</head> </head>
<body> <body>
<div class="container mt-5"> <div class="container mt-5">
<h1 class="text-center mb-4">设备测试监控</h1> <div class="d-flex flex-column flex-md-row justify-content-flex-start align-items-center mb-4">
<img src="../static/images/celex_logo.png" alt="Celex" class="mb-3 mb-md-0 me-md-3" style="height: 50px;">
<h1 class="mb-0 text-center text-md-start">通力电梯检修手柄功能检测系统</h1>
</div>
<!-- 信息区域 --> <!-- 信息区域 -->
<div class="card mb-4"> <div class="card mb-4">
<div class="card-body"> <div class="card-body">
<h5 class="card-title">测试信息</h5> <h5 class="card-title">基本信息</h5>
<div class="row"> <div class="row">
<!-- 现有的输入字段 --> <!-- 现有的输入字段 -->
<div class="col-md-3"> <div class="col-md-3">
@ -93,10 +96,6 @@
<div class="light common off" id="common-5"></div> <div class="light common off" id="common-5"></div>
<p>公共灯</p> <p>公共灯</p>
</div> </div>
<div class="light-item">
<div class="light alarm off" id="alarm-5"></div>
<p>警铃灯</p>
</div>
<div class="light-item"> <div class="light-item">
<div class="light up off" id="up-5"></div> <div class="light up off" id="up-5"></div>
<p>上行灯</p> <p>上行灯</p>
@ -105,6 +104,10 @@
<div class="light down off" id="down-5"></div> <div class="light down off" id="down-5"></div>
<p>下行灯</p> <p>下行灯</p>
</div> </div>
<div class="light-item">
<div class="light alarm off" id="alarm-5"></div>
<p>警铃灯</p>
</div>
<div class="light-item"> <div class="light-item">
<div class="light emergency_stop off" id="emergency_stop-5"></div> <div class="light emergency_stop off" id="emergency_stop-5"></div>
<p>急停灯</p> <p>急停灯</p>
@ -143,10 +146,6 @@
公共 公共
<span class="badge bg-success rounded-pill" style="display: none;"></span> <span class="badge bg-success rounded-pill" style="display: none;"></span>
</li> </li>
<li class="list-group-item d-flex justify-content-between align-items-center" data-light="alarm">
警铃
<span class="badge bg-success rounded-pill" style="display: none;"></span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center" data-light="up"> <li class="list-group-item d-flex justify-content-between align-items-center" data-light="up">
上行 上行
<span class="badge bg-success rounded-pill" style="display: none;"></span> <span class="badge bg-success rounded-pill" style="display: none;"></span>
@ -155,6 +154,10 @@
下行 下行
<span class="badge bg-success rounded-pill" style="display: none;"></span> <span class="badge bg-success rounded-pill" style="display: none;"></span>
</li> </li>
<li class="list-group-item d-flex justify-content-between align-items-center" data-light="alarm">
警铃
<span class="badge bg-success rounded-pill" style="display: none;"></span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center" data-light="emergency_stop"> <li class="list-group-item d-flex justify-content-between align-items-center" data-light="emergency_stop">
急停 急停
<span class="badge bg-success rounded-pill" style="display: none;"></span> <span class="badge bg-success rounded-pill" style="display: none;"></span>
@ -212,10 +215,15 @@
</tr> </tr>
</tbody> </tbody>
</table> </table>
<div class="text-end mt-3"> <div class="d-flex justify-content-between align-items-center mt-3">
<button class="btn btn-success" onclick="exportToExcel()"> <div class="copyright">
<i class="fas fa-file-excel me-2"></i>导出结果到Excel <small>&copy; <span id="currentYear"></span> 捷力思智能科技(上海)有限公司. 保留所有权利。</small>
</button> </div>
<div>
<button class="btn btn-success" onclick="exportToExcel()">
<i class="fas fa-file-excel me-2"></i>导出结果到Excel
</button>
</div>
</div> </div>
</div> </div>
</div> </div>
@ -237,6 +245,9 @@
locale: "zh", locale: "zh",
disableMobile: "true" disableMobile: "true"
}); });
// 设置当前年份
document.getElementById('currentYear').textContent = new Date().getFullYear();
}); });
</script> </script>