初步完成版,并加上logo和版权
This commit is contained in:
parent
221c6fc239
commit
a35baf7d3d
6
app.py
6
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)
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 46 KiB |
158
static/main.js
158
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 = '<input type="text" class="form-control serial-number" placeholder="输入设备序列号">';
|
||||
cell2.innerHTML = `
|
||||
<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}">
|
||||
<span class="pending" ${allTestsPassed ? 'style="display: none;"' : ''}>待测试</span>
|
||||
<span class="pass" ${allTestsPassed ? '' : 'style="display: none;"'}>合格</span>
|
||||
<span class="pending">待测试</span>
|
||||
<span class="pass" style="display: none;">合格</span>
|
||||
<span class="fail" style="display: none;">不合格</span>
|
||||
</label>
|
||||
</div>`;
|
||||
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();
|
||||
}
|
||||
|
||||
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('清空信号数据失败');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -17,12 +17,15 @@
|
|||
</head>
|
||||
<body>
|
||||
<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-body">
|
||||
<h5 class="card-title">测试信息</h5>
|
||||
<h5 class="card-title">基本信息</h5>
|
||||
<div class="row">
|
||||
<!-- 现有的输入字段 -->
|
||||
<div class="col-md-3">
|
||||
|
@ -93,10 +96,6 @@
|
|||
<div class="light common off" id="common-5"></div>
|
||||
<p>公共灯</p>
|
||||
</div>
|
||||
<div class="light-item">
|
||||
<div class="light alarm off" id="alarm-5"></div>
|
||||
<p>警铃灯</p>
|
||||
</div>
|
||||
<div class="light-item">
|
||||
<div class="light up off" id="up-5"></div>
|
||||
<p>上行灯</p>
|
||||
|
@ -105,6 +104,10 @@
|
|||
<div class="light down off" id="down-5"></div>
|
||||
<p>下行灯</p>
|
||||
</div>
|
||||
<div class="light-item">
|
||||
<div class="light alarm off" id="alarm-5"></div>
|
||||
<p>警铃灯</p>
|
||||
</div>
|
||||
<div class="light-item">
|
||||
<div class="light emergency_stop off" id="emergency_stop-5"></div>
|
||||
<p>急停灯</p>
|
||||
|
@ -143,10 +146,6 @@
|
|||
公共
|
||||
<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="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">
|
||||
上行
|
||||
<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>
|
||||
</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">
|
||||
急停
|
||||
<span class="badge bg-success rounded-pill" style="display: none;">✓</span>
|
||||
|
@ -212,10 +215,15 @@
|
|||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="text-end mt-3">
|
||||
<button class="btn btn-success" onclick="exportToExcel()">
|
||||
<i class="fas fa-file-excel me-2"></i>导出结果到Excel
|
||||
</button>
|
||||
<div class="d-flex justify-content-between align-items-center mt-3">
|
||||
<div class="copyright">
|
||||
<small>© <span id="currentYear"></span> 捷力思智能科技(上海)有限公司. 保留所有权利。</small>
|
||||
</div>
|
||||
<div>
|
||||
<button class="btn btn-success" onclick="exportToExcel()">
|
||||
<i class="fas fa-file-excel me-2"></i>导出结果到Excel
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -237,6 +245,9 @@
|
|||
locale: "zh",
|
||||
disableMobile: "true"
|
||||
});
|
||||
|
||||
// 设置当前年份
|
||||
document.getElementById('currentYear').textContent = new Date().getFullYear();
|
||||
});
|
||||
</script>
|
||||
|
||||
|
|
Loading…
Reference in New Issue