<template>
    <div class="_energy">
        <layout>
            <template #left>
                <div style="height: 100%;display: flex;flex-direction: column;overflow: hidden;">
                    <blowingIn :resultData="leftData.OnedayPowerConsumption" style="height: 35%;" />
                    <malfunction :resultData="MonitorList" style="flex: 1;" />
                </div>
            </template>
            <template #content>
                <!-- <p>给排水系统</p> -->
            </template>
            <template #right>
                <div style="height: 100%;display: flex;flex-direction: column;overflow: hidden;">
                    <consume :resultData="leftData" style="height: 35%;" />
                    <running :resultData="MonitorList" style="flex: 1;" />
                </div>
            </template>
        </layout>
    </div>
</template>

<script setup name="Air">
import { getEnergy } from "@/api/system/energy"
import { getAccess } from "@/api/system/passageway"
import layout from "@/components/layout_/index.vue";
import blowingIn from './modules/blowingIn.vue'
import malfunction from './modules/malfunction.vue'
import consume from './modules/consume.vue'
import running from './modules/running.vue'

const intervalId = ref(null)
const leftData = ref({})
const MonitorList = ref([])
// 生命周期
onMounted(() => {
    intervalId.value = setInterval(getEnergyData, 10000);
    getEnergyData()
    getAccessData()
});
onUnmounted(() => {
    clearInterval(intervalId.value);
})
function getEnergyData() {
    getEnergy().then((res) => {
        if (res.code == 200) {
            leftData.value = res.data
        }
    })
}

function getAccessData() {
    getAccess().then((res) => {
        if (res.code == 200) {
            MonitorList.value = res.data.DeviceList
        }
    })
}

</script>
<style lang="scss">
._energy {
    height: 100%;
}
</style>