增加序号,配置导出,导入,求和采集数据导出

This commit is contained in:
2026-07-14 16:05:43 +08:00
parent fdd232989b
commit cc2214ccf6
9 changed files with 587 additions and 42 deletions

View File

@@ -77,6 +77,7 @@ function renderSumDataList(rawList) {
split_type: item.split_type,
split_value: item.split_value,
split_name: item.split_name,
sort_order: item.sort_order || 9999,
total_orders: item.total_orders || 0,
data_source: item.data_source,
remark: item.remark || '',
@@ -97,7 +98,7 @@ function renderSumDataList(rawList) {
sumDataGroupedList = Object.values(groupMap).sort((a, b) => {
if (a.report_date !== b.report_date) return b.report_date.localeCompare(a.report_date);
return (a.config_name || '').localeCompare(b.config_name || '');
return (a.sort_order || 9999) - (b.sort_order || 9999);
});
// 分页处理
@@ -176,12 +177,21 @@ function renderSumDataPagination(total) {
// 加载求和数据
async function loadSumData(page = 1) {
sumDataCurrentPage = page;
const reportDate = document.getElementById('sum-data-report-date').value;
const startDate = document.getElementById('sum-data-start-date').value;
const endDate = document.getElementById('sum-data-end-date').value;
const configName = document.getElementById('sum-data-config-name').value;
const dataSource = document.getElementById('sum-data-source').value;
const params = new URLSearchParams();
params.append('page', '1');
params.append('page_size', '5000');
if (startDate) params.append('start_date', startDate);
if (endDate) params.append('end_date', endDate);
if (configName) params.append('config_name', configName);
if (dataSource) params.append('data_source', dataSource);
try {
const response = await fetch(`/api/sum-data?page=1&page_size=5000&report_date=${encodeURIComponent(reportDate)}&config_name=${encodeURIComponent(configName)}&data_source=${encodeURIComponent(dataSource)}`);
const response = await fetch(`/api/sum-data?${params.toString()}`);
const result = await response.json();
if (result.success) {
renderSumDataList(result.data.list || []);
@@ -195,7 +205,8 @@ async function loadSumData(page = 1) {
// 清除查询
function clearSumDataQuery() {
document.getElementById('sum-data-report-date').value = '';
document.getElementById('sum-data-start-date').value = '';
document.getElementById('sum-data-end-date').value = '';
document.getElementById('sum-data-config-name').value = '';
document.getElementById('sum-data-source').value = '';
loadSumData(1);
@@ -525,3 +536,33 @@ async function batchDeleteSumData() {
alert('删除失败: ' + error.message);
}
}
async function exportSumData() {
const startDate = document.getElementById('sum-data-start-date').value;
const endDate = document.getElementById('sum-data-end-date').value;
const configName = document.getElementById('sum-data-config-name').value;
const dataSource = document.getElementById('sum-data-source').value;
const params = new URLSearchParams();
if (startDate) params.append('start_date', startDate);
if (endDate) params.append('end_date', endDate);
if (configName) params.append('keyword', configName);
if (dataSource) params.append('data_source', dataSource);
try {
const response = await fetch(`/api/sum-data/export?${params.toString()}`);
const result = await response.json();
if (result.success) {
if (result.total === 0) {
alert('没有可导出的数据');
return;
}
window.open(result.file_path, '_blank');
} else {
alert('导出失败: ' + (result.message || '未知错误'));
}
} catch (error) {
alert('导出失败: ' + error.message);
}
}