feat(platform): route vehicle searches to detail

This commit is contained in:
lingniu
2026-07-03 21:37:32 +08:00
parent d4bd70fdf4
commit 92d7020b36
4 changed files with 56 additions and 30 deletions

View File

@@ -1,4 +1,4 @@
import { Button, Card, Form, Select, SideSheet, Space, Table, TextArea, Toast } from '@douyinfe/semi-ui';
import { Button, Card, Form, Select, Space, Table, Toast } from '@douyinfe/semi-ui';
import { useEffect, useMemo, useState } from 'react';
import { api } from '../api/client';
import type { VehicleRow } from '../api/types';
@@ -6,10 +6,9 @@ import { DataEmpty } from '../components/DataEmpty';
import { PageHeader } from '../components/PageHeader';
import { StatusTag } from '../components/StatusTag';
export function Vehicles() {
export function Vehicles({ onOpenVehicle }: { onOpenVehicle: (vin: string) => void }) {
const [rows, setRows] = useState<VehicleRow[]>([]);
const [loading, setLoading] = useState(true);
const [selected, setSelected] = useState<VehicleRow | null>(null);
const load = (values?: Record<string, string>) => {
setLoading(true);
@@ -35,9 +34,9 @@ export function Vehicles() {
{ title: '最后在线', dataIndex: 'lastSeen', width: 170 },
{ title: '位置', dataIndex: 'locationText' },
{ title: '绑定分', dataIndex: 'bindingScore', width: 90 },
{ title: '操作', render: (_: unknown, row: VehicleRow) => <Button onClick={() => setSelected(row)}></Button> }
{ title: '操作', render: (_: unknown, row: VehicleRow) => <Button onClick={() => onOpenVehicle(row.vin)}></Button> }
],
[]
[onOpenVehicle]
);
return (
@@ -64,9 +63,6 @@ export function Vehicles() {
<Table loading={loading} rowKey="vin" dataSource={rows} columns={columns} pagination={false} />
)}
</Card>
<SideSheet title="车辆详情" visible={Boolean(selected)} onCancel={() => setSelected(null)} width={520}>
<TextArea value={JSON.stringify(selected, null, 2)} autosize readOnly />
</SideSheet>
</div>
);
}