Files
guilixu-admin/.workbuddy/memory/2026-07-14.md
赵忠林 efef3a811f fix(dashboard): 修复统计数据与待处理事项获取逻辑
- 统一使用 statusFilter 查询待发货和退款/售后订单数,提高接口一致性
- 修正今日订单数统计逻辑,改为使用创建时间范围查询
- 将 dashboard 核心数据状态改为 computed,确保响应式更新
- 在统计模块调用接口时添加分页参数,减少数据传输量
- 优化今日销售额数据来源,使用 cmsStatistics 中的真实数据
- 增加异常捕获日志,提示具体错误信息,提高调试效率
2026-07-14 02:55:04 +08:00

28 lines
1.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

## 2026-07-14 修复 Dashboard 统计数据问题
### 问题描述
用户反馈 `/shop/dashboard` 页面所有统计数据都显示为 0包括用户总数、订单总数、总营业额、运行天数、今日数据概况等。
### 修复内容
#### 1. 修复 `src/store/modules/statistics.ts`
- 添加了 `todaySales``todayOrders``todayUsers``cmsStatistics` 表数据中提取的逻辑
-`fetchStatistics` 中传入 `page: 1, limit: 1` 参数,减少不必要的数据传输
- 确保在没有 `cmsStatistics` 记录时,仍然能使用基础统计数据(用户总数、订单总数、总销售额)
#### 2. 修复 `src/views/shop/dashboard/index.vue`
-`coreStats``todayStats``todoItems``reactive` 改为 `computed`,确保数据响应式更新
- 修复了今日数据使用错误来源的问题:
- 之前:`todayStats.salesAmount = totalSales.value`(使用总销售额作为今日销售额)
- 现在:`todayStats.salesAmount = todaySales.value`(使用真正的今日销售额)
- 添加了从 API 获取待处理事项数据的逻辑:
- 待发货订单:`statusFilter: 1` 查询
- 退款/售后:`statusFilter: 6` 查询
- 今日订单数:通过 `createTimeStart``createTimeEnd` 查询
### 注意事项
如果后端 `cmsStatistics` 表中没有今日数据todaySales、todayOrders、todayUsers今日数据仍会显示为 0。建议
1. 检查后端是否有定时任务更新 `cmsStatistics`
2. 或手动触发统计数据更新
3. 检查浏览器控制台是否有 API 调用失败的错误日志