refactor: handle peview mod

This commit is contained in:
Thanaphon Frappet 2024-10-30 11:54:49 +07:00
parent 817cdc0567
commit be018ec48d

View file

@ -246,6 +246,16 @@ const formDataEmployee = ref<
const productServiceList = ref< const productServiceList = ref<
Required<QuotationPayload['productServiceList'][number]>[] Required<QuotationPayload['productServiceList'][number]>[]
>([]); >([]);
const productService = computed(() => {
return selectedInstallmentNo.value.length > 0
? productServiceList.value.filter((v) => {
return (
v.installmentNo &&
selectedInstallmentNo.value.includes(v.installmentNo)
);
})
: productServiceList.value;
});
async function fetchStatus() { async function fetchStatus() {
statusQuotationForm.value = [ statusQuotationForm.value = [
@ -803,9 +813,12 @@ function storeDataLocal() {
localStorage.setItem( localStorage.setItem(
'quotation-preview', 'quotation-preview',
JSON.stringify({ JSON.stringify({
data: quotationFormData.value, data: {
...quotationFormData.value,
productServiceList: productService.value,
},
meta: { meta: {
selectedInstallmentNo: selectedInstallmentNo.value, viewMod: view.value,
source: { source: {
...quotationFormState.value.source, ...quotationFormState.value.source,
code: code:
@ -828,7 +841,14 @@ function storeDataLocal() {
}), }),
); );
window.open('/quotation/document-view', '_blank'); const documentTypes: Record<number, string> = {
3: 'invoice',
4: 'payment',
6: 'receipt',
};
const documentType = documentTypes[view.value] || '';
window.open(`/quotation/document-view?type=${documentType}`, '_blank');
} }
const QUOTATION_STATUS = [ const QUOTATION_STATUS = [
'Issued', 'Issued',
@ -1167,16 +1187,7 @@ const view = ref<View>(View.Quotation);
})) }))
" "
@delete="toggleDeleteProduct" @delete="toggleDeleteProduct"
:rows=" :rows="productService"
selectedInstallmentNo.length > 0
? productServiceList.filter((v) => {
return (
v.installmentNo &&
selectedInstallmentNo.includes(v.installmentNo)
);
})
: productServiceList
"
@update:rows=" @update:rows="
(v) => view === View.Quotation && (productServiceList = v) (v) => view === View.Quotation && (productServiceList = v)
" "
@ -1294,6 +1305,7 @@ const view = ref<View>(View.Quotation);
expand-icon="mdi-chevron-down-circle" expand-icon="mdi-chevron-down-circle"
header-class="surface-1" header-class="surface-1"
> >
{{ quotationFormData.paySplit }}
<div class="surface-1 q-pa-md full-width"> <div class="surface-1 q-pa-md full-width">
<SwitchItem :value="view"> <SwitchItem :value="view">
<template #[View.InvoicePre]> <template #[View.InvoicePre]>
@ -1388,7 +1400,12 @@ const view = ref<View>(View.Quotation);
{{ $t('general.view', { msg: $t('general.example') }) }} {{ $t('general.view', { msg: $t('general.example') }) }}
</MainButton> </MainButton>
<div v-if="view === View.Accepted"> <div
v-if="
view === View.Accepted &&
quotationFormData.quotationStatus === 'Issued'
"
>
<MainButton <MainButton
solid solid
icon="mdi-account-multiple-check-outline" icon="mdi-account-multiple-check-outline"