告警图片展示

hn2.0
fanluyan 2 years ago
parent d1ef83de14
commit 3b50cf87c0

@ -271,18 +271,19 @@
icon="el-icon-picture-outline" icon="el-icon-picture-outline"
@click.stop="handlePicHistory(item)" @click.stop="handlePicHistory(item)"
></el-button> ></el-button>
<!-- <el-button
type="primary"
:loading="btnpicloading"
@click.stop="handlePicList(item)"
>主动拍照</el-button
>
<el-button type="primary" @click.stop="handlePicHistory(item)"
>历史图片</el-button
> -->
</div> </div>
<div class="picshow" @click="handlePicAlarm(item, index)"> <div class="picshow" @click="handlePicAlarm(item)">
<img :src="item.path + '!1366x768'" ref="picJpg" /> <img
:id="'img' + index"
:ref="'imgref' + index"
:src="item.path + '!1366x768'"
ref="picJpg"
/>
<canvas
:ref="'canvansref' + index"
:id="'canvas_' + index"
class="canvasAll"
></canvas>
</div> </div>
<div class="caption"> <div class="caption">
<p class="infoTop"> <p class="infoTop">
@ -337,8 +338,14 @@
:style="{ transform: 'scale(' + zoomD + ')' }" :style="{ transform: 'scale(' + zoomD + ')' }"
@mousedown="move" @mousedown="move"
> >
<img @load="imgOnload" class="maskPic img" :src="bigPhotoPic" ref="" /> <img
<canvas id="myCanvas" class="myCanvas" ref="myCanvasbig"></canvas> @load="imgOnload"
id="bigimg"
ref="bigimgref"
class="maskPic img"
:src="bigPhotoPic"
/>
<canvas id="bigCanvas" class="myCanvas" ref="myCanvasbig"></canvas>
</div> </div>
<div class="viewClose" @click="closePic"> <div class="viewClose" @click="closePic">
<i class="el-icon-close"></i> <i class="el-icon-close"></i>
@ -510,12 +517,13 @@ export default {
this.canvasloading = true; this.canvasloading = true;
this.canvansdata = val; this.canvansdata = val;
if (val.path !== "" && this.tableData.length !== 0) { if (val.path !== "" && this.tableData.length !== 0) {
console.log(val);
this.bigPhotoPic = val.path; this.bigPhotoPic = val.path;
this.showBigpic = true; this.showBigpic = true;
setTimeout(() => {
this.$nextTick(() => { this.$nextTick(() => {
this.drawline2(val); this.drawline2(val);
}); });
}, 100);
} }
}, },
closePic() { closePic() {
@ -586,8 +594,17 @@ export default {
this.photoPic = res.data.list[0].path; this.photoPic = res.data.list[0].path;
this.selectRow = res.data.list[0]; this.selectRow = res.data.list[0];
console.log(this.selectRow); console.log(this.selectRow);
if (this.tableShow) {
this.$nextTick(() => {
this.$refs.multipleTable.setCurrentRow(this.selectRow); this.$refs.multipleTable.setCurrentRow(this.selectRow);
this.handleRowClick(this.selectRow); this.handleRowClick(this.selectRow);
});
} else {
this.$nextTick(() => {
this.drawlineListAll(this.tableData);
});
}
}) })
.catch((err) => { .catch((err) => {
console.log(err); console.log(err);
@ -662,9 +679,12 @@ export default {
// //
drawline2(data) { drawline2(data) {
console.log(data); console.log(data);
console.log(document.getElementById("bigCanvas"));
console.log(document.getElementById("bigimg"));
this.canvas = document.getElementById("bigCanvas");
this.imgpic = document.getElementById("bigimg");
console.log(this.canvas); console.log(this.canvas);
this.canvas = this.$refs.myCanvasbig; console.log(this.imgpic);
this.imgpic = this.$refs.picJpg;
this.textInfo = data.enname; this.textInfo = data.enname;
this.canvas.width = this.imgpic.offsetWidth; // this.canvas.width = this.imgpic.offsetWidth; //
this.canvas.height = this.imgpic.offsetHeight; // this.canvas.height = this.imgpic.offsetHeight; //
@ -688,7 +708,7 @@ export default {
// this.ctx.strokeStyle = "red"; //线 // this.ctx.strokeStyle = "red"; //线
this.ctx.strokeRect(top, left, width, height); // this.ctx.strokeRect(top, left, width, height); //
//this.ctx.strokeRect(data.x, data.y, data.width, data.height); //this.ctx.strokeRect(data.x, data.y, data.width, data.height);
this.ctx.font = "12px normal"; this.ctx.font = "14px normal";
this.ctx.fillStyle = "#ff0000"; this.ctx.fillStyle = "#ff0000";
//this.ctx.fillText(this.textInfo, top, left + 24); //this.ctx.fillText(this.textInfo, top, left + 24);
// //
@ -700,14 +720,15 @@ export default {
this.ctx.closePath(); this.ctx.closePath();
this.ctx.stroke(); this.ctx.stroke();
}, },
// //
drawlineListAll(val) { drawlineListAll(val) {
for (let i = 0; i < val.length; i++) { for (let i = 0; i < val.length; i++) {
console.log(i); console.log(i);
console.log(this.$refs.myCanvas); console.log(document.getElementById("canvas_" + i));
console.log(this.$refs.picJpg); console.log(document.getElementById("img" + i));
this.canvas = this.$refs.myCanvas; this.canvas = document.getElementById("canvas_" + i);
this.imgpic = this.$refs.picJpg; this.imgpic = document.getElementById("img" + i);
this.textInfo = val[i].enname; this.textInfo = val[i].enname;
console.log(this.textInfo); console.log(this.textInfo);
console.log(this.imgpic.offsetWidth); console.log(this.imgpic.offsetWidth);
@ -747,49 +768,7 @@ export default {
this.ctx.stroke(); this.ctx.stroke();
} }
}, },
//
drawlineList(data, index) {
console.log(data);
console.log(this.$refs.myCanvasbig);
console.log(this.$refs.picJpg);
console.log("picJpg" + index);
this.canvas = this.$refs.myCanvasbig;
this.imgpic = this.$refs.picJpg;
this.textInfo = data.enname;
this.canvas.width = this.imgpic[index].offsetWidth; //
this.canvas.height = this.imgpic[index].offsetHeight; //
console.log(this.canvas.width, this.canvas.height);
this.ctx = this.canvas.getContext("2d");
this.ctx.beginPath();
//线
this.ctx.strokeStyle = "#ff0000";
// 线
this.ctx.lineWidth = 1;
//
var scaleX = this.canvas.width / data.photoWidth, //this.iw
scaleY = this.canvas.height / data.photoHeight; //this.ih
console.log(scaleX, scaleY);
var top = data.x * scaleX,
left = data.y * scaleY,
width = data.width * scaleX,
height = data.height * scaleY;
console.log(top, left, width, height);
// this.ctx.strokeStyle = "red"; //线
this.ctx.strokeRect(top, left, width, height); //
//this.ctx.strokeRect(data.x, data.y, data.width, data.height);
this.ctx.font = "12px normal";
this.ctx.fillStyle = "#ff0000";
//this.ctx.fillText(this.textInfo, top, left + 24);
//
if (left > 32) {
this.ctx.fillText(this.textInfo, top, left - 4);
} else if (this.canvas.height - left + height > 32) {
this.ctx.fillText(this.textInfo, top, height - 4);
}
this.ctx.closePath();
this.ctx.stroke();
},
// //
handleRowClick(row) { handleRowClick(row) {
//this.$refs.multipleTable.toggleRowSelection(row); //this.$refs.multipleTable.toggleRowSelection(row);
@ -814,7 +793,6 @@ export default {
}); });
}, 300); }, 300);
} }
this.$nextTick(() => { this.$nextTick(() => {
this.drawline(row); this.drawline(row);
this.imgOnload(); this.imgOnload();
@ -957,7 +935,14 @@ export default {
this.tableShow = !this.tableShow; this.tableShow = !this.tableShow;
this.zoomD = 1; this.zoomD = 1;
if (!this.tableShow) { if (!this.tableShow) {
this.$nextTick(() => {
this.drawlineListAll(this.tableData); this.drawlineListAll(this.tableData);
});
} else {
this.$nextTick(() => {
this.$refs.multipleTable.setCurrentRow(this.selectRow);
this.handleRowClick(this.selectRow);
});
} }
}, },
@ -975,16 +960,18 @@ export default {
handlePicAlarm(val, index) { handlePicAlarm(val, index) {
console.log(val, index); console.log(val, index);
this.current = index; this.current = index;
this.canvansdata = val;
this.canvasloading = true; this.canvasloading = true;
this.canvansdata = val;
if (val.path !== "" && this.tableData.length !== 0) { if (val.path !== "" && this.tableData.length !== 0) {
console.log(val); console.log(val);
this.bigPhotoPic = val.path; this.bigPhotoPic = val.path;
this.showBigpic = true; this.showBigpic = true;
setTimeout(() => {
this.$nextTick(() => { this.$nextTick(() => {
console.log("huatu"); this.drawline2(val);
this.drawlineList(val, index);
}); });
}, 100);
// //
if (val.isread == 0) { if (val.isread == 0) {
setTimeout(function () { setTimeout(function () {
@ -1235,7 +1222,7 @@ export default {
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
.myCanvas { .canvasAll {
position: absolute; position: absolute;
width: 100%; width: 100%;
height: 100%; height: 100%;

Loading…
Cancel
Save