From 00e8782ca5a0ab87acca1262b4a6b679a1556d04 Mon Sep 17 00:00:00 2001 From: puriphatt Date: Tue, 4 Feb 2025 09:53:07 +0700 Subject: [PATCH] refactor: 10 => enhance infinite scroll functionality and improve TableInvoice component structure --- src/pages/10_invoice/MainPage.vue | 164 +++++++++++++++----------- src/pages/10_invoice/TableInvoice.vue | 8 +- 2 files changed, 98 insertions(+), 74 deletions(-) diff --git a/src/pages/10_invoice/MainPage.vue b/src/pages/10_invoice/MainPage.vue index 165bf911..5b0274cc 100644 --- a/src/pages/10_invoice/MainPage.vue +++ b/src/pages/10_invoice/MainPage.vue @@ -16,10 +16,8 @@ import QuotationCard from 'src/components/05_quotation/QuotationCard.vue'; import { useNavigator } from 'src/stores/navigator'; import { columns, hslaColors } from './constants'; import useFlowStore from 'src/stores/flow'; -import { useRequestList } from 'src/stores/request-list'; import { useInvoice } from 'src/stores/payment'; import { Invoice, PaymentDataStatus } from 'src/stores/payment/types'; -import { Quotation } from 'src/stores/quotations'; const $q = useQuasar(); const navigatorStore = useNavigator(); @@ -60,7 +58,7 @@ async function fetchList(opts?: { rotateFlowId?: boolean }) { debitNoteOnly: false, }); if (ret) { - data.value = ret.result; + data.value = $q.screen.xs ? [...data.value, ...ret.result] : ret.result; pageState.total = ret.total; pageMax.value = Math.ceil(ret.total / pageSize.value); } @@ -122,9 +120,12 @@ watch( () => pageState.inputSearch, () => pageState.statusFilter, () => pageSize.value, - () => page.value, ], - () => fetchList({ rotateFlowId: true }), + () => { + page.value = 1; + data.value = []; + fetchList({ rotateFlowId: true }); + }, );