import { axios } from '@/utils/request'
//  采购退货申请单列表  分页
export const purchaseReturnList = (params) => {
  const url = `/purchaseReturnApply/queryPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post'
  })
}
// 申请单新增
export const purchaseReturnSave = (params) => {
  return axios({
    url: '/purchaseReturnApply/create',
    data: params,
    method: 'post'
  })
}
//  采购退货申请单 删除
export const purchaseReturnDel = (params) => {
  return axios({
    url: `/purchaseReturnApply/delete`,
    data: params,
    method: 'post'
  })
}
// 生成采购退货单
export const createPurchaseReturnBill = (params) => {
  return axios({
    url: `/purchaseReturnApply/createPurchaseReturnBill`,
    data: params,
    method: 'post'
  })
}
// 选择产品列表
export const queryDealerScopeProductPage = (params) => {
  const url = `/purchaseReturnApply/queryDealerScopeProductPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post'
  })
}
//  采购退货 详情 添加产品
export const purchaseReturnDetailSave = (params) => {
  return axios({
    url: '/purchaseReturnApply/detail/create',
    data: params,
    method: 'post'
  })
}
//  采购退货申请单 详情 删除
export const purchaseReturnDetailDel = (params) => {
  return axios({
    url: `/purchaseReturnApply/detail/delete`,
    data: params,
    method: 'post'
  })
}
//  采购退货 详情 全部删除
export const purchaseReturnDetailDelAll = (params) => {
  return axios({
    url: `/purchaseReturnApply/detail/deleteAll`,
    data: params,
    method: 'post'
  })
}
// 申请单详情修改数量
export const purchaseReturnModifyQty = (params) => {
  return axios({
    url: `/purchaseReturnApply/detail/modifyQty`,
    data: params,
    method: 'post'
  })
}
// 申请单详情修改退货原因
export const modifyReturnReason = (params) => {
  return axios({
    url: `/purchaseReturnApply/detail/modifyReturnReason`,
    data: params,
    method: 'post'
  })
}
// 批量修改退货原因
export const modifyReturnReasonList = (params) => {
  return axios({
    url: `/purchaseReturnApply/detail/modifyReturnReasonList`,
    data: params,
    method: 'post'
  })
}
//  申请单详情列表  分页
export const purchaseReturnDetailList = (params) => {
  const url = `/purchaseReturnApply/detail/queryPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post'
  })
}
//  获取采购退货申请单 详情
export const purchaseReturnDetail = (params) => {
  return axios({
    url: `/purchaseReturnApply/findBySn/${params.sn}`,
    method: 'get'
  })
}
// 采购退货申请单提交
export const purchaseReturnSubmit = (params) => {
  return axios({
    url: `/purchaseReturnApply/submit/${params.sn}`,
    method: 'get'
  })
}
// 采购退货申请单再次编辑
export const purchaseReturnAgainCreate = (params) => {
 return axios({
   url: `/purchaseReturnApply/againCreate/${params.sn}`,
   method: 'get'
 })
}

// 导出删除项
export const exportDeleteExcel = (params) => {
  return axios({
    url: `/purchaseReturnApply/detail/downloadDeleteFailExcel/${params.sn}`,
    data: params,
    method: 'post',
    responseType: 'blob'
  })
}
// 导出错误项
export const exportErrorExcel = (params) => {
  return axios({
    url: `/purchaseReturnApply/detail/downloadFailExcel`,
    data: params,
    method: 'post',
    responseType: 'blob'
  })
}

// 解析产品的导入模板
export const purchaseReturnApplyReadExcel = (params) => {
  return axios({
    url: `/purchaseReturnApply/detail/readExcel`,
    data: params,
    method: 'post'
  })
}

// 批量导入产品
export const purchaseReturnApplyCreateList = (params) => {
  return axios({
    url: `/purchaseReturnApply/detail/createList`,
    data: params,
    method: 'post'
  })
}
// 导出明细
export const purchaseReturnApplyExport = (params) => {
 return axios({
   url: `/purchaseReturnApply/excel/${params.sn}`,
   method: 'get',
   responseType: 'blob'
 })
}
// 详情  打印
export const purchaseReturnApplyPrint = params => {
  const data = {
    url: `/purchaseReturnApply/print/${params.sn}/${params.type}`,
    method: 'get'
  }
  // 喷墨打印
  if (params.type == 'INK') {
    data.responseType = 'blob'
  }
  return axios(data)
}