import request from '@/config/axios'

export interface WeighVO {
  id?: number
  supplierName: string
  supplierName2?: string
  idCardNumber: string
  grossWeight: number
  tareWeight: number
  vehicleNumber: string
  driver: string
  netWeight: number
  administrator: string
  impurityRate: number
  originCertificateNumber: string
  plannedWeight: number
  weigher: string
  productId?: number
  productName?: string
  inStatus?: number
  remark?: string
  fileUrl?: string
  // 新增字段
  sampleDate?: string
  sampleLocation?: string
  representativeWeight?: number
  sampleWeight?: number
  impurityWeight?: number
  sandWeight?: number
  sensoryEvaluation?: string
  qualificationRate?: string
  moistureContent?: string
  sugarContent?: string
  raValue?: string
  stvValue?: string
  labTechnician?: string
  inspectionRemark?: string
}

// ERP 过磅单 API
export const WeighApi = {
  // 查询过磅单分页
  getWeighPage: async (params: any) => {
    return await request.get({ url: `/erp/weigh/page`, params })
  },

  // 查询过磅单详情
  getWeigh: async (id: number) => {
    return await request.get({ url: `/erp/weigh/get?id=` + id })
  },

  // 新增过磅单
  createWeigh: async (data: WeighVO) => {
    return await request.post({ url: `/erp/weigh/create`, data })
  },

  // 修改过磅单
  updateWeigh: async (data: WeighVO) => {
    return await request.put({ url: `/erp/weigh/update`, data })
  },

  // 删除过磅单
  deleteWeigh: async (id: number) => {
    return await request.delete({ url: `/erp/weigh/delete?id=` + id })
  },

  // 过磅单入库
  inbound: async (payload: { weighId: number; warehouseId: number; count: number }) => {
    return await request.post({ url: `/erp/weigh/inbound`, data: payload })
  },

  // 导出过磅单 Excel
  exportWeigh: async (params) => {
    return await request.download({ url: `/erp/weigh/export-excel`, params })
  }
} 