feat(platform): open raw evidence from vehicle detail
This commit is contained in:
@@ -33,9 +33,26 @@ function splitFields(value?: string) {
|
||||
.filter(Boolean);
|
||||
}
|
||||
|
||||
export function History({ initialVin, initialProtocol, onOpenVehicle }: { initialVin: string; initialProtocol?: string; onOpenVehicle: (vin: string, protocol?: string) => void }) {
|
||||
type HistoryTabKey = 'location' | 'raw';
|
||||
|
||||
function normalizeHistoryTab(value?: string): HistoryTabKey {
|
||||
return value === 'raw' ? 'raw' : 'location';
|
||||
}
|
||||
|
||||
export function History({
|
||||
initialVin,
|
||||
initialProtocol,
|
||||
initialTab,
|
||||
onOpenVehicle
|
||||
}: {
|
||||
initialVin: string;
|
||||
initialProtocol?: string;
|
||||
initialTab?: string;
|
||||
onOpenVehicle: (vin: string, protocol?: string) => void;
|
||||
}) {
|
||||
const initialFilters = { ...defaultFilters, keyword: initialVin || defaultFilters.keyword, protocol: initialProtocol };
|
||||
const [filters, setFilters] = useState<HistoryFilters>(initialFilters);
|
||||
const [activeTab, setActiveTab] = useState<HistoryTabKey>(normalizeHistoryTab(initialTab));
|
||||
const [locations, setLocations] = useState<Page<HistoryLocationRow>>(defaultPage);
|
||||
const [rawFrames, setRawFrames] = useState<Page<RawFrameRow>>(defaultPage);
|
||||
const [selectedRaw, setSelectedRaw] = useState<RawFrameRow | null>(null);
|
||||
@@ -113,9 +130,10 @@ export function History({ initialVin, initialProtocol, onOpenVehicle }: { initia
|
||||
useEffect(() => {
|
||||
const nextFilters = { ...defaultFilters, keyword: initialVin || defaultFilters.keyword, protocol: initialProtocol };
|
||||
setFilters(nextFilters);
|
||||
setActiveTab(normalizeHistoryTab(initialTab));
|
||||
loadLocations(nextFilters, 1, locationPagination.pageSize);
|
||||
loadRawFrames(nextFilters, 1, rawPagination.pageSize);
|
||||
}, [initialVin, initialProtocol]);
|
||||
}, [initialVin, initialProtocol, initialTab]);
|
||||
|
||||
const rawFieldCount = useMemo(() => Object.keys(selectedRaw?.parsedFields ?? {}).length, [selectedRaw]);
|
||||
const currentVehicleKeyword = filters.keyword?.trim() ?? '';
|
||||
@@ -164,7 +182,7 @@ export function History({ initialVin, initialProtocol, onOpenVehicle }: { initia
|
||||
</Form>
|
||||
</Card>
|
||||
<Card bordered style={{ marginTop: 16 }}>
|
||||
<Tabs>
|
||||
<Tabs activeKey={activeTab} onChange={(key) => setActiveTab(normalizeHistoryTab(String(key)))}>
|
||||
<Tabs.TabPane tab="位置历史" itemKey="location">
|
||||
<Table
|
||||
rowKey="deviceTime"
|
||||
|
||||
@@ -68,6 +68,7 @@ export function VehicleDetail({
|
||||
vin,
|
||||
protocol,
|
||||
onOpenHistory,
|
||||
onOpenRaw,
|
||||
onOpenMileage,
|
||||
onOpenVehicles,
|
||||
onQueryChange
|
||||
@@ -75,6 +76,7 @@ export function VehicleDetail({
|
||||
vin: string;
|
||||
protocol?: string;
|
||||
onOpenHistory: (vin: string, protocol?: string) => void;
|
||||
onOpenRaw: (vin: string, protocol?: string) => void;
|
||||
onOpenMileage: (vin: string, protocol?: string) => void;
|
||||
onOpenVehicles?: (filters?: Record<string, string>) => void;
|
||||
onQueryChange?: (keyword: string, protocol?: string) => void;
|
||||
@@ -384,6 +386,15 @@ export function VehicleDetail({
|
||||
>
|
||||
查看 {row.protocol} 历史
|
||||
</Button>
|
||||
<Button
|
||||
size="small"
|
||||
theme="light"
|
||||
type="tertiary"
|
||||
disabled={!row.hasRaw}
|
||||
onClick={() => onOpenRaw(resolvedVIN, row.protocol)}
|
||||
>
|
||||
查看 {row.protocol} RAW
|
||||
</Button>
|
||||
<Button
|
||||
size="small"
|
||||
theme="light"
|
||||
|
||||
Reference in New Issue
Block a user