fix(web): 修复弹窗裁切/宽度与日期选择器
This commit is contained in:
@@ -23,35 +23,44 @@
|
||||
let isUploading = $state(false);
|
||||
let uploadResult: UploadResponse | null = $state(null);
|
||||
let errorMessage = $state('');
|
||||
|
||||
type StatTrend = 'up' | 'down';
|
||||
interface StatCard {
|
||||
title: string;
|
||||
value: string;
|
||||
change: string;
|
||||
trend: StatTrend;
|
||||
description: string;
|
||||
}
|
||||
|
||||
// 实时统计数据
|
||||
let stats = $state([
|
||||
let stats = $state<StatCard[]>([
|
||||
{
|
||||
title: '本月支出',
|
||||
value: '¥0.00',
|
||||
change: '+0%',
|
||||
trend: 'up' as const,
|
||||
trend: 'up',
|
||||
description: '加载中...'
|
||||
},
|
||||
{
|
||||
title: '本月收入',
|
||||
value: '¥0.00',
|
||||
change: '+0%',
|
||||
trend: 'up' as const,
|
||||
trend: 'up',
|
||||
description: '加载中...'
|
||||
},
|
||||
{
|
||||
title: '待复核',
|
||||
value: '0',
|
||||
change: '+0%',
|
||||
trend: 'up' as const,
|
||||
trend: 'up',
|
||||
description: '需要人工确认'
|
||||
},
|
||||
{
|
||||
title: '已处理账单',
|
||||
value: '0',
|
||||
change: '+0%',
|
||||
trend: 'up' as const,
|
||||
trend: 'up',
|
||||
description: '累计处理记录'
|
||||
},
|
||||
]);
|
||||
@@ -66,62 +75,49 @@
|
||||
const lastMonth = new Date(now.getFullYear(), now.getMonth() - 1, 1);
|
||||
const previousMonth = `${lastMonth.getFullYear()}-${String(lastMonth.getMonth() + 1).padStart(2, '0')}`;
|
||||
|
||||
console.log('Current month:', currentMonth);
|
||||
console.log('Previous month:', previousMonth);
|
||||
|
||||
// 获取月度统计数据
|
||||
const monthlyResponse = await fetchMonthlyStats();
|
||||
console.log('Monthly response:', monthlyResponse);
|
||||
const monthlyStats = monthlyResponse.data || [];
|
||||
console.log('Monthly stats:', monthlyStats);
|
||||
|
||||
// 获取待复核统计
|
||||
const reviewResponse = await fetchReviewStats();
|
||||
console.log('Review response:', reviewResponse);
|
||||
const reviewTotal = reviewResponse.data?.total || 0;
|
||||
console.log('Review total:', reviewTotal);
|
||||
|
||||
// 获取已处理账单数量
|
||||
const billsResponse = await fetchBills({ page_size: 1 });
|
||||
console.log('Bills response:', billsResponse);
|
||||
const billTotal = billsResponse.data?.total || 0;
|
||||
console.log('Bill total:', billTotal);
|
||||
|
||||
// 提取当月和上月的数据
|
||||
const currentData = monthlyStats.find(m => m.month === currentMonth);
|
||||
const previousData = monthlyStats.find(m => m.month === previousMonth);
|
||||
|
||||
console.log('Current data:', currentData);
|
||||
console.log('Previous data:', previousData);
|
||||
|
||||
// 计算支出变化百分比
|
||||
const currentExpense = currentData?.expense || 0;
|
||||
const previousExpense = previousData?.expense || 0;
|
||||
const expenseChange = previousExpense > 0
|
||||
? ((currentExpense - previousExpense) / previousExpense * 100).toFixed(1)
|
||||
? (currentExpense - previousExpense) / previousExpense * 100
|
||||
: 0;
|
||||
const expenseTrend = parseFloat(expenseChange.toString()) >= 0 ? 'up' : 'down';
|
||||
const expenseTrend: StatTrend = expenseChange >= 0 ? 'up' : 'down';
|
||||
|
||||
// 计算收入变化百分比
|
||||
const currentIncome = currentData?.income || 0;
|
||||
const previousIncome = previousData?.income || 0;
|
||||
const incomeChange = previousIncome > 0
|
||||
? ((currentIncome - previousIncome) / previousIncome * 100).toFixed(1)
|
||||
? (currentIncome - previousIncome) / previousIncome * 100
|
||||
: 0;
|
||||
const incomeTrend = parseFloat(incomeChange.toString()) >= 0 ? 'up' : 'down';
|
||||
const incomeTrend: StatTrend = incomeChange >= 0 ? 'up' : 'down';
|
||||
|
||||
// 格式化金额
|
||||
const formatAmount = (amount: number) => {
|
||||
return `¥${amount.toFixed(2)}`;
|
||||
};
|
||||
|
||||
const formatChange = (change: number | string) => {
|
||||
const changeNum = typeof change === 'string' ? parseFloat(change) : change;
|
||||
const sign = changeNum >= 0 ? '+' : '';
|
||||
return `${sign}${changeNum.toFixed(1)}%`;
|
||||
const formatChange = (change: number) => {
|
||||
const sign = change >= 0 ? '+' : '';
|
||||
return `${sign}${change.toFixed(1)}%`;
|
||||
};
|
||||
|
||||
const newStats = [
|
||||
const newStats: StatCard[] = [
|
||||
{
|
||||
title: '本月支出',
|
||||
value: formatAmount(currentExpense),
|
||||
@@ -140,19 +136,18 @@
|
||||
title: '待复核',
|
||||
value: reviewTotal.toString(),
|
||||
change: '+0%',
|
||||
trend: 'up' as const,
|
||||
trend: 'up',
|
||||
description: '需要人工确认'
|
||||
},
|
||||
{
|
||||
title: '已处理账单',
|
||||
value: billTotal.toString(),
|
||||
change: '+0%',
|
||||
trend: 'up' as const,
|
||||
trend: 'up',
|
||||
description: '累计处理记录'
|
||||
},
|
||||
];
|
||||
|
||||
console.log('New stats:', newStats);
|
||||
|
||||
stats = newStats;
|
||||
} catch (err) {
|
||||
console.error('Failed to load stats:', err);
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
|
||||
let isLoading = $state(true);
|
||||
let errorMessage = $state('');
|
||||
let reviewStats: ReviewData | null = $state(null);
|
||||
let allBills: CleanedBill[] = $state([]);
|
||||
let reviewStats = $state<ReviewData | null>(null);
|
||||
let allBills = $state<CleanedBill[]>([]);
|
||||
let filterLevel = $state<'all' | 'HIGH' | 'LOW'>('all');
|
||||
|
||||
onMount(() => {
|
||||
|
||||
Reference in New Issue
Block a user