#7136 - Enable paginate event in VnSelectFilter #255
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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),
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Igual deberiamos sustiur el fetch por el fetch de arrayData y tambien al paginar usar el propio de arrayData
Asi duplicamos funcionalidad
Revisado y refactorizado:
38e3e1c004