diff --git a/src/pages/05_quotation/MainPage.vue b/src/pages/05_quotation/MainPage.vue index c3a3553e..dd37a96e 100644 --- a/src/pages/05_quotation/MainPage.vue +++ b/src/pages/05_quotation/MainPage.vue @@ -56,14 +56,16 @@ import PersonCard from 'src/components/shared/PersonCard.vue'; import { useRouter } from 'vue-router'; import ProductServiceForm from './ProductServiceForm.vue'; -const flowStore = useFlowStore(); - import { useCustomerForm, useEmployeeForm, } from 'src/pages/03_customer-management/form'; import useCustomerStore from 'stores/customer'; +import { useQuotationStore } from 'src/stores/quotations'; +import QuotationView from './QuotationView.vue'; +import { watch } from 'vue'; +const flowStore = useFlowStore(); const tabFieldRequired = ref<{ [key: string]: (keyof CustomerBranchCreate)[] }>( { main: [], @@ -290,13 +292,65 @@ function convertToTree() { // NOTE: this is meant to be used inside getService() and getProduct() before return and after return } +const quotationStore = useQuotationStore(); +const { + data: quotationData, + page: quotationPage, + pageSize: quotationPageSize, + pageMax: quotationPageMax, +} = storeToRefs(quotationStore); + onMounted(async () => { - const ret = await productServiceStore.fetchListProductService({ - page: 1, - pageSize: 9999, - }); - if (ret) productGroup.value = ret.result; + { + const ret = await productServiceStore.fetchListProductService({ + page: 1, + pageSize: 9999, + }); + if (ret) productGroup.value = ret.result; + } + + { + const ret = await quotationStore.getQuotationList({ + page: quotationPage.value, + pageSize: quotationPageSize.value, + }); + + if (ret) { + quotationData.value = ret.result; + quotationPageMax.value = Math.floor(ret.total / quotationPageSize.value); + } + } + + flowStore.rotate(); }); + +watch( + () => pageState.currentTab, + async () => { + const ret = await quotationStore.getQuotationList({ + page: quotationPage.value, + pageSize: quotationPageSize.value, + payCondition: + pageState.currentTab !== 'all' + ? ( + { + fullAmountCash: 'Full', + installmentsCash: 'Split', + fullAmountBill: 'BillFull', + installmentsBill: 'BillSplit', + } as const + )[pageState.currentTab] + : undefined, + }); + + if (ret) { + quotationData.value = ret.result; + quotationPageMax.value = Math.floor(ret.total / quotationPageSize.value); + } + + flowStore.rotate(); + }, +);