import { http } from '@/utils/http/axios';

import { useGlobSetting } from '@/hooks/setting';

const globSetting = useGlobSetting();
const urlPrefix = globSetting.urlPrefix || '';

const hsot = location.origin + urlPrefix;

/**
 * @description: 地区列表
 */
export function regionList(params) {
  return http.request({
    url: `${hsot}/region/list`,
    method: 'GET',
    params,
  });
}

/**
 * @description: 获取省份/直辖市
 */
export function getProvinceList(params?: any) {
  return http.request({
    url: '/region/queryProvinceList',
    method: 'GET',
    params,
  });
}

/**
 * @description: 获取下一级行政区域列表
 */
export function parentList(params) {
  return http.request({
    url: '/region/queryParentList',
    method: 'GET',
    params,
  });
}

/**
 * @description: 获取行政区域树形列表
 */
export function regionTreeList(params?) {
  return http.request({
    url: '/region/queryRegionTree',
    method: 'GET',
    params,
  });
}

/**
 * @description: 获取单个行政区域
 */
export function regionInfo(params) {
  return http.request({
    url: '/region/view',
    method: 'GET',
    params,
  });
}

/**
 * @description: 删除行政区域
 */
export function deleteRegion(params) {
  return http.request({
    url: '/region/delete',
    method: 'POST',
    params,
  });
}

/**
 * @description: 新增行政区域
 */
export function addRegion(params) {
  return http.request({
    url: '/region/add',
    method: 'POST',
    params,
  });
}

/**
 * @description: 编辑行政区域
 */
export function editRegion(params) {
  return http.request({
    url: '/region/update',
    method: 'POST',
    params,
  });
}
