[CLEAR-39] Add searching products
This commit is contained in:
parent
95a9f9c664
commit
b5af362a1d
@ -1,5 +1,9 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
|
<Row type="flex" justify="center" style="margin-bottom: 20px">
|
||||||
|
<Input v-model="search" @on-change="debounce" search enter-button="Wyszukaj"
|
||||||
|
placeholder="Szukaj produktu..."/>
|
||||||
|
</Row>
|
||||||
<Table :columns="columns" :border="true" :data="data" :loading="loading"/>
|
<Table :columns="columns" :border="true" :data="data" :loading="loading"/>
|
||||||
<Page @on-change="retrieveProducts" :total="pagination.total" style="margin-top:10px;"/>
|
<Page @on-change="retrieveProducts" :total="pagination.total" style="margin-top:10px;"/>
|
||||||
</div>
|
</div>
|
||||||
@ -40,14 +44,31 @@
|
|||||||
total: 0
|
total: 0
|
||||||
},
|
},
|
||||||
loading: true,
|
loading: true,
|
||||||
|
search: '',
|
||||||
|
debounceTimer: 0,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
resetData() {
|
||||||
|
this.data = [];
|
||||||
|
this.pagination = {total: 0};
|
||||||
|
this.retrieveProducts();
|
||||||
|
},
|
||||||
|
debounce(event) {
|
||||||
|
if (this.debounceTimer !== null) {
|
||||||
|
clearTimeout(this.debounceTimer);
|
||||||
|
}
|
||||||
|
this.debounceTimer = setTimeout(() => {
|
||||||
|
this.search = event.target.value;
|
||||||
|
this.resetData();
|
||||||
|
}, 800);
|
||||||
|
},
|
||||||
retrieveProducts(page = 1) {
|
retrieveProducts(page = 1) {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
this.$axios.get('/product', {
|
this.$axios.get('/product', {
|
||||||
params: {
|
params: {
|
||||||
page: page
|
page: page,
|
||||||
|
search: this.search
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
return {
|
return {
|
||||||
productsListData: null
|
productsListData: null
|
||||||
};
|
};
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user