feat(platform): add vehicle detail workbench
This commit is contained in:
@@ -450,6 +450,63 @@ export function VehicleDetail({
|
||||
}
|
||||
return actions;
|
||||
}, [activeProtocol, detail?.sourceStatus, displayLookupKey, hasResolvedVIN, missingProtocols, onOpenQuality, onOpenRealtime, onOpenVehicles, qualityCount, resolvedVIN]);
|
||||
const detailWorkbench = [
|
||||
{
|
||||
title: '实时定位',
|
||||
value: lastSeen,
|
||||
meta: evidenceSourceCount > 0 ? `${evidenceOnlineSourceCount}/${evidenceSourceCount} 来源在线` : '暂无来源',
|
||||
color: online ? 'green' as const : 'orange' as const,
|
||||
detail: '查看该车最新位置、速度、SOC、总里程和多来源实时字段。',
|
||||
disabled: !hasResolvedVIN,
|
||||
actions: [
|
||||
{ label: '查看实时', onClick: () => onOpenRealtime(resolvedVIN, activeProtocol) }
|
||||
]
|
||||
},
|
||||
{
|
||||
title: '轨迹回放',
|
||||
value: `${formatCompactNumber(overview?.historyCount ?? detail?.history?.total ?? 0)} 条历史`,
|
||||
meta: evidenceLocatedSourceCount > 0 ? `${evidenceLocatedSourceCount} 个位置来源` : '暂无位置',
|
||||
color: evidenceLocatedSourceCount > 0 ? 'blue' as const : 'grey' as const,
|
||||
detail: '回放历史轨迹,复核定位断点、速度变化和里程连续性。',
|
||||
disabled: !hasResolvedVIN,
|
||||
actions: [
|
||||
{ label: '打开轨迹', onClick: () => onOpenHistory(resolvedVIN, activeProtocol) }
|
||||
]
|
||||
},
|
||||
{
|
||||
title: 'RAW 证据',
|
||||
value: `${formatCompactNumber(overview?.rawCount ?? detail?.raw?.total ?? 0)} 帧`,
|
||||
meta: latestRaw?.frameType || '解析字段',
|
||||
color: (overview?.rawCount ?? detail?.raw?.total ?? 0) > 0 ? 'blue' as const : 'grey' as const,
|
||||
detail: '查看原始报文和解析字段,定位协议解析、来源转发和字段缺失问题。',
|
||||
disabled: !hasResolvedVIN,
|
||||
actions: [
|
||||
{ label: '查看 RAW', onClick: () => onOpenRaw(resolvedVIN, activeProtocol) }
|
||||
]
|
||||
},
|
||||
{
|
||||
title: '告警处置',
|
||||
value: `${qualityCount.toLocaleString()} 项`,
|
||||
meta: priorityQualityIssue ? qualityIssueLabel(priorityQualityIssue.issueType) : '暂无告警',
|
||||
color: qualityCount > 0 ? 'orange' as const : 'green' as const,
|
||||
detail: '进入告警队列,处理断链、VIN 缺失、字段缺失和来源不一致。',
|
||||
disabled: !hasResolvedVIN && qualityCount <= 0,
|
||||
actions: [
|
||||
{ label: '查看告警', onClick: () => onOpenQuality?.(qualityFiltersForCurrentVehicle()) }
|
||||
]
|
||||
},
|
||||
{
|
||||
title: '里程复核',
|
||||
value: `${formatCompactNumber(overview?.mileageCount ?? detail?.mileage?.total ?? 0)} 条统计`,
|
||||
meta: formatCompactNumber(evidenceMileageDelta, ' km 差异'),
|
||||
color: isFiniteNumber(evidenceMileageDelta) && Math.abs(evidenceMileageDelta) > 1 ? 'orange' as const : 'green' as const,
|
||||
detail: '核对统计口径,确认区间总值、每日里程与来源证据是否闭合。',
|
||||
disabled: !hasResolvedVIN,
|
||||
actions: [
|
||||
{ label: '查看里程', onClick: () => onOpenMileage(resolvedVIN, activeProtocol) }
|
||||
]
|
||||
}
|
||||
];
|
||||
const qualityTable = (
|
||||
<Table
|
||||
loading={loading}
|
||||
@@ -584,6 +641,36 @@ export function VehicleDetail({
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
<Card bordered title="单车服务作业台" style={{ marginTop: 16 }}>
|
||||
<div className="vp-workbench-grid">
|
||||
{detailWorkbench.map((item) => (
|
||||
<div key={item.title} className="vp-workbench-item">
|
||||
<div className="vp-workbench-head">
|
||||
<Tag color={item.color}>{item.title}</Tag>
|
||||
<Typography.Text type="secondary">{item.meta}</Typography.Text>
|
||||
</div>
|
||||
<div className="vp-workbench-value">{item.value}</div>
|
||||
<Typography.Text type="secondary">{item.detail}</Typography.Text>
|
||||
<Space wrap>
|
||||
{item.actions.map((action) => (
|
||||
<Button
|
||||
key={action.label}
|
||||
size="small"
|
||||
theme="light"
|
||||
type="primary"
|
||||
disabled={item.disabled || (item.title === '告警处置' && !onOpenQuality)}
|
||||
aria-label={`单车作业台 ${item.title} ${action.label}`}
|
||||
onClick={action.onClick}
|
||||
>
|
||||
{action.label}
|
||||
</Button>
|
||||
))}
|
||||
</Space>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
{overview || consistency ? (
|
||||
<Card bordered title="车辆服务证据链" style={{ marginTop: 16 }}>
|
||||
<div className="vp-evidence-grid">
|
||||
|
||||
@@ -83,7 +83,7 @@ test('exposes AMap operations shortcuts when map key is configured', async () =>
|
||||
render(<App />);
|
||||
|
||||
expect(await screen.findByText('地图就绪')).toBeInTheDocument();
|
||||
expect(screen.getByText('版本 platform-20260704153357')).toBeInTheDocument();
|
||||
expect(screen.getByText((content) => content.includes('platform-20260704153357'))).toBeInTheDocument();
|
||||
fireEvent.click(screen.getByRole('button', { name: '顶部地图态势' }));
|
||||
expect(window.location.hash).toBe('#/map');
|
||||
expect(await screen.findByRole('heading', { name: '实时地图' })).toBeInTheDocument();
|
||||
@@ -9869,8 +9869,21 @@ test('shows unified service overview on vehicle detail', async () => {
|
||||
render(<App />);
|
||||
|
||||
expect(await screen.findByText('车辆服务概览')).toBeInTheDocument();
|
||||
expect(screen.getByText('单车服务作业台')).toBeInTheDocument();
|
||||
expect(screen.getByText('实时定位')).toBeInTheDocument();
|
||||
expect(screen.getAllByText('轨迹回放').length).toBeGreaterThanOrEqual(1);
|
||||
expect(screen.getByText('RAW 证据')).toBeInTheDocument();
|
||||
expect(screen.getByText('告警处置')).toBeInTheDocument();
|
||||
expect(screen.getByText('里程复核')).toBeInTheDocument();
|
||||
expect(screen.getByText('2026-07-03 20:12:10')).toBeInTheDocument();
|
||||
expect(screen.getByText('12 条历史')).toBeInTheDocument();
|
||||
expect(screen.getByText('34 帧')).toBeInTheDocument();
|
||||
expect(screen.getAllByText('1 项').length).toBeGreaterThan(0);
|
||||
expect(screen.getByText('7 条统计')).toBeInTheDocument();
|
||||
expect(screen.getByText('2/3')).toBeInTheDocument();
|
||||
expect(screen.getByText('历史 12 / RAW 34 / 里程 7')).toBeInTheDocument();
|
||||
fireEvent.click(screen.getByRole('button', { name: '单车作业台 RAW 证据 查看 RAW' }));
|
||||
expect(window.location.hash).toBe('#/history-query?keyword=VIN001&tab=raw');
|
||||
});
|
||||
|
||||
test('opens quality governance from vehicle detail overview', async () => {
|
||||
@@ -10103,7 +10116,7 @@ test('shows vehicle service evidence chain before source details', async () => {
|
||||
render(<App />);
|
||||
|
||||
expect(await screen.findByText('车辆服务证据链')).toBeInTheDocument();
|
||||
expect(screen.getByText('2/3 来源在线')).toBeInTheDocument();
|
||||
expect(screen.getAllByText('2/3 来源在线').length).toBeGreaterThan(0);
|
||||
expect(screen.getAllByText('2 个来源有位置').length).toBeGreaterThan(0);
|
||||
expect(screen.getAllByText('1.4 km').length).toBeGreaterThan(0);
|
||||
expect(screen.getAllByText('125 秒').length).toBeGreaterThan(0);
|
||||
@@ -11294,7 +11307,7 @@ test('opens single vehicle quality evidence from vehicle detail', async () => {
|
||||
render(<App />);
|
||||
|
||||
expect(await screen.findByText('单车处置建议')).toBeInTheDocument();
|
||||
expect(screen.getByText('VIN 缺失')).toBeInTheDocument();
|
||||
expect(screen.getAllByText('VIN 缺失').length).toBeGreaterThan(0);
|
||||
expect(screen.getAllByText('详情页质量问题需要处理').length).toBeGreaterThan(0);
|
||||
expect(screen.getAllByText('粤A详情告警 / VIN-DETAIL-QUALITY').length).toBeGreaterThan(0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user