app-tab-page.vue 2.2 KB
Newer Older
1
<template>
2
    <TabPane :label="currentLayoutModel.caption" :name="currentLayoutModel.name" :tab="currentLayoutModel.parentName" :class="curClassName" :style="curStyle">
3 4 5 6 7 8 9 10 11 12 13 14
        <template v-if="containerModel.length > 0">
            <template v-for="name of containerModel">
                <slot :name="name"></slot>
            </template>
        </template>
    </TabPane>
</template>

<script lang="ts">
import { Component, Prop, Vue } from 'vue-property-decorator';

@Component({})
15
export default class AppTabPage extends Vue {
16 17 18 19
    /**
    * 名称
    *
    * @type {string}
20
    * @memberof AppTabPage
21 22 23 24 25 26 27
    */
    @Prop() public name!: string;

    /**
     * 布局模型详情
     *
     * @type {string}
28
     * @memberof AppTabPage
29 30 31 32
     */
    @Prop() public layoutModelDetails: any;

    /**
33
     * 当前布局模型
34
     *
35 36
     * @type {*}
     * @memberof AppTabPage
37
     */
38
    public currentLayoutModel: any;
39 40

    /**
41
     * 插槽对象
42
     *
43
     * @memberof AppTabPage
44
     */
45
    public containerModel: any[] = [];
46 47 48 49

    /**
     * 组件初始化
     *
50
     * @memberof AppTabPage
51 52 53 54 55 56 57 58
     */
    public created() {
        this.init();
    }

    /**
     * 初始化子项
     *
59
     * @memberof AppTabPage
60 61
     */
    public init() {
62 63 64
        this.currentLayoutModel = this.layoutModelDetails[this.name];
        if (this.currentLayoutModel && this.currentLayoutModel.details && this.currentLayoutModel.details.length > 0) {
            this.currentLayoutModel.details.forEach((key: string) => {
65 66 67 68 69 70
                this.containerModel.push(key);
            })
        }
    }

    /**
71 72 73 74
     * 当前容器样式类
     * 
     * @memberof AppTabPage
     */
75
    get curClassName() {
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
        return {
            'app-tab-page': true,
            [this.name]: true,
            [this.currentLayoutModel.sysCss]: this.currentLayoutModel.sysCss ? true : false
        }
    }

    /**
     * 当前容器样式
     *
     * @memberof AppTabPage
     */
    get curStyle() {
        if (this.currentLayoutModel) {
            return this.currentLayoutModel.getElementStyle();
        }
        return '';
93 94 95 96 97
    }

}
</script>
<style lang='less'>
98
@import './app-tab-page.less';
99
</style>