refactor: 05 => period.amount

This commit is contained in:
puriphatt 2025-01-23 18:02:21 +07:00
parent 40c018aa32
commit e46f238989
2 changed files with 23 additions and 12 deletions

View file

@ -705,7 +705,7 @@ function handleUpdateProductTable(
newInstallmentNo: number; newInstallmentNo: number;
}, },
) { ) {
handleChangePayType(quotationFormData.value.payCondition); // handleChangePayType(quotationFormData.value.payCondition);
// calc price // calc price
const calc = (c: QuotationPayload['productServiceList'][number]) => { const calc = (c: QuotationPayload['productServiceList'][number]) => {
const originalPrice = c.pricePerUnit || 0; const originalPrice = c.pricePerUnit || 0;

View file

@ -145,7 +145,17 @@ function calculateInstallments(param: {
// }); // });
if (param.newCount === param.oldCount) { if (param.newCount === param.oldCount) {
if (param.customIndex !== undefined && param.customAmount !== undefined) { if (param.customIndex !== undefined && param.customAmount !== undefined) {
paySplit.value[param.customIndex].amount = param.customAmount; // paySplit.value[param.customIndex].amount = param.customAmount;
paySplit.value[param.customIndex].amount = Number(
amount4Show.value[param.customIndex]?.replace(/,/g, ''),
);
if (paySplit.value[param.customIndex].amount % 1 === 0) {
const [, dec] = amount4Show.value[param.customIndex].split('.');
if (!dec) {
amount4Show.value[param.customIndex] += '.00';
}
}
// amount4Show.value[param.customIndex] = param.customAmount.toString(); // amount4Show.value[param.customIndex] = param.customAmount.toString();
} }
} }
@ -191,6 +201,7 @@ watch(
commaInput(payment.amount.toString()), commaInput(payment.amount.toString()),
); );
}, },
{ deep: true },
); );
</script> </script>
@ -322,16 +333,6 @@ watch(
amount4Show[i] += '.00'; amount4Show[i] += '.00';
} }
} }
}
"
@update:model-value="
(v) => {
if (readonly) return;
amount4Show[i] = commaInput(
v?.toString() || '0',
'string',
);
calculateInstallments({ calculateInstallments({
customIndex: i, customIndex: i,
@ -353,6 +354,16 @@ watch(
} }
} }
" "
@update:model-value="
(v) => {
if (readonly) return;
amount4Show[i] = commaInput(
v?.toString() || '0',
'string',
);
}
"
> >
<template #prepend> <template #prepend>
<q-icon name="mdi-cash" color="primary" /> <q-icon name="mdi-cash" color="primary" />