videoEquipment.vue
8.29 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
<template>
<div class="innnerBox">
<el-col :span="4">
<el-input class="search-input" prefix-icon="el-icon-search" placeholder="请输入内容" v-model="searchText">
</el-input>
<cameraTree :filterText="searchText" :treeDatas="cameraTree"></cameraTree>
<videoTree :filterText="searchText" :treeDatas="videoTree" :devsId="dev_unid"></videoTree>
</el-col>
<el-col :span="20">
<el-table :data="formattterData" height="574" stripe border v-if="tableType=='camera'">
<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="iconfont icon-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="iconfont icon-detail 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="iconfont icon-xiugai editIcon" @click="detailFun(scope.$index, scope.row)"></span>
</el-tooltip>
</template>
</el-table-column>
</el-table>
<el-table :data="formattterData" height="574" stripe border v-else-if="tableType=='video'">
<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="iconfont icon-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="iconfont icon-detail delIcon" @click="delVideo(scope.$index, scope.row)"></span>
</el-tooltip>
</template>
</el-table-column>
</el-table>
</el-col>
<cameraDialog ref="editCamera"></cameraDialog>
</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: sessionStorage.getItem('dev_unid'),
cameraArr:[],
cameraTree:[],
videoTree:[]
}
},
watch: {
},
components: {
cameraTree,cameraDialog,videoTree
},
mounted() {
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(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) => {
})
}
}
},
getVideoTable(data,type){
this.tableType=type;
this.formattterData=[];
if(data.childs){
this.formattterData=data.childs;
}else{
this.formattterData.push(data)
}
},
editVideo(){
},
delVideo(){
}
},
}
</script>
<style lang="scss" scoped>
</style>