index.vue
11.8 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
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
<template>
<div class="box">
<div>
<el-table
:data="taskInfo.mtasks[0].scenes"
border
stripe
highlight-current-row
style="width: 80%;float:left"
height="25vh"
@current-change="handleCurrentChange"
>
<el-table-column label="序号" type="index" width="50" align="center">
</el-table-column>
<el-table-column align="center" label="预置位编号" width="180">
<template slot-scope="scope">
<div>
{{ setpositionnum(scope.row.position_num) }}
</div>
</template>
</el-table-column>
<el-table-column align="center" label="预设位置配置" width="180">
<template>
<div class="yzw-setbox">
<span class="icon el-icon-delete" @click="resetRoi"></span>
</div>
</template>
</el-table-column>
<el-table-column prop="address" align="center" label="参数设置">
<template slot-scope="scope">
<div class="table-set">
<span @click="setParam(scope.row, scope.$index)">参数设置</span>
<span @click="setArea(scope.row, scope.$index)">区域设置</span>
<span @click="setDemarcate(scope.row, scope.$index)"
>标定设置</span
>
<span @click="setTimer(scope.row, scope.$index)">时间设置</span>
</div>
</template>
</el-table-column>
</el-table>
<div class="setting-box">
<div class="set-header ">基础操作</div>
<div class="set-item" @click="setsounces">
场景配置 <span class="set-icon el-icon-circle-plus"></span>
</div>
<div class="set-item">
轮询播放
<span class="set-icon">
<el-switch :width="25" v-model="switchstate" @change="suspends">
</el-switch>
</span>
</div>
<div class="set-item" @click="handleparam('upload')">
配置导入 <span class="set-icon el-icon-download"></span>
</div>
<div class="set-item" @click="handleparam('export')">
配置导出 <span class="set-icon el-icon-upload"></span>
</div>
<div class="set-item" @click="showview()">
效果展示 <span class="set-icon el-icon-s-help"></span>
</div>
</div>
<handleparam ref="handleparam"></handleparam>
</div>
<div class="yt-box">
<ytconfig
ref="yt"
@subpostion="submitPosion"
@deleteytconfig="deleteytconfig"
></ytconfig>
</div>
<div>
<parameter ref="parameter"></parameter>
</div>
<div>
<areas ref="areas"></areas>
</div>
<div>
<demarcate ref="demarcate"></demarcate>
</div>
<div>
<el-dialog
title="时间设置"
:visible.sync="timerDialog"
width="18%"
top="15%"
:before-close="handleTimerClose"
>
<div class="settimertype">
<span class="title">时间长度:</span>
<div class="timer-sel">
<el-select v-model="timersel" placeholder="请选择">
<el-option label="下拉选择" :value="0"> </el-option>
<el-option label="自定义" :value="1"> </el-option>
</el-select>
</div>
</div>
<div class="sel-box" v-show="timersel == 0">
<span class="title">长度选择:</span>
<div class="timer-sel">
<el-select v-model="timer" placeholder="请选择">
<el-option
v-for="item in timeroptions"
:key="item"
:label="item"
:value="item"
>
</el-option>
</el-select>
</div>
</div>
<div class="sel-box" v-show="timersel == 1">
<span class="title">时间长度:</span>
<div class="timer-sel">
<el-input v-model="timer" style="padding-right:23px"></el-input>
</div>
</div>
<div class="sel-box">
<span class="title">开启轮休:</span>
<div class="timer-sel">
<el-switch
width="30"
v-model="polling_state"
active-color="#13ce66"
inactive-color="#ff4949"
>
</el-switch>
</div>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="handleTimerClose">取 消</el-button>
<el-button type="primary" @click="submitTimer">确 定</el-button>
</span>
</el-dialog>
</div>
</div>
</template>
<script>
import areas from "./area";
import demarcate from "./demarcate";
import parameter from "./parameter";
import ytconfig from "./ytconfig";
import handleparam from "./handleparam";
export default {
data() {
return {
timer: 0,
polling_state: false,
timersel: 0,
timerDialog: false,
curindex: 0,
timeroptions: [30, 40, 50, 60, 100],
timerscenes: null,
currentRow: null,
taskInfo: {
mtasks: [
{
scenes: []
}
]
},
switchstate: true
};
},
props: ["taskid", "subtaskid", "playurl"],
components: {
areas,
demarcate,
parameter,
ytconfig,
handleparam
},
methods: {
setParam(scenesdata, index) {
if (this.checkpollstate()) {
this.curindex = index;
this.$refs.parameter.init(scenesdata);
}
},
setArea(roidata, index) {
if (this.checkpollstate()) {
this.curindex = index;
this.$refs.areas.showModal(roidata, this.taskInfo);
}
},
setDemarcate(scenesdata, index) {
if (this.checkpollstate()) {
this.curindex = index;
this.$refs.demarcate.showModal(scenesdata);
}
},
handleparam(type) {
this.$refs.handleparam.show(type);
},
setsounces() {
if (this.checkpollstate()) {
this.$refs.yt.openyt(this.currentRow);
}
},
getTaskParams() {
this.$api.task.getTaskParams(this.taskid, this.subtaskid).then(data => {
this.taskInfo = data;
});
},
setTimer(data) {
this.timerscenes = data;
this.polling_state = data.pollingState;
this.$store.commit("setocxstate", 0);
this.timerDialog = true;
},
resetRoi() {
this.taskInfo.mtasks[0].scenes.map(ele => {
if (ele.scene_unid == this.currentRow.scene_unid) {
ele.config = {};
ele.rois = [];
}
});
this.subRoi(this.taskInfo.mtasks);
},
setpositionnum(index) {
return index == -1 ? "未设置" : index;
},
handleTimerClose() {
this.timerDialog = false;
this.$store.commit("setocxstate", 1);
},
handleCurrentChange(val) {
this.currentRow = val;
this.$api.task
.switchScene(this.taskid, this.subtaskid, val.scene_unid)
.then(res => {
console.log(res);
});
},
suspends() {
if (this.subtaskid) {
let _s = this.switchstate ? 1 : 0;
this.$api.task
.suspendAlternate(this.taskid, this.subtaskid, _s)
.then(res => {
console.log(res);
});
}
},
checkpollstate() {
let state = false;
if (this.switchstate) {
this.$message({
message: "请先关闭预置位在进行操作!",
type: "warning"
});
state = false;
} else {
state = true;
}
return state;
},
submitPosion(positionnum) {
this.taskInfo.mtasks[0].scenes.map(ele => {
if (ele.scene_unid == this.currentRow.scene_unid) {
ele.position_num = positionnum;
}
});
this.subRoi(this.taskInfo.mtasks);
},
deleteytconfig(positionnum) {
this.taskInfo.mtasks[0].scenes.map(ele => {
if (ele.scene_unid == this.currentRow.scene_unid) {
ele.position_num = -1;
}
});
this.subRoi(this.taskInfo.mtasks);
},
submitTimer(item) {
this.taskInfo.mtasks[0].scenes.map(ele => {
if (ele.scene_unid == this.currentRow.scene_unid) {
ele.runtime = this.timer;
ele.pollingState = this.polling_state;
}
});
this.subRoi(this.taskInfo.mtasks);
},
subRoi(mdata) {
let data = {
subtask_id: this.subtaskid,
mtasks: mdata
};
this.$api.task.editRoi(this.taskid, this.subtaskid, data).then(res => {
if (res.ecode == 200) {
this.timerDialog = false;
this.$message({
message: res.enote,
type: "success"
});
this.$store.commit("setocxstate", 1);
}
});
},
showview() {
let routeData = this.$router.resolve({
name: "show",
query: {
taskid: this.taskid,
subtaskid: this.subtaskid,
playurl: this.playurl
}
});
window.open(routeData.href, "_blank");
},
submit: function(xml, type) {
let postObj = {
subtask_id: this.subtaskid,
mtasks: [
{
mtask_unid: this.taskInfo.mtasks[0].mtask_unid,
// type: 0,
// priority: 0,
scenes: this.taskInfo.mtasks[0].scenes
}
]
};
if (type == "roi") {
postObj.mtasks[0].scenes[this.curindex].rois = [
{
roi: xml
}
];
} else if (type == "config") {
postObj.mtasks[0].scenes[this.curindex].config = {
xml: xml
};
} else if (type == "calibration") {
console.log(xml);
postObj.mtasks[0].scenes[this.curindex].calibration = {
calibration: xml
};
}
this.$api.task
.editRoi(this.taskid, this.subtaskid, postObj, {
headers: {
authorization: localStorage.getItem("atoken")
}
})
.then(m => {
if (m.ecode == "200") {
this.$message({
message: "设置成功!",
type: "success"
});
switch (type) {
case "roi":
this.taskInfo.mtasks[0].scenes[this.curindex].rois = [
{
roi: xml
}
];
break;
case "calibration":
this.taskInfo.mtasks[0].scenes[this.curindex].calibration = {
calibration: xml
};
break;
default:
break;
}
}
});
}
},
watch: {
subtaskid(val) {
this.$api.task.getTaskParams(this.taskid, val).then(res => {
this.taskInfo = res;
this.switchstate = res.alternate_status == 1 ? true : false;
console.log(res.data);
});
}
}
};
</script>
<style lang="stylus" scoped>
.box{
position relative
}
.yzw-setbox{
.icon {
font-size 16px
padding 0 10px
cursor pointer
}
.icon:first-child{
color #6783E3
}
.icon:last-child{
color red
}
}
.setting-box{
width 18%;
float right
}
.table-set span{
padding 0 10px
cursor pointer
color #666666
border-right 1px solid #E5E5E5
}
.table-set span:last-child{
border-right 0
}
.table-set span:hover{
color #3BB7FF
}
.set-header{
height 3vh
line-height 3vh
text-align center
background #ACC1FF
}
.set-item{
height 3vh
line-height 3vh
padding:0 10px
color #555555
margin-top 1vh
cursor pointer
.set-icon{
display inline-block
float right
line-height 3vh
font-size 20px
color #CCCCCC
}
.set-icon:hover{
color #3BB7FF
}
}
.upload-box {
margin-right 20px
}
.yt-box{
}
.settimertype,.sel-box{
display flex
margin-bottom 10px
.title {
line-height 30px;
padding-right 10px
}
}
</style>