index.vue 1.54 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
<!-- 图表左侧的机组状态统计 -->
<template>
    <div class="state-count">
        <div class="item" :style="{'background-image': 'linear-gradient(to right, rgba(0,0,0,0), ' + item.color + ', rgba(0,0,0,0))'}" v-for="(item, key) in crewState">
            {{item.name}}: {{copyCount[key]}}
        </div>
    </div>
</template>

<script>
    import {CrewState} from '@/common/const.js';
    export default {
        props: {
            count: {
                type: Object,
                default(){
                    return {
                        warn: 0,
                        danger: 0,
                        shutdown: 0,
                        normal: 0
                    }
                }
            }
        },
        watch: {
            count(val){
                if(!val) return;
                else this.copyCount = val;
            }
        },
        data() {
            return {
                crewState: CrewState, // 机组状态
                // 复制count,防止count为空
                copyCount: {
                    warn: 0,
                    danger: 0,
                    shutdown: 0,
                    normal: 0
                },
            }
        }
    }
</script>

<style lang="scss" scoped>
    .state-count{
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        align-items: center;
        
        .item{
            width: 100%;
            height: 17%;
            @extend %flex-center;
            font-size: 0.875rem;
        }
    }
</style>