diff --git a/edc-web/app/models.py b/edc-web/app/models.py index 161e2b2..485f087 100644 --- a/edc-web/app/models.py +++ b/edc-web/app/models.py @@ -168,10 +168,10 @@ def get_test_data(page: int = 1, per_page: int = 20, params.append(f"%{serial}%") if date_from: where.append("t.create_time >= %s") - params.append(date_from) + params.append(date_from if len(date_from) > 10 else date_from) if date_to: where.append("t.create_time <= %s") - params.append(date_to + " 23:59:59") + params.append(date_to if len(date_to) > 10 else date_to + " 23:59:59") if test_mode: where.append("t.test_mode = %s") params.append(int(test_mode)) @@ -223,10 +223,10 @@ def get_all_test_data_for_export(serial: str = "", date_from: str = "", params.append(f"%{serial}%") if date_from: where.append("t.create_time >= %s") - params.append(date_from) + params.append(date_from if len(date_from) > 10 else date_from) if date_to: where.append("t.create_time <= %s") - params.append(date_to + " 23:59:59") + params.append(date_to if len(date_to) > 10 else date_to + " 23:59:59") if test_mode: where.append("t.test_mode = %s") params.append(int(test_mode)) @@ -602,10 +602,10 @@ def delete_test_data(serial: str = "", date_from: str = "", params.append(f"%{serial}%") if date_from: where.append("t.create_time >= %s") - params.append(date_from) + params.append(date_from if len(date_from) > 10 else date_from) if date_to: where.append("t.create_time <= %s") - params.append(date_to + " 23:59:59") + params.append(date_to if len(date_to) > 10 else date_to + " 23:59:59") if data_source: where.append("t.data_source = %s") params.append(data_source) diff --git a/edc-web/app/static/js/test_data.js b/edc-web/app/static/js/test_data.js index 89330a8..eec7124 100644 --- a/edc-web/app/static/js/test_data.js +++ b/edc-web/app/static/js/test_data.js @@ -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 || ''; diff --git a/edc-web/app/templates/test_data.html b/edc-web/app/templates/test_data.html index 04a3692..74eeb60 100644 --- a/edc-web/app/templates/test_data.html +++ b/edc-web/app/templates/test_data.html @@ -16,10 +16,12 @@