|
|
|
|
@ -54,8 +54,8 @@ export default { |
|
|
|
|
}, |
|
|
|
|
title:{ |
|
|
|
|
type: String, |
|
|
|
|
default: '新增', |
|
|
|
|
}, |
|
|
|
|
default: '新增' |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
data() { |
|
|
|
|
return { |
|
|
|
|
@ -69,7 +69,6 @@ export default { |
|
|
|
|
dropdownVisible: false, |
|
|
|
|
bindTimer: null, |
|
|
|
|
total: 0, |
|
|
|
|
isSearching: false, // 加这一行 |
|
|
|
|
}; |
|
|
|
|
}, |
|
|
|
|
watch: { |
|
|
|
|
@ -101,14 +100,7 @@ export default { |
|
|
|
|
let timeout = null; |
|
|
|
|
return (...args) => { |
|
|
|
|
clearTimeout(timeout); |
|
|
|
|
// 过滤无效参数,只保留字符串/数字类型 |
|
|
|
|
const validArgs = args |
|
|
|
|
.map(arg => { |
|
|
|
|
if (arg && arg.target) return arg.target.value; // 兼容事件对象 |
|
|
|
|
return arg; |
|
|
|
|
}) |
|
|
|
|
.filter(arg => arg != null); |
|
|
|
|
timeout = setTimeout(() => func.apply(this, validArgs), wait); |
|
|
|
|
timeout = setTimeout(() => func.apply(this, args), wait); |
|
|
|
|
}; |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
@ -180,25 +172,7 @@ export default { |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
handleSearch(val) { |
|
|
|
|
// 万能处理:不管传什么,最终一定拿到纯字符串 |
|
|
|
|
let searchVal = ''; |
|
|
|
|
|
|
|
|
|
// 处理 InputEvent 事件对象 |
|
|
|
|
if (val && typeof val === 'object' && val.target) { |
|
|
|
|
searchVal = (val.target.value || '').trim(); |
|
|
|
|
} |
|
|
|
|
// 处理正常字符串 |
|
|
|
|
else { |
|
|
|
|
searchVal = String(val || '').trim(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 赋值搜索文本 |
|
|
|
|
this.searchText = searchVal; |
|
|
|
|
this.localValue = searchVal; |
|
|
|
|
|
|
|
|
|
// 关键:只要执行了搜索,永远禁止回显! |
|
|
|
|
this.isSearching = true; |
|
|
|
|
|
|
|
|
|
this.searchText = val; |
|
|
|
|
this.reset(); |
|
|
|
|
this.debounceSearch(); |
|
|
|
|
}, |
|
|
|
|
@ -255,10 +229,9 @@ export default { |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
async initEcho() { |
|
|
|
|
if (this.isSearching || this.searchText) return; |
|
|
|
|
const val = this.localValue; |
|
|
|
|
// (!val || !this.echoApi)&& |
|
|
|
|
if (this.title === '新增' || !val) return; |
|
|
|
|
if (this.title=='新增') return; |
|
|
|
|
|
|
|
|
|
// 处理多选(数组) |
|
|
|
|
if (this.multiple && Array.isArray(val)) { |
|
|
|
|
|