tabsearchview-base.tsx 2.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
import { IPSAppCounterRef, IPSDETabViewPanel, IPSTabExpPanel, IPSSysImage, IPSAppDETabSearchView, IPSSearchBar } from '@ibiz/dynamic-model-api';
import { ModelTool, TabSearchViewInterface, Util } from 'ibiz-core';
import { MDViewBase } from './mdview-base';

/**
 * 实体分页搜索视图基类
 *
 * @export
 * @class TabSearchViewBase
 * @extends {MDViewBase}
 * @implements {TabSearchViewInterface}
 */
export class TabSearchViewBase extends MDViewBase implements TabSearchViewInterface {

    /**
     * 视图实例
     * 
     * @memberof TabSearchViewBase
     */
    public declare viewInstance: IPSAppDETabSearchView;

    /**
     * 分页导航面板实例
     * 
     * @memberof TabSearchViewBase
     */
    public tabExpPanelInstance!: IPSTabExpPanel;

    /**
     * 引擎初始化
     *
     * @public
     * @memberof TabSearchViewBase
     */
    public engineInit(): void {
        if (this.Environment && this.Environment.isPreviewMode) {
            return;
        }
        if (this.engine && this.tabExpPanelInstance) {
            const engineOpts = {
                view: this,
                p2k: '0',
                tabexppanel: (this.$refs[this.tabExpPanelInstance?.name] as any)?.ctrl,
                keyPSDEField: this.appDeCodeName.toLowerCase(),
                majorPSDEField: this.appDeMajorFieldName.toLowerCase(),
                isLoadDefault: this.viewInstance?.loadDefault,
            };
            if (this.searchBarInstance) {
                Object.assign(engineOpts, {
                    searchbar: (this.$refs[this.searchBarInstance?.name] as any)?.ctrl
                });
            }
            if (this.searchFormInstance) {
                Object.assign(engineOpts, {
                    searchform: (this.$refs[this.searchFormInstance?.name] as any)?.ctrl
                });
            }
            this.engine.init(engineOpts);
        }
    }

    /**
     * 初始化分页导航视图实例
     * 
     * @memberof TabSearchViewBase
     */
    public async viewModelInit() {
        this.viewInstance = (this.staticProps?.modeldata) as IPSAppDETabSearchView;
        await super.viewModelInit();
        this.tabExpPanelInstance = ModelTool.findPSControlByType("TABEXPPANEL", this.viewInstance.getPSControls()) as IPSTabExpPanel;
    }

    /**
     * 分页面板点击
     * 
     * @memberof TabSearchViewBase
     */
    public tabPanelClick(event: any) {
        if (this.engine) {
            this.engine.changeTabPanel(event);
        }
    }

    /**
     * 渲染视图主体内容区
     * 
     * @memberof TabSearchViewBase
     */
    public renderMainContent() {
        let { targetCtrlName, targetCtrlParam, targetCtrlEvent } = this.computeTargetCtrlData(this.tabExpPanelInstance);
        return this.$createElement(targetCtrlName, { slot: 'default', props: targetCtrlParam, ref: this.tabExpPanelInstance?.name, on: targetCtrlEvent });
    }

}