app-preset-title.vue 1.7 KB
Newer Older
1
<template>
Shine-zwj's avatar
Shine-zwj committed
2
    <h1 :class="curClassName" :style="curStyle">{{ curValue }}</h1>
3 4 5 6
</template>

<script lang="ts">
import { Environment } from "@/environments/environment";
Shine-zwj's avatar
Shine-zwj committed
7
import { Vue, Component, Prop } from 'vue-property-decorator';
8 9

@Component({})
10
export default class AppPresetTitle extends Vue {
Shine-zwj's avatar
Shine-zwj committed
11 12 13 14 15 16 17 18
    /**
     * 名称
     *
     * @type {string}
     * @memberof AppPresetTitle
     */
    @Prop() public name!: string;

Shine-zwj's avatar
Shine-zwj committed
19 20 21 22 23 24 25 26
    /**
     * 布局模型详情
     *
     * @type {*}
     * @memberof AppPresetTitle
     */
    @Prop() public layoutModelDetails: any;

tony001's avatar
tony001 committed
27 28 29 30 31 32
    /**
     * 下标
     *
     * @type {number}
     * @memberof AppPresetTitle
     */
tony001's avatar
tony001 committed
33
    @Prop() public index?: number;
tony001's avatar
tony001 committed
34 35 36 37 38 39 40 41

    /**
     * 项名称
     *
     * @type {*}
     * @memberof AppPresetTitle
     */
    get itemName() {
tony001's avatar
tony001 committed
42
        return (this.index || this.index === 0) ? `${this.name}_${this.index}` : this.name;
tony001's avatar
tony001 committed
43 44
    }

Shine-zwj's avatar
Shine-zwj committed
45 46 47 48 49
    /**
     * 类名
     *
     * @memberof AppPresetTitle
     */
tony001's avatar
tony001 committed
50 51 52 53 54
    get curClassName() {
        const layoutModel = this.layoutModelDetails[this.itemName];
        if (layoutModel) {
            return `app-preset-title ${this.itemName} ${layoutModel.sysCss}`;
        }
Shine-zwj's avatar
Shine-zwj committed
55 56 57 58 59 60 61
    }

    /**
     * 当前容器样式
     * 
     * @memberof AppPresetTitle
     */
tony001's avatar
tony001 committed
62 63 64 65 66
    get curStyle() {
        const layoutModel = this.layoutModelDetails[this.itemName];
        if (layoutModel) {
            return layoutModel.getElementStyle();
        }
Shine-zwj's avatar
Shine-zwj committed
67
    }
68 69 70 71

    /**
     * 当前值
     *
72
     * @memberof AppPresetTitle
73 74 75 76 77 78
     */
    public curValue: string = '';

    /**
     * 初始化
     *
79
     * @memberof AppPresetTitle
80 81 82 83 84 85 86 87 88 89
     */
    public created() {
        this.curValue = Environment.AppTitle;
    }
}
</script>

<style lang='less'>
@import './app-preset-title.less';
</style>