fix: reset edit id still not reset

This commit is contained in:
Methapon2001 2024-08-06 11:51:51 +07:00
parent a86bcf4786
commit 7c3a3d6a99

View file

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