perf: refs #8647 paginate
This commit is contained in:
parent
27691943d3
commit
df39cd4eca
|
@ -146,22 +146,14 @@ const addFilter = async (filter, params) => {
|
|||
};
|
||||
|
||||
async function fetch(params) {
|
||||
if (params) {
|
||||
for (let param in params) {
|
||||
if (params[param]) arrayData.store[param] = params[param];
|
||||
}
|
||||
}
|
||||
if (params) applyParams(params);
|
||||
arrayData.resetPagination();
|
||||
await arrayData.fetch({ append: false });
|
||||
return emitStoreData();
|
||||
}
|
||||
|
||||
async function update(params) {
|
||||
if (params) {
|
||||
for (let param in params) {
|
||||
if (params[param]) arrayData.store[param] = params[param];
|
||||
}
|
||||
}
|
||||
if (params) applyParams(params);
|
||||
const { limit, skip } = store;
|
||||
store.limit = limit + skip;
|
||||
store.skip = 0;
|
||||
|
@ -171,6 +163,12 @@ async function update(params) {
|
|||
return emitStoreData();
|
||||
}
|
||||
|
||||
const applyParams = (params) => {
|
||||
for (let param in params) {
|
||||
if (params[param]) arrayData.store[param] = params[param];
|
||||
}
|
||||
};
|
||||
|
||||
function emitStoreData() {
|
||||
if (!store.hasMoreData) isLoading.value = false;
|
||||
emit('onFetch', store.data);
|
||||
|
|
|
@ -21,6 +21,7 @@ export function useArrayData(key, userOptions) {
|
|||
onMounted(() => {
|
||||
setOptions();
|
||||
reset(['skip']);
|
||||
|
||||
const query = route.query;
|
||||
const searchUrl = store.searchUrl;
|
||||
if (query[searchUrl]) {
|
||||
|
|
Loading…
Reference in New Issue