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

//  采购入库 列表  分页
export const purchaseList = (params) => {
  const url = `/purchase/queryPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('列表查询')
    }
  })
}

//  采购入库 列表合计
export const purchasePageCount = (params) => {
  return axios({
    url: '/purchase/queryPageCount',
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('列表合计')
    }
  })
}
//  采购入库 列表 取消
export const purchaseCancel = (params) => {
  const url = `/purchase/cancel/${params.sn}`
  return axios({
    url: url,
    method: 'post',
    headers: {
      'module': encodeURIComponent('取消')
    }
  })
}

// 采购入库 明细列表 分页
export const purchaseDetailPageList = (params) => {
  const url = `/purchase/queryDetailPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('列表查询')
    }
  })
}
//  采购入库 明细列表  基础信息
export const queryDetailCount = (params) => {
  const url = `/purchase/queryBySn/${params.sn}`
  return axios({
    url: url,
    method: 'post',
    headers: {
      'module': encodeURIComponent('基础信息')
    }
  })
}
//  采购入库 明细列表 统计信息
export const purchaseDetailPageCount = (params) => {
  return axios({
    url: `/purchase/queryDetailPageCount`,
    data: params,
    method: 'post'
  })
}
// 新增/编辑 采购入库详情
export const savePurchaseDetail = (params) => {
  return axios({
    url: '/purchase/saveDetail',
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('新增/编辑')
    }
  })
}
// 编辑基础信息
export const detailBaseSave = (params) => {
  return axios({
    url: '/purchase/setSupplierInfo',
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('基础信息编辑')
    }
  })
}

// 采购入库提交
export const purchaseSubmit = (params) => {
  return axios({
    url: `/purchase/submit/${params.sn}`,
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('提交')
    }
  })
}
// 采购入库  明细详情
export const getDetailData = (params) => {
  const url = `/purchase/queryDetailBySn/${params.sn}`
  return axios({
    url: url,
    method: 'post',
    headers: {
      'module': encodeURIComponent('明细详情')
    }
  })
}

// 采购入库 编辑页面 删除 sparePartsDetailSn
export const purchaseDetailDel = (params) => {
  const url = `/purchase/deleteDetail/${params.sn}`
  return axios({
    url: url,
    method: 'post',
    headers: {
      'module': encodeURIComponent('删除')
    }
  })
}

//  采购入库   解析导入的文件
export const purchaseImportData = (params) => {
  return axios({
    url: '/purchase/detail/parseProducts',
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('导入和不可导入列表')
    }
  })
}
// 采购入库 导出错误项
export const exportPurchaseData = params => {
  const url = `/purchase/detail/downloadFailExcel`
  return axios.request({
    url: url,
    data: params,
    method: 'post',
    responseType: 'blob',
    headers: {
      'module': encodeURIComponent('导出错误项')
    }
  })
}
// 采购入库 确定要导入的数据

export const purchaseImportBatchInsert = (params) => {
  return axios({
    url: 'purchase/detail/batchInsert',
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('确定导入')
    }
  })
}

// 采购入库 审核
export const purchaseAudit = (params) => {
  return axios({
    url: '/purchase/audit',
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('审核')
    }
  })
}

// 采购入库 上传凭证
export const saveAttachment = (params) => {
  return axios({
    url: '/purchase/saveAttachment',
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('上传凭证')
    }
  })
}
// 采购入库  轮胎唯一码
export const traceCodeQueryList = (params) => {
  return axios({
    url: '/traceCode/queryList',
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('查看唯一码')
    }
  })
}
