张卓
2022-09-29 4ef1c909df36c48f7f040e9ec408fc15e6745e71
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
<template>
  <div class="alarm_realTime">
    <div class="alarm_top header_alarm">
      <img class="alarm_img" :src="require('@/assets/images/regionalOverview/alarm.png')" alt="">
      <span class="alarm_reminder">污染报警提醒(今日报警{{ totalNumber }}条) <img class="reminder_img" :src="require('@/assets/images/regionalOverview/smallBell.gif')" alt=""></span>
      <img class="open" :src="require('@/assets/images/regionalOverview/open.png')" alt="" style="cursor:pointer" @click="turnAlarmTableVisible">
    </div>
    <div class="alarm_content">
      <div class="alarm_info">
        <div class="alarm_title">
          <span v-for="(item, key) in tableTitle" :key="key"> {{ item }}</span>
        </div>
        <div v-for="(item, key) in tableData" :key="key" class="per_alarm" @click="showInfo($event, item)" @mouseleave="hiddenCard">
          <span>{{ item.alarm_time.substr(11, 5) }}</span>
          <span>{{ item.deviceName }}</span>
          <span>{{ item.index + '' + item.alarm_type }}</span>
        </div>
      </div>
    </div>
    <div
      id="alarm_height"
      class="alarm_bubble"
      :style="{ position: 'fixed', right: '400px', width: '380px', backgroundColor: '#fff',top: dynamicTop, display: showOrHidden}"
      v-if="this.tableData.length > 0"
    >
      <!--      -->
 
      <div class="alarm_bubble_top">
        <span class="alarm_bubble_top_left">七星瓢虫环境科技</span>
        <span class="alarm_bubble_top_right">{{ obj.alarm_time.substr(11, 5) }}</span>
      </div>
      <div class="alarm_bubble_body">
        <div><span>【时间】</span><span>{{ obj.alarm_time.substr(0, 10) + ' ' + obj.alarm_time.substr(11, 5) }}</span></div>
        <div><span>【点位】</span><span>{{ obj.deviceName }}</span></div>
        <div><span>【报警】</span><span>{{ obj.index + '' + obj.alarm_type }}</span></div>
        <div><span>【详情】</span><span>{{ obj.alarm_information }}</span></div>
      </div>
    </div>
    <div v-else >
      <el-empty description="暂无报警数据" :image-size="60"></el-empty>
    </div>
  </div>
</template>
 
<script>
import Bus from '@/Bus'
export default {
  name: 'AlarmReminder',
  props: {
    map: {
      type: Object,
      default: null
    }
  },
  data() {
    return {
      tableTitle: ['报警时间', '点位', '报警信息'],
      tableData: [],
      totalNumber: 0,
      dynamicTop: 0,
      bubbleTop: 0,
      showOrHidden: 'none',
      obj: {
        alarm_time: ''
      }
    }
  },
  mounted() {
    Bus.$on('monitorPointIds', (mIds) => {
      // console.log(mIds)
    })
    this.alarmReminder()
  },
  methods: {
    // 显示报警信息详情
    showInfo(event, obj) {
      this.obj = obj
      const lngLat = [this.obj.latitude, this.obj.longitude]
      this.map.setView(lngLat, 18)
      // 获取气泡的高度
      this.showOrHidden = 'block'
      const parantNode = event.target.parentElement
      // 获取节点距离浏览器视口的高度
      let top = parantNode.getBoundingClientRect().top
      // 获取节点距离浏览器视口的宽度
      const left = parantNode.getBoundingClientRect().left
      // 获取滚动条滚动距离
      const scrollTop = document.body.scrollTop || document.documentElement.scrollTop
      // 两个top相加就是节点真正的top值
      setTimeout(() => {
        this.bubbleTop = document.getElementById('alarm_height').clientHeight
        top = top + scrollTop - this.bubbleTop + 24 + 'px'
        this.dynamicTop = top
      })
    },
    // 隐藏显示的卡片
    hiddenCard() {
      this.showOrHidden = 'none'
    },
    // 获取数据
    alarmReminder() {
      this.$request({
        url: '/alarmInfo/alarmReminder',
        method: 'get',
        params: {
          organization_id: this.$store.state.orgId,
          size: 3
        }
      }).then(res => {
        // console.log(res)
        if (res.code === 0) {
          this.tableData = res.data.alarmInfors
          this.totalNumber = res.data.totalNumber
        }
      })
    },
    turnAlarmTableVisible() {
      // this.$store.state.alarmTableVisible = true
      this.$Bus.$emit('alarmTableVisible', true)
    }
  }
 
}
</script>
 
<style lang="less">
.alarm_realTime {
  width: 100%;
  margin-top: 6px;
  background-color: #fff;
  //box-shadow: 0 0 5px 1px #999;
  padding: 0;
  border: solid 1px #d9d9d9;
  border-radius: 3px;
  box-sizing: border-box;
}
.alarm_realTime > .alarm_top {
  display: inline-block;
  outline: none;
  width: 100%;
  float: left;
}
.header_alarm {
  position: relative;
  height: 40px;
  background-color: #F8F7F7;
  .alarm_img {
    position: absolute;
    top: 6px;
    left: 16px;
    width: 20px;
  }
  .alarm_reminder {
    position: absolute;
    height: 40px;
    line-height: 40px;
    left: 40px;
    font-size: 15px;
    color: #808080;
    .reminder_img {
      margin-left: 6px;
      margin-top: -3px;
      width: 24px;
      vertical-align: middle;
    }
  }
  .open {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 20px;
    line-height: 40px;
  }
}
 
.alarm_content {
  width: 100%;
  padding: 0 12px;
  margin-top: 50px;
  margin-bottom: 12px;
  .alarm_title {
    color: #fff;
    font-size: 14px;
    background-color: #66b1ff;
    font-weight: 500;
    height: 40px;
    line-height: 40px;
    border-radius: 4px 4px 0 0 ;
    span:nth-child(1) {
      width: 24%;
    }
    span:nth-child(2) {
      width: 30%;
    }
    span:nth-child(3) {
      width: 44%;
    }
    span {
      display: inline-block;
      height: 32px;
      line-height: 32px;
      text-align: center;
    }
  }
  .per_alarm {
    height: 48px;
    margin-top: 0;
    border-bottom: 1px solid rgba(128, 128, 128, .6);
    border-left: 1px solid rgba(128, 128, 128, .6);
    border-right: 1px solid rgba(128, 128, 128, .6);
    span {
      border-right: 1px solid rgba(128, 128, 128, .6);
      display: inline-block;
      color: rgba(128, 128, 128, 1);
      height: 48px;
      line-height: 48px;
      overflow:hidden;
      text-overflow:ellipsis;
      text-align: center;
      white-space:nowrap;
    }
    span:nth-child(1) {
      width: 24%;
    }
    span:nth-child(2) {
      width: 30%;
      word-wrap:break-word;
      word-break: normal;
    }
    span:nth-child(3) {
      width: 40%;
      border-right: none;
      word-wrap:break-word;
      word-break: normal;
    }
  }
  .per_alarm:nth-last-child(1) {
    border-radius:  0 0 4px 4px;
  }
  .per_alarm:hover {
    cursor: pointer;
    background-color: rgba(108, 177, 248, .12);
  }
}
 
.text {
  font-size: 14px;
}
 
.alarm_bubble {
  border-radius: 8px;
  .alarm_bubble_top {
    width: 100%;
    height: 45px;
    line-height: 44px;
    padding: 0 10px;
    background-color: #66b1ff;
    border-radius: 8px 8px 0 0;
    font-size: 16px;
    color: #fff;
    span:nth-last-child(2){
      float: left;
    }
    span:nth-last-child(1){
      float: right;
    }
  }
  .alarm_bubble_body {
    div {
      color: #808080;
      width: 100%;
      span:nth-child(1) {
        display: inline-block;
        float: left;
        line-height: 26px;
        font-size: 14px;
      }
      span:nth-child(2) {
        word-wrap:break-word;
        line-height: 26px;
        font-size: 14px;
        text-indent: 2px;
      }
 
    }
    padding: 5px 10px;
  }
}
 
</style>