fix: 里程环比改为真实值(与前一天对比)
- 后端缓存刷新时查询前一天总里程(yesterdayTotal) - 前端计算真实环比:(今日-昨日)/昨日*100% - 上涨显示蓝色↑,下跌显示红色↓ - 昨日无数据时不显示环比 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -106,7 +106,7 @@ export default function MonitoringView() {
|
||||
const [appliedMileageRange, setAppliedMileageRange] = useState({ min: '', max: '' });
|
||||
|
||||
const [vehicles, setVehicles] = useState<MonitoringVehicle[]>([]);
|
||||
const [stats, setStats] = useState<MonitoringStats>({ totalToday: 0, totalAll: 0, vehicleCount: 0 });
|
||||
const [stats, setStats] = useState<MonitoringStats>({ totalToday: 0, totalAll: 0, vehicleCount: 0, yesterdayTotal: 0 });
|
||||
const [filterOptions, setFilterOptions] = useState<MonitoringFilters>({ departments: [], customers: [], plates: [], projects: [], entities: [] });
|
||||
const [total, setTotal] = useState(0);
|
||||
const [page, setPage] = useState(1);
|
||||
@@ -713,7 +713,11 @@ export default function MonitoringView() {
|
||||
</div>
|
||||
<div className="text-2xl font-black tracking-tighter flex items-baseline gap-1">
|
||||
{Math.round(sortBy === 'today' ? stats.totalToday : stats.totalAll).toLocaleString()}
|
||||
{sortBy === 'today' && <span className="text-blue-400 text-[10px] font-bold">{'\u2191'}12%</span>}
|
||||
{sortBy === 'today' && stats.yesterdayTotal > 0 && (() => {
|
||||
const change = ((stats.totalToday - stats.yesterdayTotal) / stats.yesterdayTotal) * 100;
|
||||
const isUp = change >= 0;
|
||||
return <span className={`text-[10px] font-bold ${isUp ? 'text-blue-400' : 'text-rose-400'}`}>{isUp ? '\u2191' : '\u2193'}{Math.abs(change).toFixed(1)}%</span>;
|
||||
})()}
|
||||
</div>
|
||||
<div className="absolute -right-4 -bottom-4 w-12 h-12 bg-blue-500/10 rounded-full blur-xl"></div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user