feat: add accepted function

This commit is contained in:
Methapon2001 2025-02-24 13:06:32 +07:00
parent ab5d85d814
commit 44aed63677

View file

@ -44,7 +44,7 @@ import {
import { RequestWork } from 'src/stores/request-list/types'; import { RequestWork } from 'src/stores/request-list/types';
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
import useOptionStore from 'src/stores/options'; import useOptionStore from 'src/stores/options';
import { deleteItem, dialogWarningClose } from 'src/stores/utils'; import { deleteItem, dialog, dialogWarningClose } from 'src/stores/utils';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { Employee } from 'src/stores/employee/types'; import { Employee } from 'src/stores/employee/types';
import QuotationFormWorkerSelect from '../05_quotation/QuotationFormWorkerSelect.vue'; import QuotationFormWorkerSelect from '../05_quotation/QuotationFormWorkerSelect.vue';
@ -101,7 +101,7 @@ const productGroup = ref<ProductGroup[]>([]);
const agentPrice = ref(false); const agentPrice = ref(false);
const debitNoteData = ref<DebitNote>(); const debitNoteData = ref<DebitNote>();
const quotationData = ref<DebitNote['debitNoteQuotation']>(); const quotationData = ref<DebitNote['debitNoteQuotation']>();
const view = ref<QuotationStatus | null>(null); const view = ref<QuotationStatus>(QuotationStatus.Issued);
const fileList = ref<FileList>(); const fileList = ref<FileList>();
const receiptList = ref<Receipt[]>([]); const receiptList = ref<Receipt[]>([]);
@ -258,6 +258,7 @@ const selectedInstallmentNo = ref<number[]>([]);
const installmentAmount = ref<number>(0); const installmentAmount = ref<number>(0);
const QUOTATION_STATUS = [ const QUOTATION_STATUS = [
'Accepted',
'PaymentPending', 'PaymentPending',
'PaymentSuccess', 'PaymentSuccess',
'ProcessComplete', 'ProcessComplete',
@ -419,16 +420,23 @@ async function initStatus() {
{ {
title: 'title', title: 'title',
status: debitNoteData.value?.id !== undefined ? 'done' : 'doing', status: debitNoteData.value?.id !== undefined ? 'done' : 'doing',
active: () => view.value === null, active: () => view.value === QuotationStatus.Issued,
handler: () => { handler: () => (view.value = QuotationStatus.Issued),
view.value = null; },
}, {
title: 'accepted',
status:
debitNoteData.value?.id !== undefined
? getStatus(debitNoteData.value.quotationStatus, 1, -1)
: 'waiting',
active: () => view.value === QuotationStatus.Accepted,
handler: () => (view.value = QuotationStatus.Accepted),
}, },
{ {
title: 'payment', title: 'payment',
status: status:
debitNoteData.value?.id !== undefined debitNoteData.value?.id !== undefined
? getStatus(debitNoteData.value.quotationStatus, 1, -1) ? getStatus(debitNoteData.value.quotationStatus, 2, 1)
: 'waiting', : 'waiting',
active: () => view.value === QuotationStatus.PaymentPending, active: () => view.value === QuotationStatus.PaymentPending,
handler: async () => { handler: async () => {
@ -438,7 +446,7 @@ async function initStatus() {
{ {
title: 'receipt', title: 'receipt',
status: getStatus(debitNoteData.value?.quotationStatus, 1, 1), status: getStatus(debitNoteData.value?.quotationStatus, 2, 2),
active: () => view.value === QuotationStatus.PaymentSuccess, active: () => view.value === QuotationStatus.PaymentSuccess,
handler: () => { handler: () => {
view.value = QuotationStatus.PaymentSuccess; view.value = QuotationStatus.PaymentSuccess;
@ -447,7 +455,7 @@ async function initStatus() {
{ {
title: 'processComplete', title: 'processComplete',
status: getStatus(debitNoteData.value?.quotationStatus, 2, 1), status: getStatus(debitNoteData.value?.quotationStatus, 3, 2),
active: () => view.value === QuotationStatus.ProcessComplete, active: () => view.value === QuotationStatus.ProcessComplete,
handler: () => { handler: () => {
view.value = QuotationStatus.ProcessComplete; view.value = QuotationStatus.ProcessComplete;
@ -786,7 +794,6 @@ async function submit() {
} }
pageState.mode = 'info'; pageState.mode = 'info';
assignFormData(res.id); assignFormData(res.id);
initStatus(); initStatus();
@ -877,7 +884,8 @@ onMounted(async () => {
} }
if (typeof route.query['mode'] === 'string') { if (typeof route.query['mode'] === 'string') {
pageState.mode = route.query['mode'] as 'create' | 'edit' | 'info'; pageState.mode =
(route.query['mode'] as 'create' | 'edit' | 'info') || 'info';
} }
if (typeof route.query['tab'] === 'string') { if (typeof route.query['tab'] === 'string') {
@ -885,11 +893,34 @@ onMounted(async () => {
{ {
payment: QuotationStatus.PaymentPending, payment: QuotationStatus.PaymentPending,
receipt: QuotationStatus.PaymentSuccess, receipt: QuotationStatus.PaymentSuccess,
}[route.query['tab']] || null; }[route.query['tab']] || QuotationStatus.Issued;
} }
await useConfigStore().getConfig(); await useConfigStore().getConfig();
}); });
async function submitAccepted() {
dialog({
color: 'info',
icon: 'mdi-account-check',
title: t('dialog.title.confirmDebitNoteAccept'),
actionText: t('general.confirm'),
persistent: true,
message: t('dialog.message.quotationAccept'),
action: async () => {
if (!currentFormData.value.id) return;
const res = await debitNote.action.acceptDebitNote(
currentFormData.value.id,
);
if (res && typeof route.params['id'] === 'string') {
await assignFormData(route.params['id']);
}
},
cancel: () => {},
});
}
</script> </script>
<template> <template>
@ -954,7 +985,10 @@ onMounted(async () => {
<!-- #TODO add goToQuotation as @goto-quotation--> <!-- #TODO add goToQuotation as @goto-quotation-->
<DocumentExpansion <DocumentExpansion
v-if="view === null" v-if="
view === QuotationStatus.Issued ||
view === QuotationStatus.Accepted
"
:readonly :readonly
:registered-branch-id="quotationData?.registeredBranchId" :registered-branch-id="quotationData?.registeredBranchId"
:customer-id="quotationData?.customerBranchId" :customer-id="quotationData?.customerBranchId"
@ -985,7 +1019,10 @@ onMounted(async () => {
/> />
<WorkerItemExpansion <WorkerItemExpansion
v-if="view === null" v-if="
view === QuotationStatus.Issued ||
view === QuotationStatus.Accepted
"
:readonly :readonly
:hide-btn-add-worker=" :hide-btn-add-worker="
!readonly && !readonly &&
@ -998,7 +1035,10 @@ onMounted(async () => {
<!-- #TODO add openProductDialog at @add-product--> <!-- #TODO add openProductDialog at @add-product-->
<ProductExpansion <ProductExpansion
v-if="view === null" v-if="
view === QuotationStatus.Issued ||
view === QuotationStatus.Accepted
"
:readonly :readonly
:installment-input="currentFormData.payCondition === 'SplitCustom'" :installment-input="currentFormData.payCondition === 'SplitCustom'"
:max-installment="currentFormData.paySplitCount" :max-installment="currentFormData.paySplitCount"
@ -1016,7 +1056,10 @@ onMounted(async () => {
/> />
<PaymentExpansion <PaymentExpansion
v-if="view === null" v-if="
view === QuotationStatus.Issued ||
view === QuotationStatus.Accepted
"
readonly readonly
:total-price="summaryPrice.finalPrice" :total-price="summaryPrice.finalPrice"
class="q-mb-md" class="q-mb-md"
@ -1030,7 +1073,11 @@ onMounted(async () => {
<!-- TODO: bind additional file --> <!-- TODO: bind additional file -->
<AdditionalFileExpansion <AdditionalFileExpansion
v-if="view === null || view === QuotationStatus.PaymentPending" v-if="
view === QuotationStatus.Issued ||
view === QuotationStatus.Accepted ||
view === QuotationStatus.PaymentPending
"
:readonly :readonly
v-model:file-data="attachmentData" v-model:file-data="attachmentData"
:transform-url=" :transform-url="
@ -1075,7 +1122,11 @@ onMounted(async () => {
<!-- TODO: bind remark --> <!-- TODO: bind remark -->
<RemarkExpansion <RemarkExpansion
v-if="view === null || view === QuotationStatus.PaymentPending" v-if="
view === QuotationStatus.Issued ||
view === QuotationStatus.Accepted ||
view === QuotationStatus.PaymentPending
"
:readonly="readonly" :readonly="readonly"
v-model:remark="currentFormData.remark" v-model:remark="currentFormData.remark"
/> />
@ -1150,7 +1201,7 @@ onMounted(async () => {
installmentAmount = v.invoice.amount; installmentAmount = v.invoice.amount;
} }
view = null; view = QuotationStatus.Issued;
} }
" "
@example="() => exampleReceipt(v.id)" @example="() => exampleReceipt(v.id)"
@ -1175,36 +1226,34 @@ onMounted(async () => {
</MainButton> </MainButton>
<div class="row q-gutter-x-sm"> <div class="row q-gutter-x-sm">
<UndoButton <UndoButton outlined @click="pageState.mode = 'info'" v-if="false" />
outlined {{ pageState.mode }}
@click="
() => {
pageState.mode = 'info';
}
"
v-if="false"
/>
<SaveButton <SaveButton
v-if="!readonly && pageState.mode === 'create'" v-if="!readonly"
:disabled=" :disabled="
selectedWorkerItem.length === 0 && productService.length === 0 selectedWorkerItem.length === 0 && productService.length === 0
" "
@click="submit" @click="submit"
:label="true ? $t('debitNote.label.submit') : $t('general.save')"
:icon="
true
? 'mdi-account-multiple-check-outline'
: 'mdi-content-save-outline'
"
solid solid
></SaveButton> />
<SaveButton
v-if="false"
@click="submit"
:label="$t('debitNote.label.submit')"
icon="mdi-account-multiple-check-outline"
solid
/>
<EditButton <EditButton
v-if="false" v-if="
readonly &&
pageState.mode === 'info' &&
QuotationStatus.Issued === view
"
class="no-print" class="no-print"
@click="pageState.mode = 'edit'"
solid solid
@click="pageState.mode = 'edit'"
/> />
</div> </div>
</nav> </nav>