import { throttle } from '@ibizstudio/runtime'; import { SearchBarControlBase } from '../../../widgets/searchbar-control-base'; import { IPSEditor, IPSSearchBarFilter } from '@ibizstudio/runtime'; /** * 搜索栏部件基类 * * @export * @class AppSearchBarBase * @extends {SearchBarControlBase} */ export class AppSearchBarBase extends SearchBarControlBase { /** * 绘制过滤栏 * * @param {{ controlname: string; action: string; data: any }} { controlname 部件名称, action 事件名称, data 事件参数 } * @memberof AppSearchBarBase */ renderBarFilters(data: any) { const barFilters: Array = this.controlInstance.getPSSearchBarFilters() || []; if (barFilters.length === 0 || !data.editor) { return null; } return barFilters.map((filter: IPSSearchBarFilter) => { if (!filter.name || !Object.is(data.editor, filter.name)) { return null; } const editor: IPSEditor | null = filter.getPSEditor(); if (editor) { let filterItem: any = this.filterItems.find((item: any) => { return item.editor && Object.is(item.editor, editor.name); }); if (filterItem) { filterItem[editor.name] = data[editor.name]; } return ( ); } }); } /** * 编辑器值变化 * * @memberof AppSearchBarBase */ editorChange({ name, value }: any) { if (this.filterItems.length == 0) { return; } this.filterItems.forEach((item: any) => { if (item.editor && Object.is(name, item.editor)) { item[name] = value; } }); } /** * 绘制过滤树 * * @memberof AppSearchBarBase */ renderFilterTree() { if (!this.filterFields || this.filterFields.length == 0) { return null; } return (
{ return this.renderBarFilters(data); }, }} >
); } /** * 绘制过滤存储集合 * * @memberof AppSearchBarBase */ renderFilterFooter() { return ( ); } /** * 绘制搜索栏部件 * * @memberof AppSearchBarBase */ render() { if (!this.controlIsLoaded || !this.isExpandSearchForm) { return null; } const { controlClassNames } = this.renderOptions; return (
{this.renderFilterTree()} {this.renderFilterFooter()}
); } }