Files
admin-vben5/apps/web-antd/src/views/property/energyManagement/electricEnergy/elctricitySituation/index.vue

256 lines
5.5 KiB
Vue
Raw Normal View History

2025-07-25 15:41:29 +08:00
<script setup lang="ts">
import { Page } from '@vben/common-ui';
import { BackTop, message, Spin } from 'ant-design-vue';
import { ref, onMounted, onBeforeUnmount, reactive } from 'vue';
import FloorTree from '../components/floor-tree.vue';
import { currentReading } from '#/api/property/energyManagement/meterInfo';
2025-07-26 18:39:49 +08:00
onMounted(() => {});
onBeforeUnmount(() => {});
const readingData = ref<any>({});
const readingTime = ref('');
let readingLoading = ref(false);
async function handleSelectFloor(selectedKeys, info) {
if (typeof selectedKeys[0] === 'undefined') {
return;
}
readingLoading.value = true;
const reading = await currentReading({
meterType: 1,
floorId: selectedKeys[0],
});
readingLoading.value = false;
if (reading === null) {
message.warn('当前楼层暂无电表数据!');
}
const nowTime =
new Date().toLocaleDateString().replace(/\//g, '-') +
' ' +
new Date().toLocaleTimeString();
readingTime.value = nowTime;
readingData.value = reading;
}
function targetFn() {
return document.getElementById('right-panel');
}
2025-07-25 15:41:29 +08:00
</script>
<template>
<Page :auto-content-height="true">
<div class="flex h-full gap-[8px]">
<FloorTree
:isMeter="false"
class="w-[260px]"
@select="handleSelectFloor"
></FloorTree>
<div class="flex-1" id="right-panel">
<Spin :spinning="readingLoading" size="large" style="height: 100px">
<div class="cards-container">
<div v-for="item in readingData" class="meterInfo-card">
<h2>
{{ item.meterName }}<span>{{ item.installLocation }}</span>
</h2>
<div class="meterInfo-reading">
<p>{{ item.initReading }}</p>
<div></div>
</div>
<div class="meterInfo-list">
<ul>
<li>
<span>时间</span>
<span>{{ readingTime }}</span>
</li>
<li>
<span>采集器IP</span>
<span>{{ item.hostIp }}</span>
</li>
</ul>
</div>
<div class="button-get-plan">
<a
href="#"
v-if="item.communicationState !== 0"
style="background: #6bb1e3"
>
<span>在线</span>
</a>
<a href="#" v-else style="background: orange">
<span>离线</span>
</a>
</div>
</div>
</div>
</Spin>
</div>
<BackTop class="back-to-top" :target="targetFn"></BackTop>
</div>
</Page>
</template>
2025-07-26 18:39:49 +08:00
<style scoped>
/* 右侧内容区域样式 */
.flex-1 {
flex: 1;
overflow-y: auto; /* 添加垂直滚动条 */
padding: 10px;
height: 100%; /* 确保高度占满父容器 */
box-sizing: border-box; /* 包括padding在高度计算中 */
2025-07-26 18:39:49 +08:00
}
/* 卡片容器样式 */
.cards-container {
display: flex;
flex-wrap: wrap;
justify-content: flex-start;
gap: 20px; /* 使用gap替代margin控制间距 */
2025-07-26 18:39:49 +08:00
}
.meterInfo-card {
background: #fff;
width: 15rem;
padding-left: 2rem;
padding-right: 2rem;
padding-top: 10px;
padding-bottom: 20px;
border-radius: 10px;
border-bottom: 4px solid #87ceeb;
box-shadow: 0 6px 30px rgba(173, 216, 230, 0.3);
font-family: 'Poppins', sans-serif;
height: 290px;
margin: 0 5px 20px 5px;
}
.meterInfo-card h2 {
margin-bottom: 15px;
font-size: 27px;
color: #5faee3;
font-weight: 600;
2025-07-26 18:39:49 +08:00
}
.meterInfo-card h2 span {
display: block;
margin-top: -4px;
color: #7eb8da;
font-size: 12px;
font-weight: 400;
2025-07-26 18:39:49 +08:00
}
.meterInfo-reading {
position: relative;
background: #f0f8ff;
width: 14.46rem;
margin-left: -0.65rem;
padding: 0.2rem 1.2rem;
border-radius: 5px 0 0 5px;
2025-07-26 18:39:49 +08:00
}
.meterInfo-reading p {
margin: 0;
padding-top: 0.4rem;
2025-07-26 18:39:49 +08:00
display: flex;
font-size: 1.9rem;
font-weight: 500;
color: #4a8cbb;
2025-07-26 18:39:49 +08:00
}
.meterInfo-reading p:before {
content: '';
margin-right: 5px;
font-size: 15px;
font-weight: 300;
2025-07-26 18:39:49 +08:00
}
.meterInfo-reading p:after {
content: '/ KW.H';
margin-left: 5px;
font-size: 15px;
font-weight: 300;
2025-07-26 18:39:49 +08:00
}
.meterInfo-reading div {
position: absolute;
bottom: -23px;
right: 0px;
width: 0;
height: 0;
border-top: 13px solid #87ceeb;
border-bottom: 10px solid transparent;
border-right: 13px solid transparent;
z-index: 1;
2025-07-26 18:39:49 +08:00
}
.meterInfo-list {
margin-top: 16px;
2025-07-26 18:39:49 +08:00
}
.meterInfo-list ul {
padding: 0;
font-size: 14px;
2025-07-26 18:39:49 +08:00
}
.meterInfo-list ul li {
color: #5a7d9a;
list-style: none;
margin-bottom: 0.2rem;
display: flex;
align-items: center;
gap: 0.5rem;
2025-07-26 18:39:49 +08:00
}
.meterInfo-list ul li svg {
width: 0.9rem;
fill: currentColor;
2025-07-26 18:39:49 +08:00
}
.meterInfo-list ul li span {
font-weight: 300;
2025-07-26 18:39:49 +08:00
}
.button-get-plan {
2025-07-26 18:39:49 +08:00
display: flex;
justify-content: center;
margin-top: 1.2rem;
2025-07-26 18:39:49 +08:00
}
.button-get-plan a {
2025-07-28 10:07:02 +08:00
display: flex;
justify-content: center;
align-items: center;
color: #fff;
padding: 10px 15px;
border-radius: 5px;
text-decoration: none;
font-size: 0.8rem;
letter-spacing: 0.05rem;
font-weight: 500;
transition: all 0.3s ease;
2025-07-26 18:39:49 +08:00
}
2025-07-25 15:41:29 +08:00
.button-get-plan a:hover {
transform: translateY(-3%);
box-shadow: 0 3px 10px rgba(123, 180, 220, 0.6); /* 浅蓝色阴影 */
background: #5fa0d0; /* 悬停时略深的蓝色 */
2025-07-26 18:39:49 +08:00
}
2025-07-25 15:41:29 +08:00
.button-get-plan .svg-rocket {
margin-right: 10px;
width: 0.9rem;
fill: currentColor;
2025-07-26 18:39:49 +08:00
}
.back-to-top {
width: 50px;
height: 50px;
}
/* 返回顶部按钮 */
.back-to-top:hover {
background-color: #6bb1e3;
transform: translateY(-5px);
}
2025-07-25 15:41:29 +08:00
</style>