<template>
    <div class="_energy">
        <layout>
            <template #left>
                <div style="height: 100%;display: flex;flex-direction: column;overflow: hidden;">
                    <consume :resultData="leftData" style="flex:1;" />
                    <running :resultData="leftData" style="flex: 1;" />
                    <carbonEmission :resultData="leftData.Access" 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.AccessRecords" style="flex: 1;" />
                    <sameDay :resultData="leftData.GarageCount" style="flex: 1;" />
                    <tiring :resultData="leftData.GarRecords" style="flex: 1;" />
                </div>
            </template>
        </layout>
    </div>
</template>

<script setup name="Role">
import { getProperty } from "@/api/system/tenement"
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(getPropertyData, 10000);
    getPropertyData()
});
onUnmounted(() => {
    clearInterval(intervalId.value);
})
function getPropertyData() {
    getProperty().then((res) => {
        if (res.code == 200) {
            leftData.value = res.data
        }
    })
}
</script>
<style lang="scss">
._energy {
    height: 100%;
}
</style>