diff --git a/src/pages/05_quotation/PaymentForm.vue b/src/pages/05_quotation/PaymentForm.vue index 06566ead..5bf0e43e 100644 --- a/src/pages/05_quotation/PaymentForm.vue +++ b/src/pages/05_quotation/PaymentForm.vue @@ -32,6 +32,8 @@ const prop = defineProps<{ isDebitNote?: boolean; }>(); +const firstCodePayment = defineModel('firstCodePayment'); + const refQFile = ref[]>([]); const refQMenu = ref[]>([]); const paymentData = ref([]); @@ -206,10 +208,15 @@ onMounted(async () => { }); if (ret) { paymentData.value = ret.result; - slipFile.value = paymentData.value.map((v) => ({ - paymentId: v.id, - data: [], - })); + slipFile.value = paymentData.value.map((v, i) => { + if (i === 0) { + firstCodePayment.value = v.code; + } + return { + paymentId: v.id, + data: [], + }; + }); } }); diff --git a/src/pages/05_quotation/QuotationForm.vue b/src/pages/05_quotation/QuotationForm.vue index 6d14d322..62adb987 100644 --- a/src/pages/05_quotation/QuotationForm.vue +++ b/src/pages/05_quotation/QuotationForm.vue @@ -196,7 +196,7 @@ const selectedWorkerItem = computed(() => { ]; }); const workerList = ref([]); - +const firstCodePayment = ref(''); const selectedProductGroup = ref(''); const selectedInstallmentNo = ref([]); const installmentAmount = ref(0); @@ -1093,12 +1093,14 @@ watch( // } function storeDataLocal() { - quotationFormData.value.productServiceList = productServiceList.value; + quotationFormData.value.productServiceList = productService.value; localStorage.setItem( 'quotation-preview', JSON.stringify({ data: { + codeInvoice: code.value, + codePayment: firstCodePayment.value, ...quotationFormData.value, productServiceList: productService.value, }, @@ -1939,6 +1941,7 @@ function covertToNode() { view !== View.Complete " :data="quotationFormState.source" + v-model:first-code-payment="firstCodePayment" @fetch-status=" () => { fetchQuotation(); @@ -2105,6 +2108,8 @@ function covertToNode() { installmentAmount = props.row.amount; view = View.Invoice; + + console.log(code); } } " diff --git a/src/pages/05_quotation/preview/ViewForm.vue b/src/pages/05_quotation/preview/ViewForm.vue index 26be292e..0a12408f 100644 --- a/src/pages/05_quotation/preview/ViewForm.vue +++ b/src/pages/05_quotation/preview/ViewForm.vue @@ -86,10 +86,22 @@ const summaryPrice = ref({ finalPrice: 0, }); -async function fetchQuotationById(id: string) { +async function fetchQuotationById(id: string, codeInvoice: string) { const res = await quotationStore.getQuotation(id); + if (res) { + const installmentNo = res.paySplit.find( + (v) => codeInvoice === v.invoice?.code, + )?.no; - if (res) data.value = res; + data.value = { + ...res, + productServiceList: !!installmentNo + ? res.productServiceList.filter( + (v) => installmentNo === v.installmentNo, + ) + : res.productServiceList, + }; + } } async function getAttachment(quotationId: string) { @@ -190,7 +202,8 @@ onMounted(async () => { if (data.value) { if (!!data.value.id) { await getAttachment(data.value.id); - await fetchQuotationById(data.value.id); + if (parsed.data.fetch) + await fetchQuotationById(data.value.id, parsed.data.codeInvoice); } const resCustomerBranch = await customerStore.getBranchById( @@ -203,8 +216,15 @@ onMounted(async () => { agentPrice.value = data.value.agentPrice || parsed?.meta?.agentPrice; + const currentCode = + view.value === View.Invoice + ? parsed.data.codeInvoice + : view.value === View.Payment + ? parsed.data.codePayment + : (parsed?.meta?.source?.code ?? data.value?.code); + details.value = { - code: parsed?.meta?.source?.code ?? data.value?.code, + code: currentCode, createdAt: parsed?.meta?.source?.createdAt ?? new Date(data.value?.createdAt || ''), diff --git a/src/pages/10_invoice/MainPage.vue b/src/pages/10_invoice/MainPage.vue index 5b0274cc..12f20809 100644 --- a/src/pages/10_invoice/MainPage.vue +++ b/src/pages/10_invoice/MainPage.vue @@ -88,12 +88,16 @@ function triggerView(opts: { quotationId: string }) { window.open(url.toString(), '_blank'); } -function viewDocExample(quotationId: string) { +function viewDocExample(quotationId: string, codeInvoice: string) { + console.log(codeInvoice); + localStorage.setItem( 'quotation-preview', JSON.stringify({ data: { id: quotationId, + codeInvoice, + fetch: true, }, }), ); @@ -346,7 +350,7 @@ watch( :rows="data" :grid="pageState.gridView" @view="(quotationId) => triggerView({ quotationId })" - @preview="(quotationId) => viewDocExample(quotationId)" + @preview="(item) => viewDocExample(item.quotation.id, item.code)" >