Commit ba4a6665 authored by 杨一航's avatar 杨一航

表单调整

parent fd9d8cc4
...@@ -20,10 +20,10 @@ ...@@ -20,10 +20,10 @@
border-style: dashed; border-style: dashed;
padding: 20px; padding: 20px;
margin: 20px; margin: 20px;
/*width: 500px; */ width: 500px;
/*//border-radius: 20px;*/ border-radius: 20px;
/*//border-width: 2px;*/ border-width: 2px;
/*//border-color: #000000;*/ border-color: #000000;
} }
...@@ -32,31 +32,4 @@ ...@@ -32,31 +32,4 @@
border-radius: 0.5rem; border-radius: 0.5rem;
padding: 10px; padding: 10px;
margin: 10px; margin: 10px;
}
.button-right {
border-style: dotted;
border-color: rgb(42, 142, 72);
width: 100px;
height: 50px;
color: rgb(42, 142, 72);
background-color: white;
}
.button-wrong {
border-style: dotted;
border-color: rgb(180, 0, 0);
width: 100px;
height: 50px;
color: rgb(180, 0, 0);
background-color: white;
}
.button-disable {
border-style: dotted;
border-color: black;
width: 100px;
height: 50px;
color: black;
background-color: white;
} }
\ No newline at end of file
<div class="model-content"> <div class="model-content">
<div style="padding: 10px;"> <div class="border" style="padding: 50px;">
<div class="border" style="width: 1000px;"> <div style="margin-bottom: 20px;">
<textarea style="width: 955px; height: 300px;" (blur)="load()" #itemTextarea>{{itemStr}}</textarea> <span style="font-size: 20px;">开始音频: </span>
<button (click)="copyData();">Copy</button> <app-audio-recorder [audioUrl]="item.gameStartAudio"
(audioUploaded)="onAudioUploadSuccess($event, 'gameStartAudio')">
</app-audio-recorder>
</div> </div>
<div class="border" style="width: 1000px;"> <div style="margin-bottom: 20px;">
<span style="font-size: 20px;">标题: </span> <span style="font-size: 20px;">加载音频: </span>
<input type="text" nz-input [(ngModel)]="item.title" (blur)="save()"> <app-audio-recorder [audioUrl]="item.gameLoadingAudio"
<span style="font-size: 20px;">题目说明: </span> (audioUploaded)="onAudioUploadSuccess($event, 'gameLoadingAudio')">
<input type="text" nz-input [(ngModel)]="item.questionText" (blur)="save()"> </app-audio-recorder>
<span style="font-size: 20px;">题目说明音频: </span>
<app-audio-recorder
[audioUrl]="item.questionTextAudio"
(audioUploaded)="onAssetUploadSuccess($event, 'questionTextAudio')"
[_audioName]="item.audioFileName"
(audioName)="saveAudioFileName($event)"
></app-audio-recorder>
</div> </div>
<div class="border" style="width: 1000px;"> <div style="margin-bottom: 20px;">
<div *ngFor="let question of item.questions; let i = index"> <span style="font-size: 20px;">猫咪<b>转盘</b>待机音频: </span>
<div class="border" style="width: 950px;"> <app-audio-recorder [audioUrl]="item.waitingWheel" (audioUploaded)="onAudioUploadSuccess($event, 'waitingWheel')">
<span style="font-size: 20px;">选项类型: </span> </app-audio-recorder>
<div *ngIf="question.type=='img'"> </div>
<button class="button-right">图片</button>
&nbsp; <div style="margin-bottom: 20px;">
<button class="button-disable" (click)="question.type='txt'; save();">文字</button> <span style="font-size: 20px;">猫咪<b>走棋</b>待机音频: </span>
</div> <app-audio-recorder [audioUrl]="item.waitingPiece" (audioUploaded)="onAudioUploadSuccess($event, 'waitingPiece')">
<div *ngIf="question.type=='txt'"> </app-audio-recorder>
<button class="button-disable" (click)="question.type='img'; save();">图片</button> </div>
&nbsp;
<button class="button-right">文字</button>
</div>
<div *ngIf="question.type=='img'"> <div style="margin-bottom: 20px;">
图片: <span style="font-size: 20px;">猫咪<b>对方轮次</b>待机音频: </span>
<div style="width: 300px;"> <app-audio-recorder [audioUrl]="item.waitingTurn" (audioUploaded)="onAudioUploadSuccess($event, 'waitingTurn')">
<app-upload-image-with-preview [picUrl]="question.image" </app-audio-recorder>
(imageUploaded)="onAssetUploadSuccess($event, 'questions', i, 'image')">
</app-upload-image-with-preview>
</div>
</div>
<span>音频: </span>
<app-audio-recorder [audioUrl]="question.audio"
(audioUploaded)="onAssetUploadSuccess($event, 'questions', i, 'audio')">
</app-audio-recorder>
<div *ngIf="question.type=='txt'">
<span>文本: </span>
<input type="text" nz-input [(ngModel)]="question.text" (blur)="save()">
</div>
<br>
<button style="width: 900px; height: 30px; color: red;" (click)="removeQuestion(i)">删除题目</button>
</div>
</div>
<div class="border" style="width: 950px;">
<button style="width: 900px; height: 100px;" (click)="addQuestion()">增加题目</button>
</div>
</div> </div>
</div> </div>
</div> </div>
\ No newline at end of file
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 { ComponentBase } from './ComponentBase';
@Component({ @Component({
...@@ -8,36 +7,99 @@ import { ComponentBase } from './ComponentBase'; ...@@ -8,36 +7,99 @@ import { ComponentBase } from './ComponentBase';
templateUrl: './form.component.html', templateUrl: './form.component.html',
styleUrls: ['./form.component.css'] styleUrls: ['./form.component.css']
}) })
export class FormComponent extends ComponentBase implements OnInit, OnChanges, OnDestroy { export class FormComponent implements OnInit, OnChanges, OnDestroy {
// 储存数据用 // 储存数据用
saveKey = "card_machine"; saveKey = "test_001";
// 储存对象 // 储存对象
item: any = { item;
title: '',
questionText: '', constructor(private appRef: ApplicationRef, private changeDetectorRef: ChangeDetectorRef) {
questionTextAudio: '',
audioFileName: '', }
questions: [],
}; ngOnInit() {
addQuestion() { this.item = {
this.item.questions.push({ gameStartAudio: '',
type: 'img', gameLoadingAudio: '',
audio: '', waitingWheel: '',
text: '', waitingPiece: '',
image: '' waitingTurn: '',
}); };
// 获取存储的数据
(<any>window).courseware.getData((data) => {
if (data) {
this.item = data;
}
this.init();
this.changeDetectorRef.markForCheck();
this.changeDetectorRef.detectChanges();
this.refresh();
}, this.saveKey);
}
ngOnChanges() {
}
ngOnDestroy() {
}
init() {
}
/**
* 储存图片数据
* @param e
*/
onImageUploadSuccess(e, key) {
this.item[key] = e.url;
this.save();
}
/**
* 储存音频数据
* @param e
*/
onAudioUploadSuccess(e, key) {
this.item[key] = e.url;
this.save(); this.save();
} }
removeQuestion(idx) { onWordAudioUploadSuccess(e, idx) {
this.item.questions.splice(idx, 1); this.item.wordList[idx].audio = e.url;
this.save(); this.save();
} }
saveAudioFileName(name) { onBackWordAudioUploadSuccess(e, idx) {
this.item.audioFileName=name; this.item.wordList[idx].backWordAudio = e.url;
this.save(); this.save();
} }
}
\ No newline at end of file /**
* 储存数据
*/
save() {
(<any>window).courseware.setData(this.item, null, this.saveKey);
this.refresh();
console.log('this.item = ' + JSON.stringify(this.item));
}
/**
* 刷新 渲染页面
*/
refresh() {
setTimeout(() => {
this.appRef.tick();
}, 1);
}
}
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