fix(05): watch paysplit

This commit is contained in:
puriphatt 2024-10-18 10:13:33 +07:00
parent 5a2a854406
commit 36cabde5bc
2 changed files with 8 additions and 5 deletions

View file

@ -857,7 +857,6 @@ function storeDataLocal() {
:class="{ 'full-height': $q.screen.gt.xs }" :class="{ 'full-height': $q.screen.gt.xs }"
> >
<QuotationFormInfo <QuotationFormInfo
:mode="quotationFormState.mode"
:quotation-no="(quotationFull && quotationFull.code) || ''" :quotation-no="(quotationFull && quotationFull.code) || ''"
v-model:urgent="quotationFormData.urgent" v-model:urgent="quotationFormData.urgent"
:actor="quotationFormState.createdBy?.($i18n.locale) || ''" :actor="quotationFormState.createdBy?.($i18n.locale) || ''"

View file

@ -13,10 +13,9 @@ import SelectInput from 'src/components/shared/SelectInput.vue';
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
import { precisionRound } from 'src/utils/arithmetic'; import { precisionRound } from 'src/utils/arithmetic';
const props = defineProps<{ defineProps<{
readonly?: boolean; readonly?: boolean;
quotationNo?: string; quotationNo?: string;
mode?: null | 'info' | 'create' | 'edit';
data?: { data?: {
total: number; total: number;
discount: number; discount: number;
@ -184,7 +183,7 @@ function installmentsDate(date: Date | string) {
watch( watch(
() => payType.value, () => payType.value,
(v) => { (v) => {
if (props.mode === 'info') return; if (!payType.value) return;
if (v === 'Split' || v === 'BillSplit') { if (v === 'Split' || v === 'BillSplit') {
if (paySplitCount.value === 0) paySplitCount.value = 1; if (paySplitCount.value === 0) paySplitCount.value = 1;
} else { } else {
@ -197,7 +196,12 @@ watch(
watch( watch(
() => [paySplitCount.value, summaryPrice.value.finalPrice], () => [paySplitCount.value, summaryPrice.value.finalPrice],
([newCount, _newF], [oldCount, _oldF]) => { ([newCount, _newF], [oldCount, _oldF]) => {
if (props.mode === 'info' || paySplitCount.value === 0) return; if (
paySplitCount.value === 0 ||
!paySplitCount.value ||
!summaryPrice.value.finalPrice
)
return;
calculateInstallments({ newCount: newCount || 0, oldCount: oldCount || 0 }); calculateInstallments({ newCount: newCount || 0, oldCount: oldCount || 0 });
if (newCount !== oldCount) { if (newCount !== oldCount) {
paySplit.value[0].date && installmentsDate(paySplit.value[0].date); paySplit.value[0].date && installmentsDate(paySplit.value[0].date);