|
|
|
@ -9,6 +9,7 @@ import {
|
|
|
|
|
extractSdkResponseErrorMsg, |
|
|
|
|
getHTMLEncodedText, |
|
|
|
|
useApi, |
|
|
|
|
useGlobal, |
|
|
|
|
useI18n, |
|
|
|
|
useNuxtApp, |
|
|
|
|
useProject, |
|
|
|
@ -44,7 +45,9 @@ export function useViewData(
|
|
|
|
|
|
|
|
|
|
const { t } = useI18n() |
|
|
|
|
const { api, isLoading, error } = useApi() |
|
|
|
|
const _paginationData = ref<PaginatedType>({ page: 1, pageSize: 25 }) |
|
|
|
|
const { appInfo } = $(useGlobal()) |
|
|
|
|
const appInfoDefaultLimit = appInfo.defaultLimit || 25 |
|
|
|
|
const _paginationData = ref<PaginatedType>({ page: 1, pageSize: appInfoDefaultLimit }) |
|
|
|
|
const aggCommentCount = ref<{ row_id: string; count: number }[]>([]) |
|
|
|
|
const galleryData = ref<GalleryType>() |
|
|
|
|
const formColumnData = ref<FormType>() |
|
|
|
@ -79,8 +82,8 @@ export function useViewData(
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
const queryParams = computed(() => ({ |
|
|
|
|
offset: ((paginationData.value?.page ?? 0) - 1) * (paginationData.value?.pageSize ?? 25), |
|
|
|
|
limit: paginationData.value?.pageSize ?? 25, |
|
|
|
|
offset: ((paginationData.value.page ?? 0) - 1) * (paginationData.value.pageSize ?? appInfoDefaultLimit), |
|
|
|
|
limit: paginationData.value.pageSize ?? appInfoDefaultLimit, |
|
|
|
|
where: where?.value ?? '', |
|
|
|
|
})) |
|
|
|
|
|
|
|
|
@ -116,9 +119,9 @@ export function useViewData(
|
|
|
|
|
// total records in the current table
|
|
|
|
|
const count = paginationData.value?.totalRows ?? Infinity |
|
|
|
|
// the number of rows in a page
|
|
|
|
|
const size = paginationData.value?.pageSize ?? 25 |
|
|
|
|
const size = paginationData.value.pageSize ?? appInfoDefaultLimit |
|
|
|
|
// the current page number
|
|
|
|
|
const currentPage = paginationData.value?.page ?? 1 |
|
|
|
|
const currentPage = paginationData.value.page ?? 1 |
|
|
|
|
// the maximum possible page given the current count and the size
|
|
|
|
|
const mxPage = Math.ceil(count / size) |
|
|
|
|
// calculate targetPage where 1 <= targetPage <= mxPage
|
|
|
|
@ -263,7 +266,7 @@ export function useViewData(
|
|
|
|
|
|
|
|
|
|
async function changePage(page: number) { |
|
|
|
|
paginationData.value.page = page |
|
|
|
|
await loadData({ offset: (page - 1) * (paginationData.value.pageSize || 25), where: where?.value } as any) |
|
|
|
|
await loadData({ offset: (page - 1) * (paginationData.value.pageSize || appInfoDefaultLimit), where: where?.value } as any) |
|
|
|
|
$e('a:grid:pagination') |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|