warmFix_hasMoreData #308
|
@ -1,5 +1,5 @@
|
|||
<script setup>
|
||||
import { onMounted, ref, watch, computed } from 'vue';
|
||||
import { onMounted, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useArrayData } from 'composables/useArrayData';
|
||||
|
||||
|
@ -77,7 +77,6 @@ const arrayData = useArrayData(props.dataKey, {
|
|||
userParams: props.userParams,
|
||||
exprBuilder: props.exprBuilder,
|
||||
});
|
||||
const hasMoreData = computed(() => arrayData.hasMoreData);
|
||||
const store = arrayData.store;
|
||||
|
||||
|
||||
onMounted(() => {
|
||||
|
@ -97,7 +96,7 @@ const addFilter = async (filter, params) => {
|
|||
|
||||
async function fetch() {
|
||||
await arrayData.fetch({ append: false });
|
||||
if (!hasMoreData.value) {
|
||||
if (!arrayData.hasMoreData.value) {
|
||||
isLoading.value = false;
|
||||
}
|
||||
emit('onFetch', store.data);
|
||||
|
@ -110,8 +109,8 @@ async function paginate() {
|
|||
|
||||
isLoading.value = true;
|
||||
await arrayData.loadMore();
|
||||
if (!hasMoreData.value) {
|
||||
if (store.userParamsChanged) hasMoreData.value = true;
|
||||
if (!arrayData.hasMoreData.value) {
|
||||
if (store.userParamsChanged) arrayData.hasMoreData.value = true;
|
||||
store.userParamsChanged = false;
|
||||
endPagination();
|
||||
return;
|
||||
|
@ -142,7 +141,7 @@ async function onLoad(index, done) {
|
|||
|
||||
await paginate();
|
||||
let isDone = false;
|
||||
if (store.userParamsChanged) isDone = !hasMoreData.value;
|
||||
if (store.userParamsChanged) isDone = !arrayData.hasMoreData.value;
|
||||
done(isDone);
|
||||
}
|
||||
|
||||
|
@ -187,7 +186,7 @@ defineExpose({ fetch, addFilter });
|
|||
v-if="store.data"
|
||||
@load="onLoad"
|
||||
:offset="offset"
|
||||
jorgep
commented
Al hacer una copia de la propiedad computed dentro del componente, se puede usar con normalidad la propiedad. Si se quiere hacer arrayData.hasMoreData , hay que añadir .value Si no, no funciona y es muy lioso porque de normal no se hace .value dentro del template. Al hacer una copia de la propiedad computed dentro del componente, se puede usar con normalidad la propiedad. Si se quiere hacer arrayData.hasMoreData , hay que añadir *.value* Si no, no funciona y es muy lioso porque de normal no se hace .value dentro del template.
|
||||
:disable="disableInfiniteScroll || !hasMoreData.value"
|
||||
:disable="disableInfiniteScroll || !arrayData.hasMoreData.value"
|
||||
class="full-width"
|
||||
v-bind="$attrs"
|
||||
>
|
||||
|
@ -197,7 +196,7 @@ defineExpose({ fetch, addFilter });
|
|||
</div>
|
||||
</QInfiniteScroll>
|
||||
<div
|
||||
v-if="!isLoading && hasMoreData.value"
|
||||
v-if="!isLoading && arrayData.hasMoreData.value"
|
||||
class="w-full flex justify-center q-mt-md"
|
||||
>
|
||||
<QBtn color="primary" :label="t('Load more data')" @click="paginate()" />
|
||||
|
|
Loading…
Reference in New Issue
copia de la propiedad computed