<template>
	<div class="bottomRightBox">
		<Card title="设备监控台">
			<div class="boxData">
				<el-scrollbar style="width: 94%; margin: 3% 0% 0% 3%; height: 90%" v-if="deviceData.length > 0">
					<div style="display: flex; width: 100%; height: 170px">
						<div class="equipmentMonitoring" v-for="item in deviceData" :key="item.id">
							<div class="equipmentList" :class="item.isClosed == 1 ? 'offline' : 'online'">
								<p class="stateText">{{ item.isClosed == 1 ? "离线" : "在线" }}</p>
								<p class="bottomText">{{ item.devName }}</p>
							</div>
						</div>
					</div>
				</el-scrollbar>
				<div class="notoDta" v-if="deviceData.length == 0">
					<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;
		margin-top: 2%;
		.equipmentList {
			width: 160px;
			height: 80%;
			text-align: center;
			position: relative;
			.stateText {
				font-size: calc(100vw * 20 / 1920);
				color: #65d7f9;
				margin-top: 45%;
			}
			.bottomText {
				font-size: calc(100vw * 16 / 1920);
				color: #fff;
				position: absolute;
				bottom: -30%;
				width: 100%;
				text-align: center;
			}
		}

		.online {
			height: 100%;
			background: url("@/assets/images/distributionMonitoring/sbjkOpen.webp") no-repeat;
			background-size: 100% 100%;
		}
		.offline {
			height: 100%;
			background: url("@/assets/images/distributionMonitoring/sbjkClose.webp") no-repeat;
			background-size: 100% 100%;
			.stateText {
				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>
