feat(platform): add fleet command center

This commit is contained in:
lingniu
2026-07-05 21:34:45 +08:00
parent b892ffce81
commit a26fd71bfa
3 changed files with 183 additions and 0 deletions

View File

@@ -960,6 +960,57 @@ export function Vehicles({
onClick: () => onOpenQuality?.(serviceScopeFilters)
}
];
const totalVehicleCount = summary?.totalVehicles ?? pagination.total;
const onlineRate = totalVehicleCount > 0 ? `${(((summary?.onlineVehicles ?? 0) / totalVehicleCount) * 100).toFixed(1)}%` : '-';
const currentPageServiceableCount = rows.filter((row) => row.bindingStatus === 'bound' && row.sourceCount > 0).length;
const pendingVehicleCount = (summary?.noDataVehicles ?? 0) + (summary?.unboundVehicles ?? 0);
const fleetCommandItems = [
{
label: '在线率',
value: onlineRate,
detail: `${(summary?.onlineVehicles ?? 0).toLocaleString()} / ${totalVehicleCount.toLocaleString()} 辆在线,先进入地图看车辆分布。`,
action: '车辆地图',
color: (summary?.onlineVehicles ?? 0) > 0 ? 'green' as const : 'orange' as const,
disabled: !onOpenMap,
onClick: () => onOpenMap?.({ ...serviceScopeFilters, online: 'online' })
},
{
label: '可服务车辆',
value: `${currentPageServiceableCount.toLocaleString()}`,
detail: '当前页可归并到车辆服务的车辆,可直接查看实时状态和来源证据。',
action: '实时监控',
color: currentPageServiceableCount > 0 ? 'blue' as const : 'orange' as const,
disabled: !onOpenRealtime,
onClick: () => onOpenRealtime?.({ ...serviceScopeFilters, online: 'online' })
},
{
label: '待处理车辆',
value: `${pendingVehicleCount.toLocaleString()}`,
detail: '无来源或未绑定车辆优先进入告警闭环,避免客户查不到车。',
action: '告警通知',
color: pendingVehicleCount > 0 ? 'orange' as const : 'green' as const,
disabled: !onOpenQuality,
onClick: () => onOpenQuality?.(serviceScopeFilters)
},
{
label: '当前交付',
value: `${rows.length.toLocaleString()}`,
detail: '把当前筛选结果导出为车辆清单,再按时间窗交付轨迹和历史证据。',
action: '数据导出',
color: rows.length > 0 ? 'blue' as const : 'grey' as const,
disabled: rows.length === 0,
onClick: exportVehicles
},
{
label: '轨迹复盘',
value: filters.keyword?.trim() ? '单车可回放' : '先选车辆',
detail: filters.keyword?.trim() ? '当前已进入单车范围,可直接复盘历史轨迹。' : '先锁定 VIN、车牌或手机号再进入轨迹回放。',
action: '轨迹回放',
color: filters.keyword?.trim() ? 'green' as const : 'grey' as const,
disabled: !onOpenHistory || !filters.keyword?.trim(),
onClick: () => onOpenHistory?.({ ...serviceScopeFilters, tab: 'location' })
}
];
useEffect(() => {
setFilters(initialFilters);
@@ -1068,6 +1119,36 @@ export function Vehicles({
return (
<div className="vp-page">
<PageHeader title="车辆服务" description="围绕车辆完成实时监控、地图查看、轨迹回放、统计查询和数据导出,协议来源只作为证据过滤条件" />
<section className="vp-fleet-command-center" aria-label="客户车队指挥台">
<div className="vp-fleet-command-copy">
<Space wrap>
<Tag color="blue"></Tag>
<Tag color={filters.keyword?.trim() ? 'green' : 'grey'}>{filters.keyword?.trim() ? '单车服务' : '车辆池'}</Tag>
<Tag color={pendingVehicleCount > 0 ? 'orange' : 'green'}>{pendingVehicleCount.toLocaleString()} </Tag>
</Space>
<strong>线</strong>
<span>
</span>
</div>
<div className="vp-fleet-command-grid">
{fleetCommandItems.map((item) => (
<button
key={item.label}
type="button"
className="vp-fleet-command-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>
<section className="vp-customer-vehicle-service-hub" aria-label="客户车辆服务台">
<div className="vp-customer-vehicle-service-summary">
<Space wrap>

View File

@@ -3594,6 +3594,99 @@ button.vp-realtime-command-item:focus-visible {
line-height: 20px;
}
.vp-fleet-command-center {
margin-bottom: 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-fleet-command-copy {
padding: 18px;
border-right: 1px solid var(--vp-border);
background: #f6f9ff;
display: grid;
gap: 12px;
align-content: start;
}
.vp-fleet-command-copy strong {
color: var(--vp-text);
font-size: 20px;
font-weight: 700;
line-height: 28px;
word-break: break-word;
}
.vp-fleet-command-copy span {
color: var(--vp-text-muted);
font-size: 13px;
line-height: 20px;
}
.vp-fleet-command-grid {
padding: 14px;
display: grid;
grid-template-columns: repeat(5, minmax(0, 1fr));
gap: 10px;
}
.vp-fleet-command-item {
min-height: 148px;
padding: 12px;
border: 1px solid var(--vp-border);
border-radius: 8px;
background: #fbfcff;
color: inherit;
cursor: pointer;
font: inherit;
text-align: left;
display: grid;
gap: 8px;
align-content: start;
transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}
.vp-fleet-command-item:disabled {
cursor: not-allowed;
opacity: 0.62;
}
.vp-fleet-command-item:not(:disabled):hover,
.vp-fleet-command-item:not(:disabled):focus-visible {
border-color: rgba(22, 100, 255, 0.42);
background: #f5f9ff;
box-shadow: 0 0 0 3px rgba(22, 100, 255, 0.08);
outline: none;
}
.vp-fleet-command-item strong {
color: var(--vp-text);
font-size: 20px;
font-weight: 700;
line-height: 26px;
word-break: break-word;
}
.vp-fleet-command-item span {
color: var(--vp-text-muted);
font-size: 12px;
line-height: 18px;
word-break: break-word;
}
.vp-fleet-command-item em {
color: var(--vp-primary);
font-size: 13px;
font-style: normal;
font-weight: 700;
line-height: 20px;
}
.vp-customer-vehicle-service-hub {
margin-bottom: 16px;
border: 1px solid rgba(22, 100, 255, 0.18);
@@ -10370,6 +10463,8 @@ button.vp-realtime-command-item:focus-visible {
.vp-service-entry-grid,
.vp-current-service-board,
.vp-current-service-grid,
.vp-fleet-command-center,
.vp-fleet-command-grid,
.vp-customer-vehicle-service-hub,
.vp-customer-vehicle-service-grid,
.vp-alert-closure-timeline,

View File

@@ -2233,6 +2233,13 @@ test('shows vehicle service result summary on vehicle list filters', async () =>
render(<App />);
expect(await screen.findByText('当前车辆结果')).toBeInTheDocument();
expect(screen.getByText('客户车队指挥台')).toBeInTheDocument();
expect(screen.getByText('从车辆池直接判断运营状态:哪些车在线、哪些车可服务、哪些车要回放、统计、导出或触发告警。')).toBeInTheDocument();
expect(screen.getByRole('button', { name: '客户车队指挥台 在线率 40.3% 车辆地图' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '客户车队指挥台 可服务车辆 2 辆 实时监控' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '客户车队指挥台 待处理车辆 13 辆 告警通知' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '客户车队指挥台 当前交付 2 辆 数据导出' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '客户车队指挥台 轨迹复盘 先选车辆 轨迹回放' })).toBeInTheDocument();
expect(screen.getByText('客户车辆服务台')).toBeInTheDocument();
expect(screen.getByText('三个接入源最终服务同一辆车,客户从这里进入找车、实时、轨迹、统计、导出和告警。')).toBeInTheDocument();
expect(screen.getByRole('button', { name: '客户车辆服务台 车辆池 181 车辆 找车' })).toBeInTheDocument();