import { axios } from '@/utils/request'

//  散件入库 列表  分页
export const sparePartsList = (params) => {
  const url = `/spareParts/queryPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post'
  })
}

export const sparePartsDetailExport = (params) => {
  return axios({
    url: '/report/spareParts/exportDetail',
    data: params,
    method: 'post',
    responseType: 'blob'
  })
}

// 审核
export const sparePartsAudit = (params) => {
  return axios({
    url: `/spareParts/audit/${params.sn}`,
    method: 'get'
  })
}
// 批量审核
export const sparePartsBatchAudit = (params) => {
  return axios({
    url: `/spareParts/batchAudit`,
    data: params,
    method: 'post'
  })
}
// 多审核校验
export const sparePartsAuditVerify = (params) => {
  return axios({
    url: `/spareParts/auditVerify`,
    data: params,
    method: 'post'
  })
}
// 导出审核错误项
export const sparePartsAuditFail = (params) => {
  return axios({
    url: `/spareParts/downloadAuditFail`,
    data: params,
    method: 'post',
    responseType: 'blob'
  })
}

// 删除
export const sparePartsDelete = (params) => {
  return axios({
    url: `/spareParts/delete/${params.sn}`,
    data: params,
    method: 'post'
  })
}

// 删除明细
export const sparePartsDeleteDetail = (params) => {
  return axios({
    url: `/spareParts/deleteDetail/${params.sn}`,
    data: params,
    method: 'post'
  })
}

// 分页列表明细
export const sparePartsDetailList = (params) => {
  const url = `/spareParts/queryDetailPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post'
  })
}

// 分页列表明细合计
export const sparePartsPageCount = (params) => {
  return axios({
    url: `/spareParts/queryDetailPageCount`,
    data: params,
    method: 'post'
  })
}

// 保存
export const sparePartsSave = (params) => {
  return axios({
    url: `/spareParts/save`,
    data: params,
    method: 'post'
  })
}

// 保存明细
export const sparePartsSaveDetail = (params) => {
  return axios({
    url: `/spareParts/saveDetail`,
    data: params,
    method: 'post'
  })
}
// 明细  详情
export const sparePartsDetailD = (params) => {
  return axios({
    url: `/spareParts/queryDetailBySn/${params.sn}`,
    data: params,
    method: 'post'
  })
}
// 散件入库 下载模板
export const sparePartsDetailDownload = params => {
  return axios.request({
    url: `/spareParts/detail/downloadExcel`,
    method: 'post',
    responseType: 'blob'
  })
}
// 散件入库  解析导入的文件
export const sparePartsDetailParseProducts = params => {
  return axios({
    url: '/spareParts/detail/parseProducts',
    data: params,
    method: 'post'
  })
}
// 散件入库  批量插入
export const sparePartsDetailBatchInsert = params => {
  return axios({
    url: '/spareParts/detail/batchInsert',
    data: params,
    method: 'post'
  })
}
//  散件入库 导入产品 导出错误项
export const sparePartsDetailFailExcel = (params) => {
  const url = `/spareParts/detail/downloadFailExcel`
  return axios.request({
    url: url,
    method: 'post',
    data: params.list,
    responseType: 'blob'
  })
}

// 明细库存分页列表
export const queryDetailStockPage = (params) => {
  const url = `/spareParts/queryDetailStockPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post'
  })
}
