批量查询领域

This commit is contained in:
2026-04-17 10:56:44 +08:00
parent 8fbcf39a25
commit 7458beb8b2

View File

@@ -191,13 +191,26 @@ export default {
} }
}, },
sortedFilteredFields() { sortedFilteredFields() {
const kw = (this.fieldSearchText || '').trim().toLowerCase(); const kwRaw = String(this.fieldSearchText || '');
const list = (this.availableFields || []).filter((item) => { const normalize = (s) =>
if (!kw) return true; String(s || '')
return String(item.label || '').toLowerCase().includes(kw); .trim()
}); .replace(/\s+/g, ' ')
return list.slice().sort((a, b) => String(a.label || '').localeCompare(String(b.label || ''))); .toLowerCase();
}, const tokens = kwRaw
? kwRaw
.split(/[\r\n,;]+/g)
.map((s) => normalize(s))
.filter(Boolean)
: [];
const list = (this.availableFields || []).filter((item) => {
if (!tokens.length) return true;
const label = normalize(item.label || '');
// 严格匹配:必须与字段名完全一致(忽略大小写与空白差异)
return tokens.some((t) => t === label);
});
return list.slice().sort((a, b) => String(a.label || '').localeCompare(String(b.label || '')));
},
selectedFieldLabels() { selectedFieldLabels() {
const map = {}; const map = {};
(this.availableFields || []).forEach((i) => { map[String(i.id)] = i.label; }); (this.availableFields || []).forEach((i) => { map[String(i.id)] = i.label; });