diff --git a/src/pages/03_customer-management/form.ts b/src/pages/03_customer-management/form.ts index 1006bc1e..dbb3e35a 100644 --- a/src/pages/03_customer-management/form.ts +++ b/src/pages/03_customer-management/form.ts @@ -73,6 +73,7 @@ export const useCustomerForm = defineStore('form-customer', () => { branchStore.currentMyBranch?.id || ''; resetFormData = structuredClone(defaultFormData); resetFormData.registeredBranchId = branchStore.currentMyBranch?.id || ''; + state.value.editCustomerId = ''; return; } @@ -80,6 +81,10 @@ export const useCustomerForm = defineStore('form-customer', () => { resetFormData.registeredBranchId = branchStore.currentMyBranch?.id || ''; } + if (state.value.dialogType === 'create') { + state.value.editCustomerId = ''; + } + currentFormData.value = structuredClone(resetFormData); } @@ -103,6 +108,7 @@ export const useCustomerForm = defineStore('form-customer', () => { resetFormData.personName = data.personName; resetFormData.taxNo = data.taxNo; resetFormData.image = null; + resetFormData.customerBranch = data.branch.map((v) => ({ id: v.id, code: v.code, @@ -173,9 +179,13 @@ export const useCustomerForm = defineStore('form-customer', () => { async function submitForm() { if (state.value.saveMode === 'customer') { - await submitFormCustomer().then(() => { - state.value.dialogModal = false; - }); + const _data = await submitFormCustomer(); + if (_data) { + await assignFormData(_data.id); + state.value.dialogType = 'edit'; + state.value.editReadonly = true; + state.value.editCustomerId = _data.id; + } } }