From 9b069fbddd7189cbe29293f62f723c0048c2ad42 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 2 Jan 2024 11:38:43 +0100 Subject: [PATCH] add filter: refs #6606 --- .../InvoiceOut/InvoiceOutNegativeBases.vue | 30 ++++++++++++++----- src/stores/invoiceOutGlobal.js | 4 +-- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/pages/InvoiceOut/InvoiceOutNegativeBases.vue b/src/pages/InvoiceOut/InvoiceOutNegativeBases.vue index 63385380e..7d07b8217 100644 --- a/src/pages/InvoiceOut/InvoiceOutNegativeBases.vue +++ b/src/pages/InvoiceOut/InvoiceOutNegativeBases.vue @@ -174,7 +174,23 @@ const columns = ref([ ]); const downloadCSV = async () => { - await invoiceOutGlobalStore.getNegativeBasesCsv(dateRange.from, dateRange.to); + const params = filter.value; + + const filterParams = { + limit: 20, + where: { + and: [], + }, + }; + for (const param in params) { + if (params[param]) filterParams.where.and.push({ [param]: params[param] }); + } + + await invoiceOutGlobalStore.getNegativeBasesCsv( + dateRange.from, + dateRange.to, + JSON.stringify(filterParams) + ); }; const search = async () => { @@ -187,13 +203,13 @@ const search = async () => { } }); const searchFilter = { - limit: 20 - } + limit: 20, + }; if (and.length) { searchFilter.where = { - and - } + and, + }; } const params = { @@ -230,9 +246,7 @@ const selectWorkerId = (id) => { selectedWorkerId.value = id; }; -onMounted(async () => { - refresh(); -}); +onMounted(() => refresh());