feat(platform-web): keep protocol when opening vehicle rows
This commit is contained in:
@@ -33,7 +33,7 @@ function splitFields(value?: string) {
|
||||
.filter(Boolean);
|
||||
}
|
||||
|
||||
export function History({ initialVin, initialProtocol, onOpenVehicle }: { initialVin: string; initialProtocol?: string; onOpenVehicle: (vin: string) => void }) {
|
||||
export function History({ initialVin, initialProtocol, onOpenVehicle }: { initialVin: string; initialProtocol?: string; onOpenVehicle: (vin: string, protocol?: string) => void }) {
|
||||
const initialFilters = { ...defaultFilters, keyword: initialVin || defaultFilters.keyword, protocol: initialProtocol };
|
||||
const [filters, setFilters] = useState<HistoryFilters>(initialFilters);
|
||||
const [locations, setLocations] = useState<Page<HistoryLocationRow>>(defaultPage);
|
||||
@@ -176,7 +176,7 @@ export function History({ initialVin, initialProtocol, onOpenVehicle }: { initia
|
||||
title: '操作',
|
||||
width: 110,
|
||||
render: (_: unknown, row: HistoryLocationRow) => (
|
||||
<Button disabled={!canOpenVehicle(row.vin)} onClick={() => onOpenVehicle(row.vin)}>车辆服务</Button>
|
||||
<Button disabled={!canOpenVehicle(row.vin)} onClick={() => onOpenVehicle(row.vin, row.protocol)}>车辆服务</Button>
|
||||
)
|
||||
}
|
||||
]}
|
||||
@@ -210,7 +210,7 @@ export function History({ initialVin, initialProtocol, onOpenVehicle }: { initia
|
||||
render: (_: unknown, row: RawFrameRow) => (
|
||||
<Space>
|
||||
<Button onClick={() => setSelectedRaw(row)}>字段</Button>
|
||||
<Button disabled={!canOpenVehicle(row.vin)} onClick={() => onOpenVehicle(row.vin)}>车辆服务</Button>
|
||||
<Button disabled={!canOpenVehicle(row.vin)} onClick={() => onOpenVehicle(row.vin, row.protocol)}>车辆服务</Button>
|
||||
</Space>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ function canOpenVehicle(vin?: string) {
|
||||
return Boolean(value && value !== 'unknown');
|
||||
}
|
||||
|
||||
export function Mileage({ initialVin, initialProtocol, onOpenVehicle }: { initialVin: string; initialProtocol?: string; onOpenVehicle: (vin: string) => void }) {
|
||||
export function Mileage({ initialVin, initialProtocol, onOpenVehicle }: { initialVin: string; initialProtocol?: string; onOpenVehicle: (vin: string, protocol?: string) => void }) {
|
||||
const [rows, setRows] = useState<DailyMileageRow[]>([]);
|
||||
const [summary, setSummary] = useState<MileageSummary>(emptySummary);
|
||||
const [loading, setLoading] = useState(true);
|
||||
@@ -134,7 +134,7 @@ export function Mileage({ initialVin, initialProtocol, onOpenVehicle }: { initia
|
||||
title: '操作',
|
||||
width: 110,
|
||||
render: (_: unknown, row: DailyMileageRow) => (
|
||||
<Button disabled={!canOpenVehicle(row.vin)} onClick={() => onOpenVehicle(row.vin)}>车辆服务</Button>
|
||||
<Button disabled={!canOpenVehicle(row.vin)} onClick={() => onOpenVehicle(row.vin, row.source)}>车辆服务</Button>
|
||||
)
|
||||
}
|
||||
]}
|
||||
|
||||
@@ -76,15 +76,15 @@ export function VehicleDetail({
|
||||
|
||||
const identity = detail?.identity;
|
||||
const summary = detail?.realtimeSummary;
|
||||
const latest = detail?.realtime[0];
|
||||
const latest = detail?.realtime?.[0];
|
||||
const resolution = detail?.resolution;
|
||||
const resolvedVIN = resolution?.vin || detail?.vin || summary?.vin || identity?.vin || latest?.vin || query.keyword;
|
||||
const hasResolvedVIN = resolution?.resolved ?? detail?.lookupResolved ?? isLikelyVIN(resolvedVIN);
|
||||
const displayVIN = hasResolvedVIN ? resolvedVIN : '-';
|
||||
const displayLookupKey = resolution?.lookupKey || detail?.lookupKey || query.keyword;
|
||||
const protocols = useMemo(() => resolution?.protocols?.length ? resolution.protocols : detail?.sources ?? [], [detail?.sources, resolution?.protocols]);
|
||||
const latestRaw = detail?.raw.items[0];
|
||||
const qualityCount = detail?.quality.total ?? 0;
|
||||
const latestRaw = detail?.raw?.items?.[0];
|
||||
const qualityCount = detail?.quality?.total ?? 0;
|
||||
const online = resolution?.online || summary?.online || identity?.online || false;
|
||||
const lastSeen = resolution?.lastSeen || summary?.lastSeen || latest?.lastSeen || '-';
|
||||
const formKey = `${query.keyword}-${query.protocol ?? ''}`;
|
||||
@@ -93,7 +93,7 @@ export function VehicleDetail({
|
||||
loading={loading}
|
||||
pagination={false}
|
||||
rowKey={(row?: QualityIssueRow) => `${row?.protocol ?? ''}-${row?.issueType ?? ''}-${row?.lastSeen ?? ''}`}
|
||||
dataSource={detail?.quality.items ?? []}
|
||||
dataSource={detail?.quality?.items ?? []}
|
||||
columns={[
|
||||
{ title: '来源', dataIndex: 'protocol', width: 130 },
|
||||
{ title: '问题', dataIndex: 'issueType', width: 150 },
|
||||
@@ -260,7 +260,7 @@ export function VehicleDetail({
|
||||
loading={loading}
|
||||
pagination={false}
|
||||
rowKey="deviceTime"
|
||||
dataSource={detail?.history.items ?? []}
|
||||
dataSource={detail?.history?.items ?? []}
|
||||
columns={[
|
||||
{ title: '来源', dataIndex: 'protocol', width: 130 },
|
||||
{ title: '经度', dataIndex: 'longitude', width: 120 },
|
||||
@@ -277,7 +277,7 @@ export function VehicleDetail({
|
||||
loading={loading}
|
||||
pagination={false}
|
||||
rowKey="id"
|
||||
dataSource={detail?.raw.items ?? []}
|
||||
dataSource={detail?.raw?.items ?? []}
|
||||
columns={[
|
||||
{ title: '来源', dataIndex: 'protocol', width: 130 },
|
||||
{ title: '帧类型', dataIndex: 'frameType', width: 190 },
|
||||
@@ -294,7 +294,7 @@ export function VehicleDetail({
|
||||
loading={loading}
|
||||
pagination={false}
|
||||
rowKey="date"
|
||||
dataSource={detail?.mileage.items ?? []}
|
||||
dataSource={detail?.mileage?.items ?? []}
|
||||
columns={[
|
||||
{ title: '日期', dataIndex: 'date', width: 130 },
|
||||
{ title: '来源', dataIndex: 'source', width: 130 },
|
||||
|
||||
Reference in New Issue
Block a user