diff --git a/src/components/upload-file/UploadFileCard.vue b/src/components/upload-file/UploadFileCard.vue index 2e269d8b..b299c51d 100644 --- a/src/components/upload-file/UploadFileCard.vue +++ b/src/components/upload-file/UploadFileCard.vue @@ -54,10 +54,11 @@ onMounted(() => { @click="$emit('click')" > -
- +
+
{{ name }} - +
+ {{ uploading.loaded @@ -79,7 +80,7 @@ onMounted(() => { /> {{ idle ? `Pending` : progress !== 1 ? `Uploading...` : 'Completed' }} -
+ ('firstCodePayment'); const refQFile = ref[]>([]); const refQMenu = ref[]>([]); const paymentData = ref([]); -const submitPaymentData = ref([]); -const payAll = ref(false); +const formPaymentMethod = ref< + { + id: string; + channel: string | null; + reference: string | null; + account: string | null; + isEdit?: boolean; + }[] +>([]); const paymentStatusOpts = [ { status: 'PaymentInProcess', @@ -188,18 +196,29 @@ async function selectStatus( refQMenu.value[index].hide(); } -async function triggerSubmit() { - submitPaymentData.value.forEach(async (p) => { - const payload: PaymentPayload = { - paymentStatus: p.paymentStatus, - date: new Date(p.date), - amount: p.amount, - }; - await quotationPayment.updateQuotationPayment(p.id, payload); - }); +async function triggerSubmit(id: string) { + const index = paymentData.value.findIndex((p) => p.id === id); + if (index === -1) return; + + const p = paymentData.value[index]; + + const payload: PaymentPayload = { + paymentStatus: p.paymentStatus, + date: new Date(p.date), + amount: p.amount, + account: formPaymentMethod.value[index].account, + channel: formPaymentMethod.value[index].channel, + reference: formPaymentMethod.value[index].reference, + }; + + await quotationPayment.updateQuotationPayment(p.id, payload); + formPaymentMethod.value[index].isEdit = false; + setTimeout(async () => { + await fetchData(); + }, 300); } -onMounted(async () => { +async function fetchData() { if (!prop.data) return; const ret = await quotationPayment.getQuotationPayment({ quotationId: prop.isDebitNote === true ? undefined : prop.data.id, @@ -209,6 +228,13 @@ onMounted(async () => { }); if (ret) { paymentData.value = ret.result; + formPaymentMethod.value = ret.result.map((p, i) => ({ + id: p.id, + channel: p.channel, + reference: p.reference, + account: p.account, + isEdit: formPaymentMethod.value[i]?.isEdit || false, + })); slipFile.value = paymentData.value.map((v, i) => { if (i === 0) { firstCodePayment.value = v.code; @@ -219,474 +245,564 @@ onMounted(async () => { }; }); } +} + +onMounted(async () => { + await fetchData(); });