diff --git a/vehicle-data-platform/apps/web/src/pages/History.tsx b/vehicle-data-platform/apps/web/src/pages/History.tsx index 051634d3..5e9c4fd0 100644 --- a/vehicle-data-platform/apps/web/src/pages/History.tsx +++ b/vehicle-data-platform/apps/web/src/pages/History.tsx @@ -1,4 +1,4 @@ -import { Button, Card, Form, Select, SideSheet, Space, Table, Tabs, Toast, Typography } from '@douyinfe/semi-ui'; +import { Button, Card, Form, Select, SideSheet, Space, Table, Tabs, Tag, Toast, Typography } from '@douyinfe/semi-ui'; import { IconRefresh, IconSearch } from '@douyinfe/semi-icons'; import { useEffect, useMemo, useState } from 'react'; import { api, type RawFrameQuery } from '../api/client'; @@ -132,6 +132,11 @@ export function History({ initialVin, initialProtocol, onOpenVehicle }: { initia )} /> +
+ 当前车辆:{currentVehicleKeyword || '-'} + 当前来源:{currentProtocol || '全部来源'} + 历史位置和 RAW 帧按当前车辆与来源范围查询。 +
submit(values)}> diff --git a/vehicle-data-platform/apps/web/src/pages/Mileage.tsx b/vehicle-data-platform/apps/web/src/pages/Mileage.tsx index 34e8a0ba..b8184c22 100644 --- a/vehicle-data-platform/apps/web/src/pages/Mileage.tsx +++ b/vehicle-data-platform/apps/web/src/pages/Mileage.tsx @@ -1,4 +1,4 @@ -import { Button, Card, Form, Select, Space, Table, Tag, Toast } from '@douyinfe/semi-ui'; +import { Button, Card, Form, Select, Space, Table, Tag, Toast, Typography } from '@douyinfe/semi-ui'; import { useEffect, useState } from 'react'; import { api } from '../api/client'; import type { DailyMileageRow, MileageSummary } from '../api/types'; @@ -79,6 +79,11 @@ export function Mileage({ initialVin, initialProtocol, onOpenVehicle }: { initia )} /> +
+ 当前车辆:{currentVehicleKeyword || '-'} + 当前来源:{currentProtocol || '全部来源'} + 里程统计按当前车辆与来源范围汇总。 +
{ const nextFilters = values as Record; diff --git a/vehicle-data-platform/apps/web/src/test/App.test.tsx b/vehicle-data-platform/apps/web/src/test/App.test.tsx index 1bb86380..a345d7e5 100644 --- a/vehicle-data-platform/apps/web/src/test/App.test.tsx +++ b/vehicle-data-platform/apps/web/src/test/App.test.tsx @@ -938,6 +938,48 @@ test('applies protocol from shareable history hash to API requests', async () => method: 'POST', body: expect.stringContaining('"protocol":"JT808"') })); + expect(screen.getByText('当前车辆:粤AG18312')).toBeInTheDocument(); + expect(screen.getByText('当前来源:JT808')).toBeInTheDocument(); +}); + +test('shows vehicle and source scope on mileage hash', async () => { + window.history.replaceState(null, '', '/#/mileage?keyword=VIN-MILEAGE-001&protocol=GB32960'); + vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => { + const path = String(input); + if (path.includes('/api/ops/health')) { + return { + ok: true, + json: async () => ({ + data: { linkHealth: [], kafkaLag: 0, redisOnlineKeys: 0, tdengineWritable: true, mysqlWritable: true, runtime: { requestTimeoutMs: 5000 } }, + traceId: 'trace-test', + timestamp: 1783094400000 + }) + } as Response; + } + if (path.includes('/api/mileage/summary')) { + return { + ok: true, + json: async () => ({ + data: { vehicleCount: 1, recordCount: 2, sourceCount: 1, totalMileageKm: 12.3, averageMileagePerVin: 12.3 }, + traceId: 'trace-test', + timestamp: 1783094400000 + }) + } as Response; + } + return { + ok: true, + json: async () => ({ + data: { items: [], total: 0, limit: 20, offset: 0 }, + traceId: 'trace-test', + timestamp: 1783094400000 + }) + } as Response; + }); + + render(); + + expect(await screen.findByText('当前车辆:VIN-MILEAGE-001')).toBeInTheDocument(); + expect(screen.getByText('当前来源:GB32960')).toBeInTheDocument(); }); test('keeps row protocol when opening vehicle service from history results', async () => {