mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-portal.git
synced 2025-12-16 14:26:43 +08:00
标签清除调试
This commit is contained in:
@@ -69,8 +69,7 @@ export default {
|
|||||||
params: {},
|
params: {},
|
||||||
tag: {},
|
tag: {},
|
||||||
// 添加临时存储用于回滚
|
// 添加临时存储用于回滚
|
||||||
previousTags: [],
|
previousTags: []
|
||||||
justCreatedTag: false
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -212,8 +211,6 @@ export default {
|
|||||||
const input = this.$refs.tagSelect.$refs.input;
|
const input = this.$refs.tagSelect.$refs.input;
|
||||||
if (input) {
|
if (input) {
|
||||||
input.value = '';
|
input.value = '';
|
||||||
// 触发input事件确保组件状态更新
|
|
||||||
// input.dispatchEvent(new Event('input'));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -259,30 +256,12 @@ 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('标签创建成功',newTag);
|
||||||
|
|
||||||
// 将新标签添加到搜索结果中
|
|
||||||
this.searchResults.unshift(newTag); // 使用unshift添加到前面
|
|
||||||
this.tagMap.set(newTag.id, newTag)
|
|
||||||
|
|
||||||
this.selectedTags.push(newTag);
|
this.selectedTags.push(newTag);
|
||||||
this.$emit('change', this.selectedTags)
|
this.searchResults.push(newTag)
|
||||||
|
|
||||||
this.clearInput();
|
console.log("----------newTag---------->",this.searchResults)
|
||||||
// 重新打开下拉框显示新创建的标签
|
this.tagMap.set(newTag.id, newTag)
|
||||||
this.$nextTick(() => {
|
this.$emit('change', this.displayTags)
|
||||||
if (this.$refs.tagSelect) {
|
|
||||||
// 手动打开下拉框
|
|
||||||
this.$refs.tagSelect.focus();
|
|
||||||
// 设置一个标记,避免立即关闭
|
|
||||||
this.justCreatedTag = true;
|
|
||||||
setTimeout(() => {
|
|
||||||
this.justCreatedTag = false;
|
|
||||||
}, 100);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
} catch (error) {
|
|
||||||
this.$message.error('标签创建失败');
|
|
||||||
console.error('创建标签失败:', error);
|
|
||||||
} finally {
|
} finally {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user