This commit is contained in:
2026-03-25 15:13:34 +08:00
parent 98649a3bbe
commit e67d520c44
@@ -250,14 +250,26 @@ layout("/layouts/platform.html"){
} }
} catch (e) { } catch (e) {
} }
return text.split(/[,、]/).map(v => v.trim()).filter(Boolean) // Unit names may contain "、" (e.g. in parentheses), so split only by comma.
return text.split(/[,]/).map(v => v.trim()).filter(Boolean)
},
normalizeUnitName(name) {
return (name || "")
.toString()
.replace(/\s+/g, "")
.replace(//g, "(")
.replace(//g, ")")
.trim()
}, },
mapSuggestUnitsToIds(suggestUnits) { mapSuggestUnitsToIds(suggestUnits) {
const unitValues = this.parseSuggestUnits(suggestUnits) const unitValues = this.parseSuggestUnits(suggestUnits)
if (!unitValues.length || !this.underTakeOptions.length) return [] if (!unitValues.length || !this.underTakeOptions.length) return []
const result = [] const result = []
unitValues.forEach(unitVal => { unitValues.forEach(unitVal => {
const matched = this.underTakeOptions.find(item => item.id === unitVal || item.name === unitVal) const normalizedVal = this.normalizeUnitName(unitVal)
const matched = this.underTakeOptions.find(item => {
return item.id === unitVal || this.normalizeUnitName(item.name) === normalizedVal
})
if (matched && !result.includes(matched.id)) { if (matched && !result.includes(matched.id)) {
result.push(matched.id) result.push(matched.id)
} }