Add 10/20/50/100 page-size pagination across treasury list pages.
EOF Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import axios from 'axios';
|
||||
import {
|
||||
Alert as AAlert,
|
||||
@@ -29,10 +29,13 @@ import { api } from '@/lib/api';
|
||||
import type { FinancialAccountDto, FinancialReceivableDto } from '@mento/shared';
|
||||
import MoneyInput from '@/components/MoneyInput.vue';
|
||||
import JalaliDateInput from '@/components/JalaliDateInput.vue';
|
||||
import TreasuryListPagination from '@/components/treasury/TreasuryListPagination.vue';
|
||||
import { toman } from './treasury-format';
|
||||
import { useTreasuryListPaging } from './useTreasuryListPaging';
|
||||
import { useTreasuryMobile } from './useTreasuryMobile';
|
||||
import { formatJalaliNumeric } from '@/lib/jalali';
|
||||
import { parseMoneyNumber } from '@/lib/money';
|
||||
import { PAGE_SIZE_OPTIONS, usePageSize } from '@/lib/pageSize';
|
||||
|
||||
const { Text: ATypographyText } = Typography;
|
||||
const ASelectOption = ASelect.Option;
|
||||
@@ -44,6 +47,25 @@ const accounts = ref<FinancialAccountDto[]>([]);
|
||||
const error = ref('');
|
||||
const ok = ref('');
|
||||
const saving = ref(false);
|
||||
const {
|
||||
page,
|
||||
pageSize,
|
||||
pageSizeOptions,
|
||||
total,
|
||||
pagedRows,
|
||||
onPageSizeChange,
|
||||
showTotal,
|
||||
} = useTreasuryListPaging(() => rows.value, 'treasury.receivables');
|
||||
const installmentPageSize = usePageSize('treasury.receivables-installments', 10);
|
||||
const installmentPageSizeOptions = PAGE_SIZE_OPTIONS.map(String);
|
||||
const installmentTablePagination = computed(() => ({
|
||||
pageSize: installmentPageSize.value,
|
||||
showSizeChanger: true,
|
||||
pageSizeOptions: installmentPageSizeOptions,
|
||||
onShowSizeChange: (_current: number, size: number) => {
|
||||
installmentPageSize.value = size;
|
||||
},
|
||||
}));
|
||||
const form = ref({
|
||||
title: '',
|
||||
partyName: '',
|
||||
@@ -361,7 +383,7 @@ onMounted(() => {
|
||||
<a-divider orientation="right">قراردادها</a-divider>
|
||||
<a-empty v-if="!rows.length" description="قراردادی ثبت نشده است." />
|
||||
<template v-else>
|
||||
<div v-for="row in rows" :key="row.id">
|
||||
<div v-for="row in pagedRows" :key="row.id">
|
||||
<a-flex justify="space-between" align="flex-start" wrap="wrap" :gap="8">
|
||||
<div>
|
||||
<a-typography-text strong>{{ row.title }}</a-typography-text>
|
||||
@@ -372,7 +394,11 @@ onMounted(() => {
|
||||
</div>
|
||||
<a-typography-text strong>{{ toman(row.totalAmount) }}</a-typography-text>
|
||||
</a-flex>
|
||||
<a-list v-if="isMobile" :data-source="row.installments">
|
||||
<a-list
|
||||
v-if="isMobile"
|
||||
:data-source="row.installments"
|
||||
:pagination="installmentTablePagination"
|
||||
>
|
||||
<template #renderItem="{ item }">
|
||||
<a-list-item>
|
||||
<a-card :title="`قسط ${item.position}`" style="width: 100%">
|
||||
@@ -401,7 +427,7 @@ onMounted(() => {
|
||||
v-else
|
||||
:columns="installmentColumns"
|
||||
:data-source="row.installments"
|
||||
:pagination="false"
|
||||
:pagination="installmentTablePagination"
|
||||
row-key="id"
|
||||
:scroll="{ x: true }"
|
||||
>
|
||||
@@ -422,6 +448,14 @@ onMounted(() => {
|
||||
</a-table>
|
||||
<a-divider />
|
||||
</div>
|
||||
<TreasuryListPagination
|
||||
v-model:page="page"
|
||||
:total="total"
|
||||
:page-size="pageSize"
|
||||
:page-size-options="pageSizeOptions"
|
||||
:show-total="showTotal"
|
||||
@update:page-size="onPageSizeChange"
|
||||
/>
|
||||
</template>
|
||||
</a-card>
|
||||
</a-flex>
|
||||
|
||||
Reference in New Issue
Block a user