From 7d8aa8e552a7ae8a1c5c60d1daae233da3ca0275 Mon Sep 17 00:00:00 2001 From: zhengyiming <540361168@qq.com> Date: 星期三, 21 五月 2025 13:27:22 +0800 Subject: [PATCH] fix: 修改ui --- apps/h5/src/utils/validator.ts | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 46 insertions(+), 0 deletions(-) diff --git a/apps/h5/src/utils/validator.ts b/apps/h5/src/utils/validator.ts new file mode 100644 index 0000000..970a9c8 --- /dev/null +++ b/apps/h5/src/utils/validator.ts @@ -0,0 +1,46 @@ +import { EditorType } from '@/constants'; +import _ from 'lodash'; + +export class FormValidator { + /** + * 楠岃瘉琛ㄥ崟input-number 涓嶄负0 + */ + static validatorNumberNotNull(rule: any, value: any, callback: any) { + // eslint-disable-next-line eqeqeq + if (!value) { + return callback(new Error(rule.message)); + } + callback(); + } + + static validatorRichEditor(rule: any, value: API.IntroInfo[], callback: any) { + // eslint-disable-next-line eqeqeq + const textEditorItem = value.filter((x) => x.type === EditorType.Text); + if (textEditorItem.some((x) => !x.content)) { + return callback(new Error(rule.message)); + } + callback(); + } + static validatorWeMap(rule: any, value: WeMapModel, callback: any) { + // eslint-disable-next-line eqeqeq + if (_.isEmpty(value) || Object.values(value).some((x) => !x)) { + return callback(new Error(rule.message)); + } + callback(); + } +} + +export async function validateFormList(refs: any) { + try { + const validateList = Object.values(refs).map((x) => { + const ref = x as any; + if (Array.isArray(ref)) { + return ref[0].validate(); + } + return ref.validate(); + }); + + let res = await Promise.allSettled(validateList); + return res.every((x) => x.status === 'fulfilled'); + } catch (error) {} +} -- Gitblit v1.9.1