<template>
    <div class="headerBox">
        <div class="headerTitle">
            <p class="m-title">{{ title }}</p>
            <slot name="tailContent" />
        </div>
        <div v-show="hasIcon" class="headerIcon">
            <span v-show="reload" @click="reloadFn()">
                <img src="../../assets/img/enlarge.png" alt="" />
            </span>
            <span v-show="close" @click="closeFn()">
                <img src="../../assets/img/close.png" alt="" />
            </span>
            <span v-show="enlarge" @click="enlargeFn()">
                <img src="../../assets/img/enlarge.png" alt="" />
            </span>
            <span v-show="narrow" @click="narrowFn()">
                <img src="../../assets/img/narrow.png" alt="" />
            </span>
        </div>
    </div>
</template>
<script>
export default {
    name: 'es-header',
    props: [
        'title', // 标题
        'hasIcon', // 是否有icon
        'narrow', // narrow page
        'enlarge', // 放大页面，有icon时才有
        'reload', // reload page
        'close' // close Bobm
    ],
    methods: {
        // 页面刷新
        reloadFn() {
            let ths = this;

            ths.$emit('reloadFn');
        },
        // 页面全铺
        enlargeFn() {
            let ths = this;

            ths.$emit('enlargeFn');
        },
        // 页面缩小
        narrowFn() {
            let ths = this;

            ths.$emit('narrowFn');
        },
        // close Bobm
        closeFn() {
            let ths = this;

            ths.$emit('closeFn');
        }
    }
};
</script>
<style lang="scss" scoped>
.headerBox {
    position: relative;
}
.headerTitle {
    height: 14px;
    line-height: 14px;
    position: relative;
}
.m-title {
    height: 14px;
    line-height: 14px;
    position: relative;
    padding-left: 14px;
    font-size: 14px;
    color: #666;
    font-weight: normal;
    text-align: left;
    vertical-align: bottom;
    width: auto;
    &::before {
        position: absolute;
        top: 3px;
        left: 0;
        content: '';
        width: 8px;
        height: 8px;
        background: #3b95e9;
    }
}
.headerIcon {
    position: absolute;
    top: 0px;
    right: 0px;
    span {
        float: right;
        margin-left: 12px;
    }
    img {
        width: 12px;
        cursor: pointer;
    }
}
</style>
