import request from '@/config/axios'

// 车间仓库存 VO
export interface StockWorkshopVO {
  id: number // id
  itemId: number // 原料编号
  count: number // 库存数量
  categoryId: number // 分类
}

// 车间仓库存 API
export const StockWorkshopApi = {
  // 查询车间仓库存分页
  getStockWorkshopPage: async (params: any) => {
    return await request.get({ url: `/mes/stock-workshop/page`, params })
  },

  // 查询车间仓库存详情
  getStockWorkshop: async (id: number) => {
    return await request.get({ url: `/mes/stock-workshop/get?id=` + id })
  },

  // 新增车间仓库存
  createStockWorkshop: async (data: StockWorkshopVO) => {
    return await request.post({ url: `/mes/stock-workshop/create`, data })
  },

  // 修改车间仓库存
  updateStockWorkshop: async (data: StockWorkshopVO) => {
    return await request.put({ url: `/mes/stock-workshop/update`, data })
  },

  // 删除车间仓库存
  deleteStockWorkshop: async (id: number) => {
    return await request.delete({ url: `/mes/stock-workshop/delete?id=` + id })
  },

  // 导出车间仓库存 Excel
  exportStockWorkshop: async (params) => {
    return await request.download({ url: `/mes/stock-workshop/export-excel`, params })
  },
}

// 车间仓明细 VO
export interface StockWorkshopDetailVO {
  id: number // id
  itemId: number // 原料id
  count: number // 数量
  detailType: string // 明细类别
  itemRequisitionCode: string // 领料单
  itemRequisitionDetailId: number // 领料明细id
  feedingRecordCode: string // 投料单
  feedingRecordId: number // 投料id
  userId: number // 操作人员
  operateTime: Date // 单据时间
}

// 车间仓明细 API
export const StockWorkshopDetailApi = {
  // 查询车间仓明细分页
  getStockWorkshopDetailPage: async (params: any) => {
    return await request.get({ url: `/mes/stock-workshop-detail/page`, params })
  },

  // 查询车间仓明细详情
  getStockWorkshopDetail: async (id: number) => {
    return await request.get({ url: `/mes/stock-workshop-detail/get?id=` + id })
  },

  // 新增车间仓明细
  createStockWorkshopDetail: async (data: StockWorkshopDetailVO) => {
    return await request.post({ url: `/mes/stock-workshop-detail/create`, data })
  },

  // 修改车间仓明细
  updateStockWorkshopDetail: async (data: StockWorkshopDetailVO) => {
    return await request.put({ url: `/mes/stock-workshop-detail/update`, data })
  },

  // 删除车间仓明细
  deleteStockWorkshopDetail: async (id: number) => {
    return await request.delete({ url: `/mes/stock-workshop-detail/delete?id=` + id })
  },

  // 导出车间仓明细 Excel
  exportStockWorkshopDetail: async (params) => {
    return await request.download({ url: `/mes/stock-workshop-detail/export-excel`, params })
  },
}
