refactor: add delete
This commit is contained in:
parent
9618085ac4
commit
ae5f66eaa4
2 changed files with 115 additions and 2 deletions
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue