feat(platform-web): show vehicle analysis scope
This commit is contained in:
@@ -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
|
||||
</Button>
|
||||
)}
|
||||
/>
|
||||
<div className="vp-scope-bar">
|
||||
<span className="vp-scope-label">当前车辆:{currentVehicleKeyword || '-'}</span>
|
||||
<Tag color={currentProtocol ? 'blue' : 'green'}>当前来源:{currentProtocol || '全部来源'}</Tag>
|
||||
<Typography.Text type="tertiary">历史位置和 RAW 帧按当前车辆与来源范围查询。</Typography.Text>
|
||||
</div>
|
||||
<Card bordered>
|
||||
<Form key={`${filters.keyword ?? ''}-${filters.protocol ?? ''}-${filters.includeFields ? 'fields' : 'light'}`} initValues={filters} layout="horizontal" onSubmit={(values) => submit(values)}>
|
||||
<Form.Input field="keyword" label="车辆关键词" placeholder="VIN / 车牌 / 手机号" style={{ width: 260 }} />
|
||||
|
||||
@@ -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
|
||||
</Button>
|
||||
)}
|
||||
/>
|
||||
<div className="vp-scope-bar">
|
||||
<span className="vp-scope-label">当前车辆:{currentVehicleKeyword || '-'}</span>
|
||||
<Tag color={currentProtocol ? 'blue' : 'green'}>当前来源:{currentProtocol || '全部来源'}</Tag>
|
||||
<Typography.Text type="tertiary">里程统计按当前车辆与来源范围汇总。</Typography.Text>
|
||||
</div>
|
||||
<Card bordered>
|
||||
<Form key={filters.keyword ?? ''} initValues={filters} layout="horizontal" onSubmit={(values) => {
|
||||
const nextFilters = values as Record<string, string>;
|
||||
|
||||
@@ -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(<App />);
|
||||
|
||||
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 () => {
|
||||
|
||||
Reference in New Issue
Block a user