<template>
    <div class="_running">
        <HeadlineTag value="电梯设备统计"></HeadlineTag>
        <div class="_running_mains">
            <div class="_running_mains_left">
                <dv-decoration-9 style="width:150px;height:150px;">
                    <div class="_running_mains_left_conter">
                        <div class="_running_mains_left_conter_num">{{ resultData.ElevatorCount || 0 }}</div>
                        <div class="_running_mains_left_conter_text">电梯总量</div>
                    </div>
                </dv-decoration-9>
            </div>
            <div class="_running_mains_right">
                <div class="_running_mains_right_item" v-for="item, index in runningList" :key="index">
                    <div class="_running_mains_right_item_tuan">
                        <span class="_running_mains_right_item_tuan_flag"
                            :style="{ backgroundColor: item.color }"></span>
                        <el-text class="w-150px mb-2" truncated style="color: #ccc;">
                            {{ item.name }}
                        </el-text>
                    </div>
                    <div class="_running_mains_right_item__txt">
                        <span>{{ item.state || 0 }}</span>
                        <span :style="{ color: item.color, 'font-size': '12px', 'margin-left': '5px' }">
                            {{ item.unit || 0 }}
                        </span>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script setup>
import { ref } from "vue";
import HeadlineTag from '@/components/HeadlineTag'
const runningList = ref([
    { name: '运行正常', state: 0, color: '#409eff', unit: '台' },
    { name: '运行异常', state: 0, color: '#15acaa', unit: '台' },
])

const props = defineProps({
    resultData: {
        type: Object,
        default: {}
    }
})
watch(() => props.resultData, (newVal) => {
    if (newVal) {
        runningList.value[0].state = newVal.RunningNormally
        runningList.value[1].state = newVal.RunningAbnormal
    }
}, { deep: true, immediate: true } // 开启深度监听
)
</script>
<style lang="scss" scoped>
._running {
    display: flex;
    flex-direction: column;

    &_mains {
        flex: 1;
        margin: 30px;
        display: flex;
        align-items: center;

        &_left {
            width: 180px;
            height: 180px;
            position: relative;
            flex-shrink: 0;

            &_conter {
                position: absolute;
                left: 0;
                top: 0;
                flex-shrink: 0;
                width: 100%;
                height: 100%;
                display: flex;
                flex-direction: column;
                align-items: center;
                justify-content: center;
                color: #fff;

                &_num {
                    font-size: 18px;
                }

                &_text {
                    font-size: 12px;
                }
            }
        }

        &_right {
            margin-left: 10px;
            flex: 1;
            color: #fff;

            &_item {
                display: flex;
                align-items: center;
                gap: 40px;
                padding: 5px 0;

                &_tuan {
                    display: flex;
                    align-items: center;

                    &_flag {
                        display: block;
                        width: 7px;
                        height: 7px;
                        border-radius: 50%;
                        margin-right: 10px;
                    }
                }

                &__txt {
                    font-size: 24px;
                }
            }
        }


    }
}

@keyframes scanning {
    to {
        transform: rotate(1turn);
    }
}
</style>