<template>
    <div class="_energy">
        <layout>
            <template #left>
                <div style="height: 100%;display: flex;flex-direction: column;overflow: hidden;">
                    <running :resultData="leftData" style="flex: 1;" />
                    <consume :resultData="leftData" style="flex: 1;" />
                    <carbonEmission :resultData="leftData" style="flex: 1;" />
                </div>
            </template>
            <template #content>
                <!-- <p>视频</p> -->
            </template>
            <template #right>
                <div style="height: 100%;display: flex;flex-direction: column;overflow: hidden;">
                    <sameDay :resultData="leftData" style="flex: 1;" />
                    <eventList :resultData="leftData.MonitorList" style="flex: 2;" />
                </div>
            </template>
        </layout>
    </div>
</template>

<script setup name="Role">
import { getHikvision } from "@/api/system/monitor"
import layout from "@/components/layout_/index.vue";
import running from './modules/running.vue'
import carbonEmission from './modules/carbonEmission.vue'
import consume from './modules/consume.vue'
import sameDay from './modules/sameDay.vue'
import eventList from './modules/eventList.vue'

const intervalId = ref(null)
const leftData = ref({})
// 生命周期
onMounted(() => {
    intervalId.value = setInterval(getHikvisionData, 10000);
    getHikvisionData()
});
onUnmounted(() => {
    clearInterval(intervalId.value);
})
function getHikvisionData() {
    getHikvision().then((res) => {
        if (res.code == 200) {
            leftData.value = res.data
        }
    })
}
</script>
<style lang="scss">
._energy {
    height: 100%;
}
</style>