From ae566bf9199e54574b94474bea87606fc3b40474 Mon Sep 17 00:00:00 2001 From: icssoa <615206459@qq.com> Date: Wed, 6 Aug 2025 16:30:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20cl-form=20=E7=BB=84?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cool/utils/comm.ts | 16 ++ cool/utils/parse.ts | 4 +- pages/demo/form/form.uvue | 241 ++++++++++++++---- .../components/cl-form-item/cl-form-item.uvue | 18 +- .../cool-ui/components/cl-form/cl-form.uvue | 35 ++- 5 files changed, 250 insertions(+), 64 deletions(-) diff --git a/cool/utils/comm.ts b/cool/utils/comm.ts index 0875b6e..1fe1bf7 100644 --- a/cool/utils/comm.ts +++ b/cool/utils/comm.ts @@ -595,6 +595,22 @@ export function base64ToBlob(data: string, type: string = "image/jpeg"): Blob { // #endif } +/** + * 检查两个值是否相等 + * @param a 值1 + * @param b 值2 + * @returns 是否相等 + */ +export function isEqual(a: any, b: any): boolean { + if (isObject(a) && isObject(b)) { + return isEqual(JSON.stringify(a), JSON.stringify(b)); + } else if (isArray(a) && isArray(b)) { + return isEqual(JSON.stringify(a), JSON.stringify(b)); + } + + return a == b; +} + /** * 检查是否为小程序环境 * @returns 是否为小程序环境 diff --git a/cool/utils/parse.ts b/cool/utils/parse.ts index 416a187..74e14f6 100644 --- a/cool/utils/parse.ts +++ b/cool/utils/parse.ts @@ -111,11 +111,11 @@ export const parseClass = (data: any): string => { * @returns 转换后的UTSJSONObject对象 */ export function parseToObject(data: T): UTSJSONObject { - // #ifdef APP + // #ifdef APP-ANDROID return JSON.parseObject(JSON.stringify(data)!)!; // #endif - // #ifndef APP + // #ifndef APP-ANDROID return JSON.parse(JSON.stringify(data)) as UTSJSONObject; // #endif } diff --git a/pages/demo/form/form.uvue b/pages/demo/form/form.uvue index 05b1341..b091521 100644 --- a/pages/demo/form/form.uvue +++ b/pages/demo/form/form.uvue @@ -12,45 +12,93 @@ :disabled="saving" label-position="top" > - - + + - - + + - - + + - - + + + + - - + + + + - + + + {{ item.label }} + + + + + + + + + + + + + + + + + + + + - {{ + {{ JSON.stringify(formData, null, 4) }} @@ -58,13 +106,15 @@ - 重置 + {{ + t("重置") + }} 提交{{ t("提交") }} @@ -72,38 +122,78 @@