展开收起流程组件

<template>
    <div class="step-frame" :style="{'width': width}" :class="{'step-frame--collapse': !expanded}">
        <div v-if="collapse" class="step-frame--expand" @click="handleExpand">
            {{ expanded ? '收起' : '展开' }}
        </div>
        <transition name="slide">
            <div v-show="expanded" class="step-frame-container">
                <div class="step-frame-title">
                    {{ title }}
                </div>
                <div class="step-frame-content">
                    <slot></slot>
                </div> 
            </div>
        </transition>
    </div>
</template>

<script>
module.exports = {
    props: {
        /** 标题 */
        title: {
            type: String,
            default: ''
        },
        /** 宽度 */
        width: {
            type: String,
            default: ''
        },
        /** 是否可折叠 */
        collapse: {
            type: Boolean,
            default: true
        }
    },
    data() {
        return {
            expanded: true
        }
    },
    methods: {
        handleExpand() {
            this.expanded = !this.expanded;
        }
    }
}
</script>

<style scoped>
.step-frame {
    position: relative;
    height: 100%;
    overflow: hidden;
    transition: width 0.1s;
    border-left: 1px solid #D9D9D9;
}
.step-frame--collapse {
    width: 25px !important;
    transition: width 0.2s;
    transition-delay: 0.5s;
}
.step-frame-title {
    color: #262626;
    background: #EFEFEF;
    padding: 10px 15px;
    font-size: 14px;
    font-weight: bold;
}
.step-frame--expand {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    background: #BFBFBF;
    color: #ffffff;
    font-size: 12px;
    border-radius: 0px 6px 6px 0px;
    text-align: center;
    padding: 2px 1px;
    cursor: pointer;
    z-index: 10;
}
.step-frame-container {
    height: 100%;
}
.step-frame-content {
    height: 100%;
    overflow: auto;
}

.slide-enter-active, .slide-leave-active {
  transition: transform 0.5s, width 0.5s;
}
.slide-enter, .slide-leave-to {
  transform: translateX(-100%);
}
</style>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值