import request from '../utils/request';
import { Result, ResultList, _Pager_Params } from './types';
// 区划
export interface RegionFields {
  regionCode: string;
  regionDesc: string;
  regionName: string;
  remark: string;
  supRegionCode: string;
  version: string;
  deleteTag: string;
  regionStatus: string;
  regionValidity: string;
}
// 列表
interface GetList_Params extends _Pager_Params {
  regionCode: string;
  regionName: string;
  regionDesc: string;
  supRegionCode: string;
  status: string;
  v: string;
}
type ListResult = ResultList<RegionFields[]>;

/** 获取区划列表 */
export async function getListApi(data: Partial<GetList_Params>) {
  return request<Partial<ListResult>>({
    url: '/region/list',
    method: 'get',
    params: {
      pageNum: 1,
      pageSize: 999,
      ...data,
    },
  });
}
// 详情列表
interface GetSupList_Params {
  uuid: string;
}
export async function getSupListApi(data: GetSupList_Params) {
  return request<Partial<Result<RegionFields>>>({
    url: `/region/${data.uuid}`,
    method: 'get',
    data,
  });
}

// 新增
type _Add_Params = Partial<RegionFields>;
export async function addApi(data: _Add_Params) {
  return request<Partial<ListResult>>({
    url: '/region',
    method: 'post',
    data,
  });
}
// 编辑
type _Update_Params = Partial<RegionFields>;
export async function updateApi(data: _Update_Params) {
  return request<Partial<ListResult>>({
    url: '/region/edit',
    method: 'post',
    data,
  });
}
/**
 * @name 审批
 * @param data
 * @returns
 */
interface batchType {
  regionCodes: string[];
  regionStatus: string;
}
export async function batchApi(data: batchType) {
  return request({
    url: '/region/batch',
    method: 'post',
    data,
  });
}
