import request from '@/utils/request'
import { download, downloadPdf } from '@/utils/request'
const baseUrl = import.meta.env.VITE_APP_PRODUCTION_API

// 查询生产入库列表
export function listInboundOrder(query) {
  return request({
    url: baseUrl + '/business/inboundOrder/list',
    method: 'get',
    params: query
  })
}

// 查询生产入库详细
export function getInboundOrder(id) {
  return request({
    url: baseUrl + '/business/inboundOrder/' + id,
    method: 'get'
  })
}

// 新增生产入库
export function addInboundOrder(data) {
  return request({
    url: baseUrl + '/business/inboundOrder',
    method: 'post',
    data: data
  })
}

// 修改生产入库
export function updateInboundOrder(data) {
  return request({
    url: baseUrl + '/business/inboundOrder',
    method: 'put',
    data: data
  })
}

// 删除生产入库
export function delInboundOrder(id) {
  return request({
    url: baseUrl + '/business/inboundOrder/' + id,
    method: 'delete'
  })
}

// 根据合格证编号组 获取入库明细
export function getInboundOrderDetailByCertificateNo(certificateCodes) {
  return request({
    url: baseUrl + '/business/inboundOrder/getCertificateListByCodes',
    method: 'post',
    data: certificateCodes
  })
}

// 导出入库单pdf
export function exportInboundOrderPdf(data) {
  // return request({
  //   url: baseUrl + '/business/inboundOrder/exportPdfForOrder',
  //   method: 'post',
  //   data: data,
  //   responseType: 'blob'
  // })
  console.log(data)
  return downloadPdf(
    baseUrl + "/business/inboundOrder/exportPdfForOrder",
    {
      ...data,
    },
    `产品入库单_${new Date().getTime()}.pdf`
  )

}

export function setPrint(data) {
  return request({
    url: baseUrl + '/business/inboundOrder/setPrint',
    method: 'post',
    data: data
  })
}

export function exportCertificateLots(data) {
  download(
    baseUrl + "/business/inboundOrder/exportCertificateLots",
    {
      ...data,
    },
    `合格证_${new Date().getTime()}.xlsx`
  )
}


// 登陆人员工段export 
export function getDeptList() {
  return request({
    url: baseUrl + '/business/planDetailSubDetail/getDeptList',
    method: 'get'
  })
}

// 明细全部入库
export function inboundAllLot(data) {
  return request({
    url: baseUrl + '/business/inboundOrder/inboundAllLot',
    method: 'POST',
    data: data
  })
}
