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

@ -28,6 +28,7 @@ defineEmits<{
(e: 'delete'): void;
(e: 'changeStatus'): void;
(e: 'example'): void;
(e: 'preview'): void;
}>();
</script>
<template>
@ -121,6 +122,7 @@ defineEmits<{
outline
color="primary"
class="rounded q-ml-auto"
@click="$emit('preview')"
padding="2px 8px"
>
<q-icon name="mdi-play-box-outline" size="xs" class="q-mr-xs" />

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;
}

View file

@ -93,8 +93,8 @@ const routes: RouteRecordRaw[] = [
component: () => import('pages/05_quotation/QuotationForm.vue'),
},
{
path: '/view',
name: 'view',
path: '/quotation/document-view',
name: 'QuotationDocumentView',
component: () => import('pages/05_quotation/peview/ViewForm.vue'),
},