import dayjs from "dayjs";
import { ElMessage } from "element-plus";

interface Options {
  len: number;
  end?: string;
  start?: string;
  message?: string;
}

export function isBeyondTime({ len, start, end, message }: Options) {
  let beyondTime = true;
  if (!start || !end) {
    ElMessage.warning("请选择导出报表的时间区间!");
    return beyondTime;
  }

  beyondTime = dayjs(end).diff(start, "days") > len;

  if (beyondTime) {
    ElMessage.warning(message || "导出报表的时间区间不能超过 " + len + " 天");
  }

  return beyondTime;
}
