export enum PlanType {
  DAILY = '日常隐患排查',
  COMPREHENSIVE = '综合性隐患排查',
  OTHER = '其他隐患排查',
}

export const hazardPlanTypeOptions: Option<string>[] = [
  { label: '日常隐患排查', value: PlanType.DAILY },
  { label: '综合性隐患排查', value: PlanType.COMPREHENSIVE },
  { label: '其他隐患排查', value: PlanType.OTHER },
];

export const getHazardPlanTypeText = (v: string) => {
  return hazardPlanTypeOptions.find(t => t.value === v)?.label || '';
};

// export const hazardPlanStatusOptions: Option<number>[] = [
//   { label: '执行中', value: 1 },
//   { label: '已完成', value: 2 },
//   { label: '未开始', value: 3 },
// ];

// export const getHazardPlanStatusText = (v: number) => {
//   return hazardPlanStatusOptions.find(t => t.value === v)?.label || '';
// };

export enum PlanLevel {
  COMPANY = '公司级',
  DEPARTMENT = '部门/中心级',
  // GROUP = '班组级',
}

export const planLevelOptions: Option<string>[] = [
  { label: '公司级', value: PlanLevel.COMPANY },
  { label: '部门/中心级', value: PlanLevel.DEPARTMENT },
  // { label: '班组级', value: PlanLevel.GROUP },
];

// ! 注意 View 有个判断，单次任务的频率是 0
export enum PlanCycle {
  SINGLE = '次', // 单次任务
  WEEK = '周', // 周循环计划
  QUARTER = '季度', // 季度循环计划
  MONTH = '月', // 月循环计划
}
export const cycleOptions: Option<string>[] = [
  { label: '单次任务', value: PlanCycle.SINGLE },
  { label: '周循环计划', value: PlanCycle.WEEK },
  { label: '季度循环计划', value: PlanCycle.QUARTER },
  { label: '月循环计划', value: PlanCycle.MONTH },
];

// export const weekOptions: Option<number>[] = [
//   { label: '每周一次', value: 1 },
//   { label: '每周两次', value: 2 },
//   { label: '每周三次', value: 3 },
// ];

// export const monthOptions: Option<number>[] = [
//   { label: '每月一次', value: 1 },
//   { label: '每月两次', value: 2 },
//   { label: '每月三次', value: 3 },
// ];

// export const getFrequencyOptions = (cycle: number) => {
//   if (cycle === 1) {
//     return weekOptions;
//   } else if (cycle === 2) {
//     return monthOptions;
//   }
//   return [];
// };

// export const getWeekText = (v: number) => {
//   return weekOptions.find(t => t.value === v)?.label || '';
// };

// export const getMonthText = (v: number) => {
//   return monthOptions.find(t => t.value === v)?.label || '';
// };

export const getCycleText = (d: Hazard.InspectionPlan) => {
  // return: 单次任务, 周循环计划, 季度循环计划, 月循环计划
  const cycle = d.cycle;
  return cycleOptions.find(c => c.value === cycle)?.label || '';
};

export const getFrequencyText = (d: Hazard.InspectionPlan) => {
  const cycleValue = d.cycle;
  if (cycleValue === PlanCycle.SINGLE) {
    return '';
  }
  return `每${d.frequency === 1 ? '' : d.frequency}${cycleValue}${d.frequencyTimes}次`;
};

export const getDurationText = (d: Hazard.InspectionPlan) => {
  return `${d.startDate} - ${d.endDate}`;
};

export enum RoundState {
  Expired = 'expired',
  Current = 'current',
  UnStart = 'unStart',
  Completed = 'completed',
}
