<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.RunState" style="flex:1;" />
                </div>
            </template>
            <template #content>
                <!-- <p>电梯</p> -->
            </template>
            <template #right>
                <div style="height: 100%;display: flex;flex-direction: column;overflow: hidden;">
                    <eventList :resultData="leftData.OverloadCount" style="flex: 1;" />
                    <tiring :resultData="leftData.TrappedPerson" style="flex: 1;" />
                    <sameDay :resultData="leftData.AbnormalCount" style="flex: 1;" />
                </div>
            </template>
        </layout>
    </div>
</template>

<script setup>
import { getElevator } from "@/api/system/elevator"
import layout from "@/components/layout_/index.vue";
import running from './modules/running.vue'
import consume from './modules/consume.vue'
import carbonEmission from "./modules/carbonEmission.vue";
import sameDay from './modules/sameDay.vue'
import eventList from './modules/eventList.vue'
import tiring from './modules/tiring.vue'

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