From 3e1b545d2aace752d6e08c1cff1d25ef100f2125 Mon Sep 17 00:00:00 2001 From: 670788339 <670788339@qq.com> Date: Thu, 30 Oct 2025 19:42:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=87=E7=AD=BE=E8=BE=93=E5=85=A5=E6=A1=86?= =?UTF-8?q?=E4=B8=8B=E6=8B=89=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Course/courseTag.vue | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/src/components/Course/courseTag.vue b/src/components/Course/courseTag.vue index b02dcc98..71e5e628 100644 --- a/src/components/Course/courseTag.vue +++ b/src/components/Course/courseTag.vue @@ -11,11 +11,12 @@ :remote-method="debouncedSearch" :loading="loading" :disabled="sysTypeList.length===0" - :placeholder="sysTypeList.length === 0 ? '请先选择课程分类' : '请输入标签名称'" + :placeholder="'请输入标签名称'" @remove-tag="handleTagRemove" @change="handleSelectionChange" @keyup.enter.native="handleEnterKey" @keyup.delete.native="handleDeleteKey" + @focus="handleFocus" ref="tagSelect" > { 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: { + // 新增:处理输入框获得焦点事件 + async handleFocus() { + // 当输入框获得焦点时,加载默认的搜索结果 + if (this.sysTypeList.length > 0) { + await this.doSearch(''); + } + }, // 新增:重置标签状态的方法 resetTagState() { this.selectedTags = []; @@ -202,10 +220,11 @@ export default { }, // 修改doSearch方法,添加搜索结果为空时的提示 async doSearch(query) { - if (!query.trim()) { - this.searchResults = [] - return - } + // 不再在空查询时清空搜索结果 + // if (!query.trim()) { + // this.searchResults = [] + // return + // } this.loading = true try {