From 49b468ff5a3e3ad38485345c261441ad5b532be3 Mon Sep 17 00:00:00 2001 From: LiuJiaNan <15703339975@163.com> Date: Mon, 8 Dec 2025 09:12:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0validatorEndTimeGTCurrentDay?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/index.d.ts | 7 +++++++ utils/index.js | 17 +++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/utils/index.d.ts b/utils/index.d.ts index a089e62..2238b1f 100644 --- a/utils/index.d.ts +++ b/utils/index.d.ts @@ -333,6 +333,13 @@ export function validatorEndTime(timeStart: string): { validator: (_: any, value: any) => Promise; }; +/** + * 验证结束时间是否大于等于当前时间 + */ +export function validatorEndTimeGTCurrentDay(): { + validator: (_: any, value: any) => Promise; +}; + /** * 动态加载js资源 */ diff --git a/utils/index.js b/utils/index.js index 4ddf17a..249b47f 100644 --- a/utils/index.js +++ b/utils/index.js @@ -1,4 +1,5 @@ import { ID_NUMBER } from "../regular"; +import dayjs from "dayjs"; /** * 计算序号 @@ -523,6 +524,22 @@ export const validatorEndTime = (timeStart) => { } } +/** + * 验证结束时间是否大于等于当前时间 + */ +export const validatorEndTimeGTCurrentDay = () => { + return { + validator: (_, value) => { + if (value && value <= dayjs().format("YYYY-MM-DD hh:mm:ss")) { + return Promise.reject("结束时间必须大于当前时间"); + } + else { + return Promise.resolve(); + } + }, + } +} + /** * 动态加载js资源 */