Commit b1554773 authored by yyh's avatar yyh

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

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