Commit 710ea508 by caoyanzhi

修复可以重复添加标签的bug

parent 91b53a0c
......@@ -383,7 +383,16 @@ export default {
tagData.level = this.activeTagsGroupIndex;
switch (this.editPopType) {
case 'add':
this.selectedTags[this.activeTagsGroupIndex].push(tagData);
const isHad = this.selectedTags[this.activeTagsGroupIndex].some(item => item.tagId === tagData.tagId);
if (isHad) {
this.selectedTags[this.activeTagsGroupIndex].forEach((tag, tagIndex) => {
if (tag.tagId === tagData.tagId) {
this.selectedTags[this.activeTagsGroupIndex].splice(tagIndex, 1, tagData);
}
});
} else {
this.selectedTags[this.activeTagsGroupIndex].push(tagData);
}
break;
case 'edit':
// 注意有坑
......@@ -403,12 +412,7 @@ export default {
},
// 新增选择标签
selectedTag(tagData) {
if (tagData.refersh) {
// 表示是之前新增过的 要编辑一次
this.editPopType = 'edit';
} else {
this.editPopType = 'add';
}
this.editPopType = 'add';
this.tagData = Object.assign({}, this.tagData, tagData);
this.tagData.editCondition = false;
this.showEditTagPop = true;
......
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