<template>
    <div class="_runnings">
        <HeadlineTag value="行为检测(周)"></HeadlineTag>
        <div class="_runnings_mains" :style="{ '--heightSume': heightcon + 'px' }">
            <div class="_runnings_mains_left" id="sumeWidthil">
                <div class="_runnings_mains_left_tuan tuan1"></div>
                <div class="_runnings_mains_left_conter">
                    <div class="_runnings_mains_left_conter_num">{{ resultData.OverloadWarning || 0 }}</div>
                    <div class="_runnings_mains_left_conter_text">超载预警</div>
                </div>
            </div>
            <div class="_runnings_mains_left">
                <div class="_runnings_mains_left_tuan tuan2"></div>
                <div class="_runnings_mains_left_conter">
                    <div class="_runnings_mains_left_conter_num">{{ resultData.TrappedPersonAlarm || 0 }}</div>
                    <div class="_runnings_mains_left_conter_text">困人告警</div>
                </div>
            </div>
            <div class="_runnings_mains_left">
                <div class="_runnings_mains_left_tuan tuan3"></div>
                <div class="_runnings_mains_left_conter">
                    <div class="_runnings_mains_left_conter_num">{{ resultData.AbnormalVibration || 0 }}</div>
                    <div class="_runnings_mains_left_conter_text">异常震动</div>
                </div>
            </div>
        </div>
    </div>
</template>

<script setup>
import { ref, nextTick } from "vue";
import HeadlineTag from '@/components/HeadlineTag'
const props = defineProps({
    resultData: {
        type: Object,
        default: {}
    }
})
const runningList = ref([
    { name: '入侵检测', state: '154', color: '#409eff', tip: '划定区域人员闯入' },
    { name: '异常行为', state: '15', color: '#15acaa', tip: '徘徊、倒地、聚集' },
    { name: '丢失告警', state: '134', color: '#FFC107', tip: '物品遗留/丢失告警' },
])
const heightcon = ref(0)
watch(() => props.resultData, (newVal) => {
    if (newVal) {
        runningList.value[0].state = newVal.HousesCount
        runningList.value[1].state = newVal.HouseholdCount
        runningList.value[2].state = newVal.DrivewayCount
    }
}, { deep: true, immediate: true } // 开启深度监听
)
// 生命周期
onMounted(() => {
    nextTick(() => {
        var element = document.getElementById("sumeWidthil");
        var width = element.offsetWidth;
        heightcon.value = width
    });
});
</script>
<style lang="scss" scoped>
.tuan1 {
    background: url("@/assets/images/video_bg_1.png");
    animation: scanning 10s linear infinite;
}

.tuan2 {
    background: url("@/assets/images/video_bg_2.png");
    animation: scanning 10s linear infinite;
}

.tuan3 {
    background: url("@/assets/images/video_bg_3.png");
    animation: scanning 10s linear infinite;
}

._runnings {
    display: flex;
    align-items: center;
    flex-direction: column;

    &_mains {
        flex: 1;
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: space-around;

        &_left {
            flex-shrink: 0;
            width: 32%;
            height: var(--heightSume);
            position: relative;

            &_tuan {
                width: 100%;
                height: 100%;
                background-size: 80% 80%;
                background-position: center;
                background-repeat: no-repeat;
            }

            &_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>