forked from verdnatura/salix-front
ref #5417 fix autoload and filters
This commit is contained in:
parent
8d28a5f82c
commit
0aefe13935
|
@ -51,7 +51,9 @@ async function search() {
|
|||
}
|
||||
isLoading.value = true;
|
||||
await arrayData.addFilter({ params });
|
||||
if (!props.showAll && !Object.values(params).length) store.data = [];
|
||||
if (!props.showAll && !Object.values(userParams.value).find((param) => param)) {
|
||||
store.data = [];
|
||||
}
|
||||
isLoading.value = false;
|
||||
}
|
||||
|
||||
|
@ -59,7 +61,8 @@ async function reload() {
|
|||
isLoading.value = true;
|
||||
|
||||
await arrayData.fetch({ append: false });
|
||||
if (!props.showAll && !Object.values(userParams.value).length) store.data = [];
|
||||
if (!props.showAll && !Object.values(userParams.value).find((param) => param))
|
||||
store.data = [];
|
||||
isLoading.value = false;
|
||||
emit('refresh');
|
||||
}
|
||||
|
|
|
@ -50,10 +50,6 @@ const props = defineProps({
|
|||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
showAll: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
});
|
||||
|
||||
const emit = defineEmits(['onFetch', 'onPaginate']);
|
||||
|
@ -76,12 +72,7 @@ const arrayData = useArrayData(props.dataKey, {
|
|||
const store = arrayData.store;
|
||||
|
||||
onMounted(() => {
|
||||
if (props.autoLoad) {
|
||||
if (props.showAll) fetch();
|
||||
else if (!props.showAll && Object.values(store.userParams).length) fetch();
|
||||
else if (!props.showAll && !Object.values(store.userParams).length)
|
||||
store.data = [];
|
||||
}
|
||||
if (props.autoLoad) fetch();
|
||||
});
|
||||
|
||||
watch(
|
||||
|
|
|
@ -135,9 +135,8 @@ export function useArrayData(key, userOptions) {
|
|||
await fetch({ append: true });
|
||||
}
|
||||
|
||||
async function refresh(showAll = true) {
|
||||
if (showAll || Object.values(store.userParams).length)
|
||||
await fetch({ append: false });
|
||||
async function refresh() {
|
||||
if (Object.values(store.userParams).length) await fetch({ append: false });
|
||||
}
|
||||
|
||||
function updateStateParams() {
|
||||
|
|
|
@ -144,8 +144,7 @@ function stateColor(row) {
|
|||
order="created DESC"
|
||||
:limit="20"
|
||||
:offset="50"
|
||||
auto-load
|
||||
:show-all="false"
|
||||
:auto-load="!!$route?.query.params"
|
||||
>
|
||||
<template #body="{ rows }">
|
||||
<QTable
|
||||
|
|
|
@ -140,7 +140,6 @@ function isValidNumber(value) {
|
|||
:label="t('globals.confirm')"
|
||||
color="primary"
|
||||
flat
|
||||
@click="save"
|
||||
v-close-popup
|
||||
/>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue