feat(platform): link realtime to vehicle service
This commit is contained in:
@@ -48,7 +48,7 @@ export default function App() {
|
|||||||
const pages: Record<PageKey, JSX.Element> = {
|
const pages: Record<PageKey, JSX.Element> = {
|
||||||
dashboard: <Dashboard onOpenVehicle={openVehicle} onOpenQuality={() => setActivePage('quality')} />,
|
dashboard: <Dashboard onOpenVehicle={openVehicle} onOpenQuality={() => setActivePage('quality')} />,
|
||||||
vehicles: <Vehicles onOpenVehicle={openVehicle} />,
|
vehicles: <Vehicles onOpenVehicle={openVehicle} />,
|
||||||
realtime: <Realtime />,
|
realtime: <Realtime onOpenVehicle={openVehicle} />,
|
||||||
detail: <VehicleDetail vin={activeVin} />,
|
detail: <VehicleDetail vin={activeVin} />,
|
||||||
history: <History onOpenVehicle={openVehicle} />,
|
history: <History onOpenVehicle={openVehicle} />,
|
||||||
mileage: <Mileage onOpenVehicle={openVehicle} />,
|
mileage: <Mileage onOpenVehicle={openVehicle} />,
|
||||||
|
|||||||
@@ -6,7 +6,12 @@ import { DataEmpty } from '../components/DataEmpty';
|
|||||||
import { PageHeader } from '../components/PageHeader';
|
import { PageHeader } from '../components/PageHeader';
|
||||||
import { StatusTag } from '../components/StatusTag';
|
import { StatusTag } from '../components/StatusTag';
|
||||||
|
|
||||||
export function Realtime() {
|
function canOpenVehicle(vin?: string) {
|
||||||
|
const value = vin?.trim();
|
||||||
|
return Boolean(value && value !== 'unknown');
|
||||||
|
}
|
||||||
|
|
||||||
|
export function Realtime({ onOpenVehicle }: { onOpenVehicle: (vin: string) => void }) {
|
||||||
const [rows, setRows] = useState<VehicleRealtimeRow[]>([]);
|
const [rows, setRows] = useState<VehicleRealtimeRow[]>([]);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [filters, setFilters] = useState<Record<string, string>>({});
|
const [filters, setFilters] = useState<Record<string, string>>({});
|
||||||
@@ -95,7 +100,14 @@ export function Realtime() {
|
|||||||
{ title: 'SOC %', dataIndex: 'socPercent' },
|
{ title: 'SOC %', dataIndex: 'socPercent' },
|
||||||
{ title: '总里程 km', dataIndex: 'totalMileageKm' },
|
{ title: '总里程 km', dataIndex: 'totalMileageKm' },
|
||||||
{ title: '最新来源', dataIndex: 'primaryProtocol' },
|
{ title: '最新来源', dataIndex: 'primaryProtocol' },
|
||||||
{ title: '最后时间', dataIndex: 'lastSeen' }
|
{ title: '最后时间', dataIndex: 'lastSeen' },
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
width: 110,
|
||||||
|
render: (_: unknown, row: VehicleRealtimeRow) => (
|
||||||
|
<Button disabled={!canOpenVehicle(row.vin)} onClick={() => onOpenVehicle(row.vin)}>车辆服务</Button>
|
||||||
|
)
|
||||||
|
}
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in New Issue
Block a user