jc
fanluyan 1 year ago
parent d0e2c84d62
commit a4a7fdaaaa

@ -159,6 +159,10 @@ export default {
index: "/waterMark",
title: "水印下发",
},
{
index: "/aiWork",
title: "AI绘图",
},
],
},
],

@ -209,7 +209,17 @@ const routes = [
requiresAuth: true,
},
},
{
path: "/aiwork",
component: () => import("../views/system/drawPic.vue"),
name: "aiwork",
meta: {
title: "ai绘图",
icon: "",
keepAlive: true,
requiresAuth: true,
},
},
{
path: "/echarts",
component: () => import("../echartsDemo.vue"),

@ -0,0 +1,17 @@
import request from "../request";
//获取图片
export function getTestTerminalPhotoListApi(data) {
return request({
url: "/xymanager/getTestTerminalPhotoList",
method: "post",
data,
});
}
//上传坐标
export function takeAlarmApi(data) {
return request({
url: "/xymanager/takeAlarm",
method: "post",
data,
});
}

@ -31,12 +31,16 @@
@load="loadImage"
@error="setDefaultImage"
ref="picJpg"
id="alarmPic"
width="100%"
height="100%"
>
<template slot="error">
<img src="../../../assets/img/nodatapic2.jpg" />
</template>
</el-image>
<canvas id="myCanvas" class="myCanvas" ref="myCanvas"></canvas>
<canvas id="alarmCanvas" class="alarmCanvas" ref="alarmCanvas"></canvas>
<!-- <img :src="currentPicPath + '!1366x768'" @load="loadImage" /> -->
</div>
<div class="bigPic" v-else-if="currentPicPath && mediaType == 1">
@ -209,6 +213,26 @@ export default {
color: "", //线
borderwidth: "", //线
markEnable: "", //
recArrs: [],
picDataAlarm: [],
labelMarkArrs: [
{
centerX: 0.5709497206703911,
centerY: 0.3220675944333996,
width: 0.18324022346368715,
height: 0.1908548707753479,
type: 1,
name: "塔吊",
},
{
centerX: 0.3,
centerY: 0.3856858846918489,
width: 0.17318435754189945,
height: 0.2584493041749503,
type: 0,
name: "挖掘机",
},
],
};
},
mounted() {
@ -248,31 +272,7 @@ export default {
// Blob URL
window.URL.revokeObjectURL(url);
},
// downLoadPic(url, name) {
// const image = new Image();
// image.setAttribute("crossOrigin", "anonymous");
// image.src = url;
// image.onload = () => {
// const canvas = document.createElement("canvas");
// canvas.width = image.width;
// canvas.height = image.height;
// const ctx = canvas.getContext("2d");
// ctx.drawImage(image, 0, 0, image.width, image.height);
// canvas.toBlob((blob) => {
// const url = URL.createObjectURL(blob);
// this.download(url, name);
// // URL
// URL.revokeObjectURL(url);
// });
// };
// },
// download(href, name) {
// const eleLink = document.createElement("a");
// eleLink.download = name;
// eleLink.href = href;
// eleLink.click();
// eleLink.remove();
// },
//线
getPointList(data) {
console.log("woshi 线缆绘制", data);
@ -380,6 +380,7 @@ export default {
//
changeBigPic(data, i) {
// //console.log("222222222", this.currentPage, this.activeSmall);
this.picDataAlarm = data;
this.srcList = [];
this.localPoints = [];
this.activeSmall = i;
@ -413,6 +414,7 @@ export default {
loadImage() {
console.log("loading");
this.picLoading = false;
this.drawlineBig(this.picDataAlarm);
},
setDefaultImage(e) {
e.target.src = defaultImage;
@ -437,6 +439,110 @@ export default {
smallRightClick() {
this.$refs.scrollBox.scrollLeft += this.$refs.scrollBox.offsetWidth;
},
//
//
drawlineBig(data) {
console.log(data);
this.canvas = document.getElementById("alarmCanvas");
this.imgpic = document.getElementById("alarmPic");
console.log(document.getElementById("alarmCanvas"));
console.log(document.getElementById("alarmPic"));
console.log(this.canvas);
console.log(this.imgpic);
this.textInfo = data.enname;
this.canvas.width = this.imgpic.offsetWidth; //
this.canvas.height = this.imgpic.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;
this.labelMarkArrs = data.alarmlist;
this.recArrs = [];
for (var i = 0; i < this.labelMarkArrs.length; i++) {
console.log(this.labelMarkArrs[i]);
//
this.recArrs.push({
x:
this.labelMarkArrs[i].x * this.canvas.width -
(this.labelMarkArrs[i].width * this.canvas.width) / 2,
y:
this.labelMarkArrs[i].y * this.canvas.height -
(this.labelMarkArrs[i].height * this.canvas.height) / 2,
w: this.labelMarkArrs[i].width * this.canvas.width,
h: this.labelMarkArrs[i].height * this.canvas.height,
text: this.labelMarkArrs[i].enname + this.labelMarkArrs[i].prob + "%",
type: this.labelMarkArrs[i].label,
});
}
console.log(this.recArrs);
if (!this.recArrs.length) return;
for (var i = 0; i < this.recArrs.length; i++) {
// >2
if (this.recArrs[i].w > 2 && this.recArrs[i].h > 2) {
this.ctx.beginPath();
this.ctx.lineWidth = 2; // 线
this.ctx.strokeStyle = "rgb(255, 0, 0)"; // 线
//
this.ctx.fillStyle = "rgba(22, 158, 140, 0.4)"; //
this.ctx.strokeRect(
this.recArrs[i].x,
this.recArrs[i].y,
this.recArrs[i].w,
this.recArrs[i].h
); //
// this.ctx.fillRect(
// this.recArrs[i].x,
// this.recArrs[i].y,
// this.recArrs[i].w,
// this.recArrs[i].h
// ); //
//
if (this.recArrs[i].text) {
this.ctx.font = "100 18px 微软雅黑";
this.ctx.lineWidth = 1;
this.ctx.strokeStyle = "rgb(255,0,0)";
this.ctx.strokeText(
this.recArrs[i].text,
this.recArrs[i].x +
this.recArrs[i].w / 2 -
(this.recArrs[i].text.length / 2) * 16,
this.recArrs[i].y - 20 < 0
? this.recArrs[i].y + this.recArrs[i].h + 20
: this.recArrs[i].y - 10
);
}
}
}
// //
// 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 = "14px 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();
},
},
};
</script>
@ -481,6 +587,16 @@ export default {
z-index: 3;
pointer-events: none;
}
#alarmCanvas {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
margin: 0 auto;
cursor: pointer;
pointer-events: none;
}
&:hover {
.arrow {
opacity: 1;

@ -0,0 +1,844 @@
<template>
<div class="drawPicBox">
<div class="piclist">
<ul>
<li
v-for="item in piclist"
@click="handleClickPic(item)"
:class="{ selected: item === selectedItem }"
>
{{ getFileName(item.path) }}
</li>
</ul>
</div>
<div class="picright">
<div class="pointBox">
<h3>
标注数据
<el-button type="primary" @click="savePointer"></el-button>
{{ piclist.length }}
</h3>
<div class="picRow">
<p
v-for="(item, index) in recArrs"
:key="index"
:class="index == selectIndex ? 'bgClass' : ''"
>
<span
>{{ item.text }}{{ index }}
<el-select
size="mini"
v-model="item.type"
placeholder="请选择标注名称"
>
<el-option
v-for="(label, value, index) in markOptions"
:key="value"
:label="label"
:value="index"
>
</el-option>
</el-select>
</span>
</p>
<!-- <span>图片的宽{{ imgWidth }}px</span>
<span>图片的高{{ imgHeight }}px</span>
<span>{{ (item.w / imgWidth).toFixed(2) }}</span>
<span>{{ (item.h / imgHeight).toFixed(2) }}</span>
<span>X{{ ((item.x + item.w) / 2 / imgWidth).toFixed(2) }}</span>
<span>Y{{ ((item.y + item.h) / 2 / imgHeight).toFixed(2) }}</span> -->
</div>
</div>
<div class="picCanvans">
<div class="wrap">
<img
@load="onImageLoad"
:src="alarmPicJpg"
alt=""
class="img"
ref="imgDiv"
/>
<canvas
class="canvas_dom"
id="canvasDom"
:width="imgWidth"
:height="imgHeight"
@mousemove="moveFunction"
@mousedown="downFunction"
@mouseup="upFunction"
@mouseout="outFunction"
@contextmenu="contextMenuFunction"
>
</canvas>
</div>
</div>
</div>
</div>
</template>
<script>
import EventBus from "@/utils/event-bus";
import { getTestTerminalPhotoListApi, takeAlarmApi } from "@/utils/api/drawApi";
export default {
components: {},
data() {
return {
alarmPicJpg: "",
markOptions: {}, //
currentNodeData: "",
parentdata: "",
imgWidth: 0,
imgHeight: 0,
typeMap: {
0: "吊车",
1: "塔吊",
2: "水泥泵车",
3: "挖掘机",
4: "推土机",
5: "翻斗车",
6: "山火",
7: "烟雾",
8: "导线异物体",
9: "导线义务防尘网",
},
//
recArrs: [],
curObj: {
isRightClick: false, //
radious: 4, //
recSize: 5, //
index: -1, // index
side: 0, //
resize: false, //
draw: false, //
drag: false, //
x: 0, // x
y: 0, // y
startX: 0, // x
startY: 0, // y
centerX: 0, //x
centerY: 0, //y
},
//
labelMarkArrs: [],
hostName: "",
selectIndex: -1,
piclist: [],
photoId: "",
selectedItem: null, //
};
},
created() {
EventBus.$on("labelMark", (value) => {
this.selectIndex = -1;
//console.log(value); // value
this.labelMarkArrs = value;
console.log(this.labelMarkArrs);
this.clearCanvas();
this.recArrs = [];
for (var i = 0; i < this.labelMarkArrs.length; i++) {
console.log(this.labelMarkArrs[i]);
//
this.recArrs.push({
x:
this.labelMarkArrs[i].centerX * this.imgWidth -
(this.labelMarkArrs[i].width * this.imgWidth) / 2,
y:
this.labelMarkArrs[i].centerY * this.imgHeight -
(this.labelMarkArrs[i].height * this.imgHeight) / 2,
w: this.labelMarkArrs[i].width * this.imgWidth,
h: this.labelMarkArrs[i].height * this.imgHeight,
text: this.typeMap[this.labelMarkArrs[i].type],
type: this.labelMarkArrs[i].type,
});
}
console.log("aaaaaaaaaaaaaaaaa");
console.log(this.recArrs);
this.drawOldRect();
});
},
mounted() {
this.getPicList();
this.getTypes();
},
beforeDestroy() {
window.removeEventListener("resize", this.updateImageSize);
},
computed: {},
methods: {
getFileName(path) {
// 使lastIndexOfsubstring
const lastIndex = path.lastIndexOf("/");
if (lastIndex !== -1) {
return path.substring(lastIndex + 1);
}
return ""; // '/'
},
getPicList() {
getTestTerminalPhotoListApi()
.then((res) => {
console.log(res);
this.piclist = res.data.list;
this.alarmPicJpg = res.data.list[0].path;
this.photoId = res.data.list[0].id;
this.selectedItem = res.data.list[0]; //
})
.catch((err) => {});
},
handleClickPic(row) {
console.log(row);
this.selectedItem = row; //
this.alarmPicJpg = row.path;
this.photoId = row.id;
},
getTypes() {
this.markOptions = this.typeMap;
},
//
onImageLoad() {
this.updateImageSize();
},
updateImageSize() {
const img = this.$refs.imgDiv;
this.imgWidth = img.offsetWidth;
this.imgHeight = img.offsetHeight;
console.log(this.imgWidth, this.imgHeight);
this.clearCanvas();
this.recArrs = [];
for (var i = 0; i < this.labelMarkArrs.length; i++) {
console.log(this.labelMarkArrs[i]);
//
this.recArrs.push({
x:
this.labelMarkArrs[i].centerX * this.imgWidth -
(this.labelMarkArrs[i].width * this.imgWidth) / 2,
y:
this.labelMarkArrs[i].centerY * this.imgHeight -
(this.labelMarkArrs[i].height * this.imgHeight) / 2,
w: this.labelMarkArrs[i].width * this.imgWidth,
h: this.labelMarkArrs[i].height * this.imgHeight,
text: this.typeMap[this.labelMarkArrs[i].type],
type: this.labelMarkArrs[i].type,
});
}
console.log("aaaaaaaaaaaaaaaaa");
console.log(this.recArrs);
this.drawOldRect();
},
//
contextMenuFunction(e) {
e.preventDefault();
return false;
},
//
moveFunction(e) {
// console.log('', e);
// 线
this.clearCanvas();
// 线
this.drawRuler(e);
// // 线
this.drawOldRect();
//
this.drawRect(e);
// //
this.moveOrScale(e);
},
// /
moveOrScale(e) {
let index = this.getEventIndex(e.offsetX, e.offsetY);
let side = 0;
if (index > -1) {
side = this.getEventArea(index, e.offsetX, e.offsetY);
//
if (side > 0) {
this.drawLitRecs(index);
}
}
//
this.changeResizeCursor(side);
//
this.moveRec(e);
//
this.reSizeRec(e);
},
//
moveRec(e) {
let canvasDom = document.getElementById("canvasDom");
let ctx2d = canvasDom.getContext("2d");
if (this.curObj.drag && this.recArrs[this.curObj.index]) {
let x = this.curObj.startX + e.offsetX - this.curObj.x;
let y = this.curObj.startY + e.offsetY - this.curObj.y;
let minX = canvasDom.offsetLeft;
let maxX =
canvasDom.offsetLeft +
canvasDom.offsetWidth -
this.recArrs[this.curObj.index].w;
let minY = canvasDom.offsetTop;
let maxY =
canvasDom.offsetTop +
canvasDom.offsetHeight -
this.recArrs[this.curObj.index].h;
if (x < minX) {
x = minX;
}
if (x > maxX) {
x = maxX;
}
if (y < minY) {
y = minY;
}
if (y > maxY) {
y = maxY;
}
this.recArrs[this.curObj.index].x = x;
this.recArrs[this.curObj.index].y = y;
}
},
//
reSizeRec(e) {
const { side, index, recSize } = this.curObj;
const rec = this.recArrs[index];
if (this.curObj.resize && rec) {
const temX = rec.x;
const temY = rec.y;
const ex = e.offsetX;
const ey = e.offsetY;
if (side < 4 && temX + rec.w - ex > recSize) {
rec.x = ex;
}
if (
(side == 1 || side == 4 || side == 7) &&
temY + rec.h - ey > recSize
) {
rec.y = ey;
}
if (side < 4) {
if (temX + rec.w - ex > recSize) {
rec.w = temX + rec.w - ex;
}
} else if (side < 7) {
if (ex - temX > recSize) {
rec.w = ex - temX;
}
}
if (side == 1 || side == 4 || side == 7) {
if (temY + rec.h - ey > recSize) {
rec.h = temY + rec.h - ey;
}
} else if (side == 3 || side == 6 || side == 8) {
if (ey - temY > recSize) {
rec.h = ey - temY;
}
}
}
},
//
outFunction(e) {
let canvasDom = document.getElementById("canvasDom");
let x = e.clientX;
let y = e.clientY;
let left = canvasDom.offsetLeft;
let top = canvasDom.offsetTop;
let width = canvasDom.offsetWidth;
let height = canvasDom.offsetHeight;
let limitX = left + width;
let limitY = top + height;
if (x < left || x > limitX || y < top || y > limitY) {
console.log("鼠标移出范围, 清除canvas重新绘制");
this.clearCanvas();
this.drawOldRect();
}
},
// 线
drawRuler(e) {
let canvasDom = document.getElementById("canvasDom");
let ctx2d = canvasDom.getContext("2d");
const canvasHeight = canvasDom.offsetWidth;
const canvasWidth = canvasDom.offsetWidth;
//console.log(canvasDom);
//
ctx2d.beginPath();
//
ctx2d.strokeStyle = "red";
//
ctx2d.lineWidth = 1;
// x y 0线
ctx2d.moveTo(e.offsetX, 0);
// lineTo() 线
ctx2d.lineTo(e.offsetX, canvasHeight);
// (x: 0, y)线
ctx2d.moveTo(0, e.offsetY);
// lineTo() 线
ctx2d.lineTo(canvasWidth, e.offsetY);
ctx2d.stroke();
},
// canvas
clearCanvas() {
let canvasDom = document.getElementById("canvasDom");
let ctx2d = canvasDom.getContext("2d");
const canvasHeight = canvasDom.width;
const canvasWidth = canvasDom.height;
ctx2d.clearRect(0, 0, canvasHeight, canvasWidth);
},
//
drawRect(e) {
let canvasDom = document.getElementById("canvasDom");
let ctx2d = canvasDom.getContext("2d");
if (this.curObj.draw) {
ctx2d.strokeRect(
this.curObj.x,
this.curObj.y,
e.offsetX - this.curObj.x,
e.offsetY - this.curObj.y
);
}
},
//
drawOldRect() {
let canvasDom = document.getElementById("canvasDom");
let ctx2d = canvasDom.getContext("2d");
const canvasHeight = canvasDom.width;
const canvasWidth = canvasDom.height;
if (!this.recArrs.length) return;
for (var i = 0; i < this.recArrs.length; i++) {
// >2
if (this.recArrs[i].w > 2 && this.recArrs[i].h > 2) {
ctx2d.beginPath();
ctx2d.lineWidth = 2; // 线
ctx2d.strokeStyle = "rgb(255, 0, 0)"; // 线
//
ctx2d.fillStyle = "rgba(22, 158, 140, 0.4)"; //
ctx2d.strokeRect(
this.recArrs[i].x,
this.recArrs[i].y,
this.recArrs[i].w,
this.recArrs[i].h
); //
ctx2d.fillRect(
this.recArrs[i].x,
this.recArrs[i].y,
this.recArrs[i].w,
this.recArrs[i].h
); //
//
if (this.recArrs[i].text) {
ctx2d.font = "100 18px 微软雅黑";
ctx2d.lineWidth = 1;
ctx2d.strokeStyle = "rgb(255,0,0)";
ctx2d.strokeText(
this.recArrs[i].text,
this.recArrs[i].x +
this.recArrs[i].w / 2 -
(this.recArrs[i].text.length / 2) * 16,
this.recArrs[i].y - 20 < 0
? this.recArrs[i].y + this.recArrs[i].h + 20
: this.recArrs[i].y - 10
);
}
}
}
},
writeMarkHandle() {
this.dialogFormVisible = false;
this.drawRect();
},
//
downFunction(e) {
console.log("鼠标按下", e); // e.button 0 1 2
this.curObj.isRightClick = e.button > 1;
console.log("是否右键", this.curObj.isRightClick);
// x,y
this.curObj.x = e.offsetX;
this.curObj.y = e.offsetY;
//
//
this.curObj.index = this.getEventIndex(this.curObj.x, this.curObj.y);
console.log("落点矩形", this.curObj.index);
console.log("我是上面的数组", this.recArrs);
console.log(
"我是上面的数组点击的哪一个",
this.recArrs[this.curObj.index]
);
this.selectIndex = this.curObj.index;
// TODO...
if (this.curObj.isRightClick) {
} else {
//
//
if (this.curObj.index === -1) {
this.curObj.draw = true;
} else {
//
//
this.curObj.startX = this.recArrs[this.curObj.index].x;
this.curObj.startY = this.recArrs[this.curObj.index].y;
//
this.curObj.side = this.getEventArea(
this.curObj.index,
this.curObj.x,
this.curObj.y
);
console.log("this.curObj.side", this.curObj.side);
if (this.curObj.side < 9) {
//
console.log("在缩放");
this.curObj.resize = true;
} else {
//
console.log("在拖动");
this.curObj.drag = true;
}
//
this.drawLitRecs(this.curObj.index);
}
}
//
this.changeResizeCursor(this.curObj.side);
},
//,data9
drawLitRecs(index) {
let canvasDom = document.getElementById("canvasDom");
let ctx2d = canvasDom.getContext("2d");
const data = this.prepareLitRecs(index);
const { recSize } = this.curObj;
for (var i = 0; i < data.length; i++) {
ctx2d.strokeRect(
data[i][0] - recSize / 2,
data[i][1] - recSize / 2,
recSize,
recSize
);
}
},
//8332
prepareLitRecs(index) {
const data = this.recArrs[index];
var li = [];
li[0] = [data.x, data.y];
li[1] = [data.x, data.y + data.h / 2];
li[2] = [data.x, data.y + data.h];
li[3] = [data.x + data.w, data.y];
li[4] = [data.x + data.w, data.y + data.h / 2];
li[5] = [data.x + data.w, data.y + data.h];
li[6] = [data.x + data.w / 2, data.y];
li[7] = [data.x + data.w / 2, data.y + data.h];
return li;
},
//
changeResizeCursor(side) {
let canvasDom = document.getElementById("canvasDom");
switch (side) {
case 0:
canvasDom.style.cursor = "crosshair";
break;
case 1:
canvasDom.style.cursor = "se-resize";
break;
case 2:
canvasDom.style.cursor = "e-resize";
break;
case 3:
canvasDom.style.cursor = "ne-resize";
break;
case 4:
canvasDom.style.cursor = "sw-resize";
break;
case 5:
canvasDom.style.cursor = "w-resize";
break;
case 6:
canvasDom.style.cursor = "nw-resize";
break;
case 7:
canvasDom.style.cursor = "s-resize";
break;
case 8:
canvasDom.style.cursor = "n-resize";
break;
case 9:
canvasDom.style.cursor = "move";
break;
default:
canvasDom.style.cursor = "default";
}
},
//
getEventArea(index, x, y) {
const data = this.recArrs[index];
// console.log("this.recArrs", this.recArrs);
// console.log("data", data);
if (
x > data.x - this.curObj.radious &&
x < data.x + this.curObj.radious
) {
if (
y > data.y - this.curObj.radious &&
y < data.y + this.curObj.radious
) {
return 1;
} else if (
y > data.y + this.curObj.radious &&
y < data.y + data.h - this.curObj.radious
) {
return 2;
} else if (
y > data.y + data.h - this.curObj.radious &&
y < data.y + data.h + this.curObj.radious
) {
return 3;
}
} else if (
x > data.x + data.w - this.curObj.radious &&
x < data.x + data.w + this.curObj.radious
) {
if (
y > data.y - this.curObj.radious &&
y < data.y + this.curObj.radious
) {
return 4;
} else if (
y > data.y + this.curObj.radious &&
y < data.y + data.h - this.curObj.radious
) {
return 5;
} else if (
y > data.y + data.h - this.curObj.radious &&
y < data.y + data.h + this.curObj.radious
) {
return 6;
}
} else {
if (
y > data.y - this.curObj.radious &&
y < data.y + this.curObj.radious &&
x > data.x + this.curObj.radious &&
x < data.x + data.w - this.curObj.radious
) {
return 7;
} else if (
y > data.y + data.h - this.curObj.radious &&
y < data.y + data.h + this.curObj.radious &&
x > data.x + this.curObj.radious &&
x < data.x + data.w - this.curObj.radious
) {
return 8;
} else {
return 9;
}
}
},
// index, -1
getEventIndex(x, y) {
if (!this.recArrs.length) return -1;
for (var i = 0; i < this.recArrs.length; i++) {
const limitX = x > this.recArrs[i].x - this.curObj.radious;
const limitW =
x < this.recArrs[i].x + this.recArrs[i].w + this.curObj.radious;
const limitY = y > this.recArrs[i].y - this.curObj.radious;
const limitH =
y < this.recArrs[i].y + this.recArrs[i].h + this.curObj.radious;
// index
if (limitX && limitY && limitW && limitH) {
return i;
}
// -1
if (i == this.recArrs.length - 1) {
return -1;
}
}
},
//
upFunction(e) {
console.log("鼠标抬起", e);
if (this.curObj.isRightClick) {
if (this.curObj.index !== -1) {
//
this.recArrs.splice(this.curObj.index, 1);
this.clearCanvas();
this.drawOldRect();
}
this.curObj.isRightClick = false;
return;
}
this.curObj.resize = false;
this.curObj.drag = false;
//
if (this.curObj.draw) {
this.addToRecs(e);
this.curObj.draw = false;
}
console.log("鼠标抬起-当前矩形框", this.recArrs);
},
//
addToRecs(e) {
let rec = {
x: this.curObj.x > e.offsetX ? e.offsetX : this.curObj.x, // x
y: this.curObj.y > e.offsetY ? e.offsetY : this.curObj.y, // y
w: Math.abs(e.offsetX - this.curObj.x), //
h: Math.abs(e.offsetY - this.curObj.y), //
text: "矩形框" + this.recArrs.length, //
type: 0, //
// ...
};
//
if (rec.w > 2 && rec.h > 2) {
this.recArrs.push(rec);
console.log("recArrs", this.recArrs);
}
},
//
savePointer() {
let params = {
alarmlist: [],
photoid: this.photoId,
};
for (var i = 0; i < this.recArrs.length; i++) {
params.alarmlist.push({
x: (this.recArrs[i].x + this.recArrs[i].w / 2) / this.imgWidth,
y: (this.recArrs[i].y + this.recArrs[i].h / 2) / this.imgHeight,
width: this.recArrs[i].w / this.imgWidth,
height: this.recArrs[i].h / this.imgHeight,
label: this.recArrs[i].type,
enname: this.typeMap[this.recArrs[i].type],
});
}
console.log(params);
takeAlarmApi(params)
.then((res) => {
console.log(res);
if (res.code == 200) {
this.getPicList();
this.$message({
showClose: true,
duration: 1500,
message: res.data,
type: "success",
});
} else {
this.$message({
showClose: true,
duration: 1500,
message: "保存失败",
type: "error",
});
}
})
.catch((err) => {});
},
},
};
</script>
<style lang="less">
.drawPicBox {
width: 100%;
height: 100%;
position: relative;
display: flex;
.piclist {
width: 400px;
li {
line-height: 32px;
height: 32px;
cursor: pointer;
}
.selected {
/* 在这里添加你的选中样式 */
background-color: yellow; /* 例如,给选中的项添加黄色背景 */
}
}
.picright {
flex: 1;
.pointBox {
//background: #fcc;
right: 14px;
border-radius: 4px;
//border: 1px solid #dcdfe6;
z-index: 22;
margin-bottom: 12px;
h3 {
margin-bottom: 12px;
font-size: 14px;
line-height: 24px;
align-items: center;
display: flex;
.el-button--danger {
padding: 4px 8px;
margin-left: 14px;
}
}
.picRow {
display: flex;
align-items: center;
//height: 32px;
flex-wrap: wrap;
.bgClass {
background-color: aqua;
}
p {
line-height: 32px;
// height: 32px;
margin-bottom: 8px;
font-size: 14px;
margin-right: 12px;
span {
margin-right: 8px;
}
}
.el-select {
width: 140px;
.el-input--suffix .el-input__inner {
padding-right: 12px;
}
}
}
}
.picCanvans {
width: 100%;
height: calc(100% - 87px);
overflow: auto;
h3 {
margin-bottom: 12px;
font-size: 14px;
}
.wrap {
width: 100%;
height: 100%;
position: relative;
//border: 1px solid #dcdfe6;
// background: rgba(0, 0, 0, 0.3);
img {
position: absolute;
max-width: 100%;
max-height: calc(100% - 10px);
cursor: move;
-moz-user-select: none; /*火狐*/
-webkit-user-select: none; /*webkit浏览器*/
-ms-user-select: none; /*IE10*/
-khtml-user-select: none; /*早期浏览器*/
user-select: none;
}
.canvas_dom {
position: absolute;
}
}
}
}
}
</style>

@ -22,12 +22,12 @@ module.exports = defineConfig({
"/api": {
//表示拦截以/api开头的请求路径
//target: "http://180.166.218.222:40080", //dell
target: "http://192.168.1.190:8080", //liu 本机ip 需要去掉/Api
// target: "http://192.168.1.190:8080", //liu 本机ip 需要去掉/Api
//target: "http://192.168.50.7:8093", //liu 本机ip 需要去掉/Api
//target: "http://192.168.111.211:80", //东视
target: "http://192.168.111.211:80", //东视
changOrigin: true, //是否开启跨域
pathRewrite: {
"^/api": "", //重写api把api变成空字符因为我们真正请求的路径是没有api的
"^/api": "/api", //重写api把api变成空字符因为我们真正请求的路径是没有api的
},
},
},

Loading…
Cancel
Save