0
0
Fork 0

refactor: refs #8207 add update fn

This commit is contained in:
Jorge Penadés 2024-11-25 12:01:28 +01:00
parent a3f56aaf24
commit a1284cefc2
2 changed files with 18 additions and 13 deletions

View File

@ -130,21 +130,26 @@ const addFilter = async (filter, params) => {
await arrayData.addFilter({ filter, params }); await arrayData.addFilter({ filter, params });
}; };
async function fetch(params, keepPagination = false) { async function fetch(params) {
useArrayData(props.dataKey, params); useArrayData(props.dataKey, params);
arrayData.reset(['filter.skip', 'skip']);
await arrayData.fetch({ append: false });
return emitStoreData();
}
if (!keepPagination) await arrayData.fetch({ append: false }); async function update(params) {
else { useArrayData(props.dataKey, params);
const { limit, skip } = store; const { limit, skip } = store;
store.limit = limit + skip; store.limit = limit + skip;
store.skip = 0; store.skip = 0;
await arrayData.fetch({ append: false }); await arrayData.fetch({ append: false });
store.limit = limit; store.limit = limit;
store.skip = skip; store.skip = skip;
return emitStoreData();
} }
function emitStoreData() {
if (!store.hasMoreData) isLoading.value = false; if (!store.hasMoreData) isLoading.value = false;
emit('onFetch', store.data); emit('onFetch', store.data);
return store.data; return store.data;
} }
@ -190,7 +195,7 @@ async function onLoad(index, done) {
done(isDone); done(isDone);
} }
defineExpose({ fetch, addFilter, paginate }); defineExpose({ fetch, update, addFilter, paginate });
</script> </script>
<template> <template>

View File

@ -352,7 +352,7 @@ const openTab = (id) =>
class="q-mr-sm" class="q-mr-sm"
dense dense
flat flat
@click="tableRef.CrudModelRef.vnPaginateRef.fetch(undefined, true)" @click="tableRef.CrudModelRef.vnPaginateRef.update()"
> >
<QTooltip>{{ $t('globals.refresh') }}</QTooltip> <QTooltip>{{ $t('globals.refresh') }}</QTooltip>
</QBtn> </QBtn>