style(form): 完善filterFunction类型定义

This commit is contained in:
roymondchen 2023-11-21 11:37:38 +08:00
parent ab02c2f3ee
commit ad008b66b4
2 changed files with 10 additions and 10 deletions

View File

@ -72,19 +72,19 @@ export interface FormItem {
/** 字段名 */
name?: string | number;
/** 额外的提示信息,和 help 类似,当提示文案同时出现时,可以使用这个。 */
extra?: string | FilterFunction;
extra?: string | FilterFunction<string>;
/** 配置提示信息 */
tooltip?: string | FilterFunction;
tooltip?: string | FilterFunction<string>;
/** 是否置灰 */
disabled?: boolean | FilterFunction;
/** 使用表单中的值作为key例如配置了text则使用model.text作为key */
key?: string;
/** 是否显示 */
display?: boolean | 'expand' | FilterFunction;
display?: boolean | 'expand' | FilterFunction<boolean | 'expand'>;
/** 值发生改变时调用的方法 */
onChange?: OnChangeHandler;
/** label 标签的文本 */
text?: string | FilterFunction;
text?: string | FilterFunction<string>;
/** 右侧感叹号 */
tip?: string;
@ -158,7 +158,7 @@ export type TypeFunction = (
},
) => string;
export type FilterFunction = (
export type FilterFunction<T = boolean> = (
mForm: FormState | undefined,
data: {
model: Record<any, any>;
@ -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<string>;
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<string>;
itemExtra?: string | FilterFunction<string>;
expandAll?: boolean;
addable?: (mForm: FormState | undefined, data: any) => boolean | 'undefined' | boolean;
defaultAdd?: (mForm: FormState | undefined, data: any) => any;

View File

@ -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 = <T = any>(mForm: FormState | undefined, config: T, props: any) => {
if (typeof config !== 'function') {
return config;
}