From ad008b66b47f7a4b4a3909d429f3fcb48943ccda Mon Sep 17 00:00:00 2001 From: roymondchen Date: Tue, 21 Nov 2023 11:37:38 +0800 Subject: [PATCH] =?UTF-8?q?style(form):=20=E5=AE=8C=E5=96=84filterFunction?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/form/src/schema.ts | 18 +++++++++--------- packages/form/src/utils/form.ts | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/form/src/schema.ts b/packages/form/src/schema.ts index 2215cab13..07635b66a 100644 --- a/packages/form/src/schema.ts +++ b/packages/form/src/schema.ts @@ -72,19 +72,19 @@ export interface FormItem { /** 字段名 */ name?: string | number; /** 额外的提示信息,和 help 类似,当提示文案同时出现时,可以使用这个。 */ - extra?: string | FilterFunction; + extra?: string | FilterFunction; /** 配置提示信息 */ - tooltip?: string | FilterFunction; + tooltip?: string | FilterFunction; /** 是否置灰 */ disabled?: boolean | FilterFunction; /** 使用表单中的值作为key,例如配置了text,则使用model.text作为key */ key?: string; /** 是否显示 */ - display?: boolean | 'expand' | FilterFunction; + display?: boolean | 'expand' | FilterFunction; /** 值发生改变时调用的方法 */ onChange?: OnChangeHandler; /** label 标签的文本 */ - text?: string | FilterFunction; + text?: string | FilterFunction; /** 右侧感叹号 */ tip?: string; @@ -158,7 +158,7 @@ export type TypeFunction = ( }, ) => string; -export type FilterFunction = ( +export type FilterFunction = ( mForm: FormState | undefined, data: { model: Record; @@ -168,7 +168,7 @@ export type FilterFunction = ( prop: string; config: any; }, -) => boolean; +) => T; type OnChangeHandler = ( mForm: FormState | undefined, @@ -667,7 +667,7 @@ export interface TableConfig extends FormItem { /** 是否显示全屏按钮 */ enableFullscreen?: boolean; fixed?: boolean; - itemExtra?: string | FilterFunction; + itemExtra?: string | FilterFunction; rowKey?: string; } @@ -680,8 +680,8 @@ export interface GroupListConfig extends FormItem { tableItems?: FormConfig; titleKey?: string; titlePrefix?: string; - title?: string | FilterFunction; - itemExtra?: string | FilterFunction; + title?: string | FilterFunction; + itemExtra?: string | FilterFunction; expandAll?: boolean; addable?: (mForm: FormState | undefined, data: any) => boolean | 'undefined' | boolean; defaultAdd?: (mForm: FormState | undefined, data: any) => any; diff --git a/packages/form/src/utils/form.ts b/packages/form/src/utils/form.ts index 1e045fcc2..3ca1e445e 100644 --- a/packages/form/src/utils/form.ts +++ b/packages/form/src/utils/form.ts @@ -181,7 +181,7 @@ const getDefaultValue = function (mForm: FormState | undefined, { defaultValue, return ''; }; -export const filterFunction = (mForm: FormState | undefined, config: any, props: any) => { +export const filterFunction = (mForm: FormState | undefined, config: T, props: any) => { if (typeof config !== 'function') { return config; }