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

//  根据sn查找经销商详情
export const dealerDetailBySn = (params) => {
  return axios({
    url: `/dealer/findBySn/${params.sn}`,
    data: params,
    method: 'get',
    headers: {
      'module': encodeURIComponent('经销商详情')
    }
  })
}
// 查询商户类型
export const dealerTypeTreeList = (params) => {
  return axios({
    url: `/dealerType/queryTree`,
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('查询商户类型')
    }
  })
}
// 根据sn查找修改过后的经销商信息
export const dealerFindUpdateInfoBySn = (params) => {
  return axios({
    url: `/dealer/findUpdateInfoBySn/${params.sn}`,
    data: params,
    method: 'get',
    headers: {
      'module': encodeURIComponent('修改过的经销商详情')
    }
  })
}
// 为分区绑定经销商查询经销商列表
export const queryDealerPageList = (params) => {
  const url = `/dealer/queryDealerPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post'
  })
}
//  经销商列表有分页,不受权限控制
export const dealerQueryList = (params) => {
  const url = `/dealer/queryPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('经销商列表查询')
    }
  })
}
//  经销商 列表 有分页, 有权限控制
export const dealerSubareaScopeList = (params) => {
  const url = `/dealer/queryBySubareaScope/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('经销商列表查询')
    }
  })
}
//  经销商保存
export const dealerSave = (params) => {
  return axios({
    url: '/dealer/save',
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('保存')
    }
  })
}
//  经销商 导出
export const dealerExport = (params) => {
  return axios({
    url: '/dealer/exportList',
    data: params,
    method: 'post',
    responseType: 'blob',
    headers: {
      'module': encodeURIComponent('导出')
    }
  })
}
// 审核经销商资料
export const dealerAudit = (params) => {
  return axios({
    url: `/dealer/audit/${params.dealerAuditSn}/${params.auditState}`,
    method: 'get',
    headers: {
      'module': encodeURIComponent('审核')
    }
  })
}

// 更新经销级别
export const updateDealerLevel = (params) => {
  return axios({
    url: `/dealer/updateDealerLevel/${params.dealerSn}/${params.dealerLevel}`,
    method: 'get',
    headers: {
      'module': encodeURIComponent('级别设置')
    }
  })
}

// 更新合作状态
export const updateCooperate = (params) => {
  return axios({
    url: '/dealer/updateCooperate',
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('合作设置')
    }
  })
}

//  经销商账号  列表  有分页
export const dealerUserList = (params) => {
  const url = `/dealer/user/queryLike/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('列表查询')
    }
  })
}
// 经销商账号  详情
export const dealerUserDetail = (params) => {
  return axios({
    url: `/dealer/user/findById/${params.id}`,
    method: 'get',
    headers: {
      'module': encodeURIComponent('详情查看')
    }
  })
}
// 经销商账号  删除
export const dealerUserDel = (params) => {
  return axios({
    url: `/dealer/user/delete/${params.id}`,
    method: 'get',
    headers: {
      'module': encodeURIComponent('删除')
    }
  })
}
// 经销商账号  启禁用
export const dealerUserEnable = (params) => {
  return axios({
    url: `/dealer/user/enable/${params.id}/${params.flag}`,
    method: 'get',
    headers: {
      'module': encodeURIComponent('启用禁用')
    }
  })
}
// 经销商账号  修改密码
export const dealerUserChangeP = (params) => {
  return axios({
    url: `/dealer/user/changePWD`,
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('修改密码')
    }
  })
}
// 经销商账号  重置密码
export const dealerUserResetP = (params) => {
  return axios({
    url: `/dealer/user/resetPwd`,
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('重置密码')
    }
  })
}
// 经销商账号  保存
export const dealerUserSave = (params) => {
  return axios({
    url: `/dealer/user/save`,
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('新增')
    }
  })
}

// 根据经销商sn查询经销商信息   选择列表回显可用
export const getDealerListInfo = (params) => {
  return axios({
    url: `/dealer/queryBySns`,
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('选择经销商')
    }
  })
}

// 经销商差价分配列表
export const dealerUpsList = (params) => {
  const url = `/dealerUps/queryList`
  return axios({
    url: url,
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('经销商差价设置列表')
    }
  })
}

// 经销商差价列表删除
export const dealerUpsDelete = (params) => {
  const url = `/dealerUps/delete`
  return axios({
    url: url,
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('经销商差价设置删除')
    }
  })
}
// 差价品类列表
export const dealerUpsPlTree = (params) => {
  return axios({
    url: `/dealerUps/queryWaitingData`,
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('经销商差价设置品类树数据')
    }
  })
}

// 差价设置保存
export const dealerUpsCreate = (params) => {
  return axios({
    url: `/dealerUps/create`,
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('经销商差价设置保存')
    }
  })
}
// 修改
export const dealerUpsUpdate = (params) => {
  return axios({
    url: `/dealerUps/update`,
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('经销商差价设置编辑')
    }
  })
}

// 有轮胎（三级分类）的经销商 列表
export const queryTireDealerPage = (params) => {
  const url = `/dealer/queryTireDealerPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('经销商轮胎列表')
    }
  })
}
