Commit 3ff7819d by 416409548@qq.com

ie下修改门禁设备坐标无法修改问题优化

parent 13e6fbbb
...@@ -94,7 +94,7 @@ ...@@ -94,7 +94,7 @@
<a-col :span="24"> <a-col :span="24">
<div style="position: relative"> <div style="position: relative">
<img src="@/assets/floor.png" alt="floor" width="100%" height="100%" <img src="@/assets/floor.png" alt="floor" width="100%" height="100%"
@click="imgClick($event)" @load="floorImgLoadComplete($event)"/> @click="imgClick($event)" ref="imgBg" @load="floorImgLoadComplete($event)"/>
<img :src="doorIconPath" alt="door" <img :src="doorIconPath" alt="door"
:style="doorIconStyle" :style="doorIconStyle"
v-show="doorIconPath"/> v-show="doorIconPath"/>
...@@ -321,19 +321,24 @@ export default { ...@@ -321,19 +321,24 @@ export default {
}, },
imgClick(e) { imgClick(e) {
// 获取点击目标的x,y坐标 // 获取点击目标的x,y坐标
let target = e.target; // let target = e.target;
let fixX = target.x; var event = e || window.event;
let fixY = target.y; var target = event.target || event.srcElement;
console.log(target.pageX);
let fixX = this.$refs.imgBg.getBoundingClientRect().left;
let fixY = this.$refs.imgBg.getBoundingClientRect().top;
// let fixX = target.x;
// let fixY = target.y;
console.log(fixX, fixY); console.log(fixX, fixY);
console.log(e.x, e.y); // console.log(e.x, e.y);
let offsetWidth = target.offsetWidth; let offsetWidth = target.offsetWidth;
let offsetHeight = target.offsetHeight; let offsetHeight = target.offsetHeight;
let offsetX = (e.x - fixX); let offsetX = (event.x - fixX);
let offsetY = (e.y - fixY); let offsetY = (event.y - fixY);
this.doorIconStyle.top = offsetY - 20 + 'px'; this.doorIconStyle.top = offsetY - 20 + 'px';
this.doorIconStyle.left = offsetX - 20 + 'px'; this.doorIconStyle.left = offsetX - 20 + 'px';
let x = ((e.x - fixX) / offsetWidth).toFixed(4); let x = ((event.x - fixX) / offsetWidth).toFixed(4);
let y = ((e.y - fixY) / offsetHeight).toFixed(4); let y = ((event.y - fixY) / offsetHeight).toFixed(4);
this.model.coordinateTmp = x + "," + y; this.model.coordinateTmp = x + "," + y;
this.$refs.form.validateField('coordinateTmp'); this.$refs.form.validateField('coordinateTmp');
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment