feat(VnPaginate): refs #8197 hold data when change to Card
This commit is contained in:
parent
907bf3cf3b
commit
68fc565324
|
@ -201,7 +201,7 @@ async function fetchFilter(val) {
|
||||||
const fetchOptions = { where, include, limit };
|
const fetchOptions = { where, include, limit };
|
||||||
if (fields) fetchOptions.fields = fields;
|
if (fields) fetchOptions.fields = fields;
|
||||||
if (sortBy) fetchOptions.order = sortBy;
|
if (sortBy) fetchOptions.order = sortBy;
|
||||||
arrayData.reset(['skip', 'filter.skip', 'page']);
|
arrayData.resetPagination();
|
||||||
|
|
||||||
const { data } = await arrayData.applyFilter({ filter: fetchOptions });
|
const { data } = await arrayData.applyFilter({ filter: fetchOptions });
|
||||||
setOptions(data);
|
setOptions(data);
|
||||||
|
|
|
@ -138,7 +138,7 @@ async function clearFilters() {
|
||||||
try {
|
try {
|
||||||
isLoading.value = true;
|
isLoading.value = true;
|
||||||
store.userParamsChanged = true;
|
store.userParamsChanged = true;
|
||||||
arrayData.reset(['skip', 'filter.skip', 'page']);
|
arrayData.resetPagination();
|
||||||
// Filtrar los params no removibles
|
// Filtrar los params no removibles
|
||||||
const removableFilters = Object.keys(userParams.value).filter((param) =>
|
const removableFilters = Object.keys(userParams.value).filter((param) =>
|
||||||
$props.unremovableParams.includes(param)
|
$props.unremovableParams.includes(param)
|
||||||
|
|
|
@ -104,7 +104,9 @@ onMounted(async () => {
|
||||||
mounted.value = true;
|
mounted.value = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
onBeforeUnmount(() => arrayData.reset());
|
onBeforeUnmount(() => {
|
||||||
|
arrayData.resetPagination();
|
||||||
|
});
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => props.data,
|
() => props.data,
|
||||||
|
@ -132,7 +134,7 @@ const addFilter = async (filter, params) => {
|
||||||
|
|
||||||
async function fetch(params) {
|
async function fetch(params) {
|
||||||
useArrayData(props.dataKey, params);
|
useArrayData(props.dataKey, params);
|
||||||
arrayData.reset(['filter.skip', 'skip', 'page']);
|
arrayData.resetPagination();
|
||||||
await arrayData.fetch({ append: false, updateRouter: mounted.value });
|
await arrayData.fetch({ append: false, updateRouter: mounted.value });
|
||||||
return emitStoreData();
|
return emitStoreData();
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,7 +101,7 @@ onMounted(() => {
|
||||||
|
|
||||||
async function search() {
|
async function search() {
|
||||||
const staticParams = Object.entries(store.userParams);
|
const staticParams = Object.entries(store.userParams);
|
||||||
arrayData.reset(['skip', 'page']);
|
arrayData.resetPagination();
|
||||||
|
|
||||||
const filter = {
|
const filter = {
|
||||||
params: {
|
params: {
|
||||||
|
|
|
@ -142,6 +142,10 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
|
||||||
if (arrayDataStore.get(key)) arrayDataStore.reset(key, opts);
|
if (arrayDataStore.get(key)) arrayDataStore.reset(key, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function resetPagination() {
|
||||||
|
if (arrayDataStore.get(key)) arrayDataStore.resetPagination(key);
|
||||||
|
}
|
||||||
|
|
||||||
function cancelRequest() {
|
function cancelRequest() {
|
||||||
if (canceller) {
|
if (canceller) {
|
||||||
canceller.abort();
|
canceller.abort();
|
||||||
|
@ -165,7 +169,7 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
|
||||||
userParams = sanitizerParams(userParams, store?.exprBuilder);
|
userParams = sanitizerParams(userParams, store?.exprBuilder);
|
||||||
|
|
||||||
store.userParams = userParams;
|
store.userParams = userParams;
|
||||||
reset(['skip', 'filter.skip', 'page']);
|
resetPagination();
|
||||||
|
|
||||||
await fetch({});
|
await fetch({});
|
||||||
return { filter, params };
|
return { filter, params };
|
||||||
|
@ -192,7 +196,7 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
|
||||||
}
|
}
|
||||||
|
|
||||||
store.order = order;
|
store.order = order;
|
||||||
reset(['skip', 'filter.skip', 'page']);
|
resetPagination();
|
||||||
fetch({});
|
fetch({});
|
||||||
index++;
|
index++;
|
||||||
|
|
||||||
|
@ -275,7 +279,6 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
|
||||||
const pushUrl = { path: to };
|
const pushUrl = { path: to };
|
||||||
if (to.endsWith('/list') || to.endsWith('/'))
|
if (to.endsWith('/list') || to.endsWith('/'))
|
||||||
pushUrl.query = newUrl.query;
|
pushUrl.query = newUrl.query;
|
||||||
else destroy();
|
|
||||||
return router.push(pushUrl);
|
return router.push(pushUrl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -302,5 +305,6 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
|
||||||
isLoading,
|
isLoading,
|
||||||
deleteOption,
|
deleteOption,
|
||||||
reset,
|
reset,
|
||||||
|
resetPagination,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import VnSearchbar from 'components/ui/VnSearchbar.vue';
|
||||||
import AccountSummary from './Card/AccountSummary.vue';
|
import AccountSummary from './Card/AccountSummary.vue';
|
||||||
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
|
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
|
||||||
import VnCardMain from 'src/components/common/VnCardMain.vue';
|
import VnCardMain from 'src/components/common/VnCardMain.vue';
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const { viewSummary } = useSummaryDialog();
|
const { viewSummary } = useSummaryDialog();
|
||||||
const tableRef = ref();
|
const tableRef = ref();
|
||||||
|
@ -117,7 +118,6 @@ const exprBuilder = (param, value) => {
|
||||||
</template>
|
</template>
|
||||||
<template #body>
|
<template #body>
|
||||||
<VnTable
|
<VnTable
|
||||||
:style="{ display: !!$route.name.endsWith('List') ? '' : 'none' }"
|
|
||||||
ref="tableRef"
|
ref="tableRef"
|
||||||
:data-key="dataKey"
|
:data-key="dataKey"
|
||||||
:url="url"
|
:url="url"
|
||||||
|
|
|
@ -4,5 +4,5 @@ import AccountDescriptor from './AccountDescriptor.vue';
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<VnCard data-key="Account" :descriptor="AccountDescriptor" />
|
<VnCard data-key="AccountId" :descriptor="AccountDescriptor" />
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -41,7 +41,7 @@ const hasAccount = ref(false);
|
||||||
/>
|
/>
|
||||||
<CardDescriptor
|
<CardDescriptor
|
||||||
ref="descriptor"
|
ref="descriptor"
|
||||||
:url="`VnUsers/preview`"
|
url="VnUsers/preview"
|
||||||
:filter="filter"
|
:filter="filter"
|
||||||
module="Account"
|
module="Account"
|
||||||
@on-fetch="setData"
|
@on-fetch="setData"
|
||||||
|
|
|
@ -49,10 +49,16 @@ export const useArrayDataStore = defineStore('arrayDataStore', () => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function resetPagination(key) {
|
||||||
|
reset(key, ['skip', 'filter.skip', 'page']);
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
state,
|
||||||
get,
|
get,
|
||||||
set,
|
set,
|
||||||
clear,
|
clear,
|
||||||
reset,
|
reset,
|
||||||
|
resetPagination,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue