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

表单调整

parent fd9d8cc4
......@@ -20,10 +20,10 @@
border-style: dashed;
padding: 20px;
margin: 20px;
/*width: 500px; */
/*//border-radius: 20px;*/
/*//border-width: 2px;*/
/*//border-color: #000000;*/
width: 500px;
border-radius: 20px;
border-width: 2px;
border-color: #000000;
}
......@@ -32,31 +32,4 @@
border-radius: 0.5rem;
padding: 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 style="padding: 10px;">
<div class="border" style="width: 1000px;">
<textarea style="width: 955px; height: 300px;" (blur)="load()" #itemTextarea>{{itemStr}}</textarea>
<button (click)="copyData();">Copy</button>
<div class="border" style="padding: 50px;">
<div style="margin-bottom: 20px;">
<span style="font-size: 20px;">开始音频: </span>
<app-audio-recorder [audioUrl]="item.gameStartAudio"
(audioUploaded)="onAudioUploadSuccess($event, 'gameStartAudio')">
</app-audio-recorder>
</div>
<div class="border" style="width: 1000px;">
<span style="font-size: 20px;">标题: </span>
<input type="text" nz-input [(ngModel)]="item.title" (blur)="save()">
<span style="font-size: 20px;">题目说明: </span>
<input type="text" nz-input [(ngModel)]="item.questionText" (blur)="save()">
<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 style="margin-bottom: 20px;">
<span style="font-size: 20px;">加载音频: </span>
<app-audio-recorder [audioUrl]="item.gameLoadingAudio"
(audioUploaded)="onAudioUploadSuccess($event, 'gameLoadingAudio')">
</app-audio-recorder>
</div>
<div class="border" style="width: 1000px;">
<div *ngFor="let question of item.questions; let i = index">
<div class="border" style="width: 950px;">
<span style="font-size: 20px;">选项类型: </span>
<div *ngIf="question.type=='img'">
<button class="button-right">图片</button>
&nbsp;
<button class="button-disable" (click)="question.type='txt'; save();">文字</button>
</div>
<div *ngIf="question.type=='txt'">
<button class="button-disable" (click)="question.type='img'; save();">图片</button>
&nbsp;
<button class="button-right">文字</button>
</div>
<div style="margin-bottom: 20px;">
<span style="font-size: 20px;">猫咪<b>转盘</b>待机音频: </span>
<app-audio-recorder [audioUrl]="item.waitingWheel" (audioUploaded)="onAudioUploadSuccess($event, 'waitingWheel')">
</app-audio-recorder>
</div>
<div style="margin-bottom: 20px;">
<span style="font-size: 20px;">猫咪<b>走棋</b>待机音频: </span>
<app-audio-recorder [audioUrl]="item.waitingPiece" (audioUploaded)="onAudioUploadSuccess($event, 'waitingPiece')">
</app-audio-recorder>
</div>
<div *ngIf="question.type=='img'">
图片:
<div style="width: 300px;">
<app-upload-image-with-preview [picUrl]="question.image"
(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 style="margin-bottom: 20px;">
<span style="font-size: 20px;">猫咪<b>对方轮次</b>待机音频: </span>
<app-audio-recorder [audioUrl]="item.waitingTurn" (audioUploaded)="onAudioUploadSuccess($event, 'waitingTurn')">
</app-audio-recorder>
</div>
</div>
</div>
\ No newline at end of file
import { Component, EventEmitter, Input, OnDestroy, OnChanges, OnInit, Output, ApplicationRef, ChangeDetectorRef } from '@angular/core';
import { JsonPipe } from '@angular/common';
import { ComponentBase } from './ComponentBase';
@Component({
......@@ -8,36 +7,99 @@ import { ComponentBase } from './ComponentBase';
templateUrl: './form.component.html',
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 = {
title: '',
questionText: '',
questionTextAudio: '',
audioFileName: '',
questions: [],
};
addQuestion() {
this.item.questions.push({
type: 'img',
audio: '',
text: '',
image: ''
});
item;
constructor(private appRef: ApplicationRef, private changeDetectorRef: ChangeDetectorRef) {
}
ngOnInit() {
this.item = {
gameStartAudio: '',
gameLoadingAudio: '',
waitingWheel: '',
waitingPiece: '',
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();
}
removeQuestion(idx) {
this.item.questions.splice(idx, 1);
onWordAudioUploadSuccess(e, idx) {
this.item.wordList[idx].audio = e.url;
this.save();
}
saveAudioFileName(name) {
this.item.audioFileName=name;
onBackWordAudioUploadSuccess(e, idx) {
this.item.wordList[idx].backWordAudio = e.url;
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