<template>
    <div class="_energy">
        <layout>
            <template #left>
                <div style="height: 100%;display: flex;flex-direction: column;overflow: hidden;">
                    <deviceList :resultData="leftData.IlluminatingDevice" />
                </div>
            </template>
            <template #content>
                <!-- <p>照明</p> -->
            </template>
            <template #right>
                <div style="height: 100%;display: flex;flex-direction: column;overflow: hidden;">
                    <running :resultData="leftData" style="flex: 1;" />
                    <switchAll :resultData="leftData.RunAnalyse" style="flex: 1;" />
                    <eventList :resultData="leftData.EventList" style="flex: 1;" />
                </div>
            </template>
        </layout>
    </div>
</template>

<script setup name="Role">
import { getIlluminating } from "@/api/system/illuminating"
import layout from "@/components/layout_/index.vue";
import deviceList from './modules/deviceList.vue'
import running from './modules/running.vue'
import eventList from './modules/eventList.vue'
import switchAll from './modules/switchAll.vue'

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