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 f932570..12ee35c 100644 --- a/src/app/system-management/image-label2/image-label2.component.ts +++ b/src/app/system-management/image-label2/image-label2.component.ts @@ -75,11 +75,23 @@ export class ImageLabel2Component implements OnInit { } } if (this.markType === 0) { + if (!this.points.length) { + this.message.create('warning', '绘制完整后可保存!'); + return + } this.camerasData.dimensionedPoints.polygon = this.points } else if (this.markType === 2) { + if (this.arrowPoints.length != 2 || this.oblongPoints.length != 2 || !this.oblongPoints.find(item=>{ return item.oilUnloadingArea }) || !this.oblongPoints.find(item=>{ return !item.oilUnloadingArea })) { + this.message.create('warning', '绘制完整后可保存!'); + return + } this.camerasData.dimensionedPoints.arrow = this.arrowPoints this.camerasData.dimensionedPoints.rectangle = this.oblongPoints } else if (this.markType === 3) { + if (this.arrowPoints.length != 2) { + this.message.create('warning', '绘制完整后可保存!'); + return + } this.camerasData.dimensionedPoints.arrow = this.arrowPoints } let paramsData = JSON.parse(JSON.stringify(this.camerasData)) @@ -213,6 +225,9 @@ export class ImageLabel2Component implements OnInit { context.lineTo(moveX,moveY); context.stroke(); } else { //绘制 矩形 + if (this.oblongPoints.length === 2) { //限制数量 + return + } this.drawOblong(this.oblongPoints,context) context.strokeStyle = this.oilUnloadingArea? "green" : "red"; let element = this.getOblongInfo(this.downx,this.downy,moveX,moveY) @@ -245,6 +260,10 @@ export class ImageLabel2Component implements OnInit { this.arrowPoints.push(point); this.drawLine(this.arrowPoints,context) } else { //绘制 矩形 + if (this.oblongPoints.length === 2) { //限制数量 + this.message.create('warning', '绘制数量已达上限!'); + return + } let point = this.getOblongInfo(this.downx,this.downy,upX,upY) this.oblongPoints.push(point) this.drawOblong(this.oblongPoints,context)