feat: change tab on enter with query string

This commit is contained in:
Methapon Metanipat 2024-11-07 14:57:45 +07:00
parent 921b6c6106
commit 036f8c2891

View file

@ -82,6 +82,7 @@ import QuotationFormMetadata from './QuotationFormMetadata.vue';
import BadgeComponent from 'src/components/BadgeComponent.vue'; import BadgeComponent from 'src/components/BadgeComponent.vue';
import PaymentForm from './PaymentForm.vue'; import PaymentForm from './PaymentForm.vue';
import { api } from 'src/boot/axios'; import { api } from 'src/boot/axios';
import { useRoute } from 'vue-router';
type Node = { type Node = {
[key: string]: any; [key: string]: any;
@ -95,6 +96,7 @@ type Node = {
type ProductGroupId = string; type ProductGroupId = string;
const route = useRoute();
const useReceiptStore = useReceipt(); const useReceiptStore = useReceipt();
const configStore = useConfigStore(); const configStore = useConfigStore();
const productServiceStore = useProductServiceStore(); const productServiceStore = useProductServiceStore();
@ -531,6 +533,16 @@ async function convertDataToFormSubmit() {
if (res === true) { if (res === true) {
quotationFormState.value.mode = 'info'; quotationFormState.value.mode = 'info';
localStorage.setItem(
'new-quotation',
JSON.stringify({
quotationId: quotationFormData.value.id,
customerBranchId: quotationFormData.value.customerBranchId,
branchId: quotationFormData.value.registeredBranchId,
agentPrice: agentPrice.value,
statusDialog: 'info',
}),
);
await fetchQuotation(); await fetchQuotation();
} }
} }
@ -861,6 +873,17 @@ onMounted(async () => {
} }
pageState.isLoaded = true; pageState.isLoaded = true;
if (route.query['tab'] === 'invoice') {
view.value =
quotationFormData.value.payCondition === 'Full' ||
quotationFormData.value.payCondition === 'BillFull'
? View.Invoice
: View.InvoicePre;
}
if (route.query['tab'] === 'receipt') {
view.value = View.Receipt;
}
}); });
watch( watch(
@ -1006,7 +1029,6 @@ enum View {
Invoice, Invoice,
PaymentPre, PaymentPre,
Payment, Payment,
ReceiptPre,
Receipt, Receipt,
Complete, Complete,
} }
@ -1028,6 +1050,7 @@ const view = ref<View>(View.Quotation);
<q-img src="/icons/favicon-512x512.png" width="3rem" /> <q-img src="/icons/favicon-512x512.png" width="3rem" />
</a> </a>
<span class="column text-h6 text-bold q-ml-md"> <span class="column text-h6 text-bold q-ml-md">
<!-- TODO: change by current view -->
{{ $t('quotation.title') }} {{ $t('quotation.title') }}
<span class="text-caption text-regular app-text-muted"> <span class="text-caption text-regular app-text-muted">
{{ {{
@ -1484,11 +1507,7 @@ const view = ref<View>(View.Quotation);
<template v-else> <template v-else>
<PaymentForm <PaymentForm
v-if=" v-if="view !== View.InvoicePre && view !== View.Receipt"
view !== View.InvoicePre &&
view !== View.ReceiptPre &&
view !== View.Receipt
"
:data="quotationFormState.source" :data="quotationFormState.source"
@fetch-status=" @fetch-status="
() => { () => {
@ -1555,6 +1574,7 @@ const view = ref<View>(View.Quotation);
@click=" @click="
() => { () => {
if (props.row.invoiceId) { if (props.row.invoiceId) {
// TODO: get invoice code
selectedInstallmentNo = selectedInstallmentNo =
quotationFormState.source?.paySplit quotationFormState.source?.paySplit
.filter( .filter(