update bugs
This commit is contained in:
parent
520e239741
commit
fe46f18d60
6 changed files with 198 additions and 203 deletions
|
|
@ -269,41 +269,11 @@ const handleLazyLoad = async (event) => {
|
|||
});
|
||||
}
|
||||
|
||||
// Clear cache when filters or sorting are active to ensure fresh data
|
||||
const hasActiveFilters = Object.keys(filters).length > 0;
|
||||
const hasActiveSorting = event.sortField && event.sortOrder;
|
||||
if (hasActiveFilters || hasActiveSorting) {
|
||||
paginationStore.clearTableCache("clients");
|
||||
}
|
||||
|
||||
// For cache key, use primary sort field/order for compatibility
|
||||
const primarySortField = filtersStore.getPrimarySortField("clients") || event.sortField;
|
||||
const primarySortOrder = filtersStore.getPrimarySortOrder("clients") || event.sortOrder;
|
||||
|
||||
// Check cache first
|
||||
const cachedData = paginationStore.getCachedPage(
|
||||
"clients",
|
||||
paginationParams.page,
|
||||
paginationParams.pageSize,
|
||||
primarySortField,
|
||||
primarySortOrder,
|
||||
filters,
|
||||
);
|
||||
|
||||
if (cachedData) {
|
||||
// Use cached data
|
||||
tableData.value = cachedData.records;
|
||||
totalRecords.value = cachedData.totalRecords;
|
||||
paginationStore.setTotalRecords("clients", cachedData.totalRecords);
|
||||
|
||||
console.log("Loaded from cache:", {
|
||||
records: cachedData.records.length,
|
||||
total: cachedData.totalRecords,
|
||||
page: paginationParams.page + 1,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// Always fetch fresh data from API (cache only stores pagination/filter/sort state, not data)
|
||||
// Call API with pagination, filters, and sorting in backend format
|
||||
console.log("Making API call with:", {
|
||||
paginationParams,
|
||||
|
|
@ -325,19 +295,6 @@ const handleLazyLoad = async (event) => {
|
|||
|
||||
// Update pagination store with new total
|
||||
paginationStore.setTotalRecords("clients", result.pagination.total);
|
||||
// Cache the result using primary sort for compatibility
|
||||
paginationStore.setCachedPage(
|
||||
"clients",
|
||||
paginationParams.page,
|
||||
paginationParams.pageSize,
|
||||
primarySortField,
|
||||
primarySortOrder,
|
||||
filters,
|
||||
{
|
||||
records: result.data,
|
||||
totalRecords: result.pagination.total,
|
||||
},
|
||||
);
|
||||
} catch (error) {
|
||||
console.error("Error loading client data:", error);
|
||||
// You could also show a toast or other error notification here
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue