From 98247bb0b4da9a322c97867262c1a76c53ace520 Mon Sep 17 00:00:00 2001
From: web <candymxq888@outlook.com>
Date: 星期三, 26 三月 2025 17:05:18 +0800
Subject: [PATCH] fix: 生态报表

---
 src/views/screen/temperature/shebei/index.vue |  366 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 363 insertions(+), 3 deletions(-)

diff --git a/src/views/screen/temperature/shebei/index.vue b/src/views/screen/temperature/shebei/index.vue
index 2ccc251..3ce6d4e 100644
--- a/src/views/screen/temperature/shebei/index.vue
+++ b/src/views/screen/temperature/shebei/index.vue
@@ -1,13 +1,373 @@
 <script setup>
+import {ref, onMounted} from "vue";
+import facilityApi from "@/api/facility/index";
+import { getTemperatureMenu } from '@/api/screen/shebei/index.js'
+import {getUserType} from '@/utils/auth.js'
+import setPostParams from "@/utils/searchParams.js";
+import {useRouter} from "vue-router";
+const router = useRouter();
+const imgBaseUrl = import.meta.env.VITE_APP_IMG_BASEURL; //图片前缀
+
+const menuList = ref([])
+const deviceList = ref([])
+const userType = ref(getUserType())
+const monitorRef = ref()
+const searchVal = ref('')
+const selectNum = ref(6);
+const numOption = ref([
+    { label: '6个', value: 6 },
+    { label: '2个', value: 2 },
+    { label: '1个', value: 1 },
+])
+
+// 获取菜单列表
+const getMenu = () => {
+    getTemperatureMenu().then(res => {
+        menuList.value = res.data
+    })
+}
+
+// 获取设备
+const getDataList = () => {
+    let postParam = setPostParams()
+    facilityApi().search({ ...postParam, keywords: searchVal.value }).then(res => {
+        deviceList.value = res.data.list
+    })
+}
+
+// 全屏操作
+const handleFullScreen = () => {
+    monitorRef.value.requestFullscreen()
+}
+
+// 选择菜单
+const handleSelectMenu = (id) => {
+    facilityApi().get({ id }).then(res => {
+        deviceList.value = [res.data]
+    })
+}
+
+onMounted(() => {
+    getMenu()
+    getDataList()
+})
 
 </script>
 
 <template>
-    <div>
-        设备管理
+    <div class="shebei">
+        <div class="shebei-menu">
+            <div class="menu-t">设备列表</div>
+            <el-menu class="el-menu-vertical-demo" @select="handleSelectMenu">
+                <template v-for="(item, index) in menuList" :key="index+1">
+                    <template v-if="item?.facilityPOList?.length === 0">
+                        <el-menu-item :index="item.id">{{item.name}}</el-menu-item>
+                    </template>
+                    <template v-else>
+                        <el-sub-menu :index="item.id">
+                            <template #title>
+                                <span>{{item.name}}</span>
+                            </template>
+                            <el-menu-item v-for="(child, cidx) in item.facilityPOList" :key="cidx" :index="child.id">{{child.facilityName}}</el-menu-item>
+                        </el-sub-menu>
+                    </template>
+                </template>
+            </el-menu>
+        </div>
+        <div class="shebei-monitor">
+            <div class="monitor-tool">
+                <div class="tool-l">
+                    <div class="name">展示数量</div>
+                    <el-select
+                        v-model="selectNum"
+                        class="tool-select"
+                        placeholder="Select"
+                        style="width: 15rem"
+                    >
+                        <el-option
+                            v-for="item in numOption"
+                            :key="item.value"
+                            :label="item.label"
+                            :value="item.value"
+                        />
+                    </el-select>
+                    <el-input v-model="searchVal" style="width: 20rem" placeholder="请输入设备名称" />
+                    <el-button @click="getDataList"><el-icon><Search /></el-icon>搜索</el-button>
+                    <el-button style="margin-left: 0" v-if="userType === '1'" @click="router.push('/facilityList')"><el-icon><Plus /></el-icon>新增</el-button>
+                </div>
+                <div class="tool-r" @click="handleFullScreen">
+                    <img src="@/assets/images/flow/fullscreen.png" />
+                    全屏
+                </div>
+            </div>
+            <div class="monitor-box" ref="monitorRef">
+                <div class="list-six list" v-if="selectNum === 6">
+                    <div class="item" v-for="(item, index) in deviceList" :key="index">
+                        <div class="item-t">
+                            <div>{{item.facilityName}}</div>
+                            <div>{{item.facilityCode}}</div>
+                        </div>
+                        <div class="item-img">
+                            <img v-if="item.facilityUrl" :src="imgBaseUrl + item.facilityUrl" alt="" />
+                        </div>
+                        <div class="item-info">
+                            <div class="online">设备在线状态: <span :style="{color: item.isOnline ? '#56d12c' : '#bababa'}">{{item.isOnline ? '在线' : '掉线'}}</span></div>
+                            <div class="time">安装时间: <span>{{item.installDate}}</span></div>
+                            <div class="address">安装位置: <span>{{item.address}}</span></div>
+                        </div>
+                    </div>
+                </div>
+                <div class="list-two list" v-else-if="selectNum === 2">
+                    <div class="item" v-for="(item, index) in deviceList" :key="index">
+                        <div class="item-t">
+                            <div>{{item.facilityName}}</div>
+                            <div>{{item.facilityCode}}</div>
+                        </div>
+                        <div class="item-img">
+                            <img v-if="item.facilityUrl" :src="imgBaseUrl + item.facilityUrl" alt="" />
+                        </div>
+                        <div class="item-info">
+                            <div class="online">设备在线状态: <span :style="{color: item.online ? '#56d12c' : '#bababa'}">{{item.online ? '在线' : '掉线'}}</span></div>
+                            <div class="time">安装时间: <span>{{item.installDate}}</span></div>
+                            <div class="address">安装位置: <span>{{item.address}}</span></div>
+                        </div>
+                    </div>
+                </div>
+                <div class="list-one list" v-else-if="selectNum === 1">
+                    <div class="item" v-for="(item, index) in deviceList" :key="index">
+                        <div class="item-t">
+                            <div>{{item.facilityName}}</div>
+                            <div>{{item.facilityCode}}</div>
+                        </div>
+                        <div class="item-img">
+                            <img v-if="item.facilityUrl" :src="imgBaseUrl + item.facilityUrl" alt="" />
+                        </div>
+                        <div class="item-info">
+                            <div class="online">设备在线状态: <span :style="{color: item.isOnline ? '#56d12c' : '#bababa'}">{{item.isOnline ? '在线' : '掉线'}}</span></div>
+                            <div class="time">安装时间: <span>{{item.installDate}}</span></div>
+                            <div class="address">安装位置: <span>{{item.address}}</span></div>
+                        </div>
+                    </div>
+                </div>
+                <div class="list-single" v-else></div>
+            </div>
+        </div>
     </div>
 </template>
 
 <style scoped lang="scss">
-
+.shebei{
+    height: 100%;
+    display: flex;
+    &-menu{
+        flex-shrink: 0;
+        width: 20%;
+        height: 100%;
+        padding: 10px 0;
+        background: linear-gradient( 135deg, #91BDDB 0%, #9EC2DB 99%);
+        overflow-y: scroll;
+        &::-webkit-scrollbar {
+            display: none;
+        }
+        .menu-t{
+            height: 40px;
+            line-height: 40px;
+            padding-left: 20px;
+            font-size: 26px;
+            color: #fff;
+            background: url("@/assets/images/flow/monitor-title-bg.png") no-repeat;
+            background-size: 100% 100%;
+        }
+        .el-menu{
+            background-color: transparent;
+            border-right: none;
+            :deep(.el-menu){
+                background-color: transparent;
+            }
+            :deep(.el-sub-menu__title:hover) {
+                background-color: rgba(0, 0, 0, 0.06);
+            }
+            :deep(.el-menu-item.is-active) {
+                color: #fff;
+            }
+        }
+    }
+    &-monitor{
+        flex-shrink: 0;
+        width: 80%;
+        height: 100%;
+        background: linear-gradient( 180deg, #91BDDB 0%, rgba(102, 102, 102, 0.5) 100%);
+        .monitor-tool{
+            width: 100%;
+            height: 60px;
+            padding: 0 30px;
+            background: linear-gradient( 90deg, #91BDDB 0%, #DADFE3 100%);
+            display: flex;
+            align-items: center;
+            justify-content: space-between;
+            .tool-l{
+                display: flex;
+                align-items: center;
+                gap: 1rem;
+                .name{
+                    font-size: 1.1rem;
+                }
+            }
+            .tool-r{
+                display: flex;
+                align-items: center;
+                img{
+                    width: 25px;
+                    margin-right: 10px;
+                }
+            }
+        }
+        .monitor-box{
+            height: calc(100% - 60px);
+            padding-top: 10px;
+            .list{
+                height: 100%;
+                padding: 0 30px;
+                overflow-y: scroll;
+                &::-webkit-scrollbar {
+                    display: none;
+                }
+                .item{
+                    flex-shrink: 0;
+                    background: rgba(23,108,229,0.3);
+                    border: 1px solid #176CE5;
+                    border-radius: 8px;
+                }
+            }
+            .list-six{
+                display: flex;
+                flex-wrap: wrap;
+                gap: 20px;
+                .item{
+                    width: 32%;
+                    height: 48%;
+                    padding: 10px 20px;
+                    .item-t{
+                        height: 10%;
+                        display: flex;
+                        align-items: center;
+                        justify-content: space-between;
+                        font-size: 28px;
+                        color: #fff;
+                    }
+                    .item-img{
+                        margin-top: 10px;
+                        width: 100%;
+                        height: 68%;
+                        background-color: #000;
+                        img{
+                            width: 100%;
+                            height: 100%;
+                        }
+                    }
+                    .item-info{
+                        height: 18%;
+                        display: flex;
+                        flex-wrap: wrap;
+                        color: #fff;
+                        font-size: 1.2rem;
+                        .online,
+                        .time{
+                            width: 50%;
+                            padding: 6px 0;
+                        }
+                        .address{
+                            width: 100%;
+                        }
+                    }
+                }
+            }
+            .list-two{
+                display: flex;
+                flex-wrap: wrap;
+                gap: 20px;
+                .item{
+                    width: 49%;
+                    height: 99%;
+                    padding: 30px;
+                    .item-t{
+                        height: 10%;
+                        display: flex;
+                        align-items: center;
+                        justify-content: space-between;
+                        font-size: 36px;
+                        color: #fff;
+                    }
+                    .item-img{
+                        margin-top: 10px;
+                        width: 100%;
+                        height: 68%;
+                        background-color: #000;
+                        img{
+                            width: 100%;
+                            height: 100%;
+                        }
+                    }
+                    .item-info{
+                        display: flex;
+                        flex-wrap: wrap;
+                        color: #fff;
+                        font-size: 1.5rem;
+                        .online,
+                        .time{
+                            width: 50%;
+                            padding: 20px 0;
+                        }
+                        .address{
+                            width: 100%;
+                        }
+                    }
+                }
+            }
+            .list-one{
+                display: flex;
+                flex-direction: column;
+                align-items: center;
+                .item{
+                    width: 70%;
+                    height: 99%;
+                    padding: 30px;
+                    margin-bottom: 30px;
+                    .item-t{
+                        height: 10%;
+                        display: flex;
+                        align-items: center;
+                        justify-content: space-between;
+                        font-size: 36px;
+                        color: #fff;
+                    }
+                    .item-img{
+                        margin-top: 10px;
+                        width: 100%;
+                        height: 75%;
+                        background-color: #000;
+                        img{
+                            width: 100%;
+                            height: 100%;
+                        }
+                    }
+                    .item-info{
+                        display: flex;
+                        flex-wrap: wrap;
+                        color: #fff;
+                        font-size: 1.5rem;
+                        .online,
+                        .time{
+                            width: 50%;
+                            padding: 20px 0;
+                        }
+                        .address{
+                            width: 100%;
+                        }
+                    }
+                }
+            }
+        }
+    }
+}
 </style>
\ No newline at end of file

--
Gitblit v1.9.3