Commit 504d9048 by caoyanzhi

解决编辑之后的新数据不更新的问题

parent 18104794
......@@ -51,7 +51,7 @@
<div class="form-tip-text"><label>*更新时间预计选择日期的凌晨0点至6点</label></div>
</el-form-item>
<el-form-item label="">
<el-button type="primary" @click.stop="confirmSave">保存</el-button>
<el-button type="primary" @click.stop="postSave">保存</el-button>
<el-button>
<router-link to="/memberGroupList">返回</router-link>
</el-button>
......@@ -302,22 +302,27 @@ export default {
editTags() {
this.editPopType = 'edit';
this.showEditTagPop = true;
this.tagData = [...this.ruleForm.selectedTags[this.activeTagsGroupIndex][this.activeTagIndex]];
this.tagData = Object.assign({}, this.tagData, this.ruleForm.selectedTags[this.activeTagsGroupIndex][this.activeTagIndex]);
},
// 选择标签
selectedTag(tagData) {
this.showEditTagPop = true;
this.tagData = { ...tagData };
this.tagData = Object.assign({}, this.tagData, tagData);
},
// 保存选择的标签数据
returnTagData(data) {
let tagParams = JSON.parse(data.tagParams);
data.newTagVal = JSON.stringify(tagParams.selectedVal);
switch (this.editPopType) {
case 'add':
this.ruleForm.selectedTags[this.activeTagsGroupIndex].push(data);
break;
case 'edit':
this.ruleForm.selectedTags[this.activeTagsGroupIndex][this.activeTagIndex] = { ...data };
// 注意有坑
let tagsGroup = this.ruleForm.selectedTags[this.activeTagsGroupIndex];
tagsGroup.splice(this.activeTagIndex, 1, { ...tagsGroup[this.activeTagIndex], ...data });
this.ruleForm.selectedTags.splice(this.activeTagsGroupIndex, 1, tagsGroup);
break;
}
},
......@@ -359,9 +364,10 @@ export default {
* 点击保存
*/
confirmSave: _debounce(function() {
const that = this;
that.$refs.ruleForm.validate(valid => {
if (valid) that.postSave();
// 优化掉
return;
this.$refs.ruleForm.validate(valid => {
if (valid) this.postSave();
});
}, 500),
......@@ -524,6 +530,9 @@ export default {
});
});
this.ruleForm.selectedTags = this.ruleForm.selectedTags.filter(item => item.length > 0);
this.ruleForm.selectedTags.map(tagsGroup => {
this.ruleForm.tagsGroupRelation.push(tagsGroup[0].levelType);
});
}
})
.catch(error => {
......
......@@ -2,7 +2,7 @@
<div class="m-l-60">
<tags-group
v-for="(item, index) in selectedTagsData"
:key="index"
:key="item"
:tagsData="item"
:showTagsRelation="(index === 0 && selectedTagsData.length > 1) || (index === 1 && selectedTagsData.length > 2)"
:tagsGroupIndex="index"
......
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