/**
 * 年份       year
 * 线索来源   tubanlaiyuan
 * 线索类型   typename
 * 县区       countyid
 * 乡镇       streetid
 * 处理状态   nowStatus
 * 下发时间段 startTime-endTime
 * 线索号     caseNo
 * 是否立案   register
 */
// 线索来源
import { getChildrenTree } from '@/api/demo/system';
import { asyncGetOptions } from '@/utils/global';
import { getLoadStreet } from '@/api/tiankongdi/index';
import { getAppEnvConfig } from '@/utils/env';

const { VITE_GLOB_GEOSERVER_PREFECTURE_CITY } = getAppEnvConfig();

const counties = await getChildrenTree({ parentId: VITE_GLOB_GEOSERVER_PREFECTURE_CITY });
const streets = await getLoadStreet();

export const polygonSourceOptions = await asyncGetOptions('tubanlaiyuan');
// 线索类型
export const polygonTypeOptions = await asyncGetOptions('kctubanleixing');
// 当前状态
export const statusOptions = await asyncGetOptions('kcdangqianzhuangtai');
// 是否立案
export const registerOptions = await asyncGetOptions('kcregister');
export const countiesOptions = counties.map((item) => {
  return {
    label: item.name,
    value: item.id,
  };
});
export const streetsOptions = streets.map((item) => {
  return {
    label: item.Name,
    value: item.Id,
  };
});
export const orderUtils = {
  0: null,
  1: 'asc',
  2: 'desc',
};
export const usePageRequestUrl = {
  patternfilling: '/api/DroneCaseInfoLzwjf/LoadTaskClueFill',
};
export const usePageGetSearchItem = {
  patternfilling: ['year', 'streetid', 'time', 'caseNo'],
};
export const smallInput: any = ['patternfilling'];
export const yongtufenleiOptions = [
  { label: '产业类', value: 1 },
  { label: '公共管理服务类', value: 2 },
  { label: '设施农业类', value: 3 },
];
export const getYongtufenleiSpan = (value) => {
  let record = yongtufenleiOptions.find((item) => {
    return item.value == value;
  });
  return record?.label;
};
export const yesOrNoOptions = (value) => {
  if (value == null) {
    return '';
  }
  return value == '1' ? '是' : '否';
};
export const dataProcessing = (value) => {
  if (!value) {
    return '0亩';
  }
  if (value.indexOf('.') == -1) {
    return `${value}亩`;
  } else {
    if (value.split('.')[1].length <= 3) {
      return `${value}亩`;
    }
    const resultString = value.replace('㎡', '');
    return Number(resultString).toFixed(3) + '亩';
  }
};
export const dataProcessingCount = (value) => {
  if (!value) {
    return 0;
  }
  value = value.toString();
  if (value.indexOf('.') == -1) {
    return value;
  } else {
    if (value.split('.')[1].length <= 3) {
      return value;
    }
    const resultString = value.replace('㎡', '');
    return Number(resultString).toFixed(3);
  }
};
