// @/utils/global
import { getLoad } from '@/api/sys/sysDataItemDetail';

// 全局变量配置
export const getYearList = () => {
  const num = 4;
  const currentYear = new Date().getFullYear();
  // 存储年份数据的数组
  const list: any = [];
  // 获取当前年份
  // year.value = Number(`${currentYear}`);
  list.push({
    value: Number(`${currentYear}`),
    label: Number(`${currentYear}`),
  });
  // 获取后面几年的数据
  for (let i = 1; i <= num; i++) {
    list.push({
      value: Number(`${currentYear - i}`),
      label: Number(`${currentYear - i}`),
    });
  }
  return list;
};
// 批次
export const batchOptions = [];
// 年份
export const yearOptions = getYearList();

// 判定结果
export const mapTypeOptions = [
  { label: '合法', value: 0 },
  { label: '违法', value: 1 },
  { label: '其他', value: 2 },
];
export const keyIssuesIIMapTypeOptions = [
  { label: '合法', value: 0 },
  { label: '违法', value: 1 },
  { label: '其他', value: 2 },
  { label: '自建自用', value: 3 },
];
export const illegalTypeOptions = [
  { label: '非农化', value: 0 },
  { label: '非粮化', value: 1 },
];
export const measureOptions = [
  { label: '拆除复耕', value: 0 },
  { label: '补办手续', value: 1 },
];
export const keyIssuesIMeasureOptions = [
  { label: '拆除', value: 1 },
  { label: '拆除复耕', value: 2 },
];
export const redLineMeasureOptions = [
  { label: '恢复原地类', value: '0' },
  { label: '补办手续', value: '1' },
];
export const keyIssuesIIMeasureOptions = [
  { label: '拆除', value: 1 },
  { label: '没收', value: 2 },
];
export const mapStatusOptions = [
  { label: '待接收', value: '待接收' },
  { label: '待填报', value: '待填报' },
  { label: '待整改', value: '待整改' },
  { label: '市级驳回', value: '市级驳回' },
  { label: '县级驳回', value: '县级驳回' },
];
export const keyProblemSearchMapStatusOptions = [
  { label: '待接收', value: '待接收' },
  { label: '待填报', value: '待填报' },
  { label: '市级驳回', value: '市级驳回' },
  { label: '县级驳回', value: '县级驳回' },
];
export const keyProblemMapStatusOptions = [
  { label: '待接收', value: '待接收' },
  { label: '待填报', value: '待填报' },
  { label: '市级审核', value: '市级审核' },
  { label: '县级审核', value: '县级审核' },
  { label: '已归档', value: '已归档' },
];
export const auditMapStatusOptions = [
  { label: '市级驳回', value: '市级驳回' },
  { label: '县级驳回', value: '县级驳回' },
];
// 标注类型
export const markTypeOptions = [
  { label: '在建', value: '在建' },
  { label: '已建成', value: '已建成' },
  { label: '持续变化', value: '持续变化' },
];
// 图斑来源
export const patchSourceOptions = [
  {
    label: '全域巡查',
    value: '全域巡查',
  },
  {
    label: '卫片下发',
    value: '卫片下发',
  },
  // {
  //   label: '部级矿产卫片图斑',
  //   value: '部级矿产卫片图斑',
  // },
  // {
  //   label: '省级矿产卫片图斑',
  //   value: '省级矿产卫片图斑',
  // },
  {
    label: '省级月度图斑',
    value: '省级月度图斑',
  },
];
export const isOverdueOptions = [
  {
    label: '未超期',
    value: 0,
  },
  {
    label: '已超期',
    value: 1,
  },
];
export const illegalTypeList = [
  { label: '非农化违法用地', value: 0 },
  { label: '非粮化违法用地', value: 1 },
];
export const resultOptions = [
  { label: '立案', value: 0 },
  { label: '非立案', value: 1 },
  { label: '移交其他部门处理', value: 2 },
  { label: '未处理', value: 3 },
];
export const resultNameOptions = [
  {
    label: '立案',
    value: '立案',
  },
  {
    label: '非立案',
    value: '非立案',
  },
  {
    label: '移交其他部门处理',
    value: '移交其他部门处理',
  },
  {
    label: '未处理',
    value: '未处理',
  },
];
export const qitaUseTOOptions = [
  {
    label: '不改变原用地性质的光伏用地',
    value: '1',
  },
  {
    label: '设施农业用地',
    value: '2',
  },
  {
    label: '农村道路',
    value: '3',
  },
  {
    label: '实地未变化',
    value: '4',
  },
  {
    label: '临时用地',
    value: '5',
  },
];
export const nowStatusOptions = [
  { label: '待接收', value: '待接收' },
  { label: '待填报', value: '待填报' },
  { label: '待整改', value: '待整改' },
  { label: '市级审核', value: '市级审核' },
  { label: '县级审核', value: '县级审核' },
  { label: '已归档', value: '已归档' },
];
//获取近7个月的时间
export const getMonth = () => {
  //创建现在的时间
  const data = new Date();
  //获取年
  let year = data.getFullYear();
  //获取月
  let mon = data.getMonth() + 1;
  let arry: any = [];
  for (let i = 0; i < 6; i++) {
    if (mon <= 0) {
      year = year - 1;
      mon = mon + 12;
    }
    arry.push({
      label: `${mon}月`,
      value: mon,
    });
    mon = mon - 1;
  }
  return arry.reverse();
};
export const monthOptions = getMonth();
export const monthAllOptions = () => {
  let arr: any = getMonth();
  arr.reverse().unshift({ label: '全部', value: 0 });
  return arr;
};
// 根据字典async获取对应的筛选数据
export const asyncGetOptions = async (code: string) => {
  let arry: any = [];
  await getLoad({ code: code }).then((res) => {
    res.forEach((item: any) => {
      arry.push({
        label: item.itemName,
        value: item.itemValue,
      });
    });
  });
  return arry;
};
export const isChuliOptions = [
  { label: '是', value: '1' },
  { label: '否', value: '2' },
];
export const keyIssusesIPatchSourceOptions = await asyncGetOptions('zd1tbly');
export const keyIssusesIIPatchSourceOptions = await asyncGetOptions('zd2tbly');
export const inspectionAuditPatchSourceOptions = await asyncGetOptions('xcsjtbly');
export const degrainingPatchSourceOptions = await asyncGetOptions('gdflhbly');
export const redLinePatchSourceOptions = await asyncGetOptions('redlinetbly');

export const getZhuantiName = () => {
  let code = sessionStorage.getItem('SelectOtherZhuantiCode')
  switch(code){
    case "0000001":
      return '违法用地'
    case "0000002":
      return '巡察审计'
    case "0000003":
      return '非法采矿卫片下发'
    case "0000004":
      return '耕地非粮化'
    case "0000005":
      return '重点问题Ⅰ类'
    case "0000006":
      return '重点问题Ⅱ类'
    case "0000007":
      return '生态保护红线监管'
    case "0000008":
      return '生态修复'
    case "100001":
      return '非法采矿'
  }
}