[chore] add server side filtering for getDrinks
This commit is contained in:
parent
955f777aac
commit
ab92f16177
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue