feat(platform): add customer realtime command center

This commit is contained in:
lingniu
2026-07-05 19:49:30 +08:00
parent 30bc03a262
commit 6bfc08a841
3 changed files with 306 additions and 0 deletions

View File

@@ -1428,6 +1428,67 @@ export function Realtime({
disabled: rows.length === 0
}
];
const realtimeSourceEvidenceText = (() => {
const protocols: string[] = [];
rows.forEach((row) => {
const rowProtocols = row.protocols?.length ? row.protocols : row.primaryProtocol ? [row.primaryProtocol] : [];
rowProtocols.forEach((protocol) => {
if (protocol && !protocols.includes(protocol)) {
protocols.push(protocol);
}
});
});
return protocols.length > 0 ? protocols.join(' / ') : '暂无来源证据';
})();
const realtimeCustomerCommandItems = [
{
label: '实时地图',
value: `${locatedCount.toLocaleString()} 有定位`,
detail: '先回答客户车辆在哪里,定位无效车辆进入异常队列。',
action: '打开地图',
color: locatedCount > 0 ? 'blue' as const : 'orange' as const,
disabled: false,
onClick: () => {
window.location.hash = buildAppHash({ page: 'map', protocol: filters.protocol, filters });
}
},
{
label: '在线车辆',
value: `${onlineCount.toLocaleString()} 在线`,
detail: `${(rows.length - onlineCount).toLocaleString()} 辆离线,优先确认当前可服务车辆。`,
action: '只看在线',
color: onlineCount > 0 ? 'green' as const : 'orange' as const,
disabled: false,
onClick: () => applyFilters({ ...filters, online: 'online' })
},
{
label: '异常车辆',
value: `${mapAttentionRows.length.toLocaleString()} 关注`,
detail: mapAttentionRows[0] ? `${mapAttentionRows[0].plate || mapAttentionRows[0].vin}${realtimeIssueLabels(mapAttentionRows[0]).join('')}` : '当前没有明显离线、超时或坐标异常车辆。',
action: '关注异常',
color: mapAttentionRows.length > 0 ? 'orange' as const : 'green' as const,
disabled: false,
onClick: () => applyFilters({ ...filters, serviceStatus: 'degraded' })
},
{
label: '轨迹复盘',
value: selectedMapRow?.plate || selectedMapRow?.vin || '未选车',
detail: selectedMapRow ? '围绕选中车辆回放轨迹、核对里程和异常时间窗。' : '先从地图或表格选择一辆车。',
action: '轨迹回放',
color: selectedMapRow ? 'blue' as const : 'grey' as const,
disabled: !selectedMapRow || !canOpenVehicle(selectedMapRow.vin),
onClick: () => selectedMapRow && onOpenHistory?.(selectedMapRow.vin, selectedVehicleProtocol)
},
{
label: '导出交付',
value: `${rows.length.toLocaleString()} 当前页`,
detail: '导出车辆在线、位置、速度、SOC、里程和状态证据。',
action: '导出CSV',
color: rows.length > 0 ? 'blue' as const : 'grey' as const,
disabled: rows.length === 0,
onClick: exportRealtime
}
];
const realtimeSingleVehicleItems = [
{
label: '车辆服务',
@@ -2119,6 +2180,36 @@ export function Realtime({
return (
<div className="vp-page">
<PageHeader title={title} description={description} />
<section className="vp-realtime-command-center" aria-label="客户实时监控总控台">
<div className="vp-realtime-command-center-copy">
<Space wrap>
<Tag color="blue"></Tag>
<Tag color={amapConfigured ? 'green' : 'orange'}>{amapConfigured ? '地图可用' : '坐标预览'}</Tag>
<Tag color={mapAttentionRows.length > 0 ? 'orange' : 'green'}>{mapAttentionRows.length.toLocaleString()} </Tag>
</Space>
<Typography.Title heading={5} style={{ margin: 0 }}></Typography.Title>
<Typography.Text type="secondary">
{realtimeSourceEvidenceText}
</Typography.Text>
</div>
<div className="vp-realtime-command-center-grid">
{realtimeCustomerCommandItems.map((item) => (
<button
key={item.label}
type="button"
className="vp-realtime-command-center-item"
disabled={item.disabled}
onClick={item.onClick}
aria-label={`客户实时监控总控台 ${item.label} ${item.value} ${item.action}`}
>
<Tag color={item.color}>{item.label}</Tag>
<strong>{item.value}</strong>
<span>{item.detail}</span>
<em>{item.action}</em>
</button>
))}
</div>
</section>
<Card bordered className="vp-realtime-customer-board" bodyStyle={{ padding: 0 }}>
<div className="vp-realtime-customer-summary">
<Space wrap>