Commit 6b2a6207 authored by 范雪寒's avatar 范雪寒

Merge branch 'master' of http://vcs.ireadabc.com/template/op_09

parents f14ee978 00d881c6
<div class="model-content">
<div style="padding: 10px;">
<div *ngFor="let q of questionArr; let i = index;" style="width: 500px; margin-top: 20px; border: 1px solid #ccc; border-radius: 5px; padding: 15px;">
<div style=" display: flex; align-items: center;">
<h3 style="margin-top: 5px">question-{{i+1}}:</h3>
<app-audio-recorder
style="margin-left: 10px; "
[audioUrl]="q.audio_url"
(audioUploaded)="onAudioUploadSuccess($event, 'audio_url', q)"
></app-audio-recorder>
<button *ngIf="q.option_arr.length < 5" nz-button nzType="primary" (click)="addOptionBtnClick(q)" style="margin-left: 15px;">
+
</button>
<button nz-button nzType="danger" (click)="deleteQuestionBtnClick(i)" style="margin-left: 5px;">
x
</button>
</div>
<div *ngFor="let o of q.option_arr; let oi = index" style="margin-top: 5px; display: flex;">
<div style="width: 200px;">
<app-upload-image-with-preview
[picUrl]="o.pic_url"
(imageUploaded)="onImageUploadSuccess($event, 'pic_url', o)">
</app-upload-image-with-preview>
</div>
<div style="margin-left: 10px">
<h4>option-{{oi+1}} : </h4>
<app-audio-recorder
[audioUrl]="o.audio_url"
(audioUploaded)="onAudioUploadSuccess($event, 'audio_url', o)"
></app-audio-recorder>
<div style="display: flex; align-items: center; margin-top: 10px;">
<nz-switch [(ngModel)]="o.is_right" (ngModelChange)="save()"></nz-switch>
<button nz-button nzType="danger" (click)="deleteOptionBtnClick(q.option_arr, oi)" style="margin-left: 5px;">
delete
</button>
</div>
</div>
</div>
</div>
<button nz-button nzType="dashed" (click)="addQuestionBtnClick()" style="height: 70px; margin-top: 20px;">
<i nz-icon nzType="plus-circle" nzTheme="outline"></i>
Add Question
</button>
<div style="width: 300px;" align='center'>
<!-- <div style="width: 300px;" align='center'>
<span>图1: </span>
<app-upload-image-with-preview
[picUrl]="item.pic_url"
......@@ -29,7 +81,7 @@
[audioUrl]="item.audio_url"
(audioUploaded)="onAudioUploadSuccess($event, 'audio_url')"
></app-audio-recorder>
</div>
</div> -->
</div>
......
......@@ -14,23 +14,10 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
// 储存对象
item;
constructor(private appRef: ApplicationRef, private changeDetectorRef: ChangeDetectorRef) {
}
questionArr = [];
createShell() {
this.item.wordList.push({
word: '',
audio: '',
backWord: '',
backWordAudio: '',
});
this.save();
}
constructor(private appRef: ApplicationRef, private changeDetectorRef: ChangeDetectorRef) {
removeShell(idx) {
this.item.wordList.splice(idx, 1);
this.save();
}
ngOnInit() {
......@@ -44,6 +31,8 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
this.item = data;
}
console.log('data: ', data);
this.init();
this.changeDetectorRef.markForCheck();
this.changeDetectorRef.detectChanges();
......@@ -59,17 +48,48 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
}
init() {
if (!this.item.question_arr) {
this.item.question_arr = [];
}
this.questionArr = this.item.question_arr;
}
addQuestionBtnClick() {
this.questionArr.push({
question_audio_url: '',
option_arr: [ //选项 (多选)
]
})
this.save();
}
addOptionBtnClick(question) {
question.option_arr.push({
pic_url: '', // 图片路径
audio_url: '', //音频路径
is_right: false, //是否正确
})
this.save();
}
deleteQuestionBtnClick(index) {
this.questionArr.splice(index, 1);
this.save();
}
deleteOptionBtnClick(option, index) {
option.splice( index, 1)
this.save();
}
/**
* 储存图片数据
* @param e
*/
onImageUploadSuccess(e, key) {
onImageUploadSuccess(e, key, item) {
this.item[key] = e.url;
item[key] = e.url;
this.save();
}
......@@ -77,8 +97,8 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
* 储存音频数据
* @param e
*/
onAudioUploadSuccess(e, key) {
this.item[key] = e.url;
onAudioUploadSuccess(e, key, item) {
item[key] = e.url;
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