better meds search

This commit is contained in:
Paul Wilde 2023-03-24 12:05:37 +00:00
parent 9e77272535
commit 2acb73802a

View file

@ -6,13 +6,14 @@
</v-progress-linear> </v-progress-linear>
<v-list> <v-list>
<RecycleScroller class="scroller" <RecycleScroller class="scroller"
:items="meds" :items="filteredMeds"
:item-size="50" :item-size="50"
v-slot="{ item }" v-slot="{ item }"
key-field="id" key-field="id"
> >
<v-list-item @click="setMed(item)"> <v-list-item @click="setMed(item)">
{{ item.med_code }} : {{ item.name }} {{ item.med_code }} : {{ item.name }}
{{ item }}
</v-list-item> </v-list-item>
</RecycleScroller> </RecycleScroller>
</v-list> </v-list>
@ -35,10 +36,21 @@ export default {
created() { created() {
this.allMeds() this.allMeds()
}, },
computed: {
filteredMeds() {
let q = this.med_search.toLowerCase()
if (q == ""){ return this.meds }
let ms = this.meds.filter(m =>
m.name.toLowerCase().includes(q) ||
m.med_code.toLowerCase().includes(q)
)
return ms
}
},
methods: { methods: {
allMeds(){ allMeds(){
this.meds_loading = true this.meds_loading = true
console.log("Searching for " + this.med_search) console.log("All Meds...")
let url = this.$api_url + "/meds/list" let url = this.$api_url + "/meds/list"
axios.get(url) axios.get(url)
.then(resp => { .then(resp => {