<template>
	<div class="bottomRightBox">
		<Card title="设备监控台">
			<div class="boxData">
				<div class="equipmentMonitoring" v-for="item in deviceData" :key="item.id" v-if="deviceData.length > 0">
					<div class="equipmentList" :class="item.isClosed == 1 ? 'offline' : 'online'">
						<p>{{ item.isClosed == 1 ? "离线" : "在线" }}</p>
						<p class="bottomText">{{ item.devName }}</p>
					</div>
				</div>
				<div class="notoDta" v-else>
					<img src="@/assets/images/noData.png" alt="" />
					<p>暂无数据</p>
				</div>
			</div>
		</Card>
	</div>
</template>

<script lang="ts" setup>
import Card from "@/components/card.vue";

import { onMounted, reactive, ref, onBeforeUnmount } from "vue";
// import * as echarts from "echarts";
import { getDevStatisticsApi } from "@/api/modules/distribution";
// import Card from "@/components/card.vue";
import { GlobalStore } from "@/stores";
const store = GlobalStore();

// 配电箱设备统计
let deviceData = ref({} as any);

const getDevStatisticsList = async () => {
	const res: any = await getDevStatisticsApi({
		projectSn: store.sn
	});
	if (res.result) {
		deviceData.value = res.result.list;
	} else {
		deviceData.value = [];
	}
	console.log("配电箱实时数据", res);
};

onMounted(() => {
	getDevStatisticsList();
});
</script>

<style lang="scss" scoped>
.bottomRightBox {
	width: 100%;
	height: 100%;

	.boxData {
		width: 100%;
		height: 100%;
		display: flex;
	}
	.equipmentMonitoring {
		width: 100%;
		height: 100%;
		display: flex !important;
		justify-content: center;
		align-items: center;
		.equipmentList {
			width: 160px;
			height: 50%;
			text-align: center;
			p {
				font-size: calc(100vw * 20 / 1920);
				color: #65d7f9;
				margin-top: 36%;
			}
			.bottomText {
				font-size: calc(100vw * 16 / 1920);
				color: #fff;
				margin-top: 50%;
			}
		}
	
		.online {
			background: url("@/assets/images/distributionMonitoring/sbjkOpen.webp") no-repeat;
			background-size: 100% 100%;
		}
		.offline {
			background: url("@/assets/images/distributionMonitoring/sbjkClose.webp") no-repeat;
			background-size: 100% 100%;
			p {
				color: #ffd15e !important;
			}
			.bottomText {
				color: #fff !important;
			}
		}
	}
	.notoDta {
			width: 20%;
			height: 20%;
			margin-left: 40%;
			margin-top: 8%;
			img {
				width: 38%;
				margin: 6% 36%;
			}
			p {
				width: 100%;
				color: #fff;
				font-size: calc(100vw * 14 / 1920);
				margin: -5% 38%;
			}
		}
}
</style>
