feat(test_data): 搜索页面增加时分秒时间筛选
- HTML: 日期范围旁加 time input (step=1s),标签改为'时间范围' - JS: 新增 getDatetime() 合并日期+时间,统一查/导出/图表/删除 - 后端: date 参数智能判断,纯日期自动补 23:59:59,带时间原样使用
This commit is contained in:
@@ -119,11 +119,20 @@ function switchView(view) {
|
||||
|
||||
// ─── 查询 ────────────────────────────────────────
|
||||
|
||||
/** 合并日期和时间输入框,返回 "YYYY-MM-DD" 或 "YYYY-MM-DD HH:MM:SS" 或 "" */
|
||||
function getDatetime(dateId, timeId) {
|
||||
const d = document.getElementById(dateId).value;
|
||||
const t = document.getElementById(timeId).value;
|
||||
if (!d) return "";
|
||||
if (!t) return d;
|
||||
return d + " " + t;
|
||||
}
|
||||
|
||||
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 dateFrom = getDatetime("search-date-from", "search-time-from");
|
||||
const dateTo = getDatetime("search-date-to", "search-time-to");
|
||||
const v = VIEWS[currentView];
|
||||
|
||||
const perPage = parseInt(document.getElementById("per-page").value) || 20;
|
||||
@@ -200,8 +209,8 @@ function renderPagination() {
|
||||
|
||||
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 dateFrom = getDatetime("search-date-from", "search-time-from");
|
||||
const dateTo = getDatetime("search-date-to", "search-time-to");
|
||||
const v = VIEWS[currentView];
|
||||
|
||||
const params = new URLSearchParams();
|
||||
@@ -293,8 +302,8 @@ async function loadChart() {
|
||||
if (!container || container.style.display === 'none') return;
|
||||
|
||||
const serial = document.getElementById('search-serial').value;
|
||||
const dateFrom = document.getElementById('search-date-from').value;
|
||||
const dateTo = document.getElementById('search-date-to').value;
|
||||
const dateFrom = getDatetime('search-date-from', 'search-time-from');
|
||||
const dateTo = getDatetime('search-date-to', 'search-time-to');
|
||||
const v = VIEWS[currentView];
|
||||
|
||||
// 全部视图不适用,用 B2 或 B4
|
||||
@@ -416,8 +425,8 @@ searchData(1);
|
||||
|
||||
function confirmDelete() {
|
||||
const serial = document.getElementById('search-serial').value;
|
||||
const dateFrom = document.getElementById('search-date-from').value;
|
||||
const dateTo = document.getElementById('search-date-to').value;
|
||||
const dateFrom = getDatetime('search-date-from', 'search-time-from');
|
||||
const dateTo = getDatetime('search-date-to', 'search-time-to');
|
||||
const v = VIEWS[currentView];
|
||||
const ds = v.data_source || '';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user