diff --git a/src/components/jh-select/index.vue b/src/components/jh-select/index.vue index 74c421f3..33894491 100644 --- a/src/components/jh-select/index.vue +++ b/src/components/jh-select/index.vue @@ -52,10 +52,10 @@ export default { type: String, default: '', // 默认查询字段是 id,可自定义 }, - title:{ + title: { type: String, - default: '新增' - } + default: '新增', + }, }, data() { return { @@ -69,6 +69,7 @@ export default { dropdownVisible: false, bindTimer: null, total: 0, + isSearching: false, // 加这一行 }; }, watch: { @@ -100,7 +101,14 @@ export default { let timeout = null; return (...args) => { clearTimeout(timeout); - timeout = setTimeout(() => func.apply(this, args), wait); + // 过滤无效参数,只保留字符串/数字类型 + 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); }; }, @@ -172,7 +180,25 @@ export default { }, handleSearch(val) { - this.searchText = 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.reset(); this.debounceSearch(); }, @@ -210,7 +236,7 @@ export default { // 新增:通过接口获取完整数据 async getEchoData(val) { try { - const params = { [this.echoParamsKey]: val==null?'':val }; + const params = { [this.echoParamsKey]: val == null ? '' : val }; let res; if (this.echoMethod.toLowerCase() === 'post') { res = await axios.post(this.echoApi, params); @@ -229,9 +255,10 @@ export default { }, async initEcho() { + if (this.isSearching || this.searchText) return; const val = this.localValue; // (!val || !this.echoApi)&& - if (this.title=='新增') return; + if (this.title === '新增' || !val) return; // 处理多选(数组) if (this.multiple && Array.isArray(val)) { diff --git a/src/views/oem/oemCustomer/setCraftAbility.vue b/src/views/oem/oemCustomer/setCraftAbility.vue index 00118923..558f699e 100644 --- a/src/views/oem/oemCustomer/setCraftAbility.vue +++ b/src/views/oem/oemCustomer/setCraftAbility.vue @@ -1,7 +1,13 @@