commit
This commit is contained in:
+14
-2
@@ -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)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user