Commit 063779ea by Jaxon

fix(remoteSearchSelect): 替换blur事件为visible-change以支持多选

在多选模式下,@blur事件无法正常响应。使用@visible-change事件替代,仅在弹窗关闭时(e为false)执行原有的失焦逻辑,包括清空搜索值并重新获取选项。
1 parent e1e3b319
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
:value="value" :value="value"
v-bind="selectProps" v-bind="selectProps"
v-on="selectEvent" v-on="selectEvent"
@blur="handleSelectBlur" @visible-change="handleVisibleChange"
@change="handleSelectChange"> @change="handleSelectChange">
<el-option v-for="subItem in localOptions" <el-option v-for="subItem in localOptions"
:key="subItem[fieldName.value]" :key="subItem[fieldName.value]"
...@@ -206,10 +206,12 @@ export default { ...@@ -206,10 +206,12 @@ export default {
this.$listeners.change(e); this.$listeners.change(e);
} }
}, },
async handleVisibleChange(e) {
async handleSelectBlur() { // 在多选的情况下 @blur响应不了 用这个替代
if (!e) {
// 失焦时, 检查 query.searchValue的内容. 如果有值 // 失焦时, 检查 query.searchValue的内容. 如果有值
// 需要去掉searchValue 重新获取默认的options // 需要去掉searchValue 重新获取默认的options
console.log("失焦?", this.pageQuery.searchValue);
if (this.pageQuery.searchValue) { if (this.pageQuery.searchValue) {
console.log("重新获取默认的options"); console.log("重新获取默认的options");
this.pageQuery.searchValue = ""; this.pageQuery.searchValue = "";
...@@ -221,8 +223,8 @@ export default { ...@@ -221,8 +223,8 @@ export default {
if (isFunction(this.$listeners?.blur)) { if (isFunction(this.$listeners?.blur)) {
this.$listeners.blur(); this.$listeners.blur();
} }
}
}, },
isFunction, isFunction,
async loadMore() { async loadMore() {
if (this.loading) { if (this.loading) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!