From 859c6b7961c24c29cefd9dad28d17575eebdfebc Mon Sep 17 00:00:00 2001 From: Methapon Metanipat Date: Fri, 18 Oct 2024 12:32:55 +0700 Subject: [PATCH] feat: add additional info to preview --- src/pages/05_quotation/MainPage.vue | 7 ++++++- src/pages/05_quotation/QuotationForm.vue | 7 ++++++- src/pages/05_quotation/peview/ViewForm.vue | 6 ++++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/pages/05_quotation/MainPage.vue b/src/pages/05_quotation/MainPage.vue index 514c25c5..8a76b618 100644 --- a/src/pages/05_quotation/MainPage.vue +++ b/src/pages/05_quotation/MainPage.vue @@ -281,7 +281,12 @@ async function storeDataLocal(id: string) { localStorage.setItem( 'quotation-preview', - JSON.stringify(quotationFormData.value), + JSON.stringify({ + data: quotationFormData.value, + meta: { + createdBy: quotationFormState.value.createdBy('tha'), + }, + }), ); window.open('/quotation/document-view', '_blank'); diff --git a/src/pages/05_quotation/QuotationForm.vue b/src/pages/05_quotation/QuotationForm.vue index 39bf691d..45414cf6 100644 --- a/src/pages/05_quotation/QuotationForm.vue +++ b/src/pages/05_quotation/QuotationForm.vue @@ -619,7 +619,12 @@ async function searchEmployee(text: string) { function storeDataLocal() { localStorage.setItem( 'quotation-preview', - JSON.stringify(quotationFormData.value), + JSON.stringify({ + data: quotationFormData.value, + meta: { + createdBy: quotationFormState.value.createdBy('tha'), + }, + }), ); window.open('/quotation/document-view', '_blank'); diff --git a/src/pages/05_quotation/peview/ViewForm.vue b/src/pages/05_quotation/peview/ViewForm.vue index e88d8f52..eb833ae0 100644 --- a/src/pages/05_quotation/peview/ViewForm.vue +++ b/src/pages/05_quotation/peview/ViewForm.vue @@ -115,7 +115,9 @@ onMounted(async () => { delete localStorage['quotation-preview']; - data.value = JSON.parse(sessionStorage.getItem('quotation-preview') || '{}'); + const parsed = JSON.parse(sessionStorage.getItem('quotation-preview') || ''); + + data.value = 'data' in parsed ? parsed.data : undefined; if (data.value) { const res = await branchStore.fetchById(data.value?.registeredBranchId); @@ -149,7 +151,7 @@ onMounted(async () => { })) || []; } - summaryPrice.value = obj.productServiceList.reduce( + summaryPrice.value = (data.value?.productServiceList || []).reduce( (a, c) => { const price = precisionRound((c.pricePerUnit || 0) * c.amount); const vat = precisionRound(