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

View file

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