refactor: 07 => screen.xs fetch scroll
This commit is contained in:
parent
f559987e0c
commit
508e6d3f5b
1 changed files with 246 additions and 221 deletions
|
|
@ -241,7 +241,7 @@ async function fetchData() {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
data.value = ret.result;
|
$q.screen.xs ? data.value.push(...ret.result) : (data.value = ret.result);
|
||||||
pageMax.value = Math.ceil(ret.total / pageSize.value);
|
pageMax.value = Math.ceil(ret.total / pageSize.value);
|
||||||
pageState.total = ret.total;
|
pageState.total = ret.total;
|
||||||
}
|
}
|
||||||
|
|
@ -316,7 +316,7 @@ watch(
|
||||||
|
|
||||||
<!-- SEC: header content -->
|
<!-- SEC: header content -->
|
||||||
<section class="col surface-1 rounded bordered overflow-hidden">
|
<section class="col surface-1 rounded bordered overflow-hidden">
|
||||||
<div class="column full-height">
|
<div class="column full-height no-wrap">
|
||||||
<header
|
<header
|
||||||
class="row surface-3 justify-between full-width items-center bordered-b"
|
class="row surface-3 justify-between full-width items-center bordered-b"
|
||||||
style="z-index: 1"
|
style="z-index: 1"
|
||||||
|
|
@ -448,6 +448,16 @@ watch(
|
||||||
</article>
|
</article>
|
||||||
|
|
||||||
<article v-else class="col q-pa-md surface-2 scroll full-width">
|
<article v-else class="col q-pa-md surface-2 scroll full-width">
|
||||||
|
<q-infinite-scroll
|
||||||
|
:offset="100"
|
||||||
|
@load="
|
||||||
|
(_, done) => {
|
||||||
|
if ($q.screen.gt.xs || page === pageMax) return;
|
||||||
|
page = page + 1;
|
||||||
|
fetchData().then(() => done(page >= pageMax));
|
||||||
|
}
|
||||||
|
"
|
||||||
|
>
|
||||||
<q-table
|
<q-table
|
||||||
flat
|
flat
|
||||||
bordered
|
bordered
|
||||||
|
|
@ -466,7 +476,11 @@ watch(
|
||||||
style="background-color: hsla(var(--info-bg) / 0.07)"
|
style="background-color: hsla(var(--info-bg) / 0.07)"
|
||||||
:props="props"
|
:props="props"
|
||||||
>
|
>
|
||||||
<q-th v-for="col in props.cols" :key="col.name" :props="props">
|
<q-th
|
||||||
|
v-for="col in props.cols"
|
||||||
|
:key="col.name"
|
||||||
|
:props="props"
|
||||||
|
>
|
||||||
{{ $t(col.label) }}
|
{{ $t(col.label) }}
|
||||||
</q-th>
|
</q-th>
|
||||||
<q-th auto-width />
|
<q-th auto-width />
|
||||||
|
|
@ -637,7 +651,9 @@ watch(
|
||||||
{{ props.row.code }}
|
{{ props.row.code }}
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
<nav class="row q-ml-auto items-center justify-end no-wrap">
|
<nav
|
||||||
|
class="row q-ml-auto items-center justify-end no-wrap"
|
||||||
|
>
|
||||||
<q-btn
|
<q-btn
|
||||||
icon="mdi-eye-outline"
|
icon="mdi-eye-outline"
|
||||||
size="sm"
|
size="sm"
|
||||||
|
|
@ -718,12 +734,21 @@ watch(
|
||||||
</section>
|
</section>
|
||||||
</template>
|
</template>
|
||||||
</q-table>
|
</q-table>
|
||||||
|
<template v-slot:loading>
|
||||||
|
<div
|
||||||
|
v-if="$q.screen.lt.sm && page !== pageMax"
|
||||||
|
class="row justify-center"
|
||||||
|
>
|
||||||
|
<q-spinner-dots color="primary" size="40px" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</q-infinite-scroll>
|
||||||
</article>
|
</article>
|
||||||
|
|
||||||
<!-- SEC: footer content -->
|
<!-- SEC: footer content -->
|
||||||
<footer
|
<footer
|
||||||
class="row justify-between items-center q-px-md q-py-sm surface-2"
|
class="row justify-between items-center q-px-md q-py-sm surface-2"
|
||||||
v-if="pageMax > 0"
|
v-if="pageMax > 0 && $q.screen.gt.xs"
|
||||||
>
|
>
|
||||||
<div class="col-4">
|
<div class="col-4">
|
||||||
<div class="row items-center no-wrap">
|
<div class="row items-center no-wrap">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue