From 226da5ccfe6d0e0d35a3ac004420356d80d0006d Mon Sep 17 00:00:00 2001 From: Thanaphon Frappet Date: Mon, 21 Oct 2024 12:05:49 +0700 Subject: [PATCH] refactor: assign after submit --- src/pages/05_quotation/form.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/pages/05_quotation/form.ts b/src/pages/05_quotation/form.ts index 479e30b1..889a9eac 100644 --- a/src/pages/05_quotation/form.ts +++ b/src/pages/05_quotation/form.ts @@ -143,10 +143,12 @@ export const useQuotationForm = defineStore('form-quotation', () => { } async function submitQuotation() { + let status = false; if (currentFormState.value.mode === 'create') { const res = await quotationStore.createQuotation(currentFormData.value); if (res !== null) { + currentFormData.value.id = res.id; fileItemNewWorker.value.forEach(async (v) => { if (v.group === undefined) return; await employeeStore.postMeta({ @@ -156,7 +158,7 @@ export const useQuotationForm = defineStore('form-quotation', () => { file: v.file, }); }); - return true; + status = true; } } if (currentFormState.value.mode === 'edit' && currentFormData.value.id) { @@ -169,11 +171,16 @@ export const useQuotationForm = defineStore('form-quotation', () => { id: currentFormData.value.id, }); - if (res) return true; + if (res) status = true; } currentFormState.value.mode = 'info'; + + if (currentFormData.value.id !== undefined) { + assignFormData(currentFormData.value.id, 'info'); + } currentFormState.value.createdBy = (_) => getName() || ''; + return status; } function injectNewEmployee(