alarmEvent.vue
4.48 KB
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
<template>
<div>
<el-table :data="tableData">
<el-table-column type="index" align="center" label="#"></el-table-column>
<el-table-column align="center" prop="eventType" label="事件地点" :formatter="eventFormatter"></el-table-column>
<el-table-column align="center" prop="locationName" label="抓拍类型"></el-table-column>
<el-table-column align="center" prop="startDt" label="发生时间"></el-table-column>
<el-table-column align="center" prop="operation" label="操作">
<template slot-scope="scope">
<el-tooltip content="详情及审核" placement="bottom" effect="light" :visible-arrow="false">
<img
src="../../assets/img/home/look.png"
alt
class="edit"
@click="editVideo(scope.$index, scope.row)"
/>
</el-tooltip>
<span class="tableSpanBorder"></span>
<el-tooltip content="删除" placement="bottom" effect="light" :visible-arrow="false">
<img
src="../../assets/img/home/del.png"
alt
class="del"
@click="delFun(scope.$index, scope.row)"
/>
</el-tooltip>
</template>
</el-table-column>
</el-table>
</div>
</template>
<script>
export default {
data() {
return {
tableData:[]
}
},
methods:{
delFun(index, rows) {
rows.splice(index, 1);
},
eventFormatter(row, column, cellValue, index){
let value=''
this.eventTypeList.forEach(item=>{
if(item.code==cellValue){
value=item.name;
}
})
return value;
},
},
beforeMount(){
let that = this;
this.connect_id = new Date().getTime()
// this.cws = new WebSocket('ws://'+ this.API.IP +'/websocket/v1/integrated/connects/' + this.connect_id)
this.cws = new WebSocket('ws://192.168.9.62:20080/websocket/api/v1/integrated/connects/' + this.connect_id)
this.cws.onopen = () =>{
console.log('ws事件推送服务连接成功')
}
//事件断开
this.cws.onclose = () =>{
window.clearTimeout(that.keepAlive)
console.log('ws事件推送服务断开')
debugger
that.connect_id = new Date().getTime()
that.cws = new WebSocket('ws://192.168.9.62:20080/websocket/api/v1/integrated/connects/' + that.connect_id)
that.keepAlive = setInterval(() => {
let message = {
type: 'request',
id: new Date().getTime(),
mts: new Date().getTime(),
command:'get /websocket/v1/recv_data/connects/' + this.connect_id +'/keep_alive'
}
this.cws.send(JSON.stringify(message))
}, 20000);
}
//事件推送信息
this.cws.onmessage = (evt) =>{
let data = JSON.parse(evt.data)
try {
if(data.event_cate == 'behavior'){
debugger
let illame = this.getCode('安防事件',data.event_type);
let camername = data.event_data.device?data.event_data.device.name:''
let addressname = data.event_data.location?data.event_data.location.name:''
let dt = this.setUtcTime(data.event_dt).split(' ')[1];
let pics = 'data:image/jpeg;base64,'+data.pics[0].pic_base64
let obj = {
illame:illame,
illdt:dt,
addressname:addressname,
camername:camername,
pics:pics
}
that.tableData.unshift(obj)
} else if(data.event_data.illegal.state == 1){
let illame = this.getCode('违法类型',data.event_data.illegal.code);
let camername = data.event_data.location.name
let dt = this.setUtcTime(data.event_dt).split(' ')[1];
let pics = 'data:image/jpeg;base64,'+data.pics[0].pic_base64
let obj = {
illame:illame,
illdt:dt,
camername:camername,
pics:pics
}
that.list.unshift(obj)
}
} catch (error) {
}
if(data.command){
console.log('推送服务连接正常')
} else if(data.type =='response'){
console.log('请求任务推送成功')
}
}
this.keepAlive = setInterval(() => {
let message = {
type: 'request',
id: new Date().getTime(),
mts: new Date().getTime(),
command:'get /websocket/v1/recv_data/connects/' + this.connect_id +'/keep_alive'
}
this.cws.send(JSON.stringify(message))
}, 50000);
}
};
</script>
<style>
</style>>