Commit 46f36230 authored by Chen Jiping's avatar Chen Jiping

feat:调整表单数据结构

parent a449c751
...@@ -12,21 +12,17 @@ export class Obj { ...@@ -12,21 +12,17 @@ export class Obj {
} }
export class Exercises extends Obj { export class Exercises {
recordingTime: number;
}
text;
export class TitleInfo extends Obj { audio;
/** duration: number;
* 标题描述
*/
desc: string;
} }
export function getDefExercises(){ export function getDefExercises(){
let exercises = new Exercises(); let exercises = new Exercises();
...@@ -34,20 +30,3 @@ export function getDefExercises(){ ...@@ -34,20 +30,3 @@ export function getDefExercises(){
return exercises; return exercises;
} }
export function getDefTitle(){
let title = new TitleInfo();
title.val = "故事留声机";
title.desc = "欢乐的故事时间到了,亲爱的小玩家,请点击故事台词,仔细听,然后大声的模仿,全部完成后,根据模仿情况,你将获得相应的能量石奖励!快去试试吧!";
title.audioUrl="http://staging-teach.cdn.ireadabc.com/b9ad9112eb80f325eddd6c1583ba97fd.mp3";
return title;
}
export function getDefStory(){
let story = new Obj();
return story;
}
\ No newline at end of file
...@@ -6,20 +6,20 @@ ...@@ -6,20 +6,20 @@
<nz-form-item> <nz-form-item>
<nz-form-label [nzSpan]="4">标题</nz-form-label> <nz-form-label [nzSpan]="4">标题</nz-form-label>
<nz-form-control [nzSpan]="12"> <nz-form-control [nzSpan]="12">
<input nz-input type="text" [(ngModel)]="item.title.val" (blur)="save()"> <input nz-input type="text" [(ngModel)]="item.title" (blur)="save()">
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>
<nz-form-item> <nz-form-item>
<nz-form-label [nzSpan]="4">题目说明</nz-form-label> <nz-form-label [nzSpan]="4">题目说明</nz-form-label>
<nz-form-control [nzSpan]="12"> <nz-form-control [nzSpan]="12">
<textarea nz-input rows="4" [(ngModel)]="item.title.desc" (blur)="save()"></textarea> <textarea nz-input rows="4" [(ngModel)]="item.questionText" (blur)="save()"></textarea>
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>
<nz-form-item> <nz-form-item>
<nz-form-label [nzSpan]="4">题目音频</nz-form-label> <nz-form-label [nzSpan]="4">题目音频</nz-form-label>
<nz-form-control [nzSpan]="12"> <nz-form-control [nzSpan]="12">
<app-audio-recorder [audioUrl]="item.title.audioUrl" <app-audio-recorder [audioUrl]="item.questionTextAudio"
(audioUploaded)="onAudioUploadSuccess($event, item.title, 'audioUrl')"> (audioUploaded)="onAudioUploadSuccess($event, item, 'questionTextAudio')">
</app-audio-recorder> </app-audio-recorder>
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>
...@@ -34,16 +34,16 @@ ...@@ -34,16 +34,16 @@
<nz-form-item> <nz-form-item>
<nz-form-label [nzSpan]="4">完整音频</nz-form-label> <nz-form-label [nzSpan]="4">完整音频</nz-form-label>
<nz-form-control [nzSpan]="12"> <nz-form-control [nzSpan]="12">
<app-audio-recorder [audioUrl]="item.story.audioUrl" <app-audio-recorder [audioUrl]="item.pageAudio"
(audioUploaded)="onAudioUploadSuccess($event, item.story, 'audioUrl')"> (audioUploaded)="onAudioUploadSuccess($event, item, 'pageAudio')">
</app-audio-recorder> </app-audio-recorder>
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>
<nz-form-item> <nz-form-item>
<nz-form-label [nzSpan]="4">故事图片</nz-form-label> <nz-form-label [nzSpan]="4">故事图片</nz-form-label>
<nz-form-control [nzSpan]="6"> <nz-form-control [nzSpan]="6">
<app-upload-image-with-preview style="width: 100%" [picUrl]="item.story.picUrl" <app-upload-image-with-preview style="width: 100%" [picUrl]="item.pageImage"
(imageUploaded)="onImageUploadSuccess($event, item.story, 'picUrl')"> (imageUploaded)="onImageUploadSuccess($event, item, 'pageImage')">
</app-upload-image-with-preview> </app-upload-image-with-preview>
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>
...@@ -56,14 +56,14 @@ ...@@ -56,14 +56,14 @@
<div nz-row> <div nz-row>
<div nz-col [nzSpan]="18" [nzOffset]="1"> <div nz-col [nzSpan]="18" [nzOffset]="1">
<h4 nz-typography>文本内容:</h4> <h4 nz-typography>文本内容:</h4>
<div *ngFor="let data of item.exercisesArr; let i=index" style="margin-bottom: 5mm;" nz-col [nzXs]='24' <div *ngFor="let data of item.sentences; let i=index" style="margin-bottom: 5mm;" nz-col [nzXs]='24'
[nzSm]='24' [nzMd]='24' [nzLg]='24'> [nzSm]='24' [nzMd]='24' [nzLg]='24'>
<nz-card nzTitle="文本{{i+1}}" [nzHoverable]="true" [nzExtra]="actionCard"> <nz-card nzTitle="文本{{i+1}}" [nzHoverable]="true" [nzExtra]="actionCard">
<nz-form-item> <nz-form-item>
<nz-form-label [nzSpan]="4">音频</nz-form-label> <nz-form-label [nzSpan]="4">音频</nz-form-label>
<nz-form-control [nzSpan]="14"> <nz-form-control [nzSpan]="14">
<app-audio-recorder [audioUrl]="data.audioUrl" <app-audio-recorder [audioUrl]="data.audio"
(audioUploaded)="onAudioUploadSuccess($event, data, 'audioUrl')"> (audioUploaded)="onAudioUploadSuccess($event, data, 'audio')">
</app-audio-recorder> </app-audio-recorder>
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>
...@@ -72,13 +72,13 @@ ...@@ -72,13 +72,13 @@
<font style="color: red;">*</font>文本 <font style="color: red;">*</font>文本
</nz-form-label> </nz-form-label>
<nz-form-control [nzSpan]="14"> <nz-form-control [nzSpan]="14">
<textarea nz-input rows="4" [(ngModel)]="data.val" (blur)="save()" placeholder="输入文本内容"></textarea> <textarea nz-input rows="4" [(ngModel)]="data.text" (blur)="save()" placeholder="输入文本内容"></textarea>
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>
<nz-form-item> <nz-form-item>
<nz-form-label [nzSpan]="4">录音时间(s)</nz-form-label> <nz-form-label [nzSpan]="4">录音时间(s)</nz-form-label>
<nz-form-control [nzSpan]="14"> <nz-form-control [nzSpan]="14">
<input nz-input type="text" [(ngModel)]="data.recordingTime" (blur)="save()" placeholder="录音超过时间自动提交成绩"> <input nz-input type="text" [(ngModel)]="data.duration" (blur)="save()" placeholder="录音超过时间自动提交成绩">
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>
</nz-card> </nz-card>
......
import { Component, EventEmitter, Input, OnDestroy, OnChanges, OnInit, Output, ApplicationRef, ChangeDetectorRef } from '@angular/core'; import { Component, EventEmitter, Input, OnDestroy, OnChanges, OnInit, Output, ApplicationRef, ChangeDetectorRef } from '@angular/core';
import { JsonPipe } from '@angular/common'; import { JsonPipe } from '@angular/common';
import { getDefExercises, getDefStory, getDefTitle } from '../bean/beans'; import { getDefExercises } from '../bean/beans';
@Component({ @Component({
...@@ -48,12 +48,17 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -48,12 +48,17 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
init() { init() {
if (!this.item.title) { if (!this.item.title) {
this.item.title = getDefTitle(); this.item.title = "故事留声机";
this.save(); this.save();
} }
if (!this.item.story) { if (!this.item.questionText) {
this.item.story = getDefStory(); this.item.questionText = "欢乐的故事时间到了,亲爱的小玩家,请点击故事台词,仔细听,然后大声的模仿,全部完成后,根据模仿情况,你将获得相应的能量石奖励!快去试试吧!";
this.save();
}
if (!this.item.questionTextAudio) {
this.item.questionTextAudio = "http://staging-teach.cdn.ireadabc.com/b9ad9112eb80f325eddd6c1583ba97fd.mp3";
this.save(); this.save();
} }
...@@ -105,9 +110,9 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -105,9 +110,9 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
delCard(item, index) { delCard(item, index) {
if (confirm("确认删除吗?")) { if (confirm("确认删除吗?")) {
if (index !== -1) { if (index !== -1) {
item.exercisesArr.splice(index, 1); item.sentences.splice(index, 1);
item.exercisesArr = [...item.exercisesArr]; item.sentences = [...item.sentences];
this.save(); this.save();
} }
} }
...@@ -116,9 +121,9 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -116,9 +121,9 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
copyCard(item, index) { copyCard(item, index) {
let word = JSON.parse(JSON.stringify(item.exercisesArr[index])); let word = JSON.parse(JSON.stringify(item.sentences[index]));
this.item.exercisesArr.push(word); this.item.sentences.push(word);
this.save(); this.save();
} }
...@@ -126,7 +131,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -126,7 +131,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
addCard() { addCard() {
let word = getDefExercises(); let word = getDefExercises();
this.item.exercisesArr.push(word); this.item.sentences.push(word);
this.save(); 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