mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-portal.git
synced 2025-12-16 22:36:43 +08:00
调试
This commit is contained in:
@@ -69,7 +69,8 @@ export default {
|
|||||||
params: {},
|
params: {},
|
||||||
tag: {},
|
tag: {},
|
||||||
// 添加临时存储用于回滚
|
// 添加临时存储用于回滚
|
||||||
previousTags: []
|
previousTags: [],
|
||||||
|
allTags: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -116,8 +117,14 @@ export default {
|
|||||||
sysTypeList: {
|
sysTypeList: {
|
||||||
handler() {
|
handler() {
|
||||||
// 只有在已选择分类且有焦点时才重新加载
|
// 只有在已选择分类且有焦点时才重新加载
|
||||||
if (this.sysTypeList.length > 0 && this.$refs.tagSelect && this.$refs.tagSelect.visible) {
|
// if (this.sysTypeList.length > 0 && this.$refs.tagSelect && this.$refs.tagSelect.visible) {
|
||||||
this.doSearch('');
|
// this.doSearch('');
|
||||||
|
// }
|
||||||
|
if (this.sysTypeList.length > 0) {
|
||||||
|
this.shouldReloadAllTags = true; // 设置重新加载标志
|
||||||
|
if (this.$refs.tagSelect && this.$refs.tagSelect.visible) {
|
||||||
|
this.doSearch(''); // 触发重新加载
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
deep: true
|
deep: true
|
||||||
@@ -284,32 +291,38 @@ export default {
|
|||||||
},
|
},
|
||||||
// 修改doSearch方法,添加搜索结果为空时的提示
|
// 修改doSearch方法,添加搜索结果为空时的提示
|
||||||
async doSearch(query) {
|
async doSearch(query) {
|
||||||
// 不再在空查询时清空搜索结果
|
// 如果是初始化(query为空且allTags为空)或者分类变更后
|
||||||
// if (!query.trim()) {
|
if ((!query && this.allTags.length === 0) || this.shouldReloadAllTags) {
|
||||||
// this.searchResults = []
|
this.loading = true;
|
||||||
// return
|
|
||||||
// }
|
|
||||||
console.log("---- doSearch ------ query = " + query )
|
|
||||||
this.loading = true
|
|
||||||
try {
|
try {
|
||||||
// 获取 typeId:取 sysTypeList 最后一个有效的值
|
|
||||||
const typeId = this.sysTypeList.length > 2 ? this.sysTypeList[2] :
|
const typeId = this.sysTypeList.length > 2 ? this.sysTypeList[2] :
|
||||||
this.sysTypeList.length > 1 ? this.sysTypeList[1] :
|
this.sysTypeList.length > 1 ? this.sysTypeList[1] :
|
||||||
this.sysTypeList.length > 0 ? this.sysTypeList[0] : null;
|
this.sysTypeList.length > 0 ? this.sysTypeList[0] : null;
|
||||||
console.log("---- doSearch searchTags ------ query = " + query + " , typeId = " + typeId )
|
|
||||||
const {result:tags} = await apiCourseTag.searchTags({tagName:query,typeId:typeId})
|
const { result: tags } = await apiCourseTag.searchTags({ tagName: '', typeId: typeId });
|
||||||
console.log("-- searchTags 查询结果 tags = " + tags )
|
|
||||||
|
|
||||||
tags.forEach(item => {
|
tags.forEach(item => {
|
||||||
this.tagMap.set(item.id, item)
|
this.tagMap.set(item.id, item);
|
||||||
})
|
});
|
||||||
this.searchResults = tags
|
|
||||||
// 当搜索结果为空时,提示用户可以按回车键创建标签
|
this.allTags = tags; // 保存所有标签
|
||||||
if (tags.length === 0) {
|
this.searchResults = tags; // 初始显示所有标签
|
||||||
this.$message.info('无此标签,按回车键创建')
|
|
||||||
}
|
this.shouldReloadAllTags = false; // 重置标志位
|
||||||
} finally {
|
} finally {
|
||||||
this.loading = false
|
this.loading = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 本地过滤
|
||||||
|
const filteredTags = this.allTags.filter(tag =>
|
||||||
|
tag.tagName.toLowerCase().includes(query.toLowerCase())
|
||||||
|
);
|
||||||
|
this.searchResults = filteredTags;
|
||||||
|
|
||||||
|
// 当本地过滤结果为空时提示创建
|
||||||
|
if (filteredTags.length === 0 && query) {
|
||||||
|
this.$message.info('无此标签,按回车键创建');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user