feat(platform): add customer history evidence chain

This commit is contained in:
lingniu
2026-07-05 21:14:19 +08:00
parent 3efeeb07ac
commit 82faa046b7
3 changed files with 182 additions and 0 deletions

View File

@@ -1655,6 +1655,63 @@ export function History({
}
loadRawFrames(nextFilters, 1, rawPagination.pageSize, tab === 'fields');
};
const customerTimeWindowEvidenceItems = [
{
title: '轨迹复盘',
value: validLocations.length > 0 ? `${validLocations.length.toLocaleString()}` : '待查询',
detail: '先用车辆地图和轨迹回放解释这段时间车辆在哪里、怎么走。',
action: '查看轨迹',
color: validLocations.length > 0 ? 'green' as const : 'orange' as const,
disabled: false,
onClick: () => openQueryTab('location')
},
{
title: '里程核对',
value: formatNumber(mileageDelta, ' km'),
detail: '把同一车辆和时间窗带到统计页,核对区间差值与日报闭合。',
action: '统计查询',
color: isFiniteNumber(mileageDelta) ? 'green' as const : 'grey' as const,
disabled: !onOpenMileage || !currentVehicleKeyword,
onClick: () => onOpenMileage?.({ keyword: currentVehicleKeyword, protocol: currentProtocol, ...(filters.dateFrom ? { dateFrom: filters.dateFrom } : {}), ...(filters.dateTo ? { dateTo: filters.dateTo } : {}) })
},
{
title: '历史导出',
value: `${(rawFrames.total ?? 0).toLocaleString()}`,
detail: '下钻到历史明细和位置记录,保留客户问责时可复核的证据。',
action: '明细证据',
color: (rawFrames.total ?? 0) > 0 ? 'blue' as const : 'grey' as const,
disabled: false,
onClick: () => openQueryTab('raw')
},
{
title: '字段裁剪',
value: rawFieldRows.length > 0 ? `${rawFieldRows.length.toLocaleString()} 字段` : `${selectedFieldCount.toLocaleString()} 字段`,
detail: '按客户只需要的字段生成交付视图,避免暴露完整 RAW 结构。',
action: '字段导出',
color: rawFieldRows.length > 0 || selectedFieldCount > 0 ? 'green' as const : 'orange' as const,
disabled: false,
onClick: () => openQueryTab('fields')
},
{
title: '告警复盘',
value: anomalyTotal > 0 ? `${anomalyTotal.toLocaleString()}` : '可说明',
detail: '同一时间窗查看断链、离线、定位异常和通知闭环。',
action: '告警事件',
color: anomalyTotal > 0 ? 'orange' as const : 'blue' as const,
disabled: false,
onClick: () => {
window.location.hash = buildAppHash({
page: 'alert-events',
keyword: currentVehicleKeyword,
protocol: currentProtocol,
filters: {
...(filters.dateFrom ? { dateFrom: filters.dateFrom } : {}),
...(filters.dateTo ? { dateTo: filters.dateTo } : {})
}
});
}
}
];
const customerReplayNavigation = [
{
title: '选车和时间',
@@ -1713,6 +1770,38 @@ export function History({
<Tag color={currentProtocol ? 'blue' : 'green'}>{currentProtocol || '全部数据通道'}</Tag>
<Typography.Text type="tertiary">{scopeDescription}</Typography.Text>
</div>
<section className="vp-history-evidence-chain" aria-label="客户时间窗证据链">
<div className="vp-history-evidence-chain-summary">
<Space wrap>
<Tag color="blue"></Tag>
<Tag color={deliveryStateColor}>{deliveryState}</Tag>
<Tag color={currentVehicleKeyword ? 'green' : 'orange'}>{currentVehicleKeyword || '待选择车辆'}</Tag>
</Space>
<Typography.Title heading={5} style={{ margin: 0 }}>
</Typography.Title>
<Typography.Text type="secondary">
GB32960JT808MQTT
</Typography.Text>
</div>
<div className="vp-history-evidence-chain-grid">
{customerTimeWindowEvidenceItems.map((item) => (
<button
key={item.title}
type="button"
className="vp-history-evidence-chain-item"
disabled={item.disabled}
onClick={item.onClick}
aria-label={`客户时间窗证据链 ${item.title} ${item.action}`}
>
<Tag color={item.color}>{item.title}</Tag>
<strong>{item.value}</strong>
<span>{item.detail}</span>
<em>{item.action}</em>
</button>
))}
</div>
</section>
{mode === 'query' ? (
<section className="vp-history-service-desk" aria-label="车辆历史服务台">
<div className="vp-history-service-desk-summary">

View File

@@ -7687,6 +7687,90 @@ button.vp-realtime-command-item:focus-visible {
line-height: 18px;
}
.vp-history-evidence-chain {
margin-top: 16px;
border: 1px solid rgba(22, 100, 255, 0.18);
border-radius: var(--vp-radius);
background: #fff;
display: grid;
grid-template-columns: minmax(300px, 0.58fr) minmax(0, 1.42fr);
overflow: hidden;
box-shadow: var(--vp-shadow-sm);
}
.vp-history-evidence-chain-summary {
padding: 18px;
border-right: 1px solid var(--vp-border);
background: #f7fbff;
display: grid;
gap: 12px;
align-content: start;
}
.vp-history-evidence-chain-summary .semi-typography-secondary {
font-size: 13px;
line-height: 20px;
}
.vp-history-evidence-chain-grid {
min-width: 0;
padding: 16px;
display: grid;
grid-template-columns: repeat(5, minmax(0, 1fr));
gap: 10px;
}
.vp-history-evidence-chain-item {
min-height: 150px;
padding: 12px;
border: 1px solid rgba(22, 100, 255, 0.14);
border-radius: 8px;
background: #fbfcff;
color: inherit;
cursor: pointer;
font: inherit;
text-align: left;
display: grid;
gap: 8px;
align-content: start;
}
.vp-history-evidence-chain-item:hover,
.vp-history-evidence-chain-item:focus-visible {
border-color: rgba(22, 100, 255, 0.42);
background: #f5f9ff;
box-shadow: var(--vp-shadow-sm);
outline: none;
}
.vp-history-evidence-chain-item:disabled {
cursor: not-allowed;
opacity: 0.62;
}
.vp-history-evidence-chain-item strong {
color: var(--vp-text);
font-size: 18px;
line-height: 24px;
font-weight: 700;
word-break: break-word;
}
.vp-history-evidence-chain-item span {
color: var(--vp-text-muted);
font-size: 12px;
line-height: 18px;
word-break: break-word;
}
.vp-history-evidence-chain-item em {
color: var(--vp-primary);
font-size: 12px;
font-style: normal;
font-weight: 700;
line-height: 18px;
}
.vp-history-service-desk {
margin-top: 16px;
border: 1px solid rgba(22, 100, 255, 0.18);
@@ -10188,6 +10272,8 @@ button.vp-realtime-command-item:focus-visible {
.vp-trajectory-anomaly-grid,
.vp-trajectory-impact-board,
.vp-trajectory-impact-grid,
.vp-history-evidence-chain,
.vp-history-evidence-chain-grid,
.vp-history-service-desk,
.vp-history-service-desk-grid,
.vp-history-time-window-board,

View File

@@ -5749,6 +5749,13 @@ test('copies trajectory playback summary from history page', async () => {
expect(screen.getByRole('button', { name: '客户复盘导航 回放路线 播放轨迹' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '客户复盘导航 核对里程 统计查询' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '客户复盘导航 导出证据 复制交付' })).toBeInTheDocument();
expect(screen.getByText('客户时间窗证据链')).toBeInTheDocument();
expect(screen.getByText('同一辆车和同一时间窗,串起实时轨迹、里程核对、历史导出、字段裁剪和告警复盘。')).toBeInTheDocument();
expect(screen.getByRole('button', { name: '客户时间窗证据链 轨迹复盘 查看轨迹' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '客户时间窗证据链 里程核对 统计查询' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '客户时间窗证据链 历史导出 明细证据' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '客户时间窗证据链 字段裁剪 字段导出' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '客户时间窗证据链 告警复盘 告警事件' })).toBeInTheDocument();
expect(screen.getByText('按车辆和时间窗复盘每一段行程')).toBeInTheDocument();
expect(screen.getByText('客户需要看到路线、起止时间、里程变化、速度异常和可导出的证据。明细证据和字段裁剪只作为轨迹复盘的依据。')).toBeInTheDocument();
expect(screen.getByRole('button', { name: '轨迹回放指标 轨迹点 2' })).toBeInTheDocument();