From a9d1425f8d658dce15cb16f7902dc16953ceb03a Mon Sep 17 00:00:00 2001 From: Thanaphon Frappet Date: Mon, 7 Oct 2024 16:57:44 +0700 Subject: [PATCH] refactor: submit quotation --- src/pages/05_quotation/QuotationForm.vue | 48 +++++++++++++++++++++++- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/src/pages/05_quotation/QuotationForm.vue b/src/pages/05_quotation/QuotationForm.vue index 2263924e..c14d7cba 100644 --- a/src/pages/05_quotation/QuotationForm.vue +++ b/src/pages/05_quotation/QuotationForm.vue @@ -77,7 +77,10 @@ const ocrStore = useOcrStore(); const { locale } = useI18n(); const $q = useQuasar(); -const { currentFormData: quotationFormData } = storeToRefs(quotationForm); +const { + currentFormData: quotationFormData, + currentFormState: quotationFormState, +} = storeToRefs(quotationForm); const refSelectZoneEmployee = ref>(); const selectedBranchIssuer = ref(''); @@ -157,6 +160,35 @@ const productServiceList = ref< Required[] >([]); +function convertDataToFormSubmit() { + quotationFormData.value.productServiceList = JSON.parse( + JSON.stringify( + productServiceList.value.map((v, i) => ({ + workerIndex: [0, 1], + discount: 1, + amount: 1, + product: v.product, + work: v.work, + service: v.service, + })), + ), + ); + + quotationFormData.value.worker = JSON.parse( + JSON.stringify( + selectedWorker.value.map((v, i) => { + if (v.id === undefined) { + return v; + } else { + return v.id; + } + }), + ), + ); + + quotationForm.submitQuotation(); +} + async function getAllProduct( groupId: string, opts?: { force?: false; page?: number; pageSize?: number }, @@ -311,6 +343,11 @@ onMounted(async () => { quotationFormData.value.customerBranchId = urlParams.get('customerBranchId') || ''; + quotationFormState.value.mode = urlParams.get('statusDialog') as + | 'info' + | 'edit' + | 'create'; + // fetch option const resultOption = await fetch('/option/option.json'); const rawOption = await resultOption.json(); @@ -587,7 +624,14 @@ watch( {{ $t('general.view', { msg: $t('general.example') }) }} - +