videoEquipment.vue
10.5 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
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
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
<template>
<div class="innnerBox">
<el-row :gutter="12">
<el-col :span="6" class="treeBox minHeight">
<el-input class="search-input" prefix-icon="el-icon-search" placeholder="请输入内容" v-model="searchText">
</el-input>
<cameraTree :filterText="searchText" :treeDatas="cameraTree" @clickHandle="getTable" @getTree="getCameraTree" @getData="submitLaterGet"></cameraTree>
<videoTree :filterText="searchText" :treeDatas="videoTree" :devsId="dev_unid" @clickHandle="getTable" @getTree="getVideoTree"></videoTree>
</el-col>
<el-col :span="18" >
<el-table :data="formattterData" stripe border v-if="tableType=='camera'" :height="tableHeight">
<el-table-column prop="label" align="center" label="名称">
</el-table-column>
<el-table-column prop="url" align="center" label="取流地址">
</el-table-column>
<el-table-column align="center" label="操作">
<template slot-scope="scope">
<el-tooltip content="修改" placement="bottom" effect="light" :visible-arrow=false>
<span class="icon-fanxing-xiugai editIcon" @click="editFun(scope.$index, scope.row)"></span>
</el-tooltip>
<span class="tableSpanBorder"></span>
<el-tooltip content="删除" placement="bottom" effect="light" :visible-arrow=false>
<span class="el-icon-delete delIcon" @click="delFun(scope.$index, scope.row)"></span>
</el-tooltip>
<span class="tableSpanBorder"></span>
<el-tooltip content="详情" placement="bottom" effect="light" :visible-arrow=false >
<span class="el-icon-info editIcon" @click="detailFun(scope.$index, scope.row)"></span>
</el-tooltip>
</template>
</el-table-column>
</el-table>
<el-table :data="formattterData" stripe border v-else-if="tableType=='video'" :height="tableHeight">
<el-table-column prop="vchan_name" align="center" label="名称">
</el-table-column>
<el-table-column prop="video_url" align="center" label="取流地址">
</el-table-column>
<el-table-column align="center" label="操作">
<template slot-scope="scope">
<el-tooltip content="修改" placement="bottom" effect="light" :visible-arrow=false>
<span class="icon-fanxing-xiugai editIcon" @click="editVideo(scope.$index, scope.row)"></span>
</el-tooltip>
<span class="tableSpanBorder"></span>
<el-tooltip content="删除" placement="bottom" effect="light" :visible-arrow=false>
<span class="el-icon-delete delIcon" @click="delVideo(scope.$index, scope.row)"></span>
</el-tooltip>
</template>
</el-table-column>
</el-table>
</el-col>
<cameraDialog ref="editCamera" @getData="submitLaterGet"></cameraDialog>
<el-dialog
title="修改视频"
:visible.sync="videoEditVisible"
width="450px">
<div>
<el-form label-position="left" label-width="120px" :model="videoEditParam" ref="videoDialog" inline-message hide-required-asterisk>
<el-form-item label="名称" :rules="[ { required: true, message: '请输入名称', trigger: 'change' }]">
<el-input v-model="videoEditParam.vchan_name"></el-input>
</el-form-item>
<el-form-item label="取流地址">
<el-input v-model="videoEditParam.video_url" disabled></el-input>
</el-form-item>
</el-form>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="videoEditVisible=false">取 消</el-button>
<el-button type="primary" @click="editSave">确 定</el-button>
</span>
</el-dialog>
</el-row>
</div>
</template>
<script>
import cameraTree from './treeComponents/cameraTree'
import videoTree from './treeComponents/videoTree'
import cameraDialog from './treeComponents/cameraDialog'
export default {
data() {
return {
searchText: '',
detailObj: {},
detailImg: '',
detailVisible: false,
tableType:'camera',
tableData: [],
formattterData: [],
selectcheck: [],
currentIndex: 0,
eventList: JSON.parse(window.localStorage.getItem('安防事件')),
playurl: '',
dev_unid: localStorage.getItem('dev_unid'),
cameraArr:[],
cameraTree:[],
videoTree:[],
videoEditParam:{
vchan_name:'',
video_url:''
},
videoEditVisible:false,
vchan_duid:'',
tableHeight:window.videoEquitTableHeight
}
},
watch: {
},
components: {
cameraTree,cameraDialog,videoTree
},
mounted() {
console.log('aa',this.tableHeight)
this.getCameraTree();
this.getVideoTree();
},
methods: {
getCameraTree(){
this.tableType='camera'
this.$api.resource.treeList({
vchan_type: "camera"
},this.dev_unid).then(res=>{
this.cameraTree=res.vchan_struct;
this.cameraArr=[];
this.cameraBuildTree(res.vchan_struct)
})
},
getVideoTree(){
this.tableType='video'
this.$api.resource.getVideoList({
vchan_type: "vfile"
},this.dev_unid).then(res=>{
this.videoTree=res.list_data;
})
},
submitLaterGet(data){
this.tableType='camera'
this.$api.resource.treeList({
vchan_type: "camera"
},this.dev_unid).then(res=>{
this.cameraTree=res.vchan_struct;
this.cameraArr=[];
this.cameraBuildTree(res.vchan_struct);
this.getTable(data)
})
},
//处理树状图数据
cameraBuildTree(data, orgObject, addrObject) { // 获取相机资源
let newData = [];
for (var i = 0; i < data.length; i++) {
let obj = {};
if(data[i].org_type === 'org' || data[i].org_type === 'address') {
obj['id'] = data[i].org_code;
obj['unid'] = data[i].unid;
obj['label'] = data[i].org_name === '' ? '未命名' : data[i].org_name;
obj['url'] = '暂无';
obj['root'] = '手动添加相机资源';
obj['pid'] = data[i].org_pid;
obj['type'] = data[i].org_type;
if(data[i].childs) {
if(data[i].org_type === 'org') {
obj['children'] = this.cameraBuildTree(data[i].childs, data[i], addrObject);
} else {
obj['children'] = this.cameraBuildTree(data[i].childs, orgObject, data[i]);
}
} else {
obj['children'] = [];
}
} else if(data[i].vchan_type === 'camera') {
obj['id'] = data[i].vchan_refid;
obj['label'] = data[i].vchan_name === '' ? '未命名' : data[i].vchan_name;
obj['type'] = data[i].vchan_type;
obj['root'] = '手动添加相机资源';
obj['orgNode'] = orgObject;
obj['addrNode'] = addrObject;
obj['dir_code'] = data[i].dir_code;
obj['dir_name'] = data[i].dir_name;
obj['ip'] = data[i].ip;
obj['port'] = data[i].port;
obj['video_proto'] = data[i].video_proto;
obj['url'] = data[i].video_url; // 取流地址
obj['username'] = data[i].username;
obj['password'] = data[i].password;
obj['extend_1'] = data[i].extend_1;
obj['extend_2'] = data[i].extend_2;
this.cameraArr.push(obj)
}
newData.push(obj);
}
return newData;
},
editFun(index,row){
this.$refs.editCamera.initDialog(row,'edit',this.dev_unid)
},
delFun(index,row){
this.$confirm('此操作将永久删除该选项, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$api.resource.delCamera({},this.dev_unid,row.id).then(res=>{
if(res.ecode==200){
this.$message({
type: 'success',
message: '删除成功!'
});
let data={
org_type:"address",
unid:row.addrNode.unid
}
this.submitLaterGet(data);
}
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
});
});
},
detailFun(index,row){
this.$refs.editCamera.initDialog(row,'detail',this.dev_unid)
},
getTable(data,type) {
if(data.org_type!="root"){
this.tableType=type;
if(this.tableType=="camera"){
if(data.org_type){
this.tableType=type;
this.formattterData = [];
let filterData=[];
let search_params = {
vchan_type: "camera",
org_unid:data.unid
}
this.$api.resource.getCameraTable(search_params,this.dev_unid).then((res) => {
if(res.list_data.length > 0) {
for(var i = 0; i < res.list_data.length; i++) {
filterData = this.cameraArr.filter(list => {
return list.id === res.list_data[i].vchan_refid;
})
if(filterData.length > 0) {
this.formattterData.push(filterData[0]);
}
}
}
}).catch((err) => {
})
}else{
this.formattterData = [];
let filterData=[];
this.$api.resource.getCameraTable({},this.dev_unid,data.vchan_refid).then((res) => {
filterData = this.cameraArr.filter(list => {
return list.id === res.refid;
})
if(filterData.length > 0) {
this.formattterData.push(filterData[0]);
}
}).catch((err) => {
})
}
}else if(this.tableType=="video"){
if(data.org_type=='video'){
this.formattterData=data.childs;
}else{
this.formattterData=[];
this.formattterData.push(data)
}
}
}
},
getVideoTable(data,type){
this.tableType=type;
this.formattterData=[];
if(data.childs){
this.formattterData=data.childs;
}else{
this.formattterData.push(data)
}
},
editVideo(index,row){
this.vchan_duid=row.vchan_duid;
this.videoEditParam.vchan_name = row.vchan_name;
this.videoEditParam.video_url = row.video_url;
this.videoEditVisible=true;
},
editSave(){
this.$api.resource.editVideo({
name:this.videoEditParam.vchan_name
},this.dev_unid,this.vchan_duid).then(res=>{
if(res.ecode==200){
this.$message({
type: 'success',
message: res.enote
});
this.getVideoTree();
this.formattterData.forEach(item=>{
if(item.vchan_duid==this.vchan_duid){
item.vchan_name=this.videoEditParam.vchan_name
}
})
}else{
this.$message.error(res.enote);
}
this.videoEditVisible=false;
})
},
delVideo(){
}
},
}
</script>
<style lang="scss" scoped>
.treeBox{
border: 1px solid #EBEEF5;
padding: 12px;
}
</style>