Commit 503effd0 authored by liujiangnan's avatar liujiangnan

fix: 表单保存问题

parent 0a8f1cc1
...@@ -13,7 +13,6 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -13,7 +13,6 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
saveKey = 'ww_vocabulary'; saveKey = 'ww_vocabulary';
// 储存对象 // 储存对象
item; item;
originContent;
constructor(private appRef: ApplicationRef, constructor(private appRef: ApplicationRef,
...@@ -33,12 +32,12 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -33,12 +32,12 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
pic_id: "", pic_id: "",
vocabulary_audio: "" vocabulary_audio: ""
} }
}; };
// 获取存储的数据 // 获取存储的数据
(window as any).courseware.getData((data) => { (window as any).courseware.getData((data) => {
if (data) { if (data) {
this.item = data; this.item = data;
} }
this.changeDetectorRef.markForCheck(); this.changeDetectorRef.markForCheck();
this.changeDetectorRef.detectChanges(); this.changeDetectorRef.detectChanges();
...@@ -65,30 +64,21 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -65,30 +64,21 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
if (temp) { if (temp) {
this.item.contentObj.vocabulary = this.item.contentObj.vocabulary.trim(); this.item.contentObj.vocabulary = this.item.contentObj.vocabulary.trim();
} }
if (temp !== this.originContent.vocabulary) { this.save();
this.originContent.vocabulary = temp;
this.save();
}
} }
updatePartOfSpeech() { updatePartOfSpeech() {
const temp = this.item.contentObj.vocabularyType ? this.item.contentObj.vocabularyType.trim() : ''; const temp = this.item.contentObj.vocabularyType ? this.item.contentObj.vocabularyType.trim() : '';
if (temp) { if (temp) {
this.item.contentObj.vocabularyType = this.item.contentObj.vocabularyType.trim(); this.item.contentObj.vocabularyType = this.item.contentObj.vocabularyType.trim();
} }
if (temp !== this.originContent.vocabularyType) { this.save();
this.originContent.vocabularyType = temp;
this.save();
}
} }
updateDefinition() { updateDefinition() {
const temp = this.item.contentObj.definition ? this.item.contentObj.definition.trim() : ''; const temp = this.item.contentObj.definition ? this.item.contentObj.definition.trim() : '';
if (temp) { if (temp) {
this.item.contentObj.definition = this.item.contentObj.definition.trim(); this.item.contentObj.definition = this.item.contentObj.definition.trim();
} }
if (temp !== this.originContent.definition) { this.save();
this.originContent.definition = temp;
this.save();
}
} }
onVocabularyAudioUploadSuccess(e) { onVocabularyAudioUploadSuccess(e) {
......
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