mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-portal.git
synced 2025-12-11 03:46:44 +08:00
标签清除调试
This commit is contained in:
@@ -228,7 +228,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
//修改:创建新标签
|
//修改:创建新标签 - 修复显示问题
|
||||||
async createNewTag(tagName) {
|
async createNewTag(tagName) {
|
||||||
// 标签不能超过八个字
|
// 标签不能超过八个字
|
||||||
if (tagName.length > 8) {
|
if (tagName.length > 8) {
|
||||||
@@ -272,17 +272,30 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const {result:newTag} = await apiCourseTag.createTag(this.params)
|
const {result:newTag} = await apiCourseTag.createTag(this.params)
|
||||||
this.$message.success('标签创建成功',newTag);
|
this.$message.success('标签创建成功');
|
||||||
|
|
||||||
// 修改:将新标签添加到选中列表和搜索结果中
|
// 修改:将新标签添加到选中列表和搜索结果中
|
||||||
this.selectedTagIds.push(newTag.id);
|
this.selectedTagIds.push(newTag.id);
|
||||||
this.searchResults.push(newTag);
|
|
||||||
this.tagMap.set(newTag.id, newTag);
|
|
||||||
|
|
||||||
console.log("----------newTag---------->",this.searchResults)
|
// 创建完整的标签对象,包含id和tagName
|
||||||
|
const completeTag = {
|
||||||
|
id: newTag.id,
|
||||||
|
tagName: newTag.tagName
|
||||||
|
};
|
||||||
|
|
||||||
|
this.searchResults.push(completeTag);
|
||||||
|
this.tagMap.set(newTag.id, completeTag);
|
||||||
|
|
||||||
|
console.log("----------新创建标签---------->", completeTag)
|
||||||
|
console.log("----------当前选中标签ID---------->", this.selectedTagIds)
|
||||||
|
console.log("----------标签映射表---------->", this.tagMap)
|
||||||
|
|
||||||
// 触发change事件,传递标签对象数组和ID字符串
|
// 触发change事件,传递标签对象数组和ID字符串
|
||||||
this.$emit('change', this.displayTags, this.tagIdsString);
|
this.$emit('change', this.displayTags, this.tagIdsString);
|
||||||
|
|
||||||
|
// 清空输入框
|
||||||
|
this.clearInput();
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
}
|
}
|
||||||
@@ -301,10 +314,16 @@ export default {
|
|||||||
const {result:tags} = await apiCourseTag.searchTags({tagName:query,typeId:typeId})
|
const {result:tags} = await apiCourseTag.searchTags({tagName:query,typeId:typeId})
|
||||||
console.log("-- searchTags 查询结果 tags = " + tags )
|
console.log("-- searchTags 查询结果 tags = " + tags )
|
||||||
|
|
||||||
tags.forEach(item => {
|
// 确保每个标签对象都有完整的属性
|
||||||
|
const completeTags = tags.map(tag => ({
|
||||||
|
id: tag.id,
|
||||||
|
tagName: tag.tagName
|
||||||
|
}));
|
||||||
|
|
||||||
|
completeTags.forEach(item => {
|
||||||
this.tagMap.set(item.id, item)
|
this.tagMap.set(item.id, item)
|
||||||
})
|
})
|
||||||
this.searchResults = tags
|
this.searchResults = completeTags
|
||||||
// 当搜索结果为空时,提示用户可以按回车键创建标签
|
// 当搜索结果为空时,提示用户可以按回车键创建标签
|
||||||
if (tags.length === 0 && query.trim()) {
|
if (tags.length === 0 && query.trim()) {
|
||||||
this.$message.info('无此标签,按回车键创建')
|
this.$message.info('无此标签,按回车键创建')
|
||||||
|
|||||||
Reference in New Issue
Block a user