From 7048f96565e8f607f6a60fa38cf5ab34d8f41dd7 Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 22 Nov 2024 13:55:22 +0100 Subject: [PATCH] refactor: refs #8207 imrove logic --- src/components/ui/VnPaginate.vue | 6 +++--- src/composables/useArrayData.js | 11 ++++++++--- src/pages/Monitor/Ticket/MonitorTickets.vue | 8 +------- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/components/ui/VnPaginate.vue b/src/components/ui/VnPaginate.vue index aae18c503..fd8b82395 100644 --- a/src/components/ui/VnPaginate.vue +++ b/src/components/ui/VnPaginate.vue @@ -130,10 +130,10 @@ const addFilter = async (filter, params) => { await arrayData.addFilter({ filter, params }); }; -async function fetch(params) { +async function fetch(params, keepRowsNumber = false) { useArrayData(props.dataKey, params); - arrayData.reset(['filter.skip', 'skip', 'page']); - await arrayData.fetch({ append: false }); + if (!keepRowsNumber) arrayData.reset(['filter.skip', 'skip', 'page']); + await arrayData.fetch({ append: false, keepRowsNumber }); if (!store.hasMoreData) isLoading.value = false; emit('onFetch', store.data); diff --git a/src/composables/useArrayData.js b/src/composables/useArrayData.js index d8ee39355..0588310e7 100644 --- a/src/composables/useArrayData.js +++ b/src/composables/useArrayData.js @@ -64,7 +64,11 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) { } } - async function fetch({ append = false, updateRouter = true, totalRows = null }) { + async function fetch({ + append = false, + updateRouter = true, + keepRowsNumber = false, + }) { if (!store.url) return; cancelRequest(); @@ -107,8 +111,9 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) { if (params.filter.where || exprFilter) params.filter.where = { ...params.filter.where, ...exprFilter }; - if (totalRows) { - params.filter.limit = totalRows; + if (keepRowsNumber) { + const { limit, skip } = store; + params.filter.limit = limit + skip; params.filter.skip = 0; } params.filter = JSON.stringify(params.filter); diff --git a/src/pages/Monitor/Ticket/MonitorTickets.vue b/src/pages/Monitor/Ticket/MonitorTickets.vue index 6bae770d8..380cdf8e1 100644 --- a/src/pages/Monitor/Ticket/MonitorTickets.vue +++ b/src/pages/Monitor/Ticket/MonitorTickets.vue @@ -354,13 +354,7 @@ const openTab = (id) => class="q-mr-sm" dense flat - @click=" - () => { - const { limit, skip } = arrayData.store; - const nlimit = limit + skip; - arrayData.fetch({ totalRows: nlimit }); - } - " + @click="tableRef.CrudModelRef.vnPaginateRef.fetch(undefined, true)" > {{ $t('globals.refresh') }}