修复标签模块的分类关联标签搜索以及清除按钮问题

This commit is contained in:
王卓煜
2025-09-09 14:23:36 +08:00
parent a265c226fb
commit e81d81a3ee

View File

@@ -43,7 +43,7 @@
:disabled="!twoList.children.length" :open-delay="0" :close-delay="0" trigger="hover"
:visible-arrow="false" @hide="leaveIndex" @show="changeIndex(twoList.id)" transition="none">
<div class="course-two-content" slot="reference">{{
twoList.name }}</div>
twoList.name }}</div>-
<!-- 内容 -->
<div class="course-three-box">
<div class="course-three-box-title">
@@ -570,7 +570,7 @@ export default {
},
stagList() { //计算出选择的内容
let list = [];
// 关键词
if (this.keyword) {
list.push({
@@ -581,7 +581,7 @@ export default {
checked: true
});
}
// 课程类型
this.ctypeList.forEach(item => {
if (item.checked) {
@@ -591,7 +591,7 @@ export default {
});
}
});
// 热点标签 - 这是关键修复
this.hotTagsList.forEach(item => {
if (item.checked) {
@@ -603,7 +603,7 @@ export default {
});
}
});
// 三级分类
this.oneList.forEach(one => {
var twoChildChecked = false;
@@ -635,7 +635,7 @@ export default {
});
}
});
return list;
},
ctypeTagAll() {
@@ -935,7 +935,7 @@ export default {
//搜索条件
stagClose(tag, tagIndex) {
tag.checked = false;
// 根据标签类型处理不同的清除逻辑
if (tag.type == 0) {
// 关键词类型
@@ -954,12 +954,12 @@ export default {
item.checked = false;
}
});
// 更新course.tags移除被删除的热点标签
const checkedHotTags = this.hotTagsList.filter(tag => tag.checked);
let tagIds = checkedHotTags.map(tag => tag.id).join(',');
this.course.tags = tagIds;
} else if (tag.type == 11 || tag.type == 12 || tag.type == 13) {
// 三级分类标签
this.oneList.forEach(one => {
@@ -978,10 +978,10 @@ export default {
});
});
}
// 重置导航标题
this.navTitle = [];
// 触发搜索更新
this.searchData();
},
@@ -1030,6 +1030,21 @@ handleClearTags() {
item.checked = false;
});
this.course.tags = ''; // 清空标签ID
// 添加清除三级分类的逻辑
this.oneList.forEach(one => {
one.checked = false;
one.children.forEach(two => {
two.checked = false;
two.children.forEach(three => {
three.checked = false;
});
});
});
// 清空导航标题
this.navTitle = [];
this.searchData();
},
// 导航切换(录播课,线下课,学习项目)
@@ -1046,12 +1061,12 @@ handleClearTags() {
//点击标签
handleTagClick(item, list) {
item.checked = !item.checked;
// 更新course.tags
const checkedTags = this.hotTagsList.filter(tag => tag.checked);
let tagIds = checkedTags.map(tag => tag.id).join(',');
this.course.tags = tagIds;
// 强制触发stagList重新计算
this.$nextTick(() => {
this.searchData();
@@ -1061,7 +1076,6 @@ handleClearTags() {
handleOptionClick(item, level, list) {
// 线上品牌展示效果
this.newData = item.newData;
console.log(this.newData);
// 单选,排除法
this.oneList.forEach(one => {
one.checked = false;
@@ -1536,7 +1550,18 @@ handleClearTags() {
that.course.sysType3 += item.id;
}
});
apiCourseTag.getHotTagList(that.course).then(rs => {
if (rs.status == 200) {
// 保留已选中标签的状态
const currentCheckedTags = this.hotTagsList.filter(tag => tag.checked);
this.hotTagsList = rs.result.map(tag => ({
...tag,
checked: currentCheckedTags.some(checkedTag => checkedTag.id === tag.id)
}));
} else {
console.log(rs.message);
}
}),
this.isFind = true;
this.course.device = 1;
if (this.course.pageIndex == 1) {