<template>
    <div class="_energy">
        <layout>
            <template #left>
                <div style="height: 100%;display: flex;flex-direction: column;overflow: hidden;">
                    <deviceList :resultData="leftData.device" style="flex:1;" />
                    <tiring :resultData="leftData.TerminalOffline" style="flex: 1;" />
                </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;" />
                    <sameDay :resultData="leftData.PlaybackControls" style="flex: 1;" />
                    <eventList :resultData="leftData.TerminalLog" style="flex: 1;" />
                </div>
            </template>
        </layout>
    </div>
</template>

<script setup name="Role">
import { getBroadcast } from "@/api/system/broadcast"
import layout from "@/components/layout_/index.vue";
import running from './modules/running.vue'
import deviceList from './modules/deviceList.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(getBroadcastData, 10000);
    getBroadcastData()
});
onUnmounted(() => {
    clearInterval(intervalId.value);
})
function getBroadcastData() {
    getBroadcast().then((res) => {
        if (res.code == 200) {
            leftData.value = res.data
        }
    })
}
</script>
<style lang="scss">
._energy {
    height: 100%;
}
</style>