suerprisePlus
2024-05-30 d4c810f9803aa13d806724a5f4f71fe85abac38e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<template>
<div style="display:flex;margin-top:60px;">
    <div style="margin-left:10px;color:#32c5e9;">
        <dv-decoration-9 style="width:90px;height:90px;font-weight:600;" :dur="10" :color="['#32c5e9', '#238aa4']">{{deviceStatistic.deviceCount}}</dv-decoration-9>
        <div style="text-align: center;margin-top:25px;">设备总数</div>
    </div>
    <div style="margin:0 30px;color:#9fe6b8">
        <dv-decoration-9 style="width:90px;height:90px;font-weight:600;" :dur="10" :color="['#9fe6b8', '#70a181']">{{deviceStatistic.deviceOnlineCount}}</dv-decoration-9>
        <div style="text-align: center;margin-top:25px;font-weight:400;">在线设备</div>
    </div>
    <div style="margin-right:30px;color:#ffdb5c">
        <dv-decoration-9 style="width:90px;height:90px;font-weight:600;" :dur="10" :color="['#ffdb5c', '#b39a41']">{{deviceStatistic.deviceCount-deviceStatistic.deviceOnlineCount}}</dv-decoration-9>
        <div style="text-align: center;margin-top:25px;font-weight:400;">离线设备</div>
    </div>
    <div style="color:#fb7293;">
        <dv-decoration-9 style="width:90px;height:90px;font-weight:600;" :dur="10" :color="['#fb7293', '#ad4f65']">{{deviceStatistic.alertCount}}</dv-decoration-9>
        <div style="text-align: center;margin-top:25px;font-weight:400;">告警数量</div>
    </div>
</div>
</template>
 
<script>
import {
    getDeviceStatistic,
} from "@/api/iot/device";
export default {
    data() {
        return {
            // 设备统计信息
            deviceStatistic: {
                deviceCount: 100,
                productCount: 100,
                eventCount: 100,
                alertCount: 100,
                deviceOnlineCount:100
            },
            timer: null,
        };
    },
    created() {
        this.getDeviceStatic()
    },
    beforeDestroy() {
        this.clearData()
    },
    methods: {
        clearData() {
            if (this.timer) {
                clearInterval(this.timer)
                this.timer = null
            }
        },
        getDeviceStatic() {
            getDeviceStatistic().then(response => {
                if (response.code == 200) {
                    this.deviceStatistic = response.data;
                    // 轮询
                    this.switper()
                }
            });
        },
        //轮询
        switper() {
            if (this.timer) {
                return
            }
            let looper = (a) => {
                this.getDeviceStatic();
            };
            this.timer = setInterval(looper, 60000);
        },
 
    },
};
</script>