This commit is contained in:
SunCheng
2026-02-10 17:49:19 +08:00
parent 3e18283e52
commit d052ae5197
104 changed files with 10369 additions and 3000 deletions

View File

@@ -137,7 +137,17 @@ import ExpenseCategoryCard from './modules/ExpenseCategoryCard.vue'
import IncomeNoneCategoryCard from './modules/IncomeNoneCategoryCard.vue'
import CategoryBillPopup from '@/components/CategoryBillPopup.vue'
import GlassBottomNav from '@/components/GlassBottomNav.vue'
import { getMonthlyStatistics, getCategoryStatistics, getCategoryStatisticsByDateRange, getDailyStatistics, getTrendStatistics, getWeeklyStatistics, getRangeStatistics } from '@/api/statistics'
import {
// 新统一接口
getDailyStatisticsByRange,
getSummaryByRange,
getCategoryStatisticsByRange,
getTrendStatistics,
// 旧接口(兼容性保留)
getMonthlyStatistics,
getCategoryStatistics,
getDailyStatistics
} from '@/api/statistics'
import { useMessageStore } from '@/stores/message'
import { getCssVar } from '@/utils/theme'
@@ -351,12 +361,15 @@ const loadWeeklyData = async () => {
// 周统计 - 计算当前周的开始和结束日期
const weekStart = getWeekStartDate(currentDate.value)
const weekEnd = new Date(weekStart)
weekEnd.setDate(weekStart.getDate() + 6)
weekEnd.setDate(weekStart.getDate() + 7) // 修改:+7 天,因为 endDate 是不包含的
// 获取周统计汇总
const weekSummaryResult = await getRangeStatistics({
startDate: formatDateToString(weekStart),
endDate: formatDateToString(weekEnd)
const startDateStr = formatDateToString(weekStart)
const endDateStr = formatDateToString(weekEnd)
// 使用新的统一接口获取周统计汇总
const weekSummaryResult = await getSummaryByRange({
startDate: startDateStr,
endDate: endDateStr
})
if (weekSummaryResult?.success && weekSummaryResult.data) {
@@ -369,10 +382,10 @@ const loadWeeklyData = async () => {
}
}
// 获取周内每日统计
const dailyResult = await getWeeklyStatistics({
startDate: formatDateToString(weekStart),
endDate: formatDateToString(weekEnd)
// 使用新的统一接口获取周内每日统计
const dailyResult = await getDailyStatisticsByRange({
startDate: startDateStr,
endDate: endDateStr
})
if (dailyResult?.success && dailyResult.data) {
@@ -392,23 +405,23 @@ const loadWeeklyData = async () => {
const loadCategoryStatistics = async (year, month) => {
try {
const categoryYear = year
const categoryMonth = month
// 如果是年度统计month应该传0表示查询全年
const categoryMonth = currentPeriod.value === 'year' ? 0 : month
// 对于周统计,使用日期范围进行分类统计
if (currentPeriod.value === 'week') {
const weekStart = getWeekStartDate(currentDate.value)
const weekEnd = new Date(weekStart)
weekEnd.setDate(weekStart.getDate() + 6)
weekEnd.setHours(23, 59, 59, 999)
weekEnd.setDate(weekStart.getDate() + 7) // 修改:+7 天,因为 endDate 是不包含的
const startDateStr = formatDateToString(weekStart)
const endDateStr = formatDateToString(weekEnd)
// 并发加载支出、收入和不计收支分类(使用日期范围)
// 使用新的统一接口并发加载支出、收入和不计收支分类
const [expenseResult, incomeResult, noneResult] = await Promise.allSettled([
getCategoryStatisticsByDateRange({ startDate: startDateStr, endDate: endDateStr, type: 0 }),
getCategoryStatisticsByDateRange({ startDate: startDateStr, endDate: endDateStr, type: 1 }),
getCategoryStatisticsByDateRange({ startDate: startDateStr, endDate: endDateStr, type: 2 })
getCategoryStatisticsByRange({ startDate: startDateStr, endDate: endDateStr, type: 0 }),
getCategoryStatisticsByRange({ startDate: startDateStr, endDate: endDateStr, type: 1 }),
getCategoryStatisticsByRange({ startDate: startDateStr, endDate: endDateStr, type: 2 })
])
// 获取图表颜色配置