feat(platform): add vehicle dispatch checklist

This commit is contained in:
lingniu
2026-07-04 20:03:56 +08:00
parent 259601ed7b
commit 06d9dc1562
2 changed files with 74 additions and 1 deletions

View File

@@ -7,6 +7,7 @@ import { DataEmpty } from '../components/DataEmpty';
import { PageHeader } from '../components/PageHeader';
import { SourceStatusTags } from '../components/SourceStatusTags';
import { StatusTag } from '../components/StatusTag';
import { buildAppHash } from '../domain/appRoute';
import { buildCsv, downloadCsv, type CsvColumn } from '../domain/csvExport';
import { summarizeVehicleService, type VehicleServiceVerdict } from '../domain/vehicleService';
@@ -192,6 +193,48 @@ function vehicleGovernanceSummaryText({
].join('\n');
}
function appURL(hash: string) {
return `${window.location.origin}${window.location.pathname}${hash}`;
}
function vehicleDispatchListText({
filters,
rows,
total
}: {
filters: Record<string, string>;
rows: VehicleCoverageRow[];
total: number;
}) {
const lines = [
'【车辆处置清单】',
`当前筛选:${vehicleFilterSummary(filters).join('') || '全部车辆'}`,
`当前页:${rows.length.toLocaleString()} 辆 / 总计 ${total.toLocaleString()}`,
''
];
rows.forEach((row, index) => {
const action = vehicleActionRecommendation(row);
const status = vehicleServiceStatus(row);
const protocol = primaryRowProtocol(row, filters.protocol);
const identity = [
row.plate ? `车牌 ${row.plate}` : '车牌 -',
row.vin ? `VIN ${row.vin}` : 'VIN -',
row.phone ? `手机号 ${row.phone}` : '手机号 -',
row.oem ? `OEM ${row.oem}` : 'OEM -'
].join(' / ');
lines.push(
`${index + 1}. ${identity}`,
` 状态:${status.label};在线:${row.online ? '在线' : '离线'};来源:${sourceDiagnosisText(row)};最后时间:${row.lastSeen || '-'}`,
` 建议动作:${action.label}`,
` 车辆服务:${appURL(buildAppHash({ page: 'detail', keyword: row.vin, protocol }))}`,
` 实时监控:${appURL(buildAppHash({ page: 'realtime', keyword: row.vin, protocol }))}`,
` 轨迹回放:${appURL(buildAppHash({ page: 'history', keyword: row.vin, protocol }))}`,
` 告警事件:${appURL(buildAppHash({ page: 'alert-events', keyword: row.vin, protocol }))}`
);
});
return lines.join('\n');
}
type VehicleActionRecommendation = {
label: string;
color: 'green' | 'orange' | 'red';
@@ -451,6 +494,13 @@ export function Vehicles({
const copyGovernanceSummary = () => {
copyText(vehicleGovernanceSummaryText({ filters, summary, actionQueue }), '治理摘要');
};
const copyDispatchList = () => {
if (rows.length === 0) {
Toast.warning('当前没有可复制的车辆处置清单');
return;
}
copyText(vehicleDispatchListText({ filters, rows, total: pagination.total }), '车辆处置清单');
};
useEffect(() => {
setFilters(initialFilters);
@@ -628,6 +678,7 @@ export function Vehicles({
<Space>
<span></span>
<Button size="small" theme="light" onClick={copyGovernanceSummary}></Button>
<Button size="small" theme="light" onClick={copyDispatchList}></Button>
</Space>
)}
style={{ marginTop: 16 }}