diff --git a/src/components/ui/VnPaginate.vue b/src/components/ui/VnPaginate.vue index fd8b82395..66d5c11a5 100644 --- a/src/components/ui/VnPaginate.vue +++ b/src/components/ui/VnPaginate.vue @@ -132,8 +132,17 @@ const addFilter = async (filter, params) => { async function fetch(params, keepRowsNumber = false) { useArrayData(props.dataKey, params); - if (!keepRowsNumber) arrayData.reset(['filter.skip', 'skip', 'page']); - await arrayData.fetch({ append: false, keepRowsNumber }); + const { limit, skip } = arrayData.store; + + if (keepRowsNumber) { + arrayData.store.limit = limit + skip; + arrayData.store.skip = 0; + } + await arrayData.fetch({ append: false }); + if (keepRowsNumber) { + arrayData.store.limit = limit; + arrayData.store.skip = skip; + } if (!store.hasMoreData) isLoading.value = false; emit('onFetch', store.data); diff --git a/src/composables/useArrayData.js b/src/composables/useArrayData.js index 0588310e7..b37fa1377 100644 --- a/src/composables/useArrayData.js +++ b/src/composables/useArrayData.js @@ -64,11 +64,7 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) { } } - async function fetch({ - append = false, - updateRouter = true, - keepRowsNumber = false, - }) { + async function fetch({ append = false, updateRouter = true }) { if (!store.url) return; cancelRequest(); @@ -111,11 +107,6 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) { if (params.filter.where || exprFilter) params.filter.where = { ...params.filter.where, ...exprFilter }; - if (keepRowsNumber) { - const { limit, skip } = store; - params.filter.limit = limit + skip; - params.filter.skip = 0; - } params.filter = JSON.stringify(params.filter); store.isLoading = true;