This commit is contained in:
cun-nan 2024-10-22 10:29:38 +08:00
parent cdb9262c12
commit 0d5d6ff11d

View File

@ -57,35 +57,22 @@ export default {
return val.id return val.id
}, },
async querySearch1(queryString, cb) { async querySearch1(queryString, cb) {
await this.getUnitList(); const restaurants = this.unitList
let _this = this; let results
let obj = {};
let results = _this.unitList
if (queryString) { if (queryString) {
_this.unitList.forEach(item => { results = restaurants.filter(this.createFilter(queryString))
results = []; }else {
if (item.unitName.includes(queryString)) { results = restaurants
obj = item;
obj.value = `${item.unitName}${item.personCredit} ${item.contactMobile}`
results.push(obj)
return;
}
if (item.personCredit.includes(queryString)) {
obj = item;
obj.value = `${item.unitName}${item.personCredit} ${item.contactMobile}`
results.push(obj)
return;
}
if (item.contactMobile.includes(queryString)) {
obj = item;
obj.value = `${item.unitName}${item.personCredit} ${item.contactMobile}`
results.push(obj)
return;
}
})
} }
console.log(results,68)
cb(results); cb(results);
}, },
createFilter(queryString) {
return (restaurant) => {
return (restaurant.unitName.toLowerCase().indexOf(queryString.toLowerCase()) === 0)
}
},
changeAmount(){ changeAmount(){
this.$emit('changeAmount',this.ruleForm) this.$emit('changeAmount',this.ruleForm)
this.$forceUpdate() this.$forceUpdate()