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,