refactor: detect unsave and confirmation of employee
This commit is contained in:
parent
9f86229bd2
commit
1164748e1b
2 changed files with 48 additions and 0 deletions
|
|
@ -243,6 +243,7 @@ export const useEmployeeForm = defineStore('form-employee', () => {
|
|||
isEmployeeEdit: boolean;
|
||||
profileSubmit: boolean;
|
||||
formDataEmployeeSameAddr: boolean;
|
||||
editReadonly: boolean;
|
||||
infoEmployeePersonCard: {
|
||||
id: string;
|
||||
img: string;
|
||||
|
|
@ -275,6 +276,7 @@ export const useEmployeeForm = defineStore('form-employee', () => {
|
|||
isEmployeeEdit: false,
|
||||
profileSubmit: false,
|
||||
formDataEmployeeSameAddr: true,
|
||||
editReadonly: false,
|
||||
infoEmployeePersonCard: [],
|
||||
formDataEmployeeOwner: undefined,
|
||||
});
|
||||
|
|
@ -367,6 +369,13 @@ export const useEmployeeForm = defineStore('form-employee', () => {
|
|||
structuredClone(defaultFormData),
|
||||
);
|
||||
|
||||
function isFormDataDifferent() {
|
||||
return (
|
||||
JSON.stringify(resetEmployeeData) !==
|
||||
JSON.stringify(currentFromDataEmployee.value)
|
||||
);
|
||||
}
|
||||
|
||||
function resetFormDataEmployee(cb?: (...args: any[]) => unknown) {
|
||||
currentFromDataEmployee.value = structuredClone(resetEmployeeData);
|
||||
cb?.();
|
||||
|
|
@ -452,5 +461,7 @@ export const useEmployeeForm = defineStore('form-employee', () => {
|
|||
assignFormDataEmployee,
|
||||
|
||||
employeeFilterOwnerBranch,
|
||||
|
||||
isFormDataDifferent,
|
||||
};
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue