import request from '@/config/axios'

// 计划派工记录 VO
export interface PaigongRecordVO {
  id: number // id
  planId: number // 关联计划id
  pipeline: number // 生产线
  paigongNum: number // 派工数量
  isPreProduction: number // 是否试生产
  paigongTime: Date // 派工时间
}

// 计划派工记录 API
export const PaigongRecordApi = {
  // 查询计划派工记录分页
  getPaigongRecordPage: async (params: any) => {
    return await request.get({ url: `/mes/paigong-record/page`, params })
  },

  // 查询计划派工记录详情
  getPaigongRecord: async (id: number) => {
    return await request.get({ url: `/mes/paigong-record/get?id=` + id })
  },

  // 新增计划派工记录
  createPaigongRecord: async (data: PaigongRecordVO) => {
    return await request.post({ url: `/mes/paigong-record/create`, data })
  },

  // 修改计划派工记录
  updatePaigongRecord: async (data: PaigongRecordVO) => {
    return await request.put({ url: `/mes/paigong-record/update`, data })
  },

  // 删除计划派工记录
  deletePaigongRecord: async (id: number) => {
    return await request.delete({ url: `/mes/paigong-record/delete?id=` + id })
  },

  // 导出计划派工记录 Excel
  exportPaigongRecord: async (params) => {
    return await request.download({ url: `/mes/paigong-record/export-excel`, params })
  },

  // ==================== 子表（领料明细） ====================
  
    // 获得领料明细列表
    getPaigongRecordListByPlanId: async (planId) => {
      return await request.get({ url: `/mes/paigong-record/list-by-item-plan-id?planId=` + planId })
    }
}
