Commit a9a08389 authored by Li MingZhe's avatar Li MingZhe

feat: 首次提交

parent a70e61d2
This diff is collapsed.
...@@ -55,4 +55,4 @@ ...@@ -55,4 +55,4 @@
"tslint": "~5.18.0", "tslint": "~5.18.0",
"typescript": "~3.7.5" "typescript": "~3.7.5"
} }
} }
\ No newline at end of file
...@@ -35,7 +35,8 @@ ...@@ -35,7 +35,8 @@
<ng-template #truthyTemplate > <ng-template #truthyTemplate >
<div class="btn-delete" (click)="onBtnDeleteAudio()"> <div class="btn-delete" (click)="onBtnDeleteAudio()">
<fa-icon icon="close"></fa-icon> <!-- <fa-icon icon="close"></fa-icon> -->
<i nz-icon nzType="close" nzTheme="outline"></i>
</div> </div>
</ng-template> </ng-template>
......
...@@ -26,7 +26,7 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy { ...@@ -26,7 +26,7 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
uploadData; uploadData;
@Input() @Input()
needRemove = false; needRemove = true;
@Input() @Input()
audioItem: any = null; audioItem: any = null;
...@@ -62,8 +62,25 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy { ...@@ -62,8 +62,25 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
this.uploadUrl = url; this.uploadUrl = url;
this.uploadData = data; this.uploadData = data;
}; };
this.setUploadUrl();
} }
setUploadUrl() {
if (!this.uploadUrl) {
this.uploadUrl = (<any> window).courseware.uploadUrl();
this.uploadData = (<any> window).courseware.uploadData();
setTimeout(() => {
this.setUploadUrl();
}, 500);
}
}
init() { init() {
this.playIcon = 'play'; this.playIcon = 'play';
this.isPlaying = false; this.isPlaying = false;
...@@ -157,6 +174,7 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy { ...@@ -157,6 +174,7 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
onBtnDeleteAudio() { onBtnDeleteAudio() {
this.audioUrl = null; this.audioUrl = null;
this.audioUploaded.emit({});
this.audioRemoved.emit(); this.audioRemoved.emit();
} }
......
<div class="model-content"> <div class="model-content">
<div style="padding: 10px;"> <div style="padding: 10px; width: 800px;">
<div style="width: 300px;" align='center'> <div *ngFor="let it of item.groupArr; let i = index" style="border: 1px solid #ccc; border-radius: 10px; margin-top: 50px; display: flex; align-items: center; flex-direction: column;">
<div style="display: flex; align-items: center; justify-content: center; padding: 10px;">
<div style="font-weight: 700; font-size: 22px; margin-right: 10px;">题-{{i+1}}</div>
<button nz-button nzType="danger" (click)="onBtnDeleteGroup(i)">
<!-- <i nz-icon nzType="close" nzTheme="outline"></i> -->
删除题
</button>
</div>
<div style="display: flex; align-items: center; justify-content: center; width: 700px;">
<h4 style="width: 80px; text-align: right;">题干:</h4>
<app-audio-recorder
style="margin: 10px"
[audioUrl]="it.audio_url"
(audioUploaded)="onAudioUploadSuccess($event, 'audio_url', it)"
></app-audio-recorder>
<!-- <input type="text" nz-input [(ngModel)]="it.ques" style="width: 80%" (blur)="save()"> -->
</div>
<div style="display: flex; justify-content: center; width: 100%;">
<app-upload-image-with-preview
style="width: 50%"
[picUrl]="it.pic_url"
(imageUploaded)="onImageUploadSuccess($event, 'pic_url', it)">
</app-upload-image-with-preview>
</div>
<div style="display: flex; align-items: center; justify-content: center; margin-top: 20px; font-size: 15px; font-weight: 500;">
<span style="margin-right: 5px">句子: </span>
<div *ngFor="let op of it.optionArr">
{{op.text}} &nbsp;
</div>
<!-- <input style="width: 220px; margin-left: 10px;" type="text" nz-input [(ngModel)]="it.word" (blur)="save()"> -->
</div>
<app-audio-recorder
style="margin-left: 5px;"
[audioUrl]="it.word_audio_url"
(audioUploaded)="onAudioUploadSuccess($event, 'word_audio_url', it)"
></app-audio-recorder>
<nz-divider></nz-divider>
<div style="width: 100%; margin-top: 10px" >
<button nz-button nzType="dashed" (click)="addOptionBtnClick(it)" style="margin-top: 10px; margin-left: 30px;">
<i nz-icon nzType="plus-circle" nzTheme="outline"></i>
添加句子单词
</button>
<div style="display: flex; align-items: center; justify-content: center; flex-wrap: wrap; margin: 10px; margin-bottom: 20px;">
<div *ngFor="let op of it.optionArr; let j = index" style="margin: 5px; border: 1px solid #ccc; border-radius: 5px; padding: 5px; display: flex; align-items: center; flex-direction: column;" >
<div style="display: flex; align-items: center;">
<input style="width: 70px;" type="text" nz-input [(ngModel)]="op.text" (blur)="save()">
<label nz-checkbox [(ngModel)]="op.isEmpty" (ngModelChange)="save()" style="margin-left: 5px;">挖空</label>
<button nz-button nzType="danger" (click)="onBtnDeleteOption(j, it.optionArr)">
X
</button>
</div>
<div style="margin-top: 5px">
<app-audio-recorder
[audioUrl]="op.audio_url"
(audioUploaded)="onAudioUploadSuccess($event, 'audio_url', op)"
></app-audio-recorder>
</div>
</div>
</div>
<button nz-button nzType="dashed" (click)="addWrongBtnClick(it)" style="margin-top: 10px; margin-left: 30px;">
<i nz-icon nzType="plus-circle" nzTheme="outline"></i>
添加干扰单词
</button>
<div style="display: flex; align-items: center; justify-content: center; flex-wrap: wrap; margin: 10px; margin-bottom: 20px;">
<div *ngFor="let op of it.wrongArr; let j = index" style="margin: 5px; border: 1px solid #ccc; border-radius: 5px; padding: 2px;">
<div style="display: flex; align-items: center;">
<input style="width: 80px; margin-right: 5px;" type="text" nz-input [(ngModel)]="op.text" (blur)="save()">
<div style="margin-right: 5px;">
<app-audio-recorder
[audioUrl]="op.audio_url"
(audioUploaded)="onAudioUploadSuccess($event, 'audio_url', op)"
></app-audio-recorder>
</div>
<button nz-button nzType="danger" (click)="onBtnDeleteOption(j, it.wrongArr)">
X
</button>
</div>
</div>
</div>
</div>
</div>
<button nz-button nzType="dashed" (click)="addGroupBtnClick()" style="width: 150px; height: 55px; margin: 50px;">
<i nz-icon nzType="plus-circle" nzTheme="outline"></i>
添加题
</button>
<!-- <div style="width: 300px;" align='center'>
<span>图1: </span> <span>图1: </span>
<app-upload-image-with-preview <app-upload-image-with-preview
[picUrl]="item.pic_url" [picUrl]="item.pic_url"
...@@ -29,7 +150,7 @@ ...@@ -29,7 +150,7 @@
[audioUrl]="item.audio_url" [audioUrl]="item.audio_url"
(audioUploaded)="onAudioUploadSuccess($event, 'audio_url')" (audioUploaded)="onAudioUploadSuccess($event, 'audio_url')"
></app-audio-recorder> ></app-audio-recorder>
</div> </div> -->
</div> </div>
......
...@@ -10,7 +10,7 @@ import { JsonPipe } from '@angular/common'; ...@@ -10,7 +10,7 @@ import { JsonPipe } from '@angular/common';
export class FormComponent implements OnInit, OnChanges, OnDestroy { export class FormComponent implements OnInit, OnChanges, OnDestroy {
// 储存数据用 // 储存数据用
saveKey = "test_001"; saveKey = "dfzx_cocos_pinjuzi";
// 储存对象 // 储存对象
item; item;
...@@ -60,6 +60,36 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -60,6 +60,36 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
init() { init() {
console.log('this.item: ', this.item);
if (!this.item.groupArr) {
this.item.groupArr = [];
}
}
addGroupBtnClick() {
this.item.groupArr.push({
ques: '',
optionArr: [],
wrongArr: [],
})
this.save();
}
onBtnDeleteGroup(i) {
this.item.groupArr.splice(i, 1);
this.save();
}
addOptionBtnClick(group) {
group.optionArr.push({})
this.save();
}
addWrongBtnClick(group) {
group.wrongArr.push({})
this.save();
} }
...@@ -67,9 +97,9 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -67,9 +97,9 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
* 储存图片数据 * 储存图片数据
* @param e * @param e
*/ */
onImageUploadSuccess(e, key) { onImageUploadSuccess(e, key, it) {
this.item[key] = e.url; it[key] = e.url;
this.save(); this.save();
} }
...@@ -77,18 +107,8 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -77,18 +107,8 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
* 储存音频数据 * 储存音频数据
* @param e * @param e
*/ */
onAudioUploadSuccess(e, key) { onAudioUploadSuccess(e, key, it) {
this.item[key] = e.url; it[key] = e.url;
this.save();
}
onWordAudioUploadSuccess(e, idx) {
this.item.wordList[idx].audio = e.url;
this.save();
}
onBackWordAudioUploadSuccess(e, idx) {
this.item.wordList[idx].backWordAudio = e.url;
this.save(); this.save();
} }
...@@ -102,6 +122,17 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -102,6 +122,17 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
console.log('this.item = ' + JSON.stringify(this.item)); console.log('this.item = ' + JSON.stringify(this.item));
} }
radioChange(e, option, key) {
option[key] = e;
this.save();
}
onBtnDeleteOption(i, arr) {
arr.splice(i, 1);
this.save();
}
/** /**
* 刷新 渲染页面 * 刷新 渲染页面
*/ */
......
This diff is collapsed.
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