fix: installment force push
Some checks failed
Spell Check / Spell Check with Typos (push) Failing after 8s

This commit is contained in:
Thanaphon Frappet 2025-03-06 11:14:11 +07:00
parent e6f2a8df4e
commit 87de5b48ac
6 changed files with 52 additions and 17 deletions

View file

@ -32,6 +32,8 @@ const prop = defineProps<{
isDebitNote?: boolean; isDebitNote?: boolean;
}>(); }>();
const firstCodePayment = defineModel<string>('firstCodePayment');
const refQFile = ref<InstanceType<typeof QFile>[]>([]); const refQFile = ref<InstanceType<typeof QFile>[]>([]);
const refQMenu = ref<InstanceType<typeof QMenu>[]>([]); const refQMenu = ref<InstanceType<typeof QMenu>[]>([]);
const paymentData = ref<QuotationPaymentData[]>([]); const paymentData = ref<QuotationPaymentData[]>([]);
@ -206,10 +208,15 @@ onMounted(async () => {
}); });
if (ret) { if (ret) {
paymentData.value = ret.result; paymentData.value = ret.result;
slipFile.value = paymentData.value.map((v) => ({ slipFile.value = paymentData.value.map((v, i) => {
paymentId: v.id, if (i === 0) {
data: [], firstCodePayment.value = v.code;
})); }
return {
paymentId: v.id,
data: [],
};
});
} }
}); });
</script> </script>

View file

@ -196,7 +196,7 @@ const selectedWorkerItem = computed(() => {
]; ];
}); });
const workerList = ref<Employee[]>([]); const workerList = ref<Employee[]>([]);
const firstCodePayment = ref('');
const selectedProductGroup = ref(''); const selectedProductGroup = ref('');
const selectedInstallmentNo = ref<number[]>([]); const selectedInstallmentNo = ref<number[]>([]);
const installmentAmount = ref<number>(0); const installmentAmount = ref<number>(0);
@ -1093,12 +1093,14 @@ watch(
// } // }
function storeDataLocal() { function storeDataLocal() {
quotationFormData.value.productServiceList = productServiceList.value; quotationFormData.value.productServiceList = productService.value;
localStorage.setItem( localStorage.setItem(
'quotation-preview', 'quotation-preview',
JSON.stringify({ JSON.stringify({
data: { data: {
codeInvoice: code.value,
codePayment: firstCodePayment.value,
...quotationFormData.value, ...quotationFormData.value,
productServiceList: productService.value, productServiceList: productService.value,
}, },
@ -1939,6 +1941,7 @@ function covertToNode() {
view !== View.Complete view !== View.Complete
" "
:data="quotationFormState.source" :data="quotationFormState.source"
v-model:first-code-payment="firstCodePayment"
@fetch-status=" @fetch-status="
() => { () => {
fetchQuotation(); fetchQuotation();
@ -2105,6 +2108,8 @@ function covertToNode() {
installmentAmount = props.row.amount; installmentAmount = props.row.amount;
view = View.Invoice; view = View.Invoice;
console.log(code);
} }
} }
" "

View file

@ -86,10 +86,22 @@ const summaryPrice = ref<SummaryPrice>({
finalPrice: 0, finalPrice: 0,
}); });
async function fetchQuotationById(id: string) { async function fetchQuotationById(id: string, codeInvoice: string) {
const res = await quotationStore.getQuotation(id); const res = await quotationStore.getQuotation(id);
if (res) {
const installmentNo = res.paySplit.find(
(v) => codeInvoice === v.invoice?.code,
)?.no;
if (res) data.value = res; data.value = {
...res,
productServiceList: !!installmentNo
? res.productServiceList.filter(
(v) => installmentNo === v.installmentNo,
)
: res.productServiceList,
};
}
} }
async function getAttachment(quotationId: string) { async function getAttachment(quotationId: string) {
@ -190,7 +202,8 @@ onMounted(async () => {
if (data.value) { if (data.value) {
if (!!data.value.id) { if (!!data.value.id) {
await getAttachment(data.value.id); await getAttachment(data.value.id);
await fetchQuotationById(data.value.id); if (parsed.data.fetch)
await fetchQuotationById(data.value.id, parsed.data.codeInvoice);
} }
const resCustomerBranch = await customerStore.getBranchById( const resCustomerBranch = await customerStore.getBranchById(
@ -203,8 +216,15 @@ onMounted(async () => {
agentPrice.value = data.value.agentPrice || parsed?.meta?.agentPrice; agentPrice.value = data.value.agentPrice || parsed?.meta?.agentPrice;
const currentCode =
view.value === View.Invoice
? parsed.data.codeInvoice
: view.value === View.Payment
? parsed.data.codePayment
: (parsed?.meta?.source?.code ?? data.value?.code);
details.value = { details.value = {
code: parsed?.meta?.source?.code ?? data.value?.code, code: currentCode,
createdAt: createdAt:
parsed?.meta?.source?.createdAt ?? parsed?.meta?.source?.createdAt ??
new Date(data.value?.createdAt || ''), new Date(data.value?.createdAt || ''),

View file

@ -88,12 +88,16 @@ function triggerView(opts: { quotationId: string }) {
window.open(url.toString(), '_blank'); window.open(url.toString(), '_blank');
} }
function viewDocExample(quotationId: string) { function viewDocExample(quotationId: string, codeInvoice: string) {
console.log(codeInvoice);
localStorage.setItem( localStorage.setItem(
'quotation-preview', 'quotation-preview',
JSON.stringify({ JSON.stringify({
data: { data: {
id: quotationId, id: quotationId,
codeInvoice,
fetch: true,
}, },
}), }),
); );
@ -346,7 +350,7 @@ watch(
:rows="data" :rows="data"
:grid="pageState.gridView" :grid="pageState.gridView"
@view="(quotationId) => triggerView({ quotationId })" @view="(quotationId) => triggerView({ quotationId })"
@preview="(quotationId) => viewDocExample(quotationId)" @preview="(item) => viewDocExample(item.quotation.id, item.code)"
> >
<template #grid="{ item }"> <template #grid="{ item }">
<div class="col-md-4 col-sm-6 col-12"> <div class="col-md-4 col-sm-6 col-12">
@ -401,9 +405,7 @@ watch(
() => triggerView({ quotationId: item.row.quotation.id }) () => triggerView({ quotationId: item.row.quotation.id })
" "
@preview=" @preview="
() => { () => viewDocExample(item.row.quotation.id, item.row.code)
viewDocExample(item.row.quotation.id);
}
" "
/> />
</div> </div>

View file

@ -41,7 +41,7 @@ withDefaults(
defineEmits<{ defineEmits<{
(e: 'view', id: string): void; (e: 'view', id: string): void;
(e: 'preview', id: string): void; (e: 'preview', data: Invoice): void;
(e: 'edit', data: T, index: number): void; (e: 'edit', data: T, index: number): void;
(e: 'delete', data: T, index: number): void; (e: 'delete', data: T, index: number): void;
(e: 'download', data: T, index: number): void; (e: 'download', data: T, index: number): void;
@ -118,7 +118,7 @@ defineEmits<{
icon="mdi-play-box-outline" icon="mdi-play-box-outline"
size="12px" size="12px"
:title="$t('preview.doc')" :title="$t('preview.doc')"
@click.stop="$emit('preview', props.row.quotation.id)" @click.stop="$emit('preview', props.row)"
/> />
<q-btn <q-btn

View file

@ -414,6 +414,7 @@ export type QuotationPaymentData = {
remark: string; remark: string;
date: string; date: string;
id: string; id: string;
code: string;
}; };
export type Details = { export type Details = {