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

//  销售详情 删除
export const salesDetailDel = (params) => {
  return axios({
    url: `/sales/detail/delete`,
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent(params.salesPromoSn ? '删除产品(salesPromoSn:' + params.salesPromoSn + ')' : '删除产品')
    }
  })
}
// 销售详情 统计 正常产品
export const salesDetaiCount = (params) => {
  return axios({
    url: `/sales/detail/queryCount`,
    data: params,
    method: 'post'
  })
}
// 活动产品统计
export const salesPromoDetailCount = (params) => {
  return axios({
    url: `/salesPromo/detail/queryCount`,
    data: params,
    method: 'post'
  })
}
// 批量删除
export const salesDetailBatchDel = (params) => {
  return axios({
    url: `/sales/detail/delete/batch`,
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent(params.salesPromoSn ? '批量删除产品(salesPromoSn:' + params.salesPromoSn + ')' : '批量删除产品')
    }
  })
}
// 批量转采购额
export const batchTransferOfPurchaseAmount = (params) => {
  return axios({
    url: `/sales/detail/batchTransferOfPurchaseAmount`,
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('批量转采购额')
    }
  })
}
// 仓库设置
export const updateWarehouse = (params) => {
  return axios({
    url: '/sales/detail/updateWarehouse',
    method: 'post',
    data: params,
    headers: {
      'module': encodeURIComponent(params.salesPromoSn ? '修改仓库(salesPromoSn:' + params.salesPromoSn + ')' : '修改仓库')
    }
  })
}
// 删除全部已选产品
export const deleteNormalAll = (params) => {
  return axios({
    url: `/sales/detail/delete/normalAll`,
    method: 'post',
    data: params,
    headers: {
      'module':encodeURIComponent('正常产品全部删除')
    }
  })
}
export const deletePromoAll = (params) => {
  return axios({
    url: `/sales/detail/delete/promoAll`,
    method: 'post',
    data: params,
    headers: {
      'module':encodeURIComponent('活动产品全部删除')
    }
  })
}

// 新增销售明细
export const salesDetailInsert = (params) => {
  return axios({
    url: '/sales/detail/insert',
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent(params.promoRuleSn ? '添加产品(promoRuleSn:' + params.promoRuleSn + ')' : '添加产品')
    }
  })
}
// 批量新增销售明细
export const salesBatchInsert = (params) => {
  return axios({
    url: `/sales/detail/insertBatch`,
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent(params.promoRuleSn ? '导入产品(promoRuleSn:' + params.promoRuleSn + ')' : '导入产品')
    }
  })
}
//  销售 导入产品 导出错误项
export const salesFailExcel = (params) => {
  const url = `/sales/detail/exportImportError`
  return axios.request({
    url: url,
    method: 'post',
    data: params.list,
    responseType: 'blob'
  })
}
// 销售详情列表分页
export const salesDetailList = (params) => {
  const url = `/sales/detail/queryPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent((params.promoRuleSn ? '产品明细查询(promoRuleSn：' + params.promoRuleSn + ')' : '产品明细查询'))
    }
  })
}

// 销售详情列表不分页
export const salesDetailAllList = (params) => {
  const url = `/sales/detail/query`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent((params.promoRuleSn ? '产品明细查询(promoRuleSn：' + params.promoRuleSn + ')' : '产品明细查询'))
    }
  })
}

// 销售 - 待下推列表 - 新
export const queryAwaitDispatch = (params) => {
  const url = `/sales/detail/queryAwaitDispatch`
  return axios({
    url: url,
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('销售单待下推列表')
    }
  })
}

// 销售详情列表-不分页-新
export const salesDetailExtPromoList = (params) => {
  const url = `/sales/detail/queryExtPromoList`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent((params.salesPromoSnSet ? '产品明细查询(promoRuleSn：' + params.salesPromoSnSet + ')' : '产品明细查询'))
    }
  })
}

//  修改销售明细数量
export const salesDetailUpdateQty = (params) => {
  return axios({
    url: '/sales/detail/updateQty',
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent(params.salesPromoSn ? '修改数量(salesPromoSn:' + params.salesPromoSn + ')' : '修改数量')
    }
  })
}
// 销售  解析导入的文件
export const salesParseProducts = params => {
  return axios({
    url: '/sales/detail/importParse',
    data: params,
    method: 'post'
  })
}
// 禁用活动信息
export const salesDisablePromo = params => {
  return axios({
    url: '/sales/detail/disablePromo',
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('禁用规则')
    }
  })
}
// 启用活动
export const salesEnablePromoPromo = params => {
  return axios({
    url: '/sales/detail/enablePromo',
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('启用规则')
    }
  })
}
// 更换活动
export const salesChangePromo = params => {
  return axios({
    url: '/sales/detail/changePromo',
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('更换促销活动')
    }
  })
}
// 新活动是否参与
export const salesDetailAddPromo = (params) => {
  return axios({
    url: '/sales/detail/addPromo',
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('添加新活动')
    }
  })
}
// 修改销售明细取消数量
export const salesDetailUpdateCancelQty = (params) => {
  return axios({
    url: '/sales/detail/cancleOfBatch',
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('批量取消')
    }
  })
}
// 整单取消待下推
export const salesDetailCancleOfAll = (params) => {
  return axios({
    url: '/sales/detail/cancelAll',
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('整单取消')
    }
  })
}

// 批量新增代发货信息
export const insertBatchOfWaitDispatch = (params) => {
  return axios({
    url: '/sales/detail/pushOfBatch',
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent(params.salesBillDetailSnList.length == 1 ? '添加产品' : '批量添加产品')
    }
  })
}

// 缺货明细
export const salesStockoutDetail = (params) => {
  const url = `/oos/detail/queryBySales`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('缺货明细')
    }
  })
}

// 导出缺货明细
export const exportStockout = params => {
  const url = `/oos/detail/exportSalesOos`
  delete params.priceType
  return axios.request({
    url: url,
    data: params,
    method: 'post',
    responseType: 'blob',
    headers: {
      'module': encodeURIComponent('导出缺货明细')
    }
  })
}
// 导出分组缺货明细
export const exportGroupStockout = params => {
  const url = `/oos/detail/exportSalesOosByBrandType`
  delete params.priceType
  return axios.request({
    url: url,
    data: params,
    method: 'post',
    responseType: 'blob',
    headers: {
      'module': encodeURIComponent('导出分组缺货明细')
    }
  })
}

// 批量添加累计产品
export const salesDetailInsertBatchBorrow = (params) => {
  return axios({
    url: '/sales/detail/insertBatchBorrow',
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('批量添加累计产品')
    }
  })
}

// 导出累计产品错误项
export const exportBorrowError = params => {
  delete params.priceType
  return axios.request({
    url: '/sales/detail/exportBorrowError',
    data: params,
    method: 'post',
    responseType: 'blob',
    headers: {
      'module': encodeURIComponent('导出累计产品错误项')
    }
  })
}

// 批量导入累计产品 成功
export const importBorrowTotalProduct = (params) => {
  return axios({
    url: '/sales/detail/importList',
    method: 'post',
    data: params
  })
}

// 查看累计产品  详情列表  分页
export const accumulatedProductsList = (params) => {
  const url = `/sales/detail/queryBorrowPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('累计产品列表')
    }
  })
}

// 删除  批量删除  累计产品
export const deleteBatchBorrow = (params) => {
  return axios({
    url: '/sales/detail/deleteBatchBorrow',
    method: 'post',
    data: params
  })
}
