1,修复驿来特没有数据,只特来电有,不生成报表的问题。
2,增加历史记录,每页显示多少条的功能。
This commit is contained in:
@@ -1,3 +1,20 @@
|
||||
let historyStartDate = '';
|
||||
let historyEndDate = '';
|
||||
let historyStatus = '';
|
||||
let historyPageSize = 10;
|
||||
|
||||
// 每页显示条数变化
|
||||
function onHistoryPageSizeChange() {
|
||||
historyPageSize = parseInt(document.getElementById('history-page-size').value) || 10;
|
||||
loadHistoryWithDate(1);
|
||||
}
|
||||
|
||||
// 状态筛选变化
|
||||
function onHistoryStatusChange() {
|
||||
historyStatus = document.getElementById('history-status-filter').value;
|
||||
loadHistoryWithDate(1);
|
||||
}
|
||||
|
||||
// 批量下载历史记录
|
||||
async function batchDownloadHistory() {
|
||||
const checkboxes = document.querySelectorAll('.history-checkbox:checked');
|
||||
@@ -18,18 +35,19 @@ async function batchDownloadHistory() {
|
||||
function queryHistoryByDate() {
|
||||
const startDate = document.getElementById('history-start-date').value;
|
||||
const endDate = document.getElementById('history-end-date').value;
|
||||
if (!startDate && !endDate) {
|
||||
alert('请至少选择一个日期');
|
||||
return;
|
||||
}
|
||||
// 重新加载历史记录,带上日期参数
|
||||
loadHistoryWithDate(1, startDate, endDate);
|
||||
historyStartDate = startDate;
|
||||
historyEndDate = endDate;
|
||||
loadHistoryWithDate(1);
|
||||
}
|
||||
|
||||
// 清除日期查询
|
||||
function clearDateQuery() {
|
||||
// 清除筛选
|
||||
function clearHistoryFilter() {
|
||||
document.getElementById('history-status-filter').value = '';
|
||||
document.getElementById('history-start-date').value = '';
|
||||
document.getElementById('history-end-date').value = '';
|
||||
historyStatus = '';
|
||||
historyStartDate = '';
|
||||
historyEndDate = '';
|
||||
loadHistory(1);
|
||||
}
|
||||
|
||||
@@ -161,7 +179,7 @@ function renderHistory(list) {
|
||||
}
|
||||
|
||||
// 渲染分页控件
|
||||
function renderPagination(page, pageSize, total) {
|
||||
function renderPagination(page, total, pageSize) {
|
||||
const container = document.getElementById('history-pagination');
|
||||
if (!container) return;
|
||||
|
||||
@@ -178,8 +196,21 @@ function renderPagination(page, pageSize, total) {
|
||||
html += `<button onclick="loadHistoryWithDate(${page - 1})">上一页</button>`;
|
||||
}
|
||||
|
||||
// 页码
|
||||
for (let i = 1; i <= totalPages; i++) {
|
||||
// 页码(最多显示7个页码)
|
||||
let startPage = Math.max(1, page - 3);
|
||||
let endPage = Math.min(totalPages, startPage + 6);
|
||||
if (endPage - startPage < 6) {
|
||||
startPage = Math.max(1, endPage - 6);
|
||||
}
|
||||
|
||||
if (startPage > 1) {
|
||||
html += `<button onclick="loadHistoryWithDate(1)">1</button>`;
|
||||
if (startPage > 2) {
|
||||
html += `<span style="padding: 0 5px;">...</span>`;
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = startPage; i <= endPage; i++) {
|
||||
if (i === page) {
|
||||
html += `<button class="active">${i}</button>`;
|
||||
} else {
|
||||
@@ -187,6 +218,13 @@ function renderPagination(page, pageSize, total) {
|
||||
}
|
||||
}
|
||||
|
||||
if (endPage < totalPages) {
|
||||
if (endPage < totalPages - 1) {
|
||||
html += `<span style="padding: 0 5px;">...</span>`;
|
||||
}
|
||||
html += `<button onclick="loadHistoryWithDate(${totalPages})">${totalPages}</button>`;
|
||||
}
|
||||
|
||||
// 下一页
|
||||
if (page < totalPages) {
|
||||
html += `<button onclick="loadHistoryWithDate(${page + 1})">下一页</button>`;
|
||||
@@ -201,18 +239,19 @@ async function loadHistory(page = 1) {
|
||||
loadHistoryWithDate(page);
|
||||
}
|
||||
|
||||
async function loadHistoryWithDate(page, startDate, endDate) {
|
||||
async function loadHistoryWithDate(page) {
|
||||
try {
|
||||
let url = `/api/report/history?page=${page}&page_size=10`;
|
||||
if (startDate) url += `&start_date=${startDate}`;
|
||||
if (endDate) url += `&end_date=${endDate}`;
|
||||
let url = `/api/report/history?page=${page}&page_size=${historyPageSize}`;
|
||||
if (historyStatus) url += `&status=${historyStatus}`;
|
||||
if (historyStartDate) url += `&start_date=${historyStartDate}`;
|
||||
if (historyEndDate) url += `&end_date=${historyEndDate}`;
|
||||
const response = await fetch(url);
|
||||
const result = await response.json();
|
||||
if (result.success) {
|
||||
renderHistory(result.data.list);
|
||||
renderPagination(result.data.total, page);
|
||||
renderPagination(result.data.page, result.data.total, result.data.page_size);
|
||||
} else {
|
||||
alert('加载失败: ' + (result.error || '未知错误'));
|
||||
alert('加载失败: ' + (result.error || result.message || '未知错误'));
|
||||
}
|
||||
} catch (error) {
|
||||
alert('加载失败: ' + error.message);
|
||||
@@ -243,7 +282,7 @@ async function deleteHistory(id) {
|
||||
const result = await response.json();
|
||||
if (result.success) {
|
||||
alert('删除成功');
|
||||
loadHistory();
|
||||
loadHistoryWithDate();
|
||||
} else {
|
||||
alert('删除失败: ' + result.message);
|
||||
}
|
||||
@@ -275,7 +314,7 @@ async function batchDeleteHistory() {
|
||||
const result = await response.json();
|
||||
if (result.success) {
|
||||
alert(result.message);
|
||||
loadHistory();
|
||||
loadHistoryWithDate();
|
||||
} else {
|
||||
alert('删除失败: ' + result.message);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user