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

// 绑定经销商关系
export const bindRelation = (params) => {
  return axios({
    url: `/dealerRelation/bindRelation/${params.parentDealerSn}/${params.subDealerSn}`,
    method: 'get',
    headers:{
      'module': encodeURIComponent('关联下级')
    }
  })
}

//  经销商关系绑定 列表  有分页
export const dealerRelationList = (params) => {
  const url = `/dealerRelation/queryPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post',
    headers:{
      'module': encodeURIComponent('列表查询')
    }
  })
}

// 分页查询返利信息
export const queryRebatePage = (params) => {
  const url = `/dealerRelation/queryRebatePage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post',
    headers:{
      'module': encodeURIComponent('列表查询')
    }
  })
}

// 根据父经销商查找子经销商列表
export const querySubList = (params) => {
  return axios({
    url: `/dealerRelation/querySubList/${params.parentDealerSn}`,
    method: 'get',
    headers:{
      'module': encodeURIComponent('子经销商列表')
    }
  })
}

// 解绑经销商关系
export const unbindRelation = (params) => {
  return axios({
    url: `/dealerRelation/unbindRelation/${params.subDealerSn}`,
    method: 'get',
    headers:{
      'module': encodeURIComponent('取消关联')
    }
  })
}

// 更新经销商返利信息
export const updateRebate = (params) => {
  return axios({
    url: `/dealerRelation/updateRebate`,
    data: params,
    method: 'post',
    headers:{
      'module': encodeURIComponent('编辑')
    }
  })
}

// 经销商所属分区  列表
export const queryDealerWithBizuser = (params) => {
  const url = `/subareaAreaDealer/queryDealerWithBizuser/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post',
    headers:{
      'module': encodeURIComponent('列表查询')
    }
  })
}

// 经销商所属分区  导出
export const exportDealerWithBizuser = params => {
  const url = `/subareaAreaDealer/exportDealerWithBizuser`
  return axios.request({
    url: url,
    data: params,
    method: 'post',
    responseType: 'blob',
    headers:{
      'module': encodeURIComponent('导出')
    }
  })
}
