查询项
作者:
多列表方案中的 getQueryResolverOptions 方法可以用来设置【查询项】
class BudgetPlanBasePresenter extends QueryListPagePresenter {
protected getQueryResolverOptions(queryListDef, option): IQueryModelResolverOptions {
return {
someKey: onModelCreated: (item: QueryItem) => {
item.value
}
}
}
}
数据结构
export interface IQueryModelResolverOptions {
[key: string]: IQueryModelItemResolverOptions | IQueryModelItemResolverCreator;
}
export type IQueryModelItemResolverCreator = (options) => IQueryModelItemResolverOptions;
export interface IQueryModelItemResolverOptions<T = any> {
// 显示查询方案时,每次都会触发
onModelCreated?: (item: QueryItem) => void;
baseFieldOptionsResovler?: (
item: IQueryCriteria,
options: FieldOptions,
) => MSTFormOptions['fieldOptions'] | FieldOptions;
baseTypeResolver?: (item: IQueryCriteria, type: IType<any, any, any>) => IType<any, any, any>;
itemFieldOptionsResolver?: (
item: IQueryCriteria,
fieldOptions: MSTFormOptions['fieldOptions'] | FieldOptions,
) => MSTFormOptions['fieldOptions'] | FieldOptions;
itemTypeResolver?: (item: IQueryCriteria, modelOptions) => IType<any, any, any>;
parser?: (item: IQueryCriteria<T>) => any;
beforeInitialize?: (
item: IQueryCriteria,
gql: GQLQueryCollect,
initializers: AsyncInitializer[],
queryCriterias: IQueryCriteria[],
) => Promise<void>;
formElementRender?: (
item: QueryItem,
commonRender: () => JSX.Element,
filterRender: () => JSX.Element,
) => JSX.Element;
formElementContentRenderer?: (item: QueryItem) => JSX.Element;
componentRender?: (item: QueryItem) => JSX.Element;
fragmentResolver?: (criteria: ICriteria, item: QueryItem) => ICriteria;
validate?: (field: MSTFormField, item: QueryItem) => [boolean, string];
// 保存QueryCriteriaValue
toJS?: (value: IQueryCrtieriaValue, item: IQueryCriteria<T>) => IQueryCrtieriaValue;
toHumanString?: (item: QueryItem, operator: string) => IQueryDescribe;
// 值是否为空
isEmptyValue?: (value: IQueryCrtieriaValue, item: QueryItem) => boolean;
}