<template> <TabPane :label="currentLayoutModel.caption" :name="currentLayoutModel.name" :tab="currentLayoutModel.parentName" :class="curClassName" :style="curStyle"> <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, Watch } from 'vue-property-decorator'; @Component({}) export default class AppTabPage extends Vue { /** * 名称 * * @type {string} * @memberof AppTabPage */ @Prop() public name!: string; /** * 布局模型详情 * * @type {string} * @memberof AppTabPage */ @Prop() public layoutModelDetails: any; /** * 下标 * * @type {number} * @memberof AppTabPage */ @Prop({ default: 0 }) public index?: number; /** * 布局模型详情变更 * @param newVal * @param oldVal */ @Watch('layoutModelDetails') onLayoutModelDetailsChange(newVal: any, oldVal: any) { this.initTabPage(); } /** * 插槽对象 * * @memberof AppTabPage */ public containerModel: any[] = []; /** * 当前布局模型 * * @memberof AppTabPage */ public currentLayoutModel: any = {}; /** * 项名称 * * @type {*} * @memberof AppTabPage */ get itemName() { return this.index ? `${this.name}_${this.index}` : this.name; } /** * 初始化子项 * * @memberof AppTabPage */ public initTabPage() { this.containerModel = []; const layoutModel = this.layoutModelDetails[this.itemName]; if (layoutModel && layoutModel.details && layoutModel.details.length > 0) { this.currentLayoutModel = layoutModel; layoutModel.details.forEach((key: string) => { this.containerModel.push(key); }) } } /** * 当前容器样式类 * * @memberof AppTabPage */ get curClassName() { const layoutModel = this.layoutModelDetails[this.itemName]; if (layoutModel) { return `app-tab-page ${this.itemName} ${layoutModel.sysCss}`; } } /** * 当前容器样式 * * @memberof AppTabPage */ get curStyle() { const layoutModel = this.layoutModelDetails[this.itemName]; if (layoutModel) { return layoutModel.getElementStyle(); } } } </script> <style lang='less'> @import './app-tab-page.less'; </style>