refactor: refs #8207 imrove logic
gitea/salix-front/pipeline/pr-master This commit looks good Details

This commit is contained in:
Jorge Penadés 2024-11-22 13:55:22 +01:00
parent 50fbf64cf9
commit 7048f96565
3 changed files with 12 additions and 13 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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)"
>
<QTooltip>{{ $t('globals.refresh') }}</QTooltip>
</QBtn>