refs #6704: posible fix

This commit is contained in:
Javier Segarra 2024-01-16 08:40:03 +01:00
parent e480b17edc
commit 9daffdfa22
4 changed files with 33 additions and 25 deletions

View File

@ -65,18 +65,6 @@ onMounted(() => {
const isLoading = ref(false);
async function search() {
isLoading.value = true;
const params = { ...userParams.value };
const { params: newParams } = await arrayData.addFilter({ params });
userParams.value = newParams;
if (!props.showAll && !Object.values(params).length) store.data = [];
isLoading.value = false;
emit('search');
}
async function reload() {
isLoading.value = true;
const params = Object.values(userParams.value).filter((param) => param);
@ -87,6 +75,25 @@ async function reload() {
emit('refresh');
}
async function search() {
isLoading.value = true;
const params = { ...userParams.value };
store.pagination = true;
store.filter.skip = 0;
store.skip = 0;
const { params: newParams } = await arrayData.addFilter({ params });
userParams.value = newParams;
if (!props.showAll && !Object.values(params).length) store.data = [];
isLoading.value = false;
emit('search');
}
async function remove(key) {
userParams.value[key] = null;
await search();
emit('remove', key);
}
async function clearFilters() {
isLoading.value = true;
@ -126,11 +133,7 @@ const customTags = computed(() =>
tagsList.value.filter((tag) => (props.customTags || []).includes(tag.label))
);
async function remove(key) {
userParams.value[key] = null;
await search();
emit('remove', key);
}
function formatValue(value) {
if (typeof value === 'boolean') {

View File

@ -81,14 +81,13 @@ const store = arrayData.store;
onMounted(() => {
if (props.autoLoad) fetch();
});
onUnmounted(async ()=>{
arrayData.destroy()
});
watch(
() => props.data,
watch(()=>[props.data, store],
() => {
// store.skip = 0;
store.data = props.data;
if(store.pagination)
paginate()
}
);
@ -187,7 +186,7 @@ async function onLoad(...params) {
v-if="store.data"
@load="onLoad"
:offset="offset"
class="full-width full-height overflow-auto"
class="full-width full-height"
>
<slot name="body" :rows="store.data"></slot>
<div v-if="isLoading" class="info-row q-pa-md text-center">

View File

@ -99,7 +99,10 @@ export function useArrayData(key, userOptions) {
const { limit } = filter;
hasMoreData.value = response.data.length === limit;
if (store.pagination) {
// await loadMore();
store.pagination = false;
}
if (append) {
if (!store.data) store.data = [];
for (const row of response.data) store.data.push(row);
@ -143,7 +146,8 @@ export function useArrayData(key, userOptions) {
store.userParams = userParams;
store.skip = 0;
await fetch({ append: false });
store.filter.skip = 0;
await fetch({ append: false, loadMore: true });
return { filter, params };
}
async function removeFilter({ filter, params }) {

View File

@ -19,6 +19,8 @@ export const useArrayDataStore = defineStore('arrayDataStore', () => {
order: '',
data: ref(),
isLoading: false,
loadMore: false,
pagination: false,
exprBuilder: null,
};
}