Skip to content

Instantly share code, notes, and snippets.

@alimuradov
Created May 11, 2020 17:21
Show Gist options
  • Save alimuradov/4f1977e781e5ed2cbb030516a54d06fc to your computer and use it in GitHub Desktop.
Save alimuradov/4f1977e781e5ed2cbb030516a54d06fc to your computer and use it in GitHub Desktop.
Топчек хелпуй!!!
<template>
<section>
<div class="px-3 py-3 mb-5 mx-auto text-center">
<h1 class="display-5">Поиск лекарств</h1>
<p class="lead">узнать цены и остатки лекарств в наших аптеках</p>
</div>
<div class="mx-auto text-center">
<form id="search" class="mt-5 mb-5">
<div class="row">
<div class="col-lg-8 offset-lg-2">
<input @input="searchEvent" @change="searchEvent" class="form-control form-control-lg" type="text" placeholder="Введите название">
</div>
</div>
</form>
</div>
<div class="col-lg-8 offset-lg-2 mx-auto">
<b-table id="searchResult" head-variant="dark" hover :items="items" :fields="fields"></b-table>
</div>
</section>
</template>
<style>
</style>
<script>
export default {
data () {
return {
// Note 'isActive' is left out and will not appear in the rendered table
fields: [
{
key: 'tovar',
label: 'Наименование',
sortable: true
},
{
key: 'pharmacy',
label: 'Аптека',
sortable: false
},
{
key: 'ost',
label: 'Остаток',
sortable: true
// Variant applies to the whole column, including the header and footer
},
{
key: 'price',
label: 'Цена',
sortable: true
// Variant applies to the whole column, including the header and footer
}
],
items: [
{ tovar: 'Ацикловир-2', pharmacy: 'Агасиева 17', ost: '15', price: '189' },
{ tovar: 'Ингавиин', pharmacy: 'Пушкина', ost: '44', price: '188' },
{ tovar: 'Ципралет', pharmacy: 'Сальмана', ost: '99', price: '588' },
{ tovar: 'Лазолван', pharmacy: 'Хизроева', ost: '5', price: '356' }
]
}
},
methods: {
async searchEvent ({ type, target }) {
if (target.value.length > 3) {
const textStr = target.value
const pills = await this.$axios.$get('http://127.0.0.1:8000/search?q=' + textStr.toUpperCase())
this.data.items = pills
console.log(target.value)
}
}
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment