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) {
|
||||
useArrayData(props.dataKey, params);
|
||||
if (!keepRowsNumber) arrayData.reset(['filter.skip', 'skip', 'page']);
|
||||
await arrayData.fetch({ append: false, keepRowsNumber });
|
||||
const { limit, skip } = arrayData.store;
|
||||
|
||||
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;
|
||||
|
||||
emit('onFetch', store.data);
|
||||
|
|
|
@ -64,11 +64,7 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
|
|||
}
|
||||
}
|
||||
|
||||
async function fetch({
|
||||
append = false,
|
||||
updateRouter = true,
|
||||
keepRowsNumber = false,
|
||||
}) {
|
||||
async function fetch({ append = false, updateRouter = true }) {
|
||||
if (!store.url) return;
|
||||
|
||||
cancelRequest();
|
||||
|
@ -111,11 +107,6 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
|
|||
|
||||
if (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);
|
||||
|
||||
store.isLoading = true;
|
||||
|
|
Loading…
Reference in New Issue