Commit db8fffe1 authored by limingzhe's avatar limingzhe

feat: 表单提交

parent 3695f7ce
<div class="model-content">
<div style="padding: 40px; margin-left: 30px">
<div style="position: absolute; left: 200px; top: 100px; width: 800px;">
<h2>背景图:</h2>
<div style="width: 400px">
<app-upload-image-with-preview
[picUrl]="item.pic_url"
(imageUploaded)="onImageUploadSuccess($event, 'pic_url')"
></app-upload-image-with-preview>
</div>
<input type="text" nz-input [(ngModel)]="item.text" (blur)="save()">
<app-upload-image-with-preview
[picUrl]="item.pic_url"
(imageUploaded)="onImageUploadSuccess($event, 'pic_url')"
></app-upload-image-with-preview>
<h2 style="margin-top: 40px">音频:</h2>
<app-audio-recorder
[audioUrl]="item.audio_url"
(audioUploaded)="onAudioUploadSuccess($event, 'audio_url')"
></app-audio-recorder>
<app-custom-hot-zone></app-custom-hot-zone>
<app-upload-video></app-upload-video>
<app-lesson-title-config></app-lesson-title-config>
<h2 style="margin-top: 40px">句子:</h2>
<div *ngFor="let sentence of item.sentences;let i = index" style="width: 500px; padding-bottom: 15px;">
<div style="display: flex; align-items: center; justify-content: center; width: 100%;">
<span style="width: 70px">句子-{{i+1}}: </span>
<input type="text" nz-input [(ngModel)]="sentence.text" (blur)="save()">
<button nz-button nzType="danger" (click)="deleteSentence(i)" style="margin-left: 5px">删除</button>
</div>
</div>
<div *ngIf="item.sentences.length < 6">
<button nz-button nzType="dashed" (click)="addSentence()">添加句子</button>
</div>
</div>
</div>
\ No newline at end of file
......@@ -10,7 +10,7 @@ import {Component, EventEmitter, Input, OnDestroy, OnChanges, OnInit, Output, Ap
export class FormComponent implements OnInit, OnChanges, OnDestroy {
// 储存数据用
saveKey = "test_0011";
saveKey = "pu09";
// 储存对象
item;
......@@ -23,6 +23,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
ngOnInit() {
this.item = {};
this.item.sentences = [];
// 获取存储的数据
(<any> window).courseware.getData((data) => {
......@@ -53,6 +54,22 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
}
addSentence() {
const sentence = {
text: ''
};
this.item.sentences.push(sentence);
this.save();
}
deleteSentence(index) {
this.item.sentences.splice(index, 1);
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