import { FormRules } from "element-plus";
import { isArray, validUpperCase } from "/@/utils/validate";
export const projectFormRules: FormRules = {
  company_id: {
    trigger: "change",
    required: true,
    message: "请选择公司"
  },
  card_id: {
    trigger: "change",
    required: true,
    message: "请选择卡类型"
  },
  title: {
    trigger: "change",
    required: true,
    message: "请输入服务名称"
  },
  original_price: {
    trigger: "change",
    required: true,
    validator(_, value) {
      if (typeof value != "number") return new Error("请输入原价");
      const num = Number(value + "");
      if (num < 0) return new Error("原价不能低于0");
      return true;
    }
  },
  activity_price: {
    trigger: "change",
    required: true,
    validator(_, value) {
      if (typeof value != "number") return new Error("请输入活动价");
      const num = Number(value + "");
      if (num < 0) return new Error("原价不能低于0");
      return true;
    }
  },
  starttime: {
    trigger: "change",
    required: true,
    validator(_, value) {
      const val = value ?? "";
      if (val === "") return new Error("请选择活动开始日期");
      return true;
    }
  },
  endtime: {
    trigger: "change",
    required: true,
    validator(_, value) {
      const val = value ?? "";
      if (val === "") return new Error("请选择活动结束日期");
      return true;
    }
  },
  expiretime: {
    trigger: "change",
    required: true,
    validator(_, value) {
      const val = value ?? "";
      if (val === "") return new Error("请选择服务到期日期");
      return true;
    }
  },

  content: {
    trigger: "change",
    required: true,
    validator(_, value) {
      const val = value ?? "";
      if (val === "") return new Error("请输入服务介绍");
      return true;
    }
  }
};
