app-default-indexview-layout.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 102 103 104 105 106 107 108 109 110 111 112 113 114
import { Component } from 'vue-property-decorator';
import { IPSAppMenu } from '@ibiz/dynamic-model-api';
import { ModelTool } from 'ibiz-core';
import { AppDefaultViewLayout } from "../app-default-view-layout/app-default-view-layout";


@Component({})
export default class AppDefaultIndexViewLayout extends AppDefaultViewLayout {

    /**
     * 引擎初始化
     *
     * @public
     * @memberof AppDefaultIndexViewLayout
     */
    public engineInit(opts: any = {}): void {
        const menuInstance = (this.containerModel.findPSControl(ModelTool.findPSControlByType("APPMENU", this.containerModel.getPSControls()))) as IPSAppMenu;
        this.engine.init({
            view: this,
            menu: (this.$refs[menuInstance.name] as any).ctrl,
        });
        this.engine.load();
    }

    /**
     * 当前主题
     *
     * @memberof AppDefaultIndexViewLayout
     */
    public selectTheme() {
        let _this: any = this;
        if (_this.$router.app.$store.state.selectTheme) {
            return _this.$router.app.$store.state.selectTheme;
        } else if (localStorage.getItem('theme-class')) {
            return localStorage.getItem('theme-class');
        } else {
            return 'app-dark-blue-theme';
        }
    }

    /**
     * 初始化
     * 
     * @memberof AppDefaultIndexViewLayout 
     */
    public created() {
        let className = this.selectTheme();
        if (document.getElementsByTagName('html')[0] && document.getElementsByTagName('html')[0].classList) {
            document.getElementsByTagName('html')[0].classList.add(className);
        }
        // 初始化视图容器样式
        this.initRenderOptions();
    }

    /**
     * 计算目标部件所需参数
     *
     * @param {string} [controlType]
     * @returns
     * @memberof AppDefaultIndexViewLayout
     */
    public computeTargetCtrlData(controlInstance: any, args?: any) {
        const { targetCtrlName, targetCtrlParam, targetCtrlEvent } = super.computeTargetCtrlData(controlInstance, args);
        Object.assign(targetCtrlParam.staticProps, { viewState: this.viewState, viewtag: this.viewtag, viewIsProxyMode: this.viewProxyMode });
        Object.assign(targetCtrlEvent, {
            closeView: ($event: any) => {
                this.$emit('view-event', { viewName: this.viewInstance.codeName, action: 'viewClosed', data: $event });
            }
        })
        const { codeName, defaultPage, name } = this.viewInstance;
        Object.assign(targetCtrlParam.staticProps, {
            viewName: codeName,
            isDefaultPage: defaultPage,
            name: name,

        })
        return { targetCtrlName, targetCtrlParam, targetCtrlEvent }
    }



    /**
     * 绘制主体内容
     *
     * @return {*}  {*}
     * @memberof AppDefaultIndexViewLayout
     */
    public renderContent(): any {
        return (
            <div class='app-content'>
                <div class='app-content__body'>
                    {this.$slots.embedview}
                </div>
                <div class="app-content__footer">
                    {this.$slots.default}
                </div>
            </div>
        );
    }


    /**
     * 绘制布局
     * 
     * @memberof AppDefaultIndexViewLayout
     */
    public render(h: any) {
        const { viewClassNames } = this.renderOptions;
        return <div class={viewClassNames}>
            {this.viewIsInit ? (this.viewLayoutPanel && this.viewLayoutPanel?.useDefaultLayout) ? this.renderContent() : this.renderViewLayoutPanel() : this.renderInitLoading()}
        </div>;
    }

}