refactor: add delete

This commit is contained in:
Net 2024-08-01 16:44:13 +07:00
parent 9618085ac4
commit ae5f66eaa4
2 changed files with 115 additions and 2 deletions

View file

@ -921,6 +921,41 @@ function deleteBranchId(id: string) {
// flowStore.rotate();
// }
async function deleteByIdCheckOrwork(
id: string,
type: 'healthCheck' | 'workHistory',
indexTab: number,
) {
dialog({
color: 'info',
icon: 'mdi-alert',
title: t('saveConfirmTitle'),
actionText: t('ok'),
persistent: true,
message: t('saveConfirmMessage'),
action: async () => {
if (type === 'healthCheck') {
await employeeStore.deleteByIdCheckUp({
employeeId: currentEmployeeId.value,
checkUpId: id,
});
formDataEmployee.value.employeeCheckup?.splice(indexTab, 1);
}
if (type === 'workHistory') {
await employeeStore.deleteByIdWork({
employeeId: currentEmployeeId.value,
workId: id,
});
}
flowStore.rotate();
},
cancel: () => {},
});
}
async function onSubmitEmployee(
type: 'personalInfo' | 'healthCheck' | 'workHistory' | 'other',
indexTab: number = 0,
@ -967,6 +1002,7 @@ async function onSubmitEmployee(
);
if (res) {
formDataEmployee.value.employeeCheckup[indexTab].id = res.id;
formDataEmployee.value.employeeCheckup[indexTab].statusSave = true;
}
}
@ -983,6 +1019,7 @@ async function onSubmitEmployee(
);
if (res) {
formDataEmployee.value.employeeWork[indexTab].id = res.id;
formDataEmployee.value.employeeWork[indexTab].statusSave = true;
}
}
@ -3476,6 +3513,15 @@ watch(isMainPage, () => {
onSubmitEmployee('healthCheck', index);
}
"
@remove="
(index) => {
deleteByIdCheckOrwork(
formDataEmployee.employeeCheckup?.[index].id || '',
'healthCheck',
index,
);
}
"
/>
<FormEmployeeWorkHistory
prefix-id="form-dialog"
@ -3492,6 +3538,15 @@ watch(isMainPage, () => {
onSubmitEmployee('workHistory', index);
}
"
@remove="
(index) => {
deleteByIdCheckOrwork(
formDataEmployee.employeeWork?.[index].id || '',
'healthCheck',
index,
);
}
"
/>
<FormEmployeeOther
prefix-id="form-dialog"