bindDev.vue
4.42 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
<template>
<el-dialog :title="$t('button.positionCalibration')" width="80%" class="manage-dialog" v-if="bindVisible" :visible.sync="bindVisible" :close-on-click-modal="false" @close="closeBindDialog">
<div class="draw_desks">
<div class="gateWrap" id="gateManageChannel">
<img :src="floorImg" class="fimg" @load="loadGateData">
<div class="grender" ref="gRender"></div>
</div>
</div>
<div slot="footer" class="dialog-footer">
<el-button type="primary" class="dialog-btn dialog-confirm-btn" @click="bindVisible = false">
{{$t('button.closed')}}
</el-button>
</div>
</el-dialog>
</template>
<script>
import drawUtils from './drawUtils';
import _ from 'underscore';
export default {
extends:drawUtils,
data() {
return {
bindVisible: false,
floorImg: '',
width:0,
height:0,
groupList:[],
// zr:'',
areaId:'',
areaObj:{}
}
},
methods: {
dialogInit(row) {
this.areaObj = {...row}
this.areaId = row.id
this.floorImg = window._vionConfig.picUrl+row.pic
this.bindVisible = true;
},
loadGateData() {
let {width,height} = document.getElementById('gateManageChannel').getBoundingClientRect();
this.width = width;
this.height = height;
this.groupList = [];
this.zr = zrender.init(this.$refs.gRender, {
renderer: 'canvas',
devicePixelRatio: 2,
width: width,
height: height
});
window.zr = this.zr;
this.$api.queueManagementApi.getDevices({
areaId: this.areaId
}).then(res=>{
let data = res.data.data
data.forEach(item=>{
item.name = this.areaObj.name;
// item.id = this.areaObj.id;
item.id = item.serialnum;
item.picUrl = window._vionConfig.picUrl + "/snapshot/real/" + item.serialnum + "-01.jpg?t=" + Date.parse(new Date()) / 1000;
item.coordinate&&(item.coordinate=JSON.parse(item.coordinate))
})
this.gateList =data;
this.drawJoinMap()
});
},
drawJoinMap(){
let that = this;
console.log(this.gateList)
_.each(this.gateList,(item,index)=>{
if(item.picUrl){
let img = new Image();
img.src = item.picUrl;
img.onload = function(){
item.width = this.width;
item.height = this.height;
that.createGroup(item,index+1);
}
}
})
},
createGroup(data,index){
let left = 0;
let top = 0;
let that = this;
let group = new zrender.Group({
z:1,
draggable:true,
gateId:data.id,
gateName:data.name,
picUrl:data.picUrl,
position:[left,top]
}).on('mouseup', function (evt) {
that.saveGateData(data.id);
})
this.groupList.push(group);
this.zr.add(group);
window.group = group;
this.drawPolyImage(data,group);
},
closeBindDialog() {
this.bindVisible = false
},
}
}
</script>
<style lang="less" scoped="scoped">
.draw_desks {
position: relative;
width: 100%;
height: 700px;
}
.gateWrap{
position: relative;
width: 100%;
box-shadow: 0px 3px 12px 0px rgba(196, 200, 207, 0.8);
}
.gateWrap .fimg{
display: block;
width: 100%;
}
.gateWrap .grender{
position: absolute;
left: 0;
top: 0;
width:100%;
height: 100%;
opacity: 0.7;
}
</style>