Commit 7233d4c1 authored by Tt's avatar Tt

修改form内容

parent cfdfe0b5
No preview for this file type
import { BrowserModule } from '@angular/platform-browser';
import { NgModule, ErrorHandler } from '@angular/core';
import {MyErrorHandler} from './MyError';
import { MyErrorHandler } from './MyError';
import { AppComponent } from './app.component';
import { NgZorroAntdModule, NZ_I18N, zh_CN } from 'ng-zorro-antd';
......@@ -10,17 +10,17 @@ import { HttpClientModule } from '@angular/common/http';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { registerLocaleData } from '@angular/common';
import zh from '@angular/common/locales/zh';
import {FormComponent} from './form/form.component';
import {PlayComponent} from './play/play.component';
import {LessonTitleConfigComponent} from './common/lesson-title-config/lesson-title-config.component';
import {BackgroundImagePipe} from './pipes/background-image.pipe';
import {UploadImageWithPreviewComponent} from './common/upload-image-with-preview/upload-image-with-preview.component';
import {PlayerContentWrapperComponent} from './common/player-content-wrapper/player-content-wrapper.component';
import {CustomHotZoneComponent} from './common/custom-hot-zone/custom-hot-zone.component';
import {UploadVideoComponent} from './common/upload-video/upload-video.component';
import {TimePipe} from './pipes/time.pipe';
import {ResourcePipe} from './pipes/resource.pipe';
import {AudioRecorderComponent} from './common/audio-recorder/audio-recorder.component';
import { FormComponent } from './form/form.component';
import { PlayComponent } from './play/play.component';
import { LessonTitleConfigComponent } from './common/lesson-title-config/lesson-title-config.component';
import { BackgroundImagePipe } from './pipes/background-image.pipe';
import { UploadImageWithPreviewComponent } from './common/upload-image-with-preview/upload-image-with-preview.component';
import { PlayerContentWrapperComponent } from './common/player-content-wrapper/player-content-wrapper.component';
import { CustomHotZoneComponent } from './common/custom-hot-zone/custom-hot-zone.component';
import { UploadVideoComponent } from './common/upload-video/upload-video.component';
import { TimePipe } from './pipes/time.pipe';
import { ResourcePipe } from './pipes/resource.pipe';
import { AudioRecorderComponent } from './common/audio-recorder/audio-recorder.component';
import { FontAwesomeModule, FaIconLibrary } from '@fortawesome/angular-fontawesome';
import { fas } from '@fortawesome/free-solid-svg-icons';
import { far } from '@fortawesome/free-regular-svg-icons';
......@@ -54,15 +54,15 @@ registerLocaleData(zh);
FontAwesomeModule
],
providers: [
{provide: ErrorHandler, useClass: MyErrorHandler},
{ provide: ErrorHandler, useClass: MyErrorHandler },
{ provide: NZ_I18N, useValue: zh_CN }
],
bootstrap: [AppComponent]
})
export class AppModule {
constructor(library: FaIconLibrary) {
let fs :any = fas;
let fr :any = far;
let fs: any = fas;
let fr: any = far;
library.addIconPacks(fs, fr);
}
}
......@@ -42,13 +42,14 @@ export class ComponentBase {
// let sp = e.url.split(".mp3");
// let u = sp[0] + "_l.mp3";
// item[key[i]] = u;
// console.log("audioName: " + e.name);
// item["audioName"] = e.name || "";
// } else {
// item[key[i]] = e.url;
// }
// this.save();
// return;
// }
// this.save();
// item = item[key[i]];
// }
// }
......@@ -57,7 +58,7 @@ export class ComponentBase {
* 储存图片数据
* @param e
*/
onImageUploadSuccess(e, key, it = this.item) {
onImageUploadSuccess(e, key, it = this.item) {
it[key] = e.url;
this.save();
}
......
This diff is collapsed.
......@@ -2,9 +2,6 @@ import { Component, OnDestroy, OnChanges, OnInit, ApplicationRef, ChangeDetector
import { ComponentBase } from './ComponentBase';
import { MetaFormCreator } from './mataFormCreator';
let replaceAll = function (str, s1, s2) {
return str.replace(new RegExp(s1, "gm"), s2);
}
@Component({
selector: 'app-form',
templateUrl: './form.component.html',
......@@ -12,19 +9,21 @@ let replaceAll = function (str, s1, s2) {
})
export class FormComponent extends ComponentBase implements OnInit, OnChanges, OnDestroy {
// 储存数据用
saveKey = "ngt06_ball";
saveKey = "hy01_danci";
item = {
imgAni: {
ske: {},
tex: {},
png: {}
},
startAudio: "",
audioName: "",
title: "判断对错",
questions: [],
recordFlag: false,
title: "",
questionText: "",
questionTextAudio: "",
questions: [{
questionAudio: "",
duration: 120,
options: []
}],
bgAudio: "",
bgAudioName: "",
audioName: ""
};
isVisible = false;
......@@ -42,6 +41,8 @@ export class FormComponent extends ComponentBase implements OnInit, OnChanges, O
this.deleteCallback && this.deleteCallback();
this.handleCancel();
}
init(): void {
console.log(new MetaFormCreator().create());
}
......@@ -52,7 +53,7 @@ export class FormComponent extends ComponentBase implements OnInit, OnChanges, O
this.save();
})
}
copyoption(i, j) {
copyOption(i, j) {
let data = this.item.questions[i].options[j];
this.item.questions[i].options.push(JSON.parse(JSON.stringify(data)));
this.save();
......@@ -60,69 +61,39 @@ export class FormComponent extends ComponentBase implements OnInit, OnChanges, O
addoption(i) {
this.item.questions[i].options.push({
type: "txt",
type: "",
image: "",
audio: "",
text: "",
time: "",
duration: '',
content: '',
right: false
});
this.save();
}
removequestion(idx) {
removequestion(i) {
this.openDelete("确定删除题目?", () => {
this.item.questions.splice(idx, 1);
this.item.questions.splice(i, 1);
this.save();
})
}
addquestion() {
this.item.questions.push({
options: [],
type: "txt",
audioUrl: "",
audioName: "",
text: "",
questionAudio: "",
duration: 120,
options: []
});
this.save();
}
ngChange(i, j) {
this.save();
}
changeMain(question) {
//输出的数据可以识别到\n的换行符
let arr = question.contentMain.split(" ");
let oldArr = question.contentArr.concat();
let contetArr = arr.map(ar => {
let obj = {
text: `${ar}`,//replaceAll(`${ar}`, "\n", "<br/>"),
block: false,
check: 1,
}
for (let i = 0; i < oldArr.length; i++) {
if (obj.text == oldArr[i].text) {
obj.block = oldArr[i].block;
obj.check = oldArr[i].check;
oldArr.splice(i, 1);
break;
}
}
return obj;
})
question.contentArr = contetArr;
console.log(contetArr)
this.save();
}
onBlock(item, vis) {
item.block = vis;
deleteBgAudio() {
this.item.bgAudio = "";
this.item.bgAudioName = "";
this.save();
}
onDragonBoneSave(e, item) {
console.log(e);
ngChange(i, j) {
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