1
This commit is contained in:
@@ -356,25 +356,33 @@ export default {
|
||||
if (!base) return ''
|
||||
return prefix ? base + prefix : base
|
||||
},
|
||||
fullModelFromOption(o) {
|
||||
if (!o) return ''
|
||||
const base = String(o.modelNumber || '').trim()
|
||||
const shop = String(o.modelShop || '').trim()
|
||||
if (!base) return shop
|
||||
if (!shop) return base
|
||||
if (base.endsWith(shop)) return base
|
||||
return base + shop
|
||||
},
|
||||
queryModels(queryString, cb) {
|
||||
const q = (queryString || '').trim().toLowerCase()
|
||||
const rows = this.modelOptions
|
||||
.filter(o => {
|
||||
const m = String(o.modelNumber || '').trim()
|
||||
if (!m) return false
|
||||
const full = this.fullModelFromOption(o)
|
||||
if (!full) return false
|
||||
if (!q) return true
|
||||
const parsed = this.parseModelWithShop(m)
|
||||
return m.toLowerCase().includes(q) || parsed.base.toLowerCase().includes(q)
|
||||
const parsed = this.parseModelWithShop(full)
|
||||
return full.toLowerCase().includes(q) || parsed.base.toLowerCase().includes(q)
|
||||
})
|
||||
.slice(0, 100)
|
||||
cb(
|
||||
rows.map(o => {
|
||||
const full = String(o.modelNumber).trim()
|
||||
const full = this.fullModelFromOption(o)
|
||||
const parsed = this.parseModelWithShop(full)
|
||||
const displayBase = parsed.base || full
|
||||
return {
|
||||
value: full,
|
||||
label: this.modelOptionLabel({ ...o, modelNumber: displayBase })
|
||||
label: this.modelOptionLabel({ ...o, modelNumber: parsed.base || full })
|
||||
}
|
||||
})
|
||||
)
|
||||
@@ -383,8 +391,13 @@ export default {
|
||||
onModelSuggestionSelect(item) {
|
||||
if (!item || !item.value) return
|
||||
const key = String(item.value).trim()
|
||||
this.applyModelWithShop(key)
|
||||
const hit = this.modelOptions.find(o => o && String(o.modelNumber || '').trim() === key)
|
||||
const hit = this.modelOptions.find(o => this.fullModelFromOption(o) === key)
|
||||
if (hit && hit.modelShop) {
|
||||
this.form.model = String(hit.modelNumber || '').trim()
|
||||
this.form.shopPrefix = String(hit.modelShop || '').trim()
|
||||
} else {
|
||||
this.applyModelWithShop(key)
|
||||
}
|
||||
if (!hit) return
|
||||
const payRaw = hit.lastPaymentAmount
|
||||
const rebateRaw = hit.lastRebateAmount
|
||||
|
||||
Reference in New Issue
Block a user