import request from '@/config/axios'

export interface ProductionInVO {
  id?: number
  no?: string
  status?: number
  inTime?: number
  warehouseId?: number
  totalCount?: number
  totalPrice?: number
  remark?: string
  fileUrl?: string
  items?: ProductionInItemVO[]
}

export interface ProductionInItemVO {
  id?: number
  inId?: number
  warehouseId?: number
  productId?: number
  productName?: string
  productUnitId?: number
  productUnitName?: string
  productBarCode?: string
  productPrice?: number
  count?: number
  totalPrice?: number
  remark?: string
}

// ERP 生产入库 API
export const ProductionInApi = {
  // 查询生产入库分页
  getProductionInPage: async (params: any) => {
    return await request.get({ url: `/erp/production-in/page`, params })
  },

  // 查询生产入库详情
  getProductionIn: async (id: number) => {
    return await request.get({ url: `/erp/production-in/get?id=` + id })
  },

  // 新增生产入库
  createProductionIn: async (data: ProductionInVO) => {
    return await request.post({ url: `/erp/production-in/create`, data })
  },

  // 修改生产入库
  updateProductionIn: async (data: ProductionInVO) => {
    return await request.put({ url: `/erp/production-in/update`, data })
  },

  // 更新生产入库的状态
  updateProductionInStatus: async (id: number, status: number) => {
    return await request.put({
      url: `/erp/production-in/update-status`,
      params: {
        id,
        status
      }
    })
  },

  // 删除生产入库
  deleteProductionIn: async (ids: number[]) => {
    return await request.delete({
      url: `/erp/production-in/delete`,
      params: {
        ids: ids.join(',')
      }
    })
  },

  // 导出生产入库 Excel
  exportProductionIn: async (params: any) => {
    return await request.download({ url: `/erp/production-in/export-excel`, params })
  }
} 