From a93b9df3b29179ff14e480a154362891994cb0b4 Mon Sep 17 00:00:00 2001 From: cpf <1105965053@qq.com> Date: Thu, 28 Apr 2022 16:32:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BF=9D=E5=AD=98=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../image-label2/image-label2.component.ts | 32 +++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/src/app/system-management/image-label2/image-label2.component.ts b/src/app/system-management/image-label2/image-label2.component.ts index 0825d47..a2633dc 100644 --- a/src/app/system-management/image-label2/image-label2.component.ts +++ b/src/app/system-management/image-label2/image-label2.component.ts @@ -44,8 +44,9 @@ export class ImageLabel2Component implements OnInit { return new Promise((resolve, reject) => { that.route.queryParams.subscribe(parmas => { that.http.get(`/api/Cameras/${parmas.id}`).subscribe((info: any)=>{ - that.camerasData = info - that.markType = info.type + info.dimensionedPoints? info.dimensionedPoints = JSON.parse(info.dimensionedPoints) : null; + that.camerasData = info; + that.markType = info.type; const httpOptions = { responseType: 'blob' as 'json', params: {cameraId: parmas.id} @@ -65,14 +66,26 @@ export class ImageLabel2Component implements OnInit { //保存 save() { + if (!this.camerasData.dimensionedPoints) { + this.camerasData.dimensionedPoints = { + polygon: null, + arrow : null, + rectangle: null, + } + } if (this.markType === 0) { - console.log("多边形",this.points) + this.camerasData.dimensionedPoints.polygon = this.points } else if (this.markType === 2) { - console.log("箭头",this.arrowPoints) - console.log("矩形",this.oblongPoints) + this.camerasData.dimensionedPoints.arrow = this.arrowPoints + this.camerasData.dimensionedPoints.rectangle = this.oblongPoints } else if (this.markType === 3) { - console.log("箭头",this.arrowPoints) + this.camerasData.dimensionedPoints.arrow = this.arrowPoints } + let paramsData = JSON.parse(JSON.stringify(this.camerasData)) + paramsData.dimensionedPoints = JSON.stringify(paramsData.dimensionedPoints) + this.http.put(`/api/Cameras/${this.camerasData.id}`,paramsData).subscribe(data=>{ + this.message.create('success', '保存成功!'); + }) } //初始化背景图 @@ -173,6 +186,9 @@ export class ImageLabel2Component implements OnInit { var moveX = ev.pageX - canvas.offsetLeft; var moveY = ev.pageY - canvas.offsetTop; if (this.isDrawArrow) { //绘制 箭头 + if (this.arrowPoints.length === 2) { //限制数量 + return + } context.lineTo(moveX,moveY); context.stroke(); } else { //绘制 矩形 @@ -195,6 +211,10 @@ export class ImageLabel2Component implements OnInit { var upX = e.pageX - canvas.offsetLeft; var upY = e.pageY - canvas.offsetTop; if (this.isDrawArrow) { //绘制 箭头 + if (this.arrowPoints.length === 2) { //限制数量 + this.message.create('warning', '绘制数量已达上限!'); + return + } let point = { startX: this.downx, startY: this.downy,