Commit a7df8659 by caoyanzhi

解决单个框里面可以添加相同标签的问题

parent ab14657f
......@@ -71,7 +71,7 @@
<div class="tags-search">
<el-input type="search" placeholder="请输入关键词回车搜索标签" prefix-icon="el-icon-search" v-model="searchData" @keydown.native.enter="searchTags"></el-input>
</div>
<tag-container :data="tagsGroupList" @addTag="selectedTag"></tag-container>
<tag-container :data="tagsGroupList" :refresh="refershList" @addTag="selectedTag"></tag-container>
<div class="page-box">
<el-pagination
background
......@@ -89,7 +89,7 @@
</div>
</el-dialog>
<!-- 添加标签、编辑标签 -->
<edit-tag :showEditTagPop.sync="showEditTagPop" :tagData="tagData" :title="editPopType === 'add' ? '添加标签' : '编辑标签'" @returnTagData="returnTagData"></edit-tag>
<edit-tag :showEditTagPop.sync="showEditTagPop" :tagData="tagData" :title="editPopType === 'add' ? '添加标签' : '编辑标签'" @returnTagData="returnTagData" @refresh="refresh"></edit-tag>
<vue-gic-footer></vue-gic-footer>
</div>
</template>
......@@ -169,6 +169,7 @@ export default {
updateDay: '',
effectiveStatus: 1
},
refershList: {},
// 标签组的索引
activeTagsGroupIndex: 0,
......@@ -292,6 +293,11 @@ export default {
changeRoute(route) {
this.$router.push(route);
},
refresh(list) {
console.log('list', list);
list.changeRefersh = true;
this.refershList = list;
},
// 添加标签
addTags() {
......@@ -323,7 +329,21 @@ export default {
switch (this.editPopType) {
case 'add':
this.ruleForm.selectedTags[this.activeTagsGroupIndex].push(data);
const isHad = this.ruleForm.selectedTags.some(group => {
return group.some(item => item.tagId === data.tagId);
});
if (isHad) {
this.ruleForm.selectedTags = this.ruleForm.selectedTags.map(group => {
return group.map(tag => {
if (tag.tagId === data.tagId) {
tag = data;
}
return tag;
});
});
} else {
this.ruleForm.selectedTags[this.activeTagsGroupIndex].push(data);
}
break;
case 'edit':
// 注意有坑
......
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