From 0a9b9dfb79f20c43fee8711be9ccc00bdc5122ad Mon Sep 17 00:00:00 2001 From: puriphatt Date: Fri, 18 Oct 2024 16:14:19 +0700 Subject: [PATCH] refactor: receipt dialog & type --- src/pages/05_quotation/MainPage.vue | 19 +- src/pages/05_quotation/ReceiptDialog.vue | 310 ++++++++++++++++++----- src/stores/quotations/types.ts | 8 + 3 files changed, 271 insertions(+), 66 deletions(-) diff --git a/src/pages/05_quotation/MainPage.vue b/src/pages/05_quotation/MainPage.vue index 5bf3bee1..66629ec2 100644 --- a/src/pages/05_quotation/MainPage.vue +++ b/src/pages/05_quotation/MainPage.vue @@ -38,6 +38,7 @@ import { } from 'src/pages/03_customer-management/components'; import { useCustomerForm } from 'src/pages/03_customer-management/form'; +import { Quotation } from 'src/stores/quotations/types'; const quotationFormStore = useQuotationForm(); const customerFormStore = useCustomerForm(); @@ -60,6 +61,7 @@ const onCreateImageList = ref<{ selectedImage: string; list: { url: string; imgFile: File | null; name: string }[]; }>({ selectedImage: '', list: [] }); +const currentQuotationPayment = ref(); const pageState = reactive({ hideStat: false, @@ -204,7 +206,8 @@ function triggerQuotationDialog(opts: { window.open(url.toString(), '_blank'); } -function triggerReceiptDialog() { +function triggerReceiptDialog(data: Quotation) { + currentQuotationPayment.value = data; pageState.receiptModal = true; } @@ -528,7 +531,11 @@ async function storeDataLocal(id: string) {
-
+
@@ -940,7 +946,10 @@ async function storeDataLocal(id: string) {
- + diff --git a/src/pages/05_quotation/ReceiptDialog.vue b/src/pages/05_quotation/ReceiptDialog.vue index 2d052067..c1451245 100644 --- a/src/pages/05_quotation/ReceiptDialog.vue +++ b/src/pages/05_quotation/ReceiptDialog.vue @@ -3,9 +3,13 @@ import { storeToRefs } from 'pinia'; import { useConfigStore } from 'stores/config'; import { formatNumberDecimal, commaInput } from 'stores/utils'; import DialogForm from 'src/components/DialogForm.vue'; -import { reactive, ref } from 'vue'; +import { reactive, ref, watch } from 'vue'; +import { useQuotationPayment } from 'src/stores/quotations'; +import { Quotation, QuotationPaymentData } from 'src/stores/quotations/types'; +import { dateFormat } from 'src/utils/datetime'; const configStore = useConfigStore(); +const quotationPayment = useQuotationPayment(); const { data: config } = storeToRefs(configStore); defineEmits<{ @@ -13,15 +17,36 @@ defineEmits<{ }>(); const model = defineModel({ default: false, required: true }); +const data = defineModel('data', { required: true }); + +const paymentData = ref([]); +const payAll = ref(false); const state = reactive({ waitExpansion: true, payExpansion: [] as boolean[], }); -defineProps<{ - urgent?: boolean; -}>(); +function monthDisplay(date: Date | string) { + const arr = dateFormat(date, true).split(' '); + arr.shift(); + return arr.join(' '); +} + +watch( + () => model.value, + async (open) => { + if (!data.value) return; + if (!open) { + paymentData.value = []; + } else { + const ret = await quotationPayment.getQuotationPayment(data.value.id); + if (ret) { + paymentData.value = ret.quotationPaymentData; + } + } + }, +); -
@@ -267,18 +408,29 @@ defineProps<{
ยังไม่พบงาน -
+ -->
- อัปโหลดใบเสร็จ + {{ + $t('general.upload', { + msg: $t('quotation.receiptDialog.slip'), + }) + }}
- อัปโหลด E-Slip หรือ อัปโหลดเอกสารการชำระเงิน + {{ $t('general.upload', { msg: ' E-slip' }) }} + {{ + $t('general.or', { + msg: $t('general.upload', { + msg: $t('quotation.receiptDialog.paymentDocs'), + }), + }) + }} diff --git a/src/stores/quotations/types.ts b/src/stores/quotations/types.ts index 649e54da..520903f3 100644 --- a/src/stores/quotations/types.ts +++ b/src/stores/quotations/types.ts @@ -180,6 +180,7 @@ export type Quotation = { id: string; finalPrice: number; vat: number; + discount: number; totalDiscount: number; totalPrice: number; urgent: boolean; @@ -198,7 +199,14 @@ export type Quotation = { workName: string; code: string; statusOrder: number; + vatExcluded: number; status: Status; + quotationStatus: + | 'PaymentPending' + | 'PaymentInProcess' + | 'PaymentSuccess' + | 'ProcessComplete' + | 'Canceled'; registeredBranchId: string;