Commit 015dcb32 authored by liujiangnan's avatar liujiangnan

feat: 表单配置

parent a51e2ffb
<div class="model-content"> <div class="model-content">
<div style="padding: 10px;"> <div style="padding: 10px;">
<div class="border" style="width: 1000px;"> <div class="border" style="width: 80%; display: inline-block;">
<textarea style="width: 955px; height: 300px;" (blur)="load()" #itemTextarea>{{itemStr}}</textarea>
<button (click)="copyData();">Copy</button>
</div>
<div class="border" style="width: 1000px;">
<span style="font-size: 20px;">标题: </span> <span style="font-size: 20px;">标题: </span>
<input type="text" nz-input [(ngModel)]="item.title" (blur)="save()"> <input style="width: 200px;" type="text" nz-input [(ngModel)]="item.title" (blur)="save()">
<span style="font-size: 20px;">题目说明: </span> <br><br>
<input type="text" nz-input [(ngModel)]="item.questionText" (blur)="save()"> <span style="font-size: 20px;">引导音频: </span>
<span style="font-size: 20px;">题目说明音频: </span>
<app-audio-recorder <app-audio-recorder
style="display: inline-block;"
[audioUrl]="item.questionTextAudio" [audioUrl]="item.questionTextAudio"
(audioUploaded)="onAssetUploadSuccess($event, 'questionTextAudio')" (audioUploaded)="onAssetUploadSuccess($event, 'questionTextAudio')"
[_audioName]="item.audioFileName" [_audioName]="item.audioFileName"
(audioName)="saveAudioFileName($event)" (audioName)="saveAudioFileName($event, 'audioFileName')"
></app-audio-recorder> ></app-audio-recorder>
</div> <br><br>
<span style="font-size: 20px;">选择级别: </span>
<div class="border" style="width: 1000px;"> <nz-select [(ngModel)]="item.choseLevel" style="width: 100px;" (ngModelChange)="save()">
<div *ngFor="let question of item.questions; let i = index"> <nz-option nzValue="1" nzLabel="L1"></nz-option>
<div class="border" style="width: 950px;"> <nz-option nzValue="2" nzLabel="L2"></nz-option>
<span style="font-size: 20px;">选项类型: </span> <nz-option nzValue="3" nzLabel="L3"></nz-option>
<div *ngIf="question.type=='img'"> <nz-option nzValue="4" nzLabel="L4"></nz-option>
<button class="button-right">图片</button> <nz-option nzValue="5" nzLabel="L5"></nz-option>
&nbsp; </nz-select>
<button class="button-disable" (click)="question.type='txt'; save();">文字</button> <br><br>
</div> <span style="font-size: 20px;">书本图片: </span>
<div *ngIf="question.type=='txt'"> <div style="width: 300px; display: inline-block;">
<button class="button-disable" (click)="question.type='img'; save();">图片</button> <app-upload-image-with-preview [picUrl]="item.bookImg"
&nbsp; (imageUploaded)="onAssetUploadSuccess($event, 'bookImg')">
<button class="button-right">文字</button> </app-upload-image-with-preview>
</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>
<br><br>
<span style="font-size: 20px;">书本音频: </span>
<app-audio-recorder
style="display: inline-block;"
[audioUrl]="item.bookAudio"
(audioUploaded)="onAssetUploadSuccess($event, 'bookAudio')"
[_audioName]="item.bookAudioFileName"
(audioName)="saveAudioFileName($event, 'bookAudioFileName')"
></app-audio-recorder>
</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 { ComponentBase } from './ComponentBase'; import { ComponentBase } from './ComponentBase';
...@@ -11,33 +10,22 @@ import { ComponentBase } from './ComponentBase'; ...@@ -11,33 +10,22 @@ import { ComponentBase } from './ComponentBase';
export class FormComponent extends ComponentBase implements OnInit, OnChanges, OnDestroy { export class FormComponent extends ComponentBase implements OnInit, OnChanges, OnDestroy {
// 储存数据用 // 储存数据用
saveKey = "card_machine"; saveKey = "NJ_BookTable";
// 储存对象 // 储存对象
item: any = { item: any = {
title: '', title: '',
questionText: '',
questionTextAudio: '', questionTextAudio: '',
audioFileName: '', audioFileName: '',
questions: [], choseLevel: 1,
bookImg: '',
bookAudio: '',
bookAudioFileName: '',
}; };
addQuestion() {
this.item.questions.push({
type: 'img',
audio: '',
text: '',
image: ''
});
this.save();
}
removeQuestion(idx) {
this.item.questions.splice(idx, 1);
this.save();
}
saveAudioFileName(name) { saveAudioFileName(name, key) {
this.item.audioFileName=name; this.item[key]=name;
this.save(); this.save();
} }
} }
\ No newline at end of file
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