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<
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() {
statusQuotationForm.value = [
@ -803,9 +813,12 @@ function storeDataLocal() {
localStorage.setItem(
'quotation-preview',
JSON.stringify({
data: quotationFormData.value,
data: {
...quotationFormData.value,
productServiceList: productService.value,
},
meta: {
selectedInstallmentNo: selectedInstallmentNo.value,
viewMod: view.value,
source: {
...quotationFormState.value.source,
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 = [
'Issued',
@ -1167,16 +1187,7 @@ const view = ref<View>(View.Quotation);
}))
"
@delete="toggleDeleteProduct"
:rows="
selectedInstallmentNo.length > 0
? productServiceList.filter((v) => {
return (
v.installmentNo &&
selectedInstallmentNo.includes(v.installmentNo)
);
})
: productServiceList
"
:rows="productService"
@update:rows="
(v) => view === View.Quotation && (productServiceList = v)
"
@ -1294,6 +1305,7 @@ const view = ref<View>(View.Quotation);
expand-icon="mdi-chevron-down-circle"
header-class="surface-1"
>
{{ quotationFormData.paySplit }}
<div class="surface-1 q-pa-md full-width">
<SwitchItem :value="view">
<template #[View.InvoicePre]>
@ -1388,7 +1400,12 @@ const view = ref<View>(View.Quotation);
{{ $t('general.view', { msg: $t('general.example') }) }}
</MainButton>
<div v-if="view === View.Accepted">
<div
v-if="
view === View.Accepted &&
quotationFormData.quotationStatus === 'Issued'
"
>
<MainButton
solid
icon="mdi-account-multiple-check-outline"