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

//  采购退货列表  分页
export const purchaseReturnList = (params) => {
  const url = `/purchaseReturn/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: '/purchaseReturn/save',
    data: params,
    method: 'post'
  })
}
//  采购退货 删除
export const purchaseReturnDel = (params) => {
  return axios({
    url: `/purchaseReturn/delete/${params.id}`,
    method: 'get'
  })
}
//  采购退货 详情 删除
export const purchaseReturnDelAll = (params) => {
  return axios({
    url: `/purchaseReturn/detail/deleteAll/${params.purchaseReturnSn}`,
    method: 'get'
  })
}
//  采购退货  提交
export const purchaseReturnSubmit = (params) => {
  return axios({
    url: '/purchaseReturn/submit',
    data: params,
    method: 'post'
  })
}
//  采购退货 详情
export const purchaseReturnDetail = (params) => {
  return axios({
    url: `/purchaseReturn/findById/${params.id}`,
    method: 'get'
  })
}
//  采购退货 详情  根据sn查
export const purchaseReturnDetailSn = (params) => {
  return axios({
    url: `/purchaseReturn/findBySn/${params.sn}`,
    method: 'get'
  })
}
//  采购退货 详情 选择产品 列表  分页
export const purchaseReturnPurchaseBillDetailList = (params) => {
  const url = `/purchaseReturn/detail/queryPurchaseBillDetailPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post'
  })
}
//  采购退货 详情列表  分页
export const purchaseReturnDetailList = (params) => {
  const url = `/purchaseReturn/detail/queryPage/${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: '/purchaseReturn/detail/save',
    data: params,
    method: 'post'
  })
}
//  采购退货 详情 删除
export const purchaseReturnDetailDel = (params) => {
  return axios({
    url: `/purchaseReturn/detail/delete/${params.id}`,
    method: 'get'
  })
}
//  采购退货 生成出库单
export const purchaseReturnOutStockBill = (params) => {
  const url = `/purchaseReturn/createOutStockBill/${params.sn}`
  delete params.sn
  return axios({
    url: url,
    data: params,
    method: 'post'
  })
}
// 采购退货详情  打印
export const purchaseReturnDetailPrint = params => {
  const data = {
    url: `/purchaseReturn/print/${params.sn}/${params.type}`,
    method: 'get'
  }
  // 喷墨打印
  if (params.type == 'INK') {
    data.responseType = 'blob'
  }
  return axios.request(data)
}
// 采购退货 详情  导出
export const purchaseReturnDetailExport = params => {
  return axios.request({
    url: `/purchaseReturn/excel/${params.sn}`,
    method: 'get',
    responseType: 'blob'
  })
}
//  采购退货 完结单据
export const purchaseReturnFinishBill = (params) => {
  const url = `/purchaseReturn/finishBill/${params.sn}`
  delete params.sn
  return axios({
    url: url,
    data: params,
    method: 'post'
  })
}
