refactor: refs #8207 improve logic
gitea/salix-front/pipeline/pr-master This commit looks good
Details
gitea/salix-front/pipeline/pr-master This commit looks good
Details
This commit is contained in:
parent
0eeb22d40a
commit
661cc0b5ee
|
@ -132,8 +132,17 @@ const addFilter = async (filter, params) => {
|
||||||
|
|
||||||
async function fetch(params, keepRowsNumber = false) {
|
async function fetch(params, keepRowsNumber = false) {
|
||||||
useArrayData(props.dataKey, params);
|
useArrayData(props.dataKey, params);
|
||||||
if (!keepRowsNumber) arrayData.reset(['filter.skip', 'skip', 'page']);
|
const { limit, skip } = arrayData.store;
|
||||||
await arrayData.fetch({ append: false, keepRowsNumber });
|
|
||||||
|
if (keepRowsNumber) {
|
||||||
|
arrayData.store.limit = limit + skip;
|
||||||
|
arrayData.store.skip = 0;
|
||||||
|
}
|
||||||
|
await arrayData.fetch({ append: false });
|
||||||
|
if (keepRowsNumber) {
|
||||||
|
arrayData.store.limit = limit;
|
||||||
|
arrayData.store.skip = skip;
|
||||||
|
}
|
||||||
if (!store.hasMoreData) isLoading.value = false;
|
if (!store.hasMoreData) isLoading.value = false;
|
||||||
|
|
||||||
emit('onFetch', store.data);
|
emit('onFetch', store.data);
|
||||||
|
|
|
@ -64,11 +64,7 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetch({
|
async function fetch({ append = false, updateRouter = true }) {
|
||||||
append = false,
|
|
||||||
updateRouter = true,
|
|
||||||
keepRowsNumber = false,
|
|
||||||
}) {
|
|
||||||
if (!store.url) return;
|
if (!store.url) return;
|
||||||
|
|
||||||
cancelRequest();
|
cancelRequest();
|
||||||
|
@ -111,11 +107,6 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
|
||||||
|
|
||||||
if (params.filter.where || exprFilter)
|
if (params.filter.where || exprFilter)
|
||||||
params.filter.where = { ...params.filter.where, ...exprFilter };
|
params.filter.where = { ...params.filter.where, ...exprFilter };
|
||||||
if (keepRowsNumber) {
|
|
||||||
const { limit, skip } = store;
|
|
||||||
params.filter.limit = limit + skip;
|
|
||||||
params.filter.skip = 0;
|
|
||||||
}
|
|
||||||
params.filter = JSON.stringify(params.filter);
|
params.filter = JSON.stringify(params.filter);
|
||||||
|
|
||||||
store.isLoading = true;
|
store.isLoading = true;
|
||||||
|
|
Loading…
Reference in New Issue