<template>
    <div class="_energy">
        <layout>
            <template #left>
                <div style="height: 100%;display: flex;flex-direction: column;overflow: hidden;">
                    <blowingIn :resultData="leftData.OnedayPowerConsumption" style="flex: 1;" />
                    <temperatureTrend :resultData="leftData.OnedayWaterConsumption" style="flex: 1;" />
                    <energy :resultData="leftData.OnedayPowerConsumption" style="flex: 1;" />
                </div>
            </template>
            <template #content>
                <!-- <p>视频</p> -->
            </template>
            <template #right>
                <div style="height: 100%;display: flex;flex-direction: column;overflow: hidden;">
                    <deviceList :resultData="IlluminatingDevice" />
                </div>
            </template>
        </layout>
    </div>
</template>

<script setup name="Air">
import { getEnergy } from "@/api/system/energy"
import { getIlluminating } from "@/api/system/illuminating"
import layout from "@/components/layout_/index.vue";
import blowingIn from './modules/blowingIn.vue'
import energy from './modules/energy.vue'
import temperatureTrend from './modules/temperatureTrend.vue'
import deviceList from './modules/deviceList.vue'

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

function getIlluminatingData() {
    getIlluminating().then((res) => {
        if (res.code == 200) {
            IlluminatingDevice.value = res.data.IlluminatingDevice
        }
    })
}
</script>
<style lang="scss">
._energy {
    height: 100%;
}
</style>