feat(platform): expose source slots in vehicle service
This commit is contained in:
@@ -53,6 +53,7 @@ export interface VehicleCoverageRow {
|
||||
oem: string;
|
||||
protocols: string[];
|
||||
missingProtocols: string[];
|
||||
sourceStatus: VehicleSourceStatus[];
|
||||
sourceCount: number;
|
||||
onlineSourceCount: number;
|
||||
online: boolean;
|
||||
|
||||
@@ -33,6 +33,16 @@ function sourceEvidenceText(row: VehicleCoverageRow) {
|
||||
return `${row.onlineSourceCount}/${row.sourceCount} 来源在线`;
|
||||
}
|
||||
|
||||
function sourceStatusLabel(source: { online: boolean; hasRealtime: boolean; lastSeen: string }) {
|
||||
if (source.online) {
|
||||
return { text: '在线', color: 'green' as const };
|
||||
}
|
||||
if (source.hasRealtime || source.lastSeen) {
|
||||
return { text: '离线', color: 'orange' as const };
|
||||
}
|
||||
return { text: '未接入', color: 'grey' as const };
|
||||
}
|
||||
|
||||
function sourceConsistencyAction(row: VehicleCoverageRow, onFilter: (filters: Record<string, string>) => void) {
|
||||
const consistency = row.sourceConsistency;
|
||||
if (!consistency) {
|
||||
@@ -148,10 +158,13 @@ export function Vehicles({
|
||||
},
|
||||
{
|
||||
title: '来源证据',
|
||||
width: 240,
|
||||
width: 300,
|
||||
render: (_: unknown, row: VehicleCoverageRow) => (
|
||||
<Space spacing={4} wrap>
|
||||
{row.protocols.map((protocol) => <Tag key={protocol} color="blue">{protocol}</Tag>)}
|
||||
{(row.sourceStatus?.length ? row.sourceStatus : row.protocols.map((protocol) => ({ protocol, online: false, hasRealtime: true, lastSeen: row.lastSeen }))).map((source) => {
|
||||
const status = sourceStatusLabel(source);
|
||||
return <Tag key={source.protocol} color={status.color}>{source.protocol} {status.text}</Tag>;
|
||||
})}
|
||||
</Space>
|
||||
)
|
||||
},
|
||||
|
||||
@@ -289,6 +289,12 @@ test('shows vehicle service result summary on vehicle list filters', async () =>
|
||||
phone: '13307795425',
|
||||
oem: 'G7s',
|
||||
protocols: ['GB32960', 'JT808'],
|
||||
missingProtocols: ['YUTONG_MQTT'],
|
||||
sourceStatus: [
|
||||
{ protocol: 'GB32960', online: true, lastSeen: '2026-07-03 20:12:10', hasRealtime: true, hasHistory: false, hasRaw: false, hasMileage: false },
|
||||
{ protocol: 'JT808', online: false, lastSeen: '2026-07-03 20:10:00', hasRealtime: true, hasHistory: false, hasRaw: false, hasMileage: false },
|
||||
{ protocol: 'YUTONG_MQTT', online: false, lastSeen: '', hasRealtime: false, hasHistory: false, hasRaw: false, hasMileage: false }
|
||||
],
|
||||
sourceCount: 2,
|
||||
onlineSourceCount: 1,
|
||||
online: true,
|
||||
@@ -334,6 +340,9 @@ test('shows vehicle service result summary on vehicle list filters', async () =>
|
||||
expect(screen.getByText('待绑定')).toBeInTheDocument();
|
||||
expect(screen.getByText('VIN-MULTI-001')).toBeInTheDocument();
|
||||
expect(screen.getAllByText('来源证据').length).toBeGreaterThanOrEqual(1);
|
||||
expect(screen.getByText('GB32960 在线')).toBeInTheDocument();
|
||||
expect(screen.getByText('JT808 离线')).toBeInTheDocument();
|
||||
expect(screen.getByText('YUTONG_MQTT 未接入')).toBeInTheDocument();
|
||||
expect(screen.getByText('1/2 来源在线')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user