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

//  销售退货 审核
export const salesReturnAudit = (params) => {
  return axios({
    url: `/salesReturn/audit/${params.sn}`,
    method: 'get'
  })
}
//  销售退货 删除
export const salesReturnDel = (params) => {
  return axios({
    url: `/salesReturn/delete/${params.sn}`,
    method: 'get'
  })
}

//  销售退货明细 删除
export const salesReturnDetailDel = (params) => {
  return axios({
    url: `/salesReturn/detail/delete/${params.id}`,
    method: 'get'
  })
}

//  销售退货明细 整单删除
export const salesReturnDelAll = (params) => {
  return axios({
    url: `/salesReturn/detail/deleteAll/${params.sn}`,
    method: 'get'
  })
}
// 销售退货  列表  统计
export const salesReturnCount = (params) => {
  const url = `/salesReturn/queryCount`
  return axios({
    url: url,
    data: params,
    method: 'post'
  })
}
// 明细列表统计，不传sn 是所有统计
export const salesReturnQueryCount = (params) => {
  const url = `/salesReturn/detail/queryCount`
  return axios({
    url: url,
    data: params,
    method: 'post'
  })
}

//  销售退货 分页查询销售退货明细
export const salesReturnDetailList = (params) => {
  const url = `/salesReturn/detail/queryPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post'
  })
}
//  销售退货 分页查询产品
export const salesReturnProductList = (params) => {
  const url = `/salesReturn/detail/querySalesBillDetailPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post'
  })
}
//  产品添加和修改
export const salesReturnSaveProduct = (params) => {
  return axios({
    url: '/salesReturn/detail/save',
    data: params,
    method: 'post'
  })
}

// 退货打折
export const salesReturnDiscount = (params) => {
  return axios({
    url: '/salesReturn/discount',
    data: params,
    method: 'post'
  })
}

//  销售退货 导出
export const salesReturnExport = (params) => {
  return axios({
    url: '/salesReturn/export',
    data: params,
    method: 'post'
  })
}

// 根据SN查询销售退货单
export const salesReturnDetail = (params) => {
  return axios({
    url: `/salesReturn/findBySn/${params.sn}`,
    method: 'get'
  })
}

//  销售退货 付款
export const salesReturnPay = (params) => {
  return axios({
    url: '/salesReturn/pay',
    data: params,
    method: 'post'
  })
}

//  销售退货 打印
export const salesReturnPrint = (params) => {
  return axios({
    url: '/salesReturn/print',
    data: params,
    method: 'post'
  })
}

//  销售退货 打印预览
export const salesReturnprintPreview = (params) => {
  return axios({
    url: '/salesReturn/printPreview',
    data: params,
    method: 'post'
  })
}

//  销售退货 列表分页
export const salesReturnList = (params) => {
  const url = `/salesReturn/queryPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post'
  })
}

//  销售退货单保存
export const salesReturnSave = (params) => {
  return axios({
    url: '/salesReturn/save',
    data: params,
    method: 'post'
  })
}
//  销售退货 提交
export const salesReturnSubmit = (params) => {
  return axios({
    url: `/salesReturn/submit/${params.sn}`,
    method: 'get'
  })
}
// 销售退货 详情  打印
export const salesReturnDetailPrint = params => {
  const data = {
    url: `salesReturn/print/${params.sn}/${params.type}`,
    method: 'get',
  }
  // 喷墨打印
  if(params.type=='INK'){
    data.responseType = 'blob'
  }
  return axios.request(data)
}
// 销售退货 详情  导出
export const salesDetailExport = params => {
  return axios.request({
    url: `salesReturn/excel/${params.sn}`,
    method: 'get',
    responseType: 'blob'
  })
}
