commit
This commit is contained in:
+14
-2
@@ -250,14 +250,26 @@ layout("/layouts/platform.html"){
|
||||
}
|
||||
} 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) {
|
||||
const unitValues = this.parseSuggestUnits(suggestUnits)
|
||||
if (!unitValues.length || !this.underTakeOptions.length) return []
|
||||
const result = []
|
||||
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)) {
|
||||
result.push(matched.id)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user