// 农机档案数据类型定义

export interface MachineryRecord {
  id: string;
  // 基本信息
  name: string;
  model: string;
  category: MachineryCategory;
  usage: MachineryUsage;
  manufacturer: string;
  manufactureDate: string;
  purchaseDate: string;
  
  // 技术参数
  engineNumber: string;
  chassisNumber: string;
  power: string; // 功率
  weight: string; // 重量
  workingWidth: string; // 工作幅宽
  fuelTankCapacity?: string; // 油箱大小（升）
  
  // 购机信息
  purchasePrice: number;
  supplier: string;
  invoiceNumber: string;
  invoiceUrl?: string; // 发票文件URL
  
  // 保险信息
  insuranceCompany?: string;
  insurancePolicyNumber?: string;
  insuranceStartDate?: string;
  insuranceEndDate?: string;
  insuranceAmount?: number;
  
  // 使用信息
  status: MachineryStatus;
  currentLocation?: string;
  operator?: string;
  department?: string;
  
  // 保养信息
  maintenanceCycle?: number; // 保养周期数值
  maintenanceCycleUnit?: 'day' | 'month' | 'year'; // 保养周期单位
  
  // 其他信息
  remarks?: string;
  tags: string[];
  qrCode: string; // 二维码内容
  
  // 系统信息
  createdAt: string;
  updatedAt: string;
  createdBy: string;
  updatedBy: string;
}

export type MachineryCategory = 
  | '耕地机械'
  | '播种机械'
  | '收获机械'
  | '植保机械'
  | '灌溉机械'
  | '运输机械'
  | '其他';

export type MachineryUsage = '旱地' | '水田' | '通用' | '其他';

export type MachineryStatus = '正常' | '待维护' | '已报废';

export interface MachineryChangeHistory {
  id: string;
  machineryId: string;
  fieldName: string;
  fieldLabel: string;
  oldValue: any;
  newValue: any;
  operator: string;
  operatedAt: string;
}

export interface MachineryTag {
  id: string;
  name: string;
  color: string;
  createdAt: string;
}

export interface MachineryFilter {
  category?: MachineryCategory;
  usage?: MachineryUsage;
  status?: MachineryStatus;
  tags?: string[];
  searchKeyword?: string;
}

export type MaintenanceType = '日常保养' | '定期维护' | '故障维修' | '年检';

export interface MaterialUsage {
  materialId: string;
  quantity: number;
}

export interface MaintenanceRecord {
  id: string;
  machineryId: string;
  type: MaintenanceType;
  startTime: string;
  endTime: string;
  workHours: number;
  nextMaintenanceTime?: string;
  maintenanceItems: string;
  partsAndMaterials?: MaterialUsage[]; // 农资物料使用情况
  cost: number;
  technician: string;
  remarks?: string;
  createdAt: string;
  createdBy: string;
}

// 农资物料类型（用于维护记录选择）
export type MaterialType = '种子' | '化肥' | '农药' | '配件' | '耗材' | '其他';

export interface Material {
  id: string;
  code: string;
  name: string;
  type: MaterialType;
  spec: string;
  model?: string;
  supplier: string;
  currentStock: number;
  unit: string;
  purchasePrice: number;
  status: '正常' | '临期预警' | '库存预警' | '已过期';
}
