mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-portal.git
synced 2025-12-07 01:46:42 +08:00
标签输入框下拉调整
This commit is contained in:
@@ -11,11 +11,12 @@
|
|||||||
:remote-method="debouncedSearch"
|
:remote-method="debouncedSearch"
|
||||||
:loading="loading"
|
:loading="loading"
|
||||||
:disabled="sysTypeList.length===0"
|
:disabled="sysTypeList.length===0"
|
||||||
:placeholder="sysTypeList.length === 0 ? '请先选择课程分类' : '请输入标签名称'"
|
:placeholder="'请输入标签名称'"
|
||||||
@remove-tag="handleTagRemove"
|
@remove-tag="handleTagRemove"
|
||||||
@change="handleSelectionChange"
|
@change="handleSelectionChange"
|
||||||
@keyup.enter.native="handleEnterKey"
|
@keyup.enter.native="handleEnterKey"
|
||||||
@keyup.delete.native="handleDeleteKey"
|
@keyup.delete.native="handleDeleteKey"
|
||||||
|
@focus="handleFocus"
|
||||||
ref="tagSelect"
|
ref="tagSelect"
|
||||||
>
|
>
|
||||||
<el-option
|
<el-option
|
||||||
@@ -108,9 +109,26 @@ export default {
|
|||||||
newVal.forEach(tag => {
|
newVal.forEach(tag => {
|
||||||
if (tag.id) this.tagMap.set(tag.id, tag);
|
if (tag.id) this.tagMap.set(tag.id, tag);
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
// 监听分类变化,重新加载搜索结果
|
||||||
|
sysTypeList: {
|
||||||
|
handler() {
|
||||||
|
// 只有在已选择分类且有焦点时才重新加载
|
||||||
|
if (this.sysTypeList.length > 0 && this.$refs.tagSelect && this.$refs.tagSelect.visible) {
|
||||||
|
this.doSearch('');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
deep: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
// 新增:处理输入框获得焦点事件
|
||||||
|
async handleFocus() {
|
||||||
|
// 当输入框获得焦点时,加载默认的搜索结果
|
||||||
|
if (this.sysTypeList.length > 0) {
|
||||||
|
await this.doSearch('');
|
||||||
|
}
|
||||||
|
},
|
||||||
// 新增:重置标签状态的方法
|
// 新增:重置标签状态的方法
|
||||||
resetTagState() {
|
resetTagState() {
|
||||||
this.selectedTags = [];
|
this.selectedTags = [];
|
||||||
@@ -202,10 +220,11 @@ export default {
|
|||||||
},
|
},
|
||||||
// 修改doSearch方法,添加搜索结果为空时的提示
|
// 修改doSearch方法,添加搜索结果为空时的提示
|
||||||
async doSearch(query) {
|
async doSearch(query) {
|
||||||
if (!query.trim()) {
|
// 不再在空查询时清空搜索结果
|
||||||
this.searchResults = []
|
// if (!query.trim()) {
|
||||||
return
|
// this.searchResults = []
|
||||||
}
|
// return
|
||||||
|
// }
|
||||||
|
|
||||||
this.loading = true
|
this.loading = true
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user