<template>
    <el-row :gutter="40" class="panel-group">
        <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col" v-for="num in panelData" :key="num.type">
            <div class="card-panel">
                <div :class="'card-panel-icon-wrapper icon-'+num.type">
                    <svg-icon :icon-class="num.type" class-name="card-panel-icon" />
                    <div class="card-panel-text">{{ num.name }}</div>
                </div>
                <div class="card-panel-description">
                    <count-to :start-val="0" :end-val="num.total" :duration="2600" :decimals=1 class="card-panel-num" />
                    <div class="card-panel-change-zero" v-if="num.change==0"><span class="card-panel-change-text">同比昨日</span>0</div>
                    <div class="card-panel-change-num" v-else :class="num.change>0 ? 'up' : 'down'"><span class="card-panel-change-text">同比昨日</span>{{ Math.abs(num.change) }}</div>
                </div>
            </div>
        </el-col>
    </el-row>
</template>

<script>
import CountTo from 'vue-count-to'
export default {
    components: {
        CountTo
    },
    props: {
        panelData: {
            type: Array,
            default: new Array(4)
        },
    },
    data() {
        return {

        }
    },
    methods: {

    }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
.panel-group {
    margin-top: 18px;
    .card-panel-col {
        margin-bottom: 32px;
    }
    .card-panel {
        height: 108px;
        font-size: 12px;
        position: relative;
        overflow: hidden;
        color: #666;
        background: #fff;
        box-shadow: 4px 4px 40px rgba(0, 0, 0, .05);
        border-color: rgba(0, 0, 0, .05);
        .icon-peoples {
            color: #40c9c6;
        }
        .icon-document {
            color: #36a3f7;
        }
        .icon-order {
            color: #f4516c;
        }
        .icon-gains {
            color: #34bfa3;
        }
        .card-panel-icon-wrapper {
            float: left;
            width: 110px;
            padding: 16px;
            transition: all 0.38s ease-out;
            border-radius: 6px;
            .card-panel-text {
                line-height: 18px;
                color: rgba(50, 50, 50, .9);
                font-size: 17px;
                margin-top: 12px;
            }
            text-align: center;
            /*background: #efefef;*/
        }
        .card-panel-icon {
            font-size: 48px;
        }
        .card-panel-description {
            float: right;
            margin: 22px 26px;
            margin-left: 0px;
            .card-panel-change-num {
                float: right;
                text-align: right;
                margin-top: 15px;
                font-size: 16px;
                display: inline-block;
                position: relative;
            }
            .down,
            .up {
                &:before {
                    content: "";
                    width: 0;
                    height: 0;
                    border-left: 7px solid transparent;
                    border-right: 7px solid transparent;
                    position: absolute;
                    left: -20px;
                    top: 3px;
                }
            }
            .up {
                &:before { border-bottom: 11px solid #67c23a; }
            }
            .down {
                &:before { border-top: 11px solid #f56c6c; }
            }
            .card-panel-change-zero {
                float: right;
                text-align: right;
                margin-top: 15px;
                font-size: 16px;
                display: inline-block;
                position: relative;
                &:before {
                    content: "";
                    width: 12px;
                    height: 3px;
                    background-color: darkorange;
                    position: absolute;
                    left: -16px;
                    top: 7px;
                }
            }
            .card-panel-num {
                display: block;
                font-weight: bold;
                font-size: 28px;
            }
            .card-panel-change-text {
                font-size: .8rem;
                position: absolute;
                left: -80px;
                top: 3px;
            }
        }
    }
}

</style>
