Commit 5d9f90d2 authored by yyh's avatar yyh

update wordsManager

parent b1554773
......@@ -233,10 +233,11 @@ export default class Add extends Vue {
this.show = true;
this.wordType = wordType;
this.currentWords = word ? word.data : this.words;
if(flag === 'update') {
if (flag === 'update') {
const { index, parentIndex } = this.currentAction;
this.wordName = parentIndex === -1 ? this.words[index].label : this.words[parentIndex].data[index].label;
this.wordType = parentIndex === -1 ? this.words[index].type :this.words[parentIndex].data[index].type;
const currentWord = parentIndex === -1 ? this.words[index] : this.words[parentIndex].data[index];
this.wordName = currentWord.label;
this.wordType = currentWord.type;
}
this.flag = flag;
}
......@@ -253,12 +254,12 @@ export default class Add extends Vue {
if (this.wordType === DataType.Select) {
tempData = { ...tempData, options: this.options};
}
let { index } = this.currentAction;
if (this.flag === 'update') {
this.currentWords.splice(this.currentAction.index, 1, tempData);
this.currentWords.splice(index, 1, tempData);
} else if (this.flag === 'before') {
this.currentWords.splice( this.currentAction.index , 0 , tempData);
this.currentWords.splice(index , 0 , tempData);
} else if (this.flag === 'after') {
let { index } = this.currentAction;
this.currentWords.splice( ++index , 0 , tempData);
} else {
this.currentWords.push(tempData);
......
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