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

//  销售退货 审核
export const salesReturnAudit = (params) => {
  return axios({
    url: `/salesReturn/audit`,
    data: params,
    method: 'post',
    headers:{
              'module': encodeURIComponent('审核')
        }
  })
}
//  销售退货 品检
export const salesReturnCheck = (params) => {
  return axios({
    url: `/salesReturn/check`,
    data: params,
    method: 'post',
    headers:{
        'module': encodeURIComponent('品检')
    }
  })
}

//  销售退货 删除
export const salesReturnDel = (params) => {
  return axios({
    url: `/salesReturn/delete/${params.salesReturnBillSn}`,
    method: 'get',
    headers:{
        'module': encodeURIComponent('删除')
    }
  })
}

//  销售退货 取消
export const salesReturnCancelBill = (params) => {
  return axios({
    url: `/salesReturn/cancelBill/${params.salesReturnBillSn}`,
    method: 'get',
    headers:{
        'module': encodeURIComponent('取消')
    }
  })
}

// 再次编辑
export const updateAgain = (params) => {
  return axios({
    url: `/salesReturn/updateAgain/${params.salesReturnBillSn}`,
    method: 'get',
    headers:{
        'module': encodeURIComponent('再次编辑')
    }
  })
}

// 修改退货仓库
export const updateWarehouse = (params) => {
  return axios({
    url: `/salesReturn/updateWarehouse`,
    data: params,
    method: 'post',
    headers:{
        'module': encodeURIComponent('修改退货仓库')
    }
  })
}

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

// 新建销售退货单
export const salesReturnInsert = (params) => {
  return axios({
    url: '/salesReturn/insert',
    data: params,
    method: 'post',
    headers:{
        'module': encodeURIComponent('新增')
    }
  })
}
// 修改销售退货单基本信息
export const salesReturnModify = (params) => {
  return axios({
    url: '/salesReturn/modify',
    data: params,
    method: 'post',
    headers:{
        'module': encodeURIComponent('修改基本信息')
    }
  })
}
// 销售退货单付款
export const salesReturnPay = (params) => {
  return axios({
    url: '/salesReturn/pay',
    data: params,
    method: 'post',
    headers:{
        'module': encodeURIComponent('付款')
    }
  })
}

//  销售退货 打印预览
export const salesReturnPrint = (params) => {
  return axios.request({
    url: `/salesReturn/print/${params.priceType}`,
    data: params,
    method: 'post',
    responseType: 'blob',
    headers:{
        'module': encodeURIComponent('打印')
    }
  })
}

//  销售退货 导出
export const salesReturnExport = (params) => {
  return axios.request({
    url: `/salesReturn/export/${params.salesReturnBillSn}/${params.priceType}`,
    method: 'get',
    responseType: 'blob',
    headers:{
        'module': encodeURIComponent('导出Excel')
    }
  })
}

//  销售退货 分页查询产品
export const salesReturnList = (params,type) => {
  const url = `/salesReturn/queryPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post',
    headers:{
      'module': encodeURIComponent(type==1?'选择销退单':'列表查询')
    }
  })
}
//  收货品检 分页查询产品
export const takeQueryPage = (params) => {
  const url = `/salesReturn/takeQueryPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post',
    headers:{
        'module': encodeURIComponent('列表查询')
    }
  })
}
// 销售退货 统计
export const salesReturnQueryCount = (params) => {
  const url = `/salesReturn/queryCount`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post'
  })
}

// 销售退货 操作记录
export const salesReturnChangeLogList = (params) => {
  const url = `/salesReturn/changeLog/queryPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post',
    headers:{
        'module': encodeURIComponent('操作记录')
    }
  })
}

//  销售退货 提交
export const salesReturnSubmit = (params) => {
  return axios({
    url: `/salesReturn/submit`,
    data: params,
    method: 'post',
    headers:{
        'module': encodeURIComponent('提交')
    }
  })
}

// 抓单列表
export const salesQueryByReturn = (params) => {
  const url = `/sales/detail/queryByReturn/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post',
    headers:{
        'module': encodeURIComponent('抓单明细列表查询')
    }
  })
}

// 可选产品列表
export const queryDealerProductPage = (params) => {
  const url = `/product/querySalesReturnPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post',
    headers:{
        'module': encodeURIComponent('可选产品列表查询')
    }
  })
}

// 退货确认  列表  分页
export const salesReturnFinancialList = (params) => {
  const url = `/salesReturn/queryPageByFinancial/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post',
    headers:{
        'module': encodeURIComponent('列表查询')
    }
  })
}
// 退货确认  详情  列表  分页
export const salesReturnFinancialDetailList = (params) => {
  const url = `/salesReturn/detail/queryPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post',
    headers:{
        'module': encodeURIComponent('明细列表查询')
    }
  })
}

// 销售退货 客服确认
export const customerServiceConfirm = (params) => {
  return axios({
    url: `/salesReturn/customerServiceConfirm/${params.salesReturnBillSn}`,
    method: 'get',
    headers:{
        'module': encodeURIComponent('客服确认')
    }
  })
}
// 收货提交审核
export const salesReturnReceive = (params) => {
  return axios({
    url: `/salesReturn/receive/${params.salesReturnBillSn}`,
    method: 'get',
    headers:{
        'module': encodeURIComponent('提交')
    }
  })
}

// 退货确认 退货确认
export const salesReturnFinancial = (params) => {
  return axios({
    url: '/salesReturn/financial',
    data: params,
    method: 'post',
    headers:{
        'module': encodeURIComponent('退货确认')
    }
  })
}
// 退货确认 下载模板
export const salesReturnDownload = params => {
  return axios.request({
    url: `/salesReturn/detail/downloadExcel`,
    method: 'post',
    responseType: 'blob'
  })
}
// 退货确认  解析导入的文件
export const salesReturnParseProducts = params => {
  return axios({
    url: '/salesReturn/detail/parseProducts',
    data: params,
    method: 'post'
  })
}
// 退货确认  批量插入
export const salesReturnBatchInsert = params => {
  return axios({
    url: '/salesReturn/detail/batchInsert',
    data: params,
    method: 'post',
    headers:{
        'module': encodeURIComponent('导入产品')
    }
  })
}
//  销售退货 导入产品 导出错误项
export const salesReturnFailExcel = (params) => {
  const url = `/salesReturn/detail/downloadFailExcel/${params.grabFlag}`
  delete params.grabFlag
  return axios.request({
    url: url,
    method: 'post',
    data: params.list,
    responseType: 'blob',
    headers:{
        'module': encodeURIComponent('导出错误项')
    }
  })
}

// 收货产品信息批量导入
export const salesReturnDetailBatchByReceive = (params) => {
  return axios({
    url: '/salesReturn/detail/insertBatchByReceive',
    data: params,
    method: 'post',
    headers:{
        'module': encodeURIComponent('导入产品')
    }
  })
}
// 收货导出错误项
export const salesReturnDetailImportError = (params) => {
  return axios({
    url: '/salesReturn/detail/exportImportError',
    data: params,
    method: 'post',
    responseType: 'blob',
    headers:{
        'module': encodeURIComponent('导出错误项')
    }
  })
}
// 获取审批人员默认值
export const queryLastFinishDingUser = (params) => {
  return axios({
    url: '/salesReturn/queryLastFinishDingUser',
    data: params,
    method: 'post'
  })
}

// 销售退货一览表   列表
export const queryOverviewPage = (params) => {
  const url = `/salesReturn/queryOverviewPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post',
    headers:{
        'module': encodeURIComponent('列表查询')
    }
  })
}

// 抓单  设置退货单价
export const grabSalesBill = (params) => {
  return axios({
    url: '/salesReturn/detail/grabSalesBill',
    data: params,
    method: 'post',
    headers:{
        'module': encodeURIComponent('设置退货单价')
    }
  })
}
// 判断 各级别价格不完整，不让提交
export const submitVerify = (params) => {
  return axios({
    url: '/salesReturn/submitVerify',
    data: params,
    method: 'post',
    headers:{
        'module': encodeURIComponent('提交前价格校验')
    }
  })
}
