refs #7136 $props
This commit is contained in:
parent
d9200ca79f
commit
e638d4496f
|
@ -28,6 +28,10 @@ const $props = defineProps({
|
||||||
type: Number,
|
type: Number,
|
||||||
default: 30,
|
default: 30,
|
||||||
},
|
},
|
||||||
|
skip: {
|
||||||
|
type: Number,
|
||||||
|
default: 0,
|
||||||
|
},
|
||||||
params: {
|
params: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: null,
|
default: null,
|
||||||
|
@ -38,18 +42,19 @@ const emit = defineEmits(['onFetch']);
|
||||||
defineExpose({ fetch, paginate });
|
defineExpose({ fetch, paginate });
|
||||||
|
|
||||||
const arrayData = useArrayData($props.url ?? $props.dataKey, {
|
const arrayData = useArrayData($props.url ?? $props.dataKey, {
|
||||||
|
autoLoad: $props.autoLoad,
|
||||||
url: $props.url,
|
url: $props.url,
|
||||||
filter: $props.filter,
|
filter: $props.filter,
|
||||||
where: $props.where,
|
where: $props.where,
|
||||||
|
sortBy: $props.sortBy,
|
||||||
limit: $props.limit,
|
limit: $props.limit,
|
||||||
order: $props.order,
|
params: $props.params,
|
||||||
userParams: $props.userParams,
|
|
||||||
exprBuilder: $props.exprBuilder,
|
|
||||||
});
|
});
|
||||||
const store = arrayData.store;
|
const store = arrayData.store;
|
||||||
|
|
||||||
const pagination = ref({
|
const pagination = ref({
|
||||||
sortBy: $props.order,
|
sortBy: $props.sortBy,
|
||||||
|
skip: $props.skip,
|
||||||
rowsPerPage: +$props.limit,
|
rowsPerPage: +$props.limit,
|
||||||
page: 1,
|
page: 1,
|
||||||
hasMoreData: true,
|
hasMoreData: true,
|
||||||
|
@ -63,9 +68,11 @@ onMounted(async () => {
|
||||||
|
|
||||||
async function paginate() {
|
async function paginate() {
|
||||||
if (!pagination.value.hasMoreData) return emit('onFetch', []);
|
if (!pagination.value.hasMoreData) return emit('onFetch', []);
|
||||||
|
const skip = pagination.value.page * $props.limit;
|
||||||
|
pagination.value.skip = skip;
|
||||||
await fetch(
|
await fetch(
|
||||||
{
|
{
|
||||||
skip: pagination.value.page * $props.limit,
|
skip,
|
||||||
},
|
},
|
||||||
{ append: true }
|
{ append: true }
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue