Commit c50b5fbe authored by yu's avatar yu

删除提示

parent 1160f5fa
......@@ -188,7 +188,7 @@
</div>
<br>
<span style="font-size: 20px;">选项音频:</span>
<div style="display: flex">
<div>
<app-audio-recorder [audioUrl]="question.options[j+1].audio"
......@@ -230,4 +230,17 @@
<div style="color: #f00;font-size: 12px;">为保证游戏效果,每题最多配置5对选项</div>
</button>
</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>
\ No newline at end of file
......@@ -28,8 +28,10 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
}
removeQuestion(idx) {
this.item.questions.splice(idx, 1);
this.save();
this.openDelete("确定删除题目?", () => {
this.item.questions.splice(idx, 1);
this.save();
})
}
addOption(i) {
......@@ -52,12 +54,14 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
}
removeOption(i, j) {
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.forEach((option, idx) => {
option.pairIdx = Math.floor(idx / 2);
});
this.save();
this.openDelete("确定删除题目?", () => {
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.forEach((option, idx) => {
option.pairIdx = Math.floor(idx / 2);
});
this.save();
})
}
copyOption(i, j) {
if (this.item.questions[i].options.length >= 10) {
......@@ -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