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

// request.defaults.baseURL = '/ezhizao-yzbh-crm'
// const headUrl = '/ezhizao-yzbh-crm'
// 查询company列表
export function listCompany(query) {
  request.defaults.baseURL = '/ezhizao-yzbh-crm'
  return request({
    url: '/business/company/list',
    method: 'get',
    params: query
  })
}

// 查询company详细
export function getCompany(id) {
  request.defaults.baseURL = '/ezhizao-yzbh-crm'
  return request({
    url: '/business/company/' + id,
    method: 'get'
  })
}

// 新增company
export function addCompany(data) {
  request.defaults.baseURL = '/ezhizao-yzbh-crm'
  return request({
    url: '/business/company',
    method: 'post',
    data: data
  })
}

// 修改company
export function updateCompany(data) {
  request.defaults.baseURL = '/ezhizao-yzbh-crm'
  return request({
    url: '/business/company',
    method: 'put',
    data: data
  })
}

// 删除company
export function delCompany(id) {
  request.defaults.baseURL = '/ezhizao-yzbh-crm'
  return request({
    url: '/business/company/' + id,
    method: 'delete'
  })
}

export function setCompanyLeader(data) {
  request.defaults.baseURL = '/ezhizao-yzbh-crm'
  return request({
    url: '/business/company/setCompanyLeader',
    method: 'post',
    data: data
  })
}

export function setCompanyAdviser(data) {
  request.defaults.baseURL = '/ezhizao-yzbh-crm'
  return request({
    url: '/business/company/setCompanyAdviser',
    method: 'post',
    data: data
  })
}

export function initArea() {
  request.defaults.baseURL = '/ezhizao-yzbh-crm'
  return request({
    url: '/business/company/initArea',
    method: 'get'
  })
}

export function importCompanyTemplate() {
  request.defaults.baseURL = '/ezhizao-yzbh-crm'
  download(
    "business/company/importTemplate",
    {
    },
    `客户导入模板${new Date().getTime()}.xlsx`
  )

}

export function importTemplateEntrust() {
  request.defaults.baseURL = '/ezhizao-yzbh-crm'
  download(
    "business/company/importTemplateEntrust",
    {
    },
    `委托导入模板${new Date().getTime()}.xlsx`
  )

}

export function importCompanyZero() {
  request.defaults.baseURL = '/ezhizao-yzbh-crm'
  download(
    "business/company/importTemplateIsZero",
    {
    },
    `客户导入模板${new Date().getTime()}.xlsx`
  )

}