feat: preview route and trigger preview

This commit is contained in:
Methapon Metanipat 2024-10-18 10:56:10 +07:00
parent b74ff126e3
commit 8f880fd34d
5 changed files with 24 additions and 4 deletions

View file

@ -275,6 +275,17 @@ async function fetchQuotationList() {
}
watch(() => pageState.currentTab, fetchQuotationList);
async function storeDataLocal(id: string) {
await quotationFormStore.assignFormData(id, 'assign');
localStorage.setItem(
'quotation-preview',
JSON.stringify(quotationFormData.value),
);
window.open('/quotation/document-view', '_blank');
}
</script>
<template>
@ -538,6 +549,7 @@ watch(() => pageState.currentTab, fetchQuotationList);
: v.createdBy.firstName + ' ' + v.createdBy.lastName
"
:total-price="v.finalPrice"
@preview="storeDataLocal(v.id)"
@view="
() => {
triggerQuotationDialog({

View file

@ -621,7 +621,7 @@ function storeDataLocal() {
JSON.stringify(quotationFormData.value),
);
window.open('/view', '_blank');
window.open('/quotation/document-view', '_blank');
}
</script>

View file

@ -94,7 +94,10 @@ export const useQuotationForm = defineStore('form-quotation', () => {
currentFormData.value = structuredClone(resetFormData);
}
async function assignFormData(id: string, mode: 'info' | 'edit' = 'info') {
async function assignFormData(
id: string,
mode: 'info' | 'edit' | 'assign' = 'info',
) {
const data = await quotationStore.getQuotation(id);
if (!data) return; // NOTE: Error should be handled globally by axios instance
@ -127,6 +130,9 @@ export const useQuotationForm = defineStore('form-quotation', () => {
locale === 'eng'
? data.createdBy.firstNameEN + ' ' + data.createdBy.lastNameEN
: data.createdBy.firstName + ' ' + data.createdBy.lastName;
if (mode === 'assign') return;
currentFormState.value.mode = mode;
}