refactor: reset form

This commit is contained in:
Thanaphon Frappet 2024-11-20 14:41:42 +07:00
parent 937f7cbad4
commit 1a1f2cb9f3
2 changed files with 7 additions and 0 deletions

View file

@ -663,6 +663,7 @@ watch(
async () => {
await fetchList();
customerBranchFormState.dialogModal = false;
customerBranchFormStore.resetForm();
flowStore.rotate();
}
"

View file

@ -527,6 +527,11 @@ export const useCustomerBranchForm = defineStore('form-customer-branch', () => {
currentFormData.value = structuredClone(resetFormData);
}
function resetForm() {
resetFormData = structuredClone(defaultFormData);
currentFormData.value = structuredClone(resetFormData);
}
function isFormDataDifferent() {
return (
JSON.stringify(resetFormData) !== JSON.stringify(currentFormData.value)
@ -574,6 +579,7 @@ export const useCustomerBranchForm = defineStore('form-customer-branch', () => {
initForm,
isFormDataDifferent,
submitForm,
resetForm,
};
});