Commit c50b5fbe authored by yu's avatar yu

删除提示

parent 1160f5fa
...@@ -230,4 +230,17 @@ ...@@ -230,4 +230,17 @@
<div style="color: #f00;font-size: 12px;">为保证游戏效果,每题最多配置5对选项</div> <div style="color: #f00;font-size: 12px;">为保证游戏效果,每题最多配置5对选项</div>
</button> </button>
</div> </div>
<nz-modal [(nzVisible)]="isVisible" [nzTitle]="null" [nzContent]="modalContent" [nzFooter]="modalFooter"
(nzOnCancel)="handleCancel()">
<ng-template #modalContent>
<p>{{deleteTitle}}</p>
</ng-template>
<ng-template #modalFooter>
<button nz-button nzType="default" (click)="handleCancel()">取消</button>
<button nz-button nzType="primary" (click)="handleOk()">确定</button>
</ng-template>
</nz-modal>
</div> </div>
\ No newline at end of file
...@@ -28,8 +28,10 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -28,8 +28,10 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
} }
removeQuestion(idx) { removeQuestion(idx) {
this.openDelete("确定删除题目?", () => {
this.item.questions.splice(idx, 1); this.item.questions.splice(idx, 1);
this.save(); this.save();
})
} }
addOption(i) { addOption(i) {
...@@ -52,12 +54,14 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -52,12 +54,14 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
} }
removeOption(i, j) { removeOption(i, j) {
this.openDelete("确定删除题目?", () => {
const pairIdx = this.item.questions[i].options[j].pairIdx; const pairIdx = this.item.questions[i].options[j].pairIdx;
this.item.questions[i].options = this.item.questions[i].options.filter((option) => option.pairIdx != pairIdx); this.item.questions[i].options = this.item.questions[i].options.filter((option) => option.pairIdx != pairIdx);
this.item.questions[i].options.forEach((option, idx) => { this.item.questions[i].options.forEach((option, idx) => {
option.pairIdx = Math.floor(idx / 2); option.pairIdx = Math.floor(idx / 2);
}); });
this.save(); this.save();
})
} }
copyOption(i, j) { copyOption(i, j) {
if (this.item.questions[i].options.length >= 10) { if (this.item.questions[i].options.length >= 10) {
...@@ -116,6 +120,21 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -116,6 +120,21 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
} }
isVisible = false;
deleteTitle = "是否删除题目";
deleteCallback = function () { };
openDelete(title, callback) {
this.deleteCallback = callback;
this.deleteTitle = title;
this.isVisible = true;
}
handleCancel() {
this.isVisible = false;
}
handleOk() {
this.deleteCallback && this.deleteCallback();
this.handleCancel();
}
/** /**
* 储存图片数据 * 储存图片数据
......
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