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

// 发货列表分页
export const dispatchlList = (params) => {
  const url = `/dispatch/queryPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post',
    headers:{
      'module': encodeURIComponent('列表查询')
    }
  })
}

// 发货单明细列表分页
export const dispatchDetaillList = (params) => {
  const url = `/dispatch/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 dispatchDetaillListForOut = (params) => {
  const url = `/dispatch/detail/queryPageForOut/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post',
    headers:{
      'module': encodeURIComponent('明细列表查询')
    }
  })
}
// 根据销售单sn查询关联的所有发货单
export const queryBySalesBillSn = (params) => {
  return axios({
    url: `/dispatch/queryBySalesBillSn/${params.salesBillSn}`,
    method: 'get'
  })
}
// 根据销售单SN查询发货单
export const findBySalesBillSn = (params) => {
  return axios({
    url: `/dispatch/findBySalesBillSn/${params.salesBillSn}`,
    method: 'get'
  })
}
// 根据发货单SN查询发货单对象
export const dispatchFindBySn = (params) => {
  return axios({
    url: `/dispatch/findBySn/${params.dispatchBillSn}`,
    method: 'get'
  })
}
// 发货单统计查询
export const dispatchQueryCount = (params) => {
  return axios({
    url: '/dispatch/queryCount',
    data: params,
    method: 'post'
  })
}
// 对单通过
export const dispatchCheck = (params) => {
  return axios({
    url: `/dispatch/check/${params.dispatchBillSn}`,
    data: params,
    method: 'post',
    headers:{
      'module': encodeURIComponent('对单通过')
    }
  })
}
// 出库
export const dispatchStockOut = (params) => {
  return axios({
    url: `/dispatch/stockOut/${params.dispatchBillSn}`,
    method: 'get',
    headers:{
      'module': encodeURIComponent('出库')
    }
  })
}
// 修改库存类型
export const dispatchUpdateStockType = (params) => {
  return axios({
    url: '/dispatch/updateStockType',
    data: params,
    method: 'post',
    headers:{
      'module': encodeURIComponent('下推单修改轮胎库存类型')
    }
  })
}
// 备货审核
export const dispatchStockUpAduit = (params) => {
  return axios({
    url: '/dispatch/stockUpAduit',
    data: params,
    method: 'post',
    headers:{
      'module': encodeURIComponent('备货审核')
    }
  })
}
// 允许备货打印
export const dispatchPrintStatus = (params) => {
  return axios({
    url: `/dispatch/updatePrintStatus/${params.dispatchBillSn}/${params.printStatus}`,
    method: 'get',
    headers:{
      'module': encodeURIComponent(params.printStatus == 'UNABLE_PRINT' ? '暂不打印' : '允许备货打印')
    }
  })
}
// 查询备货说明列表
export const queryExplainList = (params) => {
  return axios({
    url: `/dispatch/queryExplainList/${params.dispatchBillSn}`,
    method: 'get',
    headers:{
      'module': encodeURIComponent('查询备货说明列表')
    }
  })
}
// 保存备货说明
export const saveExplain = (params) => {
  return axios({
    url: '/dispatch/saveExplain',
    data: params,
    method: 'post',
    headers:{
      'module': encodeURIComponent('保存备货说明')
    }
  })
}
// 批量备货打印
export const dispatchBatchPrintStatus = (params) => {
  return axios({
    url: `/dispatch/batchUpdatePrintStatus`,
    data: params,
    method: 'post',
    headers:{
      'module': encodeURIComponent('允许备货打印')
    }
  })
}
// 下推 详情  打印
export const dispatchDetailPrint = params => {
  const url = `/dispatch/print/${params.type}`
  return axios.request({
    url: url,
    data: params,
    method: 'post',
    headers:{
      'module': encodeURIComponent(params.type.indexOf('_TYPE')>=0 ? '发货分类打印' : '发货打印')
    }
  })
}
// 下推  详情  该销售单的产品二级分类
export const dispatchDetailType = (params) => {
  return axios({
    url: `/dispatch/detail/queryProductType/${params.dispatchBillSn}`,
    method: 'get'
  })
}
// 下推 详情  导出Excel
export const dispatchDetailExcel = params => {
  const url = `/dispatch/excel/${params.printType}`
  return axios.request({
    url: url,
    data: params,
    method: 'post',
    responseType: 'blob',
    headers:{
      'module': encodeURIComponent(params.printType.indexOf('_TYPE')>=0 ? '发货分类导出' : '导出Excel')
    }
  })
}
// 备货审核列表分页
export const dispatchlBhshList = (params) => {
  const url = `/dispatch/queryBhshPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post',
    headers:{
      'module': encodeURIComponent('列表查询')
    }
  })
}
// 发货单统计查询
export const dispatchQueryBhshCount = (params) => {
  return axios({
    url: '/dispatch/queryBhshCount',
    data: params,
    method: 'post'
  })
}
