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) {
|
async function fetch(params) {
|
||||||
if (params) {
|
if (params) applyParams(params);
|
||||||
for (let param in params) {
|
|
||||||
if (params[param]) arrayData.store[param] = params[param];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
arrayData.resetPagination();
|
arrayData.resetPagination();
|
||||||
await arrayData.fetch({ append: false });
|
await arrayData.fetch({ append: false });
|
||||||
return emitStoreData();
|
return emitStoreData();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function update(params) {
|
async function update(params) {
|
||||||
if (params) {
|
if (params) applyParams(params);
|
||||||
for (let param in params) {
|
|
||||||
if (params[param]) arrayData.store[param] = params[param];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const { limit, skip } = store;
|
const { limit, skip } = store;
|
||||||
store.limit = limit + skip;
|
store.limit = limit + skip;
|
||||||
store.skip = 0;
|
store.skip = 0;
|
||||||
|
@ -171,6 +163,12 @@ async function update(params) {
|
||||||
return emitStoreData();
|
return emitStoreData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const applyParams = (params) => {
|
||||||
|
for (let param in params) {
|
||||||
|
if (params[param]) arrayData.store[param] = params[param];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
function emitStoreData() {
|
function emitStoreData() {
|
||||||
if (!store.hasMoreData) isLoading.value = false;
|
if (!store.hasMoreData) isLoading.value = false;
|
||||||
emit('onFetch', store.data);
|
emit('onFetch', store.data);
|
||||||
|
|
|
@ -21,6 +21,7 @@ export function useArrayData(key, userOptions) {
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
setOptions();
|
setOptions();
|
||||||
reset(['skip']);
|
reset(['skip']);
|
||||||
|
|
||||||
const query = route.query;
|
const query = route.query;
|
||||||
const searchUrl = store.searchUrl;
|
const searchUrl = store.searchUrl;
|
||||||
if (query[searchUrl]) {
|
if (query[searchUrl]) {
|
||||||
|
|
Loading…
Reference in New Issue