import request from '@/utils/request'

// 查询服务区列表
export function listArea(query) {
  return request({
    url: '/ems/basecfg/area/list',
    method: 'get',
    params: query
  })
}

export function listTotalArea() {
  return request({
    url: '/ems/basecfg/area/listTotal',
    method: 'get'
  })
}

// 查询服务区详细
export function getArea(id) {
  return request({
    url: '/ems/basecfg/area/' + id,
    method: 'get'
  })
}

// 新增服务区
export function addArea(data) {
  return request({
    url: '/ems/basecfg/area',
    method: 'post',
    data: data
  })
}

// 修改服务区
export function updateArea(data) {
  return request({
    url: '/ems/basecfg/area',
    method: 'put',
    data: data
  })
}

// 删除服务区
export function delArea(id) {
  return request({
    url: '/ems/basecfg/area/' + id,
    method: 'delete'
  })
}

// 查询区域树结构
export function areaTreeSelect(tier) {
  return request({
    url: '/ems/basecfg/area/areaTree?tier=' + tier,
    method: 'get'
  })
}

export function areaTreeSelectByCode(tier, code) {
  return request({
    url: '/ems/basecfg/area/areaTreeByCode?tier=' + tier + '&code=' + code,
    method: 'get'
  })
}

export function areaTreeSelectByTag(tier, tagCode) {
  return request({
    url: '/ems/basecfg/area/areaTreeByTag?tier=' + tier + '&tagCode=' + tagCode,
    method: 'get'
  })
}

export function areaWithFacsCategory(category, subCategory) {
  return request({
    url: '/ems/basecfg/area/listWithFacsCategory?facsCategory=' + category + '&facsSubCategory=' + subCategory,
    method: 'get'
  })
}

export function areaWithFacsCategoryAsTree(category, subCategory) {
  return request({
    url: '/ems/basecfg/area/listWithFacsCategoryAsTree?facsCategory=' + category + '&facsSubCategory=' + subCategory,
    method: 'get'
  })
}
