Commit 015dcb32 authored by liujiangnan's avatar liujiangnan

feat: 表单配置

parent a51e2ffb
<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>
<div class="border" style="width: 1000px;">
<div class="border" style="width: 80%; display: inline-block;">
<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>
<input style="width: 200px;" type="text" nz-input [(ngModel)]="item.title" (blur)="save()">
<br><br>
<span style="font-size: 20px;">引导音频: </span>
<app-audio-recorder
style="display: inline-block;"
[audioUrl]="item.questionTextAudio"
(audioUploaded)="onAssetUploadSuccess($event, 'questionTextAudio')"
[_audioName]="item.audioFileName"
(audioName)="saveAudioFileName($event)"
(audioName)="saveAudioFileName($event, 'audioFileName')"
></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 *ngIf="question.type=='img'">
图片:
<div style="width: 300px;">
<app-upload-image-with-preview [picUrl]="question.image"
(imageUploaded)="onAssetUploadSuccess($event, 'questions', i, 'image')">
<br><br>
<span style="font-size: 20px;">选择级别: </span>
<nz-select [(ngModel)]="item.choseLevel" style="width: 100px;" (ngModelChange)="save()">
<nz-option nzValue="1" nzLabel="L1"></nz-option>
<nz-option nzValue="2" nzLabel="L2"></nz-option>
<nz-option nzValue="3" nzLabel="L3"></nz-option>
<nz-option nzValue="4" nzLabel="L4"></nz-option>
<nz-option nzValue="5" nzLabel="L5"></nz-option>
</nz-select>
<br><br>
<span style="font-size: 20px;">书本图片: </span>
<div style="width: 300px; display: inline-block;">
<app-upload-image-with-preview [picUrl]="item.bookImg"
(imageUploaded)="onAssetUploadSuccess($event, 'bookImg')">
</app-upload-image-with-preview>
</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>
<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>
\ 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';
......@@ -11,33 +10,22 @@ import { ComponentBase } from './ComponentBase';
export class FormComponent extends ComponentBase implements OnInit, OnChanges, OnDestroy {
// 储存数据用
saveKey = "card_machine";
saveKey = "NJ_BookTable";
// 储存对象
item: any = {
title: '',
questionText: '',
questionTextAudio: '',
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) {
this.item.audioFileName=name;
saveAudioFileName(name, key) {
this.item[key]=name;
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