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 }"
>
<QuotationFormInfo
:mode="quotationFormState.mode"
:quotation-no="(quotationFull && quotationFull.code) || ''"
v-model:urgent="quotationFormData.urgent"
:actor="quotationFormState.createdBy?.($i18n.locale) || ''"

View file

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