Commit fda77d27 authored by 邵世尧's avatar 邵世尧

提交

parent d381f1ce
<div class="model-content">
<div style="position: absolute;left: 100px;top:20px;width: 500px;">
<nz-radio-group [(ngModel)]="side">
<label nz-radio nzValue="A"(click)="sideB()">默认背面</label>
<label nz-radio nzValue="B"(click)="sideA()">默认正面</label>
<nz-radio-group [(ngModel)]="side" (ngModelChange)="sidec()">
<label nz-radio nzValue="A">默认背面</label>
<label nz-radio nzValue="B">默认正面</label>
</nz-radio-group>
<div *ngFor="let it of picArr; let i = index" class="card-item" style="padding: 0.5vw;">
......@@ -27,7 +27,7 @@
<div *ngIf="it.optionTypeA == 'A'" style="width: 60%">
<input style="width: 80%; margin-bottom: 0.5vw" type="text" nz-input placeholder="" [(ngModel)]="it.title" (blur)="saveItem()">
<input style="width: 80%; margin-bottom: 0.5vw" type="text" nz-input placeholder="" [(ngModel)]="it.title" (blur)="save()">
</div>
......
import {Component, EventEmitter, Input, OnDestroy, OnChanges, OnInit, Output, ApplicationRef, ChangeDetectorRef} from '@angular/core';
import {Component, EventEmitter, Input, OnDestroy, OnChanges, OnInit, Output, ApplicationRef, ChangeDetectorRef, ViewChild, ElementRef} from '@angular/core';
import { NzMessageService } from 'ng-zorro-antd';
......@@ -8,194 +9,162 @@ import {Component, EventEmitter, Input, OnDestroy, OnChanges, OnInit, Output, Ap
styleUrls: ['./form.component.css']
})
export class FormComponent implements OnInit, OnChanges, OnDestroy {
// @Input()
item;
@ViewChild('videoContainer')
videoContainer: ElementRef;
@ViewChild('videoNode')
videoNode: ElementRef;
@Output()
update = new EventEmitter();
picArr = [];
_item: any;
saveKey = 'ssy003';
radioValue;
intervalId;
picArr;
side
saveKey = 'ssy003';
// @Input()
set item(item) {
this._item = item;
// this.init();
}
get item() {
return this._item;
}
@Output()
update = new EventEmitter();
constructor(private nzMessageService: NzMessageService,
private appRef: ApplicationRef,
public changeDetectorRef: ChangeDetectorRef) {
}
ngOnChanges() {
constructor(private appRef: ApplicationRef,private changeDetectorRef: ChangeDetectorRef) {
}
ngOnInit() {
this.item = {};
this.item.contentObj = {};
const getData = (<any> window).courseware.getData;
getData((data) => {
if (data) {
this.item = data;
} else {
this.item = {};
}
if ( !this.item.contentObj ) {
this.item.contentObj = {};
}
if(this.item.sideA==1){
this.side='B';
}
else if(this.item.sideB==1){
this.side='A';
}
console.log('~data:', data);
this.init();
this.changeDetectorRef.markForCheck();
this.changeDetectorRef.detectChanges();
this.refresh();
this.initDefaultData();
// this.initDefaultData();
console.log('data:', data);
this.init();
this.changeDetectorRef.markForCheck();
this.changeDetectorRef.detectChanges();
this.refresh();
}, this.saveKey);
// this.initData();
}
ngOnChanges() {
}
ngOnDestroy() {
}
sidec(){
if(this.side=="A"){
this.item.sideA=0;
this.item.sideB=1;
init() {
if (this.item.contentObj.picArr) {
this.picArr = this.item.contentObj.picArr;
} else {
this.picArr = this.getDefaultPicArr();
this.item.contentObj.picArr = this.picArr;
}
if(this.side=="B"){
this.item.sideA=1;
this.item.sideB=0;
}
this.save();
}
console.log('item:' , this.item);
// this.picArr = this.getDefaultPicArr();
// this.item.contentObj.picArr = this.picArr;
// console.log('this.item:;', this.picArr);
initDefaultData() {
}
cardItemData(){
return {
title: "",
pic_url: "",
audio_url: ""
const picArr = this.item.contentObj.picArr;
if (!picArr) {
};
const picArr = [];
for (let i = 0; i < 6; i ++) {
picArr.push({
pic_url: '',
audio_url: '',
title:'',
sideA:'',
sideB:''
});
}
sideA(){
this.item.sideA=1;
this.item.sideB=0;
this.picArr=[];
this.item.contentObj.picArr = this.picArr;
for(let i=0;i<6;i++){
let item = this.cardItemData();
this.picArr.push(item);
this.item.contentObj.picArr = picArr;
}
this.saveItem();
}
sideB(){
this.item.sideB=1;
this.item.sideA=0;
this.picArr=[];
this.item.contentObj.picArr = this.picArr;
for(let i=0;i<6;i++){
let item = this.cardItemData();
this.picArr.push(item);
}
this.saveItem();
console.log('init~data:', this.picArr);
}
getDefaultPicArr() {
let arr = [];
return arr;
ngOnDestroy() {
console.log('in ngOnDestory');
}
init() {
this.picArr = this.item.contentObj.picArr || [];
addItem6() {
this.picArr=[];
this.item.contentObj.picArr = this.picArr;
for(let i=0;i<6;i++){
let item = this.cardItemData();
this.picArr.push(item);
}
this.saveItem();
console.log('init~data:', this.picArr);
}
onImageUploadSuccessByItem(e, item) {
onImageUploadSuccessByItem(e, item, id = null) {
if (id != null) {
item[id + '_pic_url'] = e.url;
} else {
item.pic_url = e.url;
this.save();
}
onAudioUploadSuccessByItem(e, item) {
item.audio_url = e.url;
this.save();
}
radioClick(it, radioValue) {
it.radioValue = radioValue;
// this.update.emit(this.item);
this.saveItem();
// console.log('this.item: ', this.item);
}
clickCheckBox() {
console.log(' in clickCheckBox');
this.saveItem();
}
saveItem() {
onAudioUploadSuccessByItem(e, item, id = null) {
console.log(' in saveItem');
if (id != null) {
item[id + '_audio_url'] = e.url;
} else {
item.audio_url = e.url;
}
// this.update.emit(this.item);
this.save();
}
save() {
(<any> window).courseware.setData(this.item, null, this.saveKey);
console.log('side'+this.item);
this.refresh();
}
......@@ -203,8 +172,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
setTimeout(() => {
this.appRef.tick();
}, 1);
console.log("===========================================================================================");
}
}
This diff is collapsed.
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