This commit is contained in:
van
2026-06-03 12:06:53 +08:00
parent de32ec4a93
commit 75f9a61654
3 changed files with 193 additions and 36 deletions
@@ -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