export interface VehicleRecord {
  id: string;
  plateNo: string;
  vin: string;
  vehicleNo: string;
  color: string;
  year: string;
  purchaseDate: string;
  parking: string;
  ownership: string;
  scrapDate: string;
  ratingTime: string;
  operateCompany: string;
  vehicleSource: string;
  leaseCompany: string;
  vehicleType: string;
  brand: string;
  model: string;
  customer: string;
  department: string;
  manager: string;
  contractNo: string;
  operateStatus: string;
  vehicleStatus: string;
  licenseStatus: string;
  insuranceStatus: string;
  mileage: string;
  location: string;
  gpsTime: string;
  regDate: string;
  inspectExpire: string;
  lastDeliveryTime: string;
  lastDeliveryMile: string;
  lastReturnTime: string;
  lastReturnMile: string;
  lastDeliveryPerson?: string;
  lastReturnPerson?: string;
  outStatus: string;
  onlineStatus: string;
  projectName: string;
  vehicleLedgerType?: string;
  locationAddress?: string;
  lastDeliveryRegion?: string;
  lastReturnRegion?: string;
  opsManagers?: string[];
  /** 运营城市数据来源：车机 / GPS / 人工 */
  operateCitySource?: '车机' | 'GPS' | '人工';
  /** 是否对接车机；未对接时通常依靠 GPS 判定省-市 */
  telematicsLinked?: boolean;
  /** GPS 纬度（有则优先用于地图定位） */
  gpsLat?: number;
  /** GPS 经度（有则优先用于地图定位） */
  gpsLng?: number;
}

export type KpiKey =
  | 'all'
  | 'lease'
  | 'self'
  | 'stock'
  | 'nonOperating'
  | 'exit'
  | 'licenseAbnormal'
  | 'insuranceAbnormal';

export interface VehicleFilters {
  plateNos: string[];
  operateCities: string[];
  brand: string;
  model: string;
  customer: string;
  department: string;
  projectName: string;
  projectType: string;
  contractNo: string;
  ownership: string;
  operateCompany: string;
  operateStatus: string;
  vehicleSource: string;
  leaseCompany: string;
  commercialInsurance: string;
  compulsoryInsurance: string;
  parking: string;
  areaRegion: string;
}

export type InsuranceType = '交强险' | '商业险';

/** 保险采购记录（列表到期时间取同车同险种最新一条） */
export interface InsurancePurchaseRecord {
  id: string;
  vehicleId: string;
  insuranceType: InsuranceType;
  /** 保险到期日 YYYY-MM-DD */
  expireDate: string;
  /** 采购日期，用于判定「最新一条」 */
  purchasedAt: string;
}

export const EMPTY_FILTERS: VehicleFilters = {
  plateNos: [],
  operateCities: [],
  brand: '',
  model: '',
  customer: '',
  department: '',
  projectName: '',
  projectType: '',
  contractNo: '',
  ownership: '',
  operateCompany: '',
  operateStatus: '',
  vehicleSource: '',
  leaseCompany: '',
  commercialInsurance: '',
  compulsoryInsurance: '',
  parking: '',
  areaRegion: '',
};
