feat: 每日趋势图使用全部数据,不受日期筛选控制
This commit is contained in:
@@ -53,6 +53,7 @@
|
||||
let isLoading = $state(false);
|
||||
let errorMessage = $state('');
|
||||
let records: CleanedBill[] = $state([]);
|
||||
let allRecords: CleanedBill[] = $state([]); // 全部账单数据(不受日期筛选,用于每日趋势图)
|
||||
let monthlyStats: MonthlyStat[] = $state([]); // 月度统计(全部数据)
|
||||
let isDemo = $state(false);
|
||||
let serverAvailable = $state(true);
|
||||
@@ -88,6 +89,7 @@
|
||||
|
||||
// 派生分析数据
|
||||
let analysisRecords = $derived(isDemo ? demoRecords : toAnalysisRecords(records));
|
||||
let allAnalysisRecords = $derived(isDemo ? demoRecords : toAnalysisRecords(allRecords)); // 全部数据用于每日趋势图
|
||||
let categoryStats = $derived(calculateCategoryStats(analysisRecords));
|
||||
let dailyExpenseData = $derived(calculateDailyExpenseData(analysisRecords));
|
||||
let totalStats = $derived(calculateTotalStats(analysisRecords));
|
||||
@@ -122,13 +124,14 @@
|
||||
return;
|
||||
}
|
||||
|
||||
// 并行获取数据:筛选后的账单 + 全部月度统计
|
||||
const [billsResponse, monthlyResponse] = await Promise.all([
|
||||
// 并行获取数据:筛选后的账单 + 全部账单 + 全部月度统计
|
||||
const [billsResponse, allBillsResponse, monthlyResponse] = await Promise.all([
|
||||
fetchBills({
|
||||
page_size: 10000,
|
||||
start_date: toDateString(startYear, startMonth, startDay),
|
||||
end_date: toDateString(endYear, endMonth, endDay),
|
||||
}),
|
||||
fetchBills({ page_size: 10000 }), // 获取全部数据,不传日期筛选
|
||||
fetchMonthlyStats(),
|
||||
]);
|
||||
|
||||
@@ -142,6 +145,11 @@
|
||||
errorMessage = billsResponse.message || '加载失败';
|
||||
}
|
||||
|
||||
// 处理全部账单数据(用于每日趋势图)
|
||||
if (allBillsResponse.result && allBillsResponse.data) {
|
||||
allRecords = allBillsResponse.data.bills || [];
|
||||
}
|
||||
|
||||
// 处理月度统计数据
|
||||
if (monthlyResponse.result && monthlyResponse.data) {
|
||||
monthlyStats = monthlyResponse.data;
|
||||
@@ -246,8 +254,8 @@
|
||||
<!-- 总览卡片 -->
|
||||
<OverviewCards {totalStats} records={analysisRecords} />
|
||||
|
||||
<!-- 每日支出趋势图(按分类堆叠) -->
|
||||
<DailyTrendChart records={analysisRecords} categories={sortedCategories()} />
|
||||
<!-- 每日支出趋势图(按分类堆叠) - 使用全部数据 -->
|
||||
<DailyTrendChart records={allAnalysisRecords} categories={sortedCategories()} />
|
||||
|
||||
<div class="grid gap-6 lg:grid-cols-2">
|
||||
<!-- 分类支出排行 -->
|
||||
|
||||
Reference in New Issue
Block a user