import { axios } from '@/utils/request'
// 审核调拨退货
export const allocateReturnAudit = params => {
  return axios({
    url: '/allocateReturn/audit',
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('审核')
    }
  })
}
// 删除调拨退货
export const allocateReturnDelete = params => {
  return axios({
    url: `/allocateReturn/delete/${params.allocateReturnSn}`,
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('删除')
    }
  })
}
// 品检 提交
export const allocateReturnCheckSubmit = params => {
  return axios({
    url: '/allocateReturn/check',
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('提交')
    }
  })
}
// 财务审核调拨退货
export const allocateReturnFinanceAudit = params => {
  return axios({
    url: '/allocateReturn/financeAudit',
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('退货确认')
    }
  })
}
// 导出excel
export const allocateReturnExcel = params => {
  return axios({
    url: `/allocateReturn/excel/${params.allocateReturnSn}`,
    method: 'get',
    responseType: 'blob',
    headers: {
      'module': encodeURIComponent('导出excel')
    }
  })
}
// 打印
export const allocateReturnPrint = params => {
  return axios({
    url: `/allocateReturn/print/${params.printType}`,
    method: 'post',
    data: params,
    responseType: 'blob',
    headers: {
      'module': encodeURIComponent('打印')
    }
  })
}
// 查询调拨退货详情
export const allocateReturnQueryBySn = params => {
  return axios({
    url: `/allocateReturn/queryBySn/${params.allocateReturnSn}`,
    method: 'get'
  })
}
// 分页查询调拨退货列表
export const allocateReturnQueryPage = (params) => {
  const url = `/allocateReturn/queryPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('列表查询')
    }
  })
}
// 分页查询调拨退货确认列表
export const allocateReturnQueryConfirmPage = (params) => {
  const url = `/allocateReturn/queryConfirmPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('列表查询')
    }
  })
}
// 保存调拨退货
export const allocateReturnSave = params => {
  return axios({
    url: '/allocateReturn/save',
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('新增')
    }
  })
}
// 提交调拨退货
export const allocateReturnSubmit = params => {
  return axios({
    url: '/allocateReturn/submit',
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('提交')
    }
  })
}

// 调拨退货品检批量处理
export const allocateReturnCheck = params => {
  return axios({
    url: `/allocReturnDetail/check/${params.allocateReturnSn}/${params.allocateCheckType}`,
    data: params.list,
    method: 'post',
    headers: {
      'module': encodeURIComponent(params.allocateCheckType == 'CUSTOM' ? '修改返库数量' : '批量返库')
    }
  })
}

// 删除调拨退货明细
export const allocReturnDetailDelete = params => {
  return axios({
    url: '/allocReturnDetail/delete',
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('删除')
    }
  })
}
// 新增调拨退货明细
export const allocReturnDetailInsert = params => {
  return axios({
    url: '/allocReturnDetail/insert',
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('添加')
    }
  })
}
// 批量添加退货明细
export const allocReturnDetailInsertBatch = params => {
  return axios({
    url: '/allocReturnDetail/insertBatch',
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('批量添加')
    }
  })
}
// 分页查询调拨退货明细列表
export const allocReturnDetailQueryPage = (params) => {
  const url = `/allocReturnDetail/queryPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('明细列表查询')
    }
  })
}
// 更新调拨退货明细
export const allocReturnDetailUpdate = params => {
  return axios({
    url: '/allocReturnDetail/update',
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('修改明细')
    }
  })
}

// 调拨退货  不抓单  选择产品分页列表（经销商）
export const queryStockProductPage = (params) => {
  const url = `/allocateReturn/queryStockProductPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('列表查询')
    }
  })
}

// 调拨退货  不抓单  选择产品分页列表（非经销商）
export const stockQueryStockProductPage = (params) => {
  const url = `/stock/queryStockProductPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('列表查询')
    }
  })
}
