Commit a651205d authored by 李维's avatar 李维

修改快速创建热区为追加模式

parent fcf83e4c
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -221,6 +221,15 @@ export class CustomHotZoneComponent implements OnInit, OnDestroy, OnChanges { ...@@ -221,6 +221,15 @@ export class CustomHotZoneComponent implements OnInit, OnDestroy, OnChanges {
} }
addHotZone(itemName) {
// this.imgArr.push({});
// this.hotZoneArr.push({});
const item = this.getHotZoneItem();
item.itemName = itemName;
this.hotZoneArr.push(item);
this.refreshItem(item);
this.refreshHotZoneId();
}
addBtnClick() { addBtnClick() {
// this.imgArr.push({}); // this.imgArr.push({});
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
<h2 >热区位置配置:</h2> <h2 >热区位置配置:</h2>
<app-custom-hot-zone <app-custom-hot-zone
#customHotZone
[bgItem]="item.bgItem" [bgItem]="item.bgItem"
[hotZoneItemArr]="item.hotZoneItemArr" [hotZoneItemArr]="item.hotZoneItemArr"
(save)="saveHotZone(item, $event)" (save)="saveHotZone(item, $event)"
...@@ -43,7 +44,7 @@ ...@@ -43,7 +44,7 @@
<h2 style="margin-top: 10px;">快速创建热区:</h2> <h2 style="margin-top: 10px;">快速创建热区:</h2>
<div style="font-size: 16px; border: 2px solid #ccc; border-radius: 10px; padding: 10px 150px 10px 10px;"> <div style="font-size: 16px; border: 2px solid #ccc; border-radius: 10px; padding: 10px 150px 10px 10px;">
<input type="text" nz-input [(ngModel)]="fastHotZoneStr"/> <input type="text" nz-input [(ngModel)]="fastHotZoneStr"/>
<button nz-button nzType="danger" [disabled]="fastHotZoneStr==''" (click)="handleFastCreatHotZoneItems();" style="position: absolute; right: 30px; margin-right: 10px;"><i nz-icon nzType="import"></i>生成</button> <button nz-button nzType="danger" [disabled]="fastHotZoneStr==''" (click)="handleFastCreatHotZoneItems();" style="position: absolute; right: 30px; margin-right: 10px;"><i nz-icon nzType="import"></i>创建</button>
</div> </div>
<h2 style="margin-top: 10px;">热区内容配置:</h2> <h2 style="margin-top: 10px;">热区内容配置:</h2>
......
...@@ -9,7 +9,9 @@ import { ...@@ -9,7 +9,9 @@ import {
HostListener, HostListener,
ApplicationRef, ApplicationRef,
ChangeDetectorRef, ChangeDetectorRef,
AfterViewInit AfterViewInit,
ViewChild,
ElementRef
} from '@angular/core'; } from '@angular/core';
import { JsonPipe } from '@angular/common'; import { JsonPipe } from '@angular/common';
import { removeItemFromArr } from '../play/Unit'; import { removeItemFromArr } from '../play/Unit';
...@@ -51,7 +53,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy, AfterViewIni ...@@ -51,7 +53,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy, AfterViewIni
CROSSWORD_PUZZLE = "9"; CROSSWORD_PUZZLE = "9";
SORT_WORDS = "10"; SORT_WORDS = "10";
@ViewChild('customHotZone', {static: true}) customHotZone: ElementRef;
constructor(private appRef: ApplicationRef, private changeDetectorRef: ChangeDetectorRef, private nzMessageService: NzMessageService, private modal: NzModalService) { constructor(private appRef: ApplicationRef, private changeDetectorRef: ChangeDetectorRef, private nzMessageService: NzMessageService, private modal: NzModalService) {
...@@ -80,41 +82,34 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy, AfterViewIni ...@@ -80,41 +82,34 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy, AfterViewIni
// 快速创建热区 // 快速创建热区
handleFastCreatHotZoneItems() { handleFastCreatHotZoneItems() {
this.modal.confirm({ this.fastHotZoneStr = this.fastHotZoneStr.replace(/,/g, ",");
nzTitle: '<i>确定要快速创建热区吗?</i>', const hotZoneNames = this.fastHotZoneStr.split(",");
nzContent: '<b>原有热区会被全部覆盖,此操作不可恢复!</b>', hotZoneNames.forEach((hotZoneName, index) => {
nzOnOk: () => { this.customHotZone["addHotZone"](hotZoneName)
this.fastHotZoneStr = this.fastHotZoneStr.replace(/,/g, ","); // newHotZoneItemArr.push({
const hotZoneNames = this.fastHotZoneStr.split(","); // "index": index,
const newHotZoneItemArr = []; // "itemType": "rect",
// "itemName": hotZoneName,
hotZoneNames.forEach((hotZoneName, index) => { // "fontSize": 50,
newHotZoneItemArr.push({ // "fontName": "BRLNSR_1",
"index": index, // "fontColor": "#8f3758",
"itemType": "rect", // "fontScale": 0.734375,
"itemName": hotZoneName, // "imgScale": 1,
"fontSize": 50, // "mapScale": 0.734375,
"fontName": "BRLNSR_1", // "rect": {
"fontColor": "#8f3758", // "x": 0,
"fontScale": 0.734375, // "y": 0,
"imgScale": 1, // "width": 100,
"mapScale": 0.734375, // "height": 100
"rect": { // }
"x": 0, // })
"y": 0, })
"width": 100, // const data = this.item;
"height": 100 // data.hotZoneItemArr = newHotZoneItemArr;
} this.fastHotZoneStr = "";
}) this.nzMessageService.success('创建成功,需要保存热区');
}) // this.item = JSON.parse(JSON.stringify(data));
const data = this.item; // this.save()
data.hotZoneItemArr = newHotZoneItemArr;
this.fastHotZoneStr = "";
this.item = JSON.parse(JSON.stringify(data));
this.save()
}
});
} }
// 添加热区配置 // 添加热区配置
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment