feat: 新增 edc-web Flask 前端管理系统 + 需求文档
- edc-web: Flask 项目骨架(设备管理、测试操作、测试信息三大页面) - edc_server: 升级子模块(tb_serialnet 透传支持) - docs: 测试工装EDC管理系统需求文档
This commit is contained in:
86
edc-web/app/static/js/test_data.js
Normal file
86
edc-web/app/static/js/test_data.js
Normal file
@@ -0,0 +1,86 @@
|
||||
// 测试信息页
|
||||
|
||||
let currentPage = 1;
|
||||
let totalPages = 1;
|
||||
|
||||
async function searchData(page = 1) {
|
||||
currentPage = page;
|
||||
const serial = document.getElementById("search-serial").value;
|
||||
const dateFrom = document.getElementById("search-date-from").value;
|
||||
const dateTo = document.getElementById("search-date-to").value;
|
||||
|
||||
const params = new URLSearchParams({ page, per_page: 20 });
|
||||
if (serial) params.set("serial", serial);
|
||||
if (dateFrom) params.set("date_from", dateFrom);
|
||||
if (dateTo) params.set("date_to", dateTo);
|
||||
|
||||
try {
|
||||
const resp = await fetch(`/api/test-data?${params}`);
|
||||
const data = await resp.json();
|
||||
renderTable(data.records);
|
||||
totalPages = data.pages;
|
||||
renderPagination();
|
||||
} catch (e) {
|
||||
console.error("查询失败:", e);
|
||||
}
|
||||
}
|
||||
|
||||
function renderTable(records) {
|
||||
const tbody = document.querySelector("#test-data-table tbody");
|
||||
if (!records.length) {
|
||||
tbody.innerHTML = '<tr><td colspan="17" style="text-align:center;color:#999;">暂无数据</td></tr>';
|
||||
return;
|
||||
}
|
||||
tbody.innerHTML = records.map(r => `
|
||||
<tr>
|
||||
<td>${r.id}</td>
|
||||
<td>${r.serial || '-'}</td>
|
||||
<td>${r.dpg430_addr}</td>
|
||||
<td>${r.sub_type === 1 ? 'PD132' : r.sub_type === 2 ? 'DLD110' : '-'}</td>
|
||||
<td>${r.str_type || '-'}</td>
|
||||
<td>${r.iffinish === '1' ? '是' : '否'}</td>
|
||||
<td>${r.fault_info || '无'}</td>
|
||||
<td>${r.relay_out || '无'}</td>
|
||||
<td>${r.ppvalue?.toFixed(2) || '-'}</td>
|
||||
<td>${r.idle_freq || '-'}</td>
|
||||
<td>${r.enter_freq || '-'}</td>
|
||||
<td>${r.exit_freq || '-'}</td>
|
||||
<td>${r.enter_dist || '-'}</td>
|
||||
<td>${r.exit_dist || '-'}</td>
|
||||
<td>${r.enter_speed || '-'}</td>
|
||||
<td>${r.exit_speed || '-'}</td>
|
||||
<td>${r.create_time || '-'}</td>
|
||||
</tr>
|
||||
`).join("");
|
||||
}
|
||||
|
||||
function renderPagination() {
|
||||
const div = document.getElementById("pagination");
|
||||
let html = "";
|
||||
html += `<button onclick="searchData(${currentPage - 1})" ${currentPage <= 1 ? 'disabled' : ''}>上一页</button>`;
|
||||
for (let i = 1; i <= totalPages; i++) {
|
||||
if (i === currentPage) {
|
||||
html += `<button class="active">${i}</button>`;
|
||||
} else {
|
||||
html += `<button onclick="searchData(${i})">${i}</button>`;
|
||||
}
|
||||
}
|
||||
html += `<button onclick="searchData(${currentPage + 1})" ${currentPage >= totalPages ? 'disabled' : ''}>下一页</button>`;
|
||||
div.innerHTML = html;
|
||||
}
|
||||
|
||||
function exportCSV() {
|
||||
const serial = document.getElementById("search-serial").value;
|
||||
const dateFrom = document.getElementById("search-date-from").value;
|
||||
const dateTo = document.getElementById("search-date-to").value;
|
||||
|
||||
const params = new URLSearchParams();
|
||||
if (serial) params.set("serial", serial);
|
||||
if (dateFrom) params.set("date_from", dateFrom);
|
||||
if (dateTo) params.set("date_to", dateTo);
|
||||
|
||||
window.location.href = `/api/test-data/export?${params}`;
|
||||
}
|
||||
|
||||
// 初始加载
|
||||
searchData(1);
|
||||
Reference in New Issue
Block a user