adminforth 2.4.0-next.125 → 2.4.0-next.126
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/spa/src/afcl/Table.vue +18 -9
- package/package.json +1 -1
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
<i18n-t
|
|
45
45
|
keypath="Showing {from} to {to} of {total}" tag="span" class="afcl-table-pagination-text text-sm font-normal text-lightTablePaginationText dark:text-darkTablePaginationText mb-4 md:mb-0 block w-full md:inline md:w-auto"
|
|
46
46
|
>
|
|
47
|
-
<template #from><span class="font-semibold text-lightTablePaginationNumeration dark:text-darkTablePaginationNumeration">{{ Math.min((currentPage - 1) * props.pageSize + 1,
|
|
48
|
-
<template #to><span class="font-semibold text-lightTablePaginationNumeration dark:text-darkTablePaginationNumeration">{{ Math.min(currentPage * props.pageSize,
|
|
49
|
-
<template #total><span class="font-semibold text-lightTablePaginationNumeration dark:text-darkTablePaginationNumeration">{{
|
|
47
|
+
<template #from><span class="font-semibold text-lightTablePaginationNumeration dark:text-darkTablePaginationNumeration">{{ Math.min((currentPage - 1) * props.pageSize + 1, dataResult.total) }}</span></template>
|
|
48
|
+
<template #to><span class="font-semibold text-lightTablePaginationNumeration dark:text-darkTablePaginationNumeration">{{ Math.min(currentPage * props.pageSize, dataResult.total) }}</span></template>
|
|
49
|
+
<template #total><span class="font-semibold text-lightTablePaginationNumeration dark:text-darkTablePaginationNumeration">{{ dataResult.total }}</span></template>
|
|
50
50
|
</i18n-t>
|
|
51
51
|
|
|
52
52
|
<ul class="afcl-table-pagination-list inline-flex -space-x-px rtl:space-x-reverse text-sm h-8">
|
|
@@ -74,6 +74,8 @@
|
|
|
74
74
|
|
|
75
75
|
<script setup lang="ts">
|
|
76
76
|
import { ref, type Ref, computed } from 'vue';
|
|
77
|
+
import { asyncComputed } from '@vueuse/core';
|
|
78
|
+
import { IconArrowRightOutline, IconArrowLeftOutline } from '@iconify-prerendered/vue-flowbite';
|
|
77
79
|
|
|
78
80
|
const props = withDefaults(
|
|
79
81
|
defineProps<{
|
|
@@ -83,7 +85,7 @@
|
|
|
83
85
|
}[],
|
|
84
86
|
data: {
|
|
85
87
|
[key: string]: any,
|
|
86
|
-
}[],
|
|
88
|
+
}[] | ((offset: number, limit: number) => Promise<{data: {[key: string]: any}[], total: number}>),
|
|
87
89
|
evenHighlights?: boolean,
|
|
88
90
|
pageSize?: number,
|
|
89
91
|
}>(), {
|
|
@@ -94,14 +96,21 @@
|
|
|
94
96
|
|
|
95
97
|
const currentPage = ref(1);
|
|
96
98
|
|
|
99
|
+
const dataResult = asyncComputed( async() => {
|
|
100
|
+
if (typeof props.data === 'function') {
|
|
101
|
+
return await props.data(currentPage.value, props.pageSize);
|
|
102
|
+
}
|
|
103
|
+
const start = (currentPage.value - 1) * props.pageSize;
|
|
104
|
+
const end = start + props.pageSize;
|
|
105
|
+
return { data: props.data.slice(start, end), total: props.data.length };
|
|
106
|
+
});
|
|
107
|
+
|
|
97
108
|
const totalPages = computed(() => {
|
|
98
|
-
return Math.ceil(
|
|
109
|
+
return dataResult.value?.total ? Math.ceil(dataResult.value.total / props.pageSize) : 1;
|
|
99
110
|
});
|
|
100
111
|
|
|
101
|
-
const dataPage =
|
|
102
|
-
|
|
103
|
-
const end = start + props.pageSize;
|
|
104
|
-
return props.data.slice(start, end);
|
|
112
|
+
const dataPage = asyncComputed( async() => {
|
|
113
|
+
return dataResult.value.data;
|
|
105
114
|
});
|
|
106
115
|
|
|
107
116
|
function switchPage(p: number) {
|