whyczyk
2021-10-08 f82084fde5fe67ea93c81e34a395ba650f661766
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<template>
    <div class="map-panel-content">
        <div class="content-item content-item-nowrap">
            蓄电池组告警数目:{{info.nums.code}}
            <a class="content-detail" href="javascript:;" @click="goBattWarn">详情>></a>
        </div>
        <div class="content-item content-item-nowrap">
            蓄电池组落后数目:{{info.nums.sum}}
            <a class="content-detail" href="javascript:;" @click="goBehind">详情>></a>
        </div>
        <div class="content-item content-item-nowrap">
            蓄电池组延时数目:{{info.nums.newsum}}
            <a class="content-detail" href="javascript:;" @click="goTimeout">详情>></a>
        </div>
        <div class="content-item">
            <el-button type="primary" size="mini" @click="goRealTime">实时数据</el-button>
            <el-button type="primary" size="mini" @click="goHistory">历史数据</el-button>
            <el-button v-if="isCanDel" type="danger" size="mini" @click="delHome">移除机房</el-button>
        </div>
        <div class="content-item">地址:{{info.Address}}</div>
    </div>
</template>
 
<script>
import {
    delMapHome
} from "@/assets/js/api";
 
export default {
    props: ['infos'],
    data() {
        return {
            isCanDel: false,
            username: sessionStorage.getItem('username'),
            info: {
                num: 369,
                StationId: "42070471",
                StationName: "贵州省-贵阳市-观山湖区-观山湖区护理学院-设备1",
                StationName3: "观山湖区护理学院",
                Address: "湖北省武汉市武昌区",
                longitude: 114.37285909,
                latitude: 30.56442241,
                information: "",
                FBSDeviceId: 910000111,
                nums: {
                    code: 0,
                    sum: 0,
                    newsum: 0
                }
            }
        }
    },
    watch: {
        rightMenuVisible(value) {
            if (value) {
                document.body.addEventListener('click', this.closeMenu)
            } else {
                document.body.removeEventListener('click', this.closeMenu)
            }
        },
        'infos': {
            handler(val) {
                this.info = JSON.parse(JSON.stringify(val));
            },
            deep: true
        }
    },
    mounted() {
 
    },
    methods: {
        // 跳转到历史数据
        goHistory() {
            window.parent.parent.postMessage({
                cmd: "syncPage",
                params: {
                    pageInfo: {
                        label: "历史数据",
                        name: "history",
                        src: "#/history" + this.search,
                        closable: true
                    }
                }
            }, "*");
        },
        // 跳转到实时数据
        goRealTime() {
            window.parent.parent.postMessage({
                cmd: "syncPage",
                params: {
                    pageInfo: {
                        label: "实时监控",
                        name: "movingRingSysteRrealTime",
                        src: "#/moving-ring-system" + this.search,
                        closable: true
                    }
                }
            }, "*");
        },
        // 跳转告警界面
        goBattWarn() {
            window.parent.parent.postMessage({
                cmd: "syncPage",
                params: {
                    pageInfo: {
                        label: "电池告警实时查询",
                        name: "batteryrTimequery",
                        src: "#/batteryrTimequery" + this.search + '&fromType=fromIndex',
                        closable: true
                    }
                }
            }, "*");
        },
        // 跳转到落后机房
        goBehind() {
            this.$layer.msg('该功能暂未开启');
        },
        // 跳转到延时
        goTimeout() {
            this.$layer.msg('该功能暂未开启');
        },
        // 移除机房
        delHome() {
            let content = "确认从地图上移除" + this.info.StationName
            this.$layer.confirm(content, {
                icon: 3
            }, index => {
                this.$layer.close(index);
                let loading = this.$layer.loading(1);
                delMapHome(this.info).then(res => {
                    let rs = JSON.parse(res.data.result);
                    if (rs.code == 1) {
                        this.$layer.msg("删除成功");
                        // 关闭等待框
                        this.$layer.close(loading);
                        // 触发删除事件,告诉父组件
                        this.$emit('delHome');
                    } else {
                        // 关闭等待框
                        this.$layer.close(loading);
                        this.$layer.msg("删除失败")
                    }
                }).catch(error => {
                    console.log(error)
                    // 关闭等待框
                    this.$layer.close(loading);
                });
            });
        },
        setInfo(info) {
            this.info = info;
        },
    },
    computed: {
        search() {
            let list = this.info.StationName.split('-');
            return '?province=' + list[0] + '&city=' + list[1] + '&county=' + list[2] + '&home=' + list[3]
        },
    },
}
</script>
 
<style scoped>
.map-panel-content {
    width: 300px;
}
 
.content-item {
    padding: 4px;
    font-size: 12px;
}
 
.content-item-nowrap {
    white-space: nowrap;
}
 
.content-detail {
    margin-left: 8px;
}
</style>