diff --git a/src/pages/05_quotation/peview/ViewForm.vue b/src/pages/05_quotation/peview/ViewForm.vue index 24ecc175..a9900a75 100644 --- a/src/pages/05_quotation/peview/ViewForm.vue +++ b/src/pages/05_quotation/peview/ViewForm.vue @@ -9,6 +9,8 @@ import useOptionStore from 'stores/options'; import { formatNumberDecimal } from 'stores/utils'; import { useQuotationForm } from 'pages/05_quotation/form'; import { useConfigStore } from 'stores/config'; +import useBranchStore from 'stores/branch'; +import { baseUrl } from 'stores/utils'; import { commaInput } from 'stores/utils'; // NOTE Import Types @@ -24,6 +26,7 @@ import PrintButton from 'src/components/button/PrintButton.vue'; const quotationForm = useQuotationForm(); const optionStore = useOptionStore(); const configStore = useConfigStore(); +const branchStore = useBranchStore(); const { data: config } = storeToRefs(configStore); @@ -48,6 +51,7 @@ type SummaryPrice = { const note = ref(''); const productList = ref([]); +const bankList = ref([]); const elements = ref([]); const chunks = ref([[]]); @@ -61,21 +65,6 @@ const summaryPrice = ref({ finalPrice: 0, }); -const bankList = ref([ - { - id: 'cm14grwo30003z8chvzouoc87', - currentlyUse: true, - branchId: 'cm14grwo30002z8ch55keto89', - bankUrl: - 'http://192.168.1.61:20102/api/v1/branch/cm14grwo30002z8ch55keto89/bank-qr/cm14grwo30003z8chvzouoc87?ts=1729148488206', - bankName: 'ktb', - bankBranch: 'โรงพยาบาลศิริราชปิยมหาราชการุณย์', - accountType: '', - accountNumber: '1-520-361442-23', - accountName: 'บริษัท สยามเทคโนโลยี จำกัด', - }, -]); - async function assignData() { for (let i = 0; i < productList.value.length; i++) { let el = elements.value.at(-1); @@ -128,7 +117,16 @@ onMounted(async () => { data.value = JSON.parse(sessionStorage.getItem('quotation-preview') || '{}'); - if (data) { + if (data.value) { + const res = await branchStore.fetchById(data.value?.registeredBranchId); + + if (res) { + bankList.value = res.bank.map((v) => ({ + ...v, + bankUrl: `${baseUrl}/branch/${res.id}/bank-qr/${v.id}?ts=${Date.now()}`, + })); + } + productList.value = data.value?.productServiceList.map((v) => ({ id: v.product.id,