ZaiZai 1 year ago
parent
commit
b9e74a2be0

+ 1 - 1
public/version.json

@@ -1,3 +1,3 @@
 {
-  "value": "20240820110759"
+  "value": "20240820174157"
 }

+ 6 - 0
src/router/modules/base.js

@@ -308,6 +308,12 @@ export default [
                 redirect: '/tentative/acquisition/data',
                 meta: { title: '物联网采集' },
                 children: [
+                    {
+                        path: '/tentative/acquisition/humidity',
+                        name: 'tentative-acquisition-humidity',
+                        meta: { title: '温湿度' },
+                        component: () => import('~src/views/tentative/acquisition/humidity.vue'),
+                    },
                     {
                         path: '/tentative/acquisition/data',
                         name: 'tentative-acquisition-data',

+ 169 - 0
src/styles/tentative/acquisition/equipment.scss

@@ -0,0 +1,169 @@
+.hc-tentative-acquisition-humidity-equipment {
+    position: relative;
+    .hc-card-item-box.equipment-list {
+        padding: 0;
+        background: transparent;
+        border-radius: 0;
+        border: 1px solid #eaeaea;
+        .hc-card-item-header {
+            background: #eaeaea;
+            padding: 6px 10px;
+            height: auto;
+            margin-bottom: 0;
+            color: unset;
+            .item-header .status-dot {
+                position: relative;
+                height: 16px;
+                width: 16px;
+                border-radius: 50px;
+                background: #ffb3b7;
+                display: flex;
+                justify-content: center;
+                align-items: center;
+                &:after {
+                    position: relative;
+                    display: block;
+                    content: '';
+                    background: #f0434c;
+                    height: 10px;
+                    width: 10px;
+                    border-radius: 50px;
+                }
+                &.run {
+                    background: #b2e4d2;
+                    &:after {
+                        background: #2bb781;
+                    }
+                }
+            }
+            .item-extra .icon-btn {
+                font-size: 18px;
+                cursor: pointer;
+                transition: opacity .2s;
+                &:hover{
+                    opacity: 0.7;
+                }
+            }
+        }
+        .equipment-list-data {
+            padding: 14px;
+            .item {
+                position: relative;
+                padding: 12px 24px;
+                border-radius: 5px;
+                .icon-box {
+                    font-size: 60px;
+                    margin-right: 16px;
+                    overflow: hidden;
+                }
+                .content {
+                    position: relative;
+                    line-height: 1.6;
+                    .name {
+                        color: #20222A;
+                        font-size: 22px;
+                        font-weight: bold;
+                    }
+                    .num {
+                        font-size: 28px;
+                        font-weight: bold;
+                    }
+                    .time {
+                        color: #20222A;
+                        font-size: 12px;
+                    }
+                }
+                //温度
+                &.temperature {
+                    background: #DBE4FF;
+                    .icon-box, .content .num {
+                        color: #1D4590;
+                    }
+                }
+                //湿度
+                &.humidity {
+                    background: #EAFFE0;
+                    .icon-box, .content .num {
+                        color: #91CC75;
+                    }
+                }
+            }
+            .item + .item {
+                margin-left: 14px;
+            }
+        }
+    }
+    .hc-card-item-box.equipment-list + .hc-card-item-box.equipment-list {
+        margin-top: 20px;
+    }
+}
+
+.hc-tentative-acquisition-humidity-equipment-info {
+    position: relative;
+    height: 100%;
+    background: white;
+    border-radius: 3px;
+    display: flex;
+    .data-statistics {
+        position: relative;
+        width: 370px;
+        border-right: 1px solid #EEEEEE;
+        .equipment-list-data-item {
+            position: relative;
+            padding: 12px 24px;
+            border-radius: 5px;
+            .icon-box {
+                font-size: 60px;
+                margin-right: 16px;
+                overflow: hidden;
+            }
+            .content {
+                position: relative;
+                line-height: 1.6;
+                .name {
+                    color: #20222A;
+                    font-size: 22px;
+                    font-weight: bold;
+                }
+                .num {
+                    font-size: 28px;
+                    font-weight: bold;
+                }
+                .time {
+                    color: #20222A;
+                    font-size: 12px;
+                }
+            }
+            //温度
+            &.temperature {
+                background: #DBE4FF;
+                .icon-box, .content .num {
+                    color: #1D4590;
+                }
+            }
+            //湿度
+            &.humidity {
+                background: #EAFFE0;
+                .icon-box, .content .num {
+                    color: #91CC75;
+                }
+            }
+        }
+        .equipment-list-data-item + .equipment-list-data-item {
+            margin-top: 20px;
+        }
+        .equipment-list-data-echart {
+            position: relative;
+            margin-top: 20px;
+            height: calc(100% - 287px);
+        }
+    }
+    .data-table {
+        position: relative;
+        flex: 1;
+        .el-card.hc-card-box.hc-new-card-box {
+            box-shadow: none;
+            --el-card-bg-color:transparent;
+        }
+    }
+}

+ 1 - 1
src/views/tentative/acquisition/data.vue

@@ -6,7 +6,7 @@
                     <span class="text-18px">数据采集分类</span>
                 </template>
                 <template #extra>
-                    <el-button _icon hc-btn size="small" type="primary" @click="addDataFormModal">
+                    <el-button hc-btn _icon size="small" type="primary" @click="addDataFormModal">
                         <hc-icon name="add" />
                     </el-button>
                 </template>

+ 81 - 0
src/views/tentative/acquisition/humidity.vue

@@ -0,0 +1,81 @@
+<template>
+    <hc-card scrollbar>
+        <template #header>
+            <div class="w-40">
+                <el-select v-model="searchForm.status" clearable placeholder="设备状态">
+                    <el-option label="运行中" :value="1" />
+                    <el-option label="已关闭" :value="2" />
+                </el-select>
+            </div>
+            <div class="ml-14px w-260px">
+                <hc-search-input v-model="searchForm.ip" placeholder="设备IP搜索" @search="searchClick" />
+            </div>
+        </template>
+        <div class="hc-tentative-acquisition-humidity-equipment">
+            <hc-card-item class="equipment-list">
+                <template #header>
+                    <div class="status-dot run" />
+                    <div class="name ml-10px">300900317</div>
+                </template>
+                <template #extra>
+                    <div class="icon-btn text-#2bb781">
+                        <el-tooltip content="重启">
+                            <hc-icon name="restart" />
+                        </el-tooltip>
+                    </div>
+                    <div class="icon-btn ml-10px text-#f0434c">
+                        <el-tooltip content="关机">
+                            <hc-icon name="shut-down" />
+                        </el-tooltip>
+                    </div>
+                    <el-button size="small" class="ml-10px" @click="viewDetailsClick">查看详情</el-button>
+                </template>
+                <div class="equipment-list-data hc-flex">
+                    <div class="item temperature hc-flex">
+                        <div class="icon-box">
+                            <hc-icon name="temp-hot" />
+                        </div>
+                        <div class="content">
+                            <div class="name">温度</div>
+                            <div class="num">24.1℃</div>
+                            <div class="time">记录时间:2024年8月19日 13:55:24</div>
+                        </div>
+                    </div>
+                    <div class="item humidity hc-flex">
+                        <div class="icon-box">
+                            <hc-icon name="water-percent" />
+                        </div>
+                        <div class="content">
+                            <div class="name">湿度</div>
+                            <div class="num">24.1%</div>
+                            <div class="time">记录时间:2024年8月19日 13:55:24</div>
+                        </div>
+                    </div>
+                </div>
+            </hc-card-item>
+        </div>
+        <!-- 详情 -->
+        <HcEquipmentData v-model="isEquipmentDataShow" />
+    </hc-card>
+</template>
+
+<script setup>
+import { onMounted, ref } from 'vue'
+import HcEquipmentData from './model/equipment-data.vue'
+
+//搜索表单
+const searchForm = ref({ status: null, ip: null })
+const searchClick = () => {
+    window.$message.warning('暂不支持此操作')
+}
+
+//查看详情
+const isEquipmentDataShow = ref(false)
+const viewDetailsClick = () => {
+    isEquipmentDataShow.value = true
+}
+</script>
+
+<style lang="scss">
+@import "~src/styles/tentative/acquisition/equipment";
+</style>

+ 257 - 0
src/views/tentative/acquisition/model/equipment-data.vue

@@ -0,0 +1,257 @@
+<template>
+    <hc-drawer v-model="isShow" to-id="hc-main-box">
+        <div class="hc-tentative-acquisition-humidity-equipment-info">
+            <div class="data-statistics">
+                <hc-body>
+                    <div class="equipment-list-data-item temperature hc-flex">
+                        <div class="icon-box">
+                            <hc-icon name="temp-hot" />
+                        </div>
+                        <div class="content">
+                            <div class="name">温度</div>
+                            <div class="num">24.1℃</div>
+                            <div class="time">记录时间:2024年8月19日 13:55:24</div>
+                        </div>
+                    </div>
+                    <div class="equipment-list-data-item humidity hc-flex">
+                        <div class="icon-box">
+                            <hc-icon name="water-percent" />
+                        </div>
+                        <div class="content">
+                            <div class="name">湿度</div>
+                            <div class="num">24.1%</div>
+                            <div class="time">记录时间:2024年8月19日 13:55:24</div>
+                        </div>
+                    </div>
+                    <div class="equipment-list-data-echart">
+                        <hc-charts :option="setChartsOption" />
+                    </div>
+                </hc-body>
+            </div>
+            <div class="data-table">
+                <hc-card>
+                    <template #header>
+                        <div class="mr-14px w-410px">
+                            <el-date-picker
+                                v-model="dateTimeArr" type="datetimerange" :shortcuts="shortcuts" class="w-full!"
+                                value-format="YYYY-MM-DD HH:mm:ss" format="YYYY-MM-DD HH:mm:ss"
+                                range-separator="至" start-placeholder="开始日期时间" end-placeholder="结束日期时间"
+                            />
+                        </div>
+                        <el-button type="primary" @click="searchClick">搜索</el-button>
+                    </template>
+                    还在开发中...
+                </hc-card>
+            </div>
+        </div>
+    </hc-drawer>
+</template>
+
+<script setup>
+import { ref, watch } from 'vue'
+import { getObjValue } from 'js-fast-way'
+
+const props = defineProps({
+    data: {
+        type: Object,
+        default: () => ({}),
+    },
+})
+
+//双向绑定
+const isShow = defineModel('modelValue', {
+    default: false,
+})
+
+//监听可否编辑
+const dataInfo = ref(props.data)
+watch(() => props.data, (data) => {
+    dataInfo.value = getObjValue(data)
+}, { immediate: true, deep: true })
+
+//监听显示
+watch(isShow, (val) => {
+    if (val) getInfoData()
+})
+
+//获取数据详情
+const getInfoData = () => {
+    setChartsData()
+}
+
+//搜索表单
+const searchForm = ref({ nodeId: -1, startTime: '', endTime: '', deviceAddr: null })
+const searchClick = () => {
+    console.log(searchForm.value)
+    console.log(dateTimeArr.value)
+}
+
+//日期时间选择
+const dateTimeArr = ref('')
+const shortcuts = [
+    {
+        text: '最近1小时',
+        value: () => {
+            const end = new Date()
+            const start = new Date(end - 3600 * 1000) // 1小时前
+            return [start, end]
+        },
+    },
+    {
+        text: '今天',
+        value: () => {
+            const end = new Date()
+            const start = new Date(end.setHours(0, 0, 0, 0))
+            return [start, new Date()]
+        },
+    },
+    {
+        text: '昨天',
+        value: () => {
+            const end = new Date()
+            end.setDate(end.getDate() - 1)
+            const start = new Date(end.setHours(0, 0, 0, 0))
+            return [start, new Date(start.getTime() + 24 * 3600 * 1000 - 1)]
+        },
+    },
+    {
+        text: '最近7天',
+        value: () => {
+            const end = new Date()
+            const start = new Date(end - 7 * 24 * 3600 * 1000)
+            return [start, end]
+        },
+    },
+    {
+        text: '最近30天',
+        value: () => {
+            const end = new Date()
+            const start = new Date(end - 30 * 24 * 3600 * 1000)
+            return [start, end]
+        },
+    },
+    {
+        text: '本月',
+        value: () => {
+            const end = new Date()
+            const start = new Date(end.getFullYear(), end.getMonth(), 1)
+            return [start, end]
+        },
+    },
+    {
+        text: '上个月',
+        value: () => {
+            const end = new Date()
+            const start = new Date(end.getFullYear(), end.getMonth() - 1, 1)
+            const lastDayOfLastMonth = new Date(end.getFullYear(), end.getMonth(), 0)
+            return [start, lastDayOfLastMonth]
+        },
+    },
+]
+
+
+
+//图表数据
+const setChartsOption = ref({})
+const setChartsData = () => {
+    const data = [
+        { time: '00:00:00', temperature: 27, humidity: 50 },
+        { time: '00:30:00', temperature: 28.5, humidity: 41 },
+        { time: '01:00:00', temperature: 32, humidity: 60 },
+        { time: '01:30:00', temperature: 27, humidity: 48 },
+        { time: '02:00:00', temperature: 28, humidity: 40 },
+        { time: '02:30:00', temperature: 29.5, humidity: 55 },
+        { time: '03:00:00', temperature: 30.5, humidity: 48 },
+        { time: '03:30:00', temperature: 30, humidity: 61 },
+        { time: '04:00:00', temperature: 27.2, humidity: 54 },
+    ]
+    setChartsOption.value = {
+        tooltip: {
+            trigger: 'axis',
+            axisPointer: {
+                type: 'cross',
+            },
+            formatter: function (params) {
+                let result = params[0].axisValue + '<br/>'
+                params.forEach(function (item) {
+                    let unit = item.seriesName === '温度' ? '°C' : '%'
+                    result += item.marker + '  ' + item.seriesName + ': ' + item.value + unit + '<br/>'
+                })
+                return result
+            },
+        },
+        legend: {
+            data: ['温度', '湿度'],
+        },
+        xAxis: {
+            type: 'category',
+            data: data.map(item => item.time),
+            axisLine: {
+                onZero: false,
+            },
+        },
+        yAxis: [
+            {
+                type: 'value',
+                name: '温度(°C)',
+                min: 23,
+                max: 33,
+                interval: 2,
+                position: 'left',
+                axisLabel: {
+                    formatter: '{value}°C',
+                },
+            },
+            {
+                type: 'value',
+                name: '湿度(%)',
+                min: 20,
+                max: 70,
+                interval: 10,
+                position: 'right',
+                axisLabel: {
+                    formatter: '{value}%',
+                },
+            },
+        ],
+        series: [
+            {
+                name: '温度',
+                type: 'line',
+                yAxisIndex: 0,
+                data: data.map(item => item.temperature),
+                smooth: true,
+                lineStyle: {
+                    color: '#1D4590',
+                },
+                itemStyle: {
+                    color: '#1D4590',
+                },
+            },
+            {
+                name: '湿度',
+                type: 'line',
+                yAxisIndex: 1,
+                data: data.map(item => item.humidity),
+                smooth: true,
+                lineStyle: {
+                    color: '#91CC75',
+                },
+                itemStyle: {
+                    color: '#91CC75',
+                },
+            },
+        ],
+        grid: {
+            left: '3%',
+            right: '4%',
+            bottom: '3%',
+            containLabel: true,
+        },
+    }
+}
+</script>
+
+<style lang="scss">
+@import "~src/styles/tentative/acquisition/equipment";
+</style>