treegridexview-base.tsx 3.5 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 95 96 97 98 99 100 101
import { MDViewBase } from "./mdview-base";
import { TreeGridExViewEngine, ModelTool, TreeGridExViewInterface } from 'ibiz-core';
import { IPSAppDETreeGridExView, IPSDETreeGridEx } from '@ibiz/dynamic-model-api';

/**
 * 实体树表格视图基类
 *
 * @export
 * @class TreeGridExView
 * @extends {MDViewBase}
 * @implements {TreeGridExViewInterface}
 */
export class TreeGridExView extends MDViewBase implements TreeGridExViewInterface {

    /**
     * 视图实例
     *
     * @memberof TreeViewBase
     */
    public declare viewInstance: IPSAppDETreeGridExView;

    /**
     * 树表格实例
     * 
     * @memberof TreeGridExView
     */
    public treeGridExInstance!: IPSDETreeGridEx;

    /**
     * 引擎初始化
     *
     * @public
     * @memberof TreeGridExView
     */
    public engineInit(opts: any = {}): void {
        if (this.Environment && this.Environment.isPreviewMode) {
            return;
        }
        if (this.engine && this.treeGridExInstance) {
            let engineOpts = Object.assign({
                view: this,
                treegridex: (this.$refs[this.treeGridExInstance.name] as any).ctrl,
                p2k: '0',
                opendata: (args: any[], fullargs?: any[], params?: any, $event?: any, xData?: any) => {
                    this.opendata(args, fullargs, params, $event, xData);
                },
                newdata: (args: any[], fullargs?: any[], params?: any, $event?: any, xData?: any) => {
                    this.newdata(args, fullargs, params, $event, xData);
                },
                keyPSDEField: this.appDeCodeName.toLowerCase(),
                majorPSDEField: this.appDeMajorFieldName.toLowerCase(),
                isLoadDefault: this.viewInstance.loadDefault
            }, opts)
            if (this.searchFormInstance?.name && this.$refs[this.searchFormInstance.name]) {
                engineOpts.searchform = ((this.$refs[this.searchFormInstance.name] as any).ctrl);
            }
            if (this.quickSearchFormInstance?.name && this.$refs[this.quickSearchFormInstance.name]) {
                engineOpts.quicksearchform = ((this.$refs[this.quickSearchFormInstance.name] as any).ctrl);
            }
            if (this.searchBarInstance?.name && this.$refs[this.searchBarInstance.name]) {
                engineOpts.searchbar = ((this.$refs[this.searchBarInstance.name] as any).ctrl);
            }
            this.engine.init(engineOpts);
        }
    }

    /**
      * 初始化树表格视图实例
      * 
      * @memberof TreeGridExView
      */
    public async viewModelInit() {
        this.viewInstance = (this.staticProps.modeldata) as IPSAppDETreeGridExView;
        await super.viewModelInit();
        this.treeGridExInstance = ModelTool.findPSControlByName('treegridex', this.viewInstance.getPSControls()) as IPSDETreeGridEx;
    }


    /**
     * 渲染视图主体内容区
     * 
     * @memberof TreeGridExView
     */
    public renderMainContent() {
        if (!this.treeGridExInstance) {
            return null;
        }
        let { targetCtrlName, targetCtrlParam, targetCtrlEvent }: { targetCtrlName: string, targetCtrlParam: any, targetCtrlEvent: any } = this.computeTargetCtrlData(this.treeGridExInstance);
        return this.$createElement(targetCtrlName, { props: targetCtrlParam, ref: this.treeGridExInstance.name, on: targetCtrlEvent },);
    }

    /**
     * 快速搜索
     *
     * @returns {void}
     * @memberof TreeViewBase
     */
    public onSearch(): void {
        this.engine.search({ srfnodefilter: this.queryParams.quickSearchValue });
    }
}