import type { RefObject } from 'react'; import { Truck } from 'lucide-react'; import { motion } from 'motion/react'; import Blur from '../../../../components/Blur'; import type { MonitoringVehicle } from '../../types'; import { vehicleStatisticTime } from '../oneos-time'; import { vehicleSourceDisplay } from '../source-display'; export default function VehicleList({ pageLoading, vehicles, isHighMileageAlert, relativeNow, isRangeMode, onVehicleClick, loadingMore, hasMore, total, sentinelRef, }: { pageLoading: boolean; vehicles: MonitoringVehicle[]; isHighMileageAlert: (vehicle: MonitoringVehicle) => boolean; relativeNow: number; isRangeMode: boolean; onVehicleClick: (vehicle: MonitoringVehicle) => void; loadingMore: boolean; hasMore: boolean; total: number; sentinelRef: RefObject; }) { return (
{pageLoading && (
{Array.from({ length: 6 }).map((_, i) => (
))}
)}
{vehicles.map((v) => { const highMileageAlert = isHighMileageAlert(v); const statisticTime = vehicleStatisticTime(v, relativeNow); const sourceDisplay = vehicleSourceDisplay(v); return ( onVehicleClick(v)} >
{v.plate} {v.isOnline ? '在线' : '离线'} {sourceDisplay.label}
{statisticTime.label}
{v.rentStatus || ''}{v.department ? ` · ${v.department.replace('业务', '')}` : ''} {v.customer || '-'}
{v.customer || '-'}
{[v.rentStatus, v.department?.replace('业务', ''), v.project].filter(Boolean).join(' · ') || '暂无归属信息'}
{Math.max(0, v.dailyKm || 0).toLocaleString()} km
{v.totalKm != null ? v.totalKm.toLocaleString() : '-'} km
{!v.isDataSynced && v.totalKm == null && (
)}
{(v.isDataSynced || v.totalKm != null) ? <>{Math.max(0, v.dailyKm || 0).toLocaleString()} km : 未对接}
{v.totalKm != null ? `${v.totalKm.toLocaleString()} km` : '未对接'}
); })}
{vehicles.length === 0 && !loadingMore && (

未找到匹配数据

)} {/* 加载更多提示 */} {loadingMore && (
加载中...
)} {!hasMore && vehicles.length > 0 && (
已加载全部 {total} 条
)} {/* 哨兵元素:进入视口时触发加载更多 */}
); }