Commit a2cb5174 authored by Tt's avatar Tt

组件提供

parent 5c44512d
...@@ -22,20 +22,21 @@ ...@@ -22,20 +22,21 @@
<div *ngFor="let group of item; let m = index" style="border: 1px solid #000;"> <div *ngFor="let info of item; let m = index" style="border: 1px solid #000;">
<div style="width: 300px; margin-top: 15px"> <div style="width: 300px; margin-top: 15px">
<span>请输入标题: </span> <span>请输入标题: </span>
<input type="text" nz-input [(ngModel)]="item.title" (blur)="save()" /> <input type="text" nz-input [(ngModel)]="info.title" (blur)="save()" />
</div> </div>
<div style="margin-top: 15px"> <div style="margin-top: 15px">
<span>标题音频: </span> <span>标题音频: </span>
<app-audio-recorder [audioUrl]="item.audio_title" (audioUploaded)="onAudioUploadSuccess($event, 'audio_title')"> <app-audio-recorder [audioUrl]="info.audio_title"
(audioUploaded)="onAudioUploadSuccess($event,m, 'audio_title')">
</app-audio-recorder> </app-audio-recorder>
</div> </div>
<div *ngFor="let it of group; let i = index" style="padding: 0.5vw"> <div *ngFor="let it of info.group; let i = index" style="padding: 0.5vw">
<div class="border" style="display: flex; align-items: center"> <div class="border" style="display: flex; align-items: center">
<div class="item-box" style="width: 100%"> <div class="item-box" style="width: 100%">
<h2 style="padding-bottom: 1vw">连线组-{{ i + 1 }}</h2> <h2 style="padding-bottom: 1vw">连线组-{{ i + 1 }}</h2>
......
...@@ -59,7 +59,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -59,7 +59,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
init() { init() {
if (this.item.length == 0) { if (this.item.length == 0) {
this.item.push([]); this.addGroup();
} }
} }
...@@ -68,7 +68,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -68,7 +68,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
* @param e * @param e
*/ */
onImageUploadSuccess(e, key) { onImageUploadSuccess(e, key) {
this.item[key] = e.url; // this.item[key] = e.url;
this.save(); this.save();
} }
...@@ -76,18 +76,16 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -76,18 +76,16 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
* 储存音频数据 * 储存音频数据
* @param e * @param e
*/ */
onAudioUploadSuccess(e, key) { onAudioUploadSuccess(e, i, key) {
this.item[key] = e.url; this.item[i][key] = e.url;
this.save(); this.save();
} }
onWordAudioUploadSuccess(e, idx) { onWordAudioUploadSuccess(e, idx) {
this.item.wordList[idx].audio = e.url;
this.save(); this.save();
} }
onBackWordAudioUploadSuccess(e, idx) { onBackWordAudioUploadSuccess(e, idx) {
this.item.wordList[idx].backWordAudio = e.url;
this.save(); this.save();
} }
...@@ -145,7 +143,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -145,7 +143,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
* 添加选项组 * 添加选项组
*/ */
addItem(i) { addItem(i) {
let group = this.item[i]; let group = this.item[i].group;
if (group.length >= 5) return; if (group.length >= 5) return;
const data = { const data = {
...@@ -169,7 +167,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -169,7 +167,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
} }
deleteItem(i, data) { deleteItem(i, data) {
let group = this.item[i]; let group = this.item[i].group;
const index = group.indexOf(data); const index = group.indexOf(data);
if (index !== -1) { if (index !== -1) {
group.splice(index, 1); group.splice(index, 1);
...@@ -178,7 +176,11 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -178,7 +176,11 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
this.save(); this.save();
} }
addGroup() { addGroup() {
this.item.push([]); this.item.push({
title: '',
audio_title: '',
group: []
});
} }
} }
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