import { PROJECT_STATUS, YYYYMMDDHHmmss } from "@/constants/constants";
import moment from "moment";

export default {
  /** 返回YYYY-MM-DD HH:mm:ss */
  datetimeFilter(epochTime: number) {
    return moment(epochTime).format(YYYYMMDDHHmmss);
  },
  booleanEnableDisableFilter(val: boolean) {
    if (typeof val !== "boolean") return "无";
    return { true: "启用", false: "禁用" }[val + ""];
  },
  booleanYesNoFilter(val: boolean) {
    if (val === null) return "无";
    return { true: "是", false: "否" }[val + ""];
  },
  courseTypeFilter(val: string) {
    if (typeof val !== "string") return "无";
    return { PUBLIC: "公共科目", MAJOR: "专业科目" }[val + ""];
  },
  projectStatusFilter(val: string) {
    if (typeof val !== "string") return "无";
    return PROJECT_STATUS.find((p) => p.code === val)?.name;
  },
};
