Commit b1554773 authored by yyh's avatar yyh

模板字段类型和label增加修改功能

parent e1748a7b
...@@ -132,7 +132,7 @@ export default class Index extends Vue { ...@@ -132,7 +132,7 @@ export default class Index extends Vue {
private async addProofHandler() { private async addProofHandler() {
const { name } = this.templateInfo; const { name } = this.templateInfo;
if (!name) { if (!name) {
return this.$router.push({path: 'addTemplate'}) return this.$router.push({path: 'addTemplate'});
} }
let query: any = { let query: any = {
templateId: this.templateInfo.id, templateId: this.templateInfo.id,
......
...@@ -80,6 +80,11 @@ export default class Add extends Vue { ...@@ -80,6 +80,11 @@ export default class Add extends Vue {
text: '删除', text: '删除',
action: this.delWord.bind(this), action: this.delWord.bind(this),
}, },
{
icon: 'shanchu4',
text: '编辑',
action: this.updateWord.bind(this),
},
]; ];
private readonly typeObj: any = { private readonly typeObj: any = {
[DataType.Input]: '单行文本', [DataType.Input]: '单行文本',
...@@ -180,6 +185,12 @@ export default class Add extends Vue { ...@@ -180,6 +185,12 @@ export default class Add extends Vue {
const word = parentIndex !== -1 ? this.words[parentIndex] : null; const word = parentIndex !== -1 ? this.words[parentIndex] : null;
this.preAddWord({ wordType, word}, 'before'); this.preAddWord({ wordType, word}, 'before');
} }
private updateWord() {
const { index, parentIndex } = this.currentAction;
const wordType = parentIndex === -1 ? DataType.Unit : DataType.Input;
const word = parentIndex !== -1 ? this.words[parentIndex] : null;
this.preAddWord({ wordType, word}, 'update');
}
private addAfter() { private addAfter() {
const { index, parentIndex } = this.currentAction; const { index, parentIndex } = this.currentAction;
const wordType = parentIndex === -1 ? DataType.Unit : DataType.Input; const wordType = parentIndex === -1 ? DataType.Unit : DataType.Input;
...@@ -222,6 +233,11 @@ export default class Add extends Vue { ...@@ -222,6 +233,11 @@ export default class Add extends Vue {
this.show = true; this.show = true;
this.wordType = wordType; this.wordType = wordType;
this.currentWords = word ? word.data : this.words; this.currentWords = word ? word.data : this.words;
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;
}
this.flag = flag; this.flag = flag;
} }
private deepClone(data: any) { private deepClone(data: any) {
...@@ -237,7 +253,9 @@ export default class Add extends Vue { ...@@ -237,7 +253,9 @@ export default class Add extends Vue {
if (this.wordType === DataType.Select) { if (this.wordType === DataType.Select) {
tempData = { ...tempData, options: this.options}; tempData = { ...tempData, options: this.options};
} }
if (this.flag === 'before') { if (this.flag === 'update') {
this.currentWords.splice(this.currentAction.index, 1, tempData);
} else if (this.flag === 'before') {
this.currentWords.splice( this.currentAction.index , 0 , tempData); this.currentWords.splice( this.currentAction.index , 0 , tempData);
} else if (this.flag === 'after') { } else if (this.flag === 'after') {
let { index } = this.currentAction; let { index } = this.currentAction;
......
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