diff --git a/src/components/FetchData.vue b/src/components/FetchData.vue index 42299e4ff..285a3e30d 100644 --- a/src/components/FetchData.vue +++ b/src/components/FetchData.vue @@ -79,22 +79,18 @@ async function paginate() { pagination.value.page += 1; } -async function fetch(fetchFilter = {}, options = { append: false }) { +async function fetch(fetchFilter = {}) { try { - const filter = Object.assign(fetchFilter, $props.filter); // eslint-disable-line vue/no-dupe-keys + const filter = Object.assign(fetchFilter, $props.filter, $props.params); // eslint-disable-line vue/no-dupe-keys if ($props.where && !fetchFilter.where) filter.where = $props.where; if ($props.sortBy) filter.order = $props.sortBy; if ($props.limit) filter.limit = $props.limit; if ($props.skip) filter.skip = $props.skip; - const { data } = await axios.get($props.url, { - params: { filter: JSON.stringify(filter), ...$props.params }, - }); - pagination.value.hasMoreData = data.length === pagination.value.rowsPerPage; + await arrayData.applyFilter(filter); - if (options.append) { - store.data.push(...data); - } else store.data = data; + const { data } = store; + pagination.value.hasMoreData = data.length === pagination.value.rowsPerPage; emit('onFetch', data); diff --git a/src/components/common/VnSelectFilter.vue b/src/components/common/VnSelectFilter.vue index 7c44cc706..c1f203b3e 100644 --- a/src/components/common/VnSelectFilter.vue +++ b/src/components/common/VnSelectFilter.vue @@ -60,7 +60,7 @@ const $props = defineProps({ }, limit: { type: [Number, String], - default: '4', + default: '30', }, fetchRef: { type: Object, @@ -161,9 +161,8 @@ watch(modelValue, (newValue) => { const isLoading = ref(false); async function onScroll(scrollEv) { - const { to, ref, direction } = scrollEv; + const { to, direction } = scrollEv; const lastIndex = myOptions.value.length - 1; - const optionIndex = ref.getOptionIndex(); if (!$props.url && !$props.fetchRef) return; if (direction === 'decrease') return; diff --git a/src/composables/useArrayData.js b/src/composables/useArrayData.js index 093806567..79d5b7fa6 100644 --- a/src/composables/useArrayData.js +++ b/src/composables/useArrayData.js @@ -80,8 +80,7 @@ export function useArrayData(key, userOptions) { exprFilter = where ? { where } : null; } - Object.assign(filter, store.userFilter, exprFilter); - Object.assign(store.filter, filter); + Object.assign(store.filter, filter, store.userFilter, exprFilter); const params = { filter: JSON.stringify(store.filter), };