fix: reset quotation split and split count

This commit is contained in:
puriphatt 2024-11-26 10:42:23 +07:00
parent db0e43ddbb
commit 1b37bc21a1
2 changed files with 35 additions and 17 deletions

View file

@ -136,6 +136,9 @@ const refSelectZoneEmployee = ref<InstanceType<typeof SelectZone>>();
const mrz = ref<Awaited<ReturnType<typeof parseResultMRZ>>>();
const toggleWorker = ref(true);
const tempPaySplitCount = ref(0);
const tempPaySplit = ref<
{ no: number; amount: number; name?: string; invoice?: boolean }[]
>([]);
const currentQuotationId = ref<string | undefined>(undefined);
const date = ref();
const preSelectedWorker = ref<Employee[]>([]);
@ -371,6 +374,10 @@ async function fetchQuotation() {
const id = currentQuotationId.value || quotationFormData.value.id || '';
await quotationForm.assignFormData(id, quotationFormState.value.mode);
tempPaySplitCount.value = quotationFormData.value.paySplitCount || 0;
tempPaySplit.value = JSON.parse(
JSON.stringify(quotationFormData.value.paySplit),
);
}
await assignToProductServiceList();
@ -697,6 +704,9 @@ function convertToTable(nodes: Node[]) {
}).finalPrice,
}));
tempPaySplit.value = JSON.parse(
JSON.stringify(quotationFormData.value.paySplit),
);
pageState.productServiceModal = false;
}
@ -960,10 +970,6 @@ function getStatus(
doneIndex: number,
doingIndex: number,
) {
console.log(
status,
QUOTATION_STATUS.findIndex((v) => v === status),
);
return QUOTATION_STATUS.findIndex((v) => v === status) >= doneIndex
? 'done'
: QUOTATION_STATUS.findIndex((v) => v === status) >= doingIndex
@ -1402,7 +1408,8 @@ async function getWorkerFromCriteria(
<QuotationFormInfo
:view="view"
:installment-no="selectedInstallmentNo"
:pay-split-fixed="tempPaySplitCount"
:pay-split-count-fixed="tempPaySplitCount"
:pay-split-fixed="tempPaySplit"
v-model:pay-type="quotationFormData.payCondition"
v-model:pay-bank="payBank"
v-model:pay-split-count="quotationFormData.paySplitCount"
@ -1701,15 +1708,17 @@ async function getWorkerFromCriteria(
</q-expansion-item>
</template>
<QuotationFormReceipt
v-if="view === View.Receipt"
v-for="(v, i) in receiptList"
:amount="v.amount"
:date="v.date"
:pay-type="quotationFormData.payCondition"
:index="i"
:pay-split-count="quotationFormData.paySplitCount || 0"
/>
<template v-if="view === View.Receipt">
<QuotationFormReceipt
v-for="(v, i) in receiptList"
:key="i"
:amount="v.amount"
:date="v.date"
:pay-type="quotationFormData.payCondition"
:index="i"
:pay-split-count="quotationFormData.paySplitCount || 0"
/>
</template>
</div>
</section>
</article>

View file

@ -19,7 +19,13 @@ const props = defineProps<{
readonly?: boolean;
quotationNo?: string;
installmentNo?: number[];
paySplitFixed?: number;
paySplitCountFixed?: number;
paySplitFixed?: {
no: number;
amount: number;
name?: string;
invoice?: boolean;
}[];
view?: View;
data?: {
total: number;
@ -156,8 +162,9 @@ function calculateInstallments(param: {
watch(
() => payType.value,
(v) => {
if (v === 'Split' && props.paySplitFixed) {
paySplitCount.value = props.paySplitFixed;
if (v === 'Split' && props.paySplitCountFixed && props.paySplitFixed) {
paySplitCount.value = props.paySplitCountFixed;
paySplit.value = JSON.parse(JSON.stringify(props.paySplitFixed));
}
},
);
@ -276,6 +283,8 @@ watch(
:model-value="commaInput(period.amount.toString())"
dense
outlined
debounce="500"
@focus="(e) => (e.target as HTMLInputElement).select()"
@update:model-value="
(v) => {
if (typeof v === 'string') amount4Show[i] = commaInput(v);