[chore] add server side filtering for getDrinks

This commit is contained in:
Tim Gröger 2021-11-13 13:24:02 +01:00
parent 955f777aac
commit ab92f16177
2 changed files with 14 additions and 5 deletions

View File

@ -8,10 +8,10 @@
row-key="id"
grid
:loading="loading"
:filter="search"
@request="onRequest"
>
<!--
:filter="search"
:filter-method="filter"
-->
<template #top-right>
@ -328,7 +328,7 @@ export default defineComponent({
});
return retVal;
},
filterable: true,
filterable: false,
sortable: false,
public: false,
},
@ -393,10 +393,10 @@ export default defineComponent({
const loading = ref(false);
async function onRequest(props: { pagination: PaginationInterface; filter?: string }) {
async function onRequest(props: { pagination: PaginationInterface; filter?: Search }) {
const { page, rowsPerPage, sortBy, descending } = props.pagination;
loading.value = true;
console.log('search_keys', search_keys);
const fetchCount = rowsPerPage === 0 ? pagination.value.rowsNumber : rowsPerPage;
const startRow = (page - 1) * rowsPerPage;
try {
@ -404,6 +404,8 @@ export default defineComponent({
offset: startRow,
limit: fetchCount,
descending,
search_name: props.filter.value,
search_key: props.filter.key,
});
pagination.value.page = page;
pagination.value.rowsPerPage = rowsPerPage;

View File

@ -138,8 +138,15 @@ export const usePricelistStore = defineStore({
this.extraIngredients.splice(index, 1);
}
},
async getDrinks(filter: { limit?: number; offset?: number; descending?: boolean }) {
async getDrinks(filter: {
limit?: number;
offset?: number;
descending?: boolean;
search_name?: string;
search_key?: string;
}) {
if (!filter) filter = { limit: 10 };
console.log('filter_api', filter);
const { data } = await api.get<Array<FG.Drink>>('pricelist/drinks', {
params: filter,
});