refactor: add deleteWorkHistory and deleteHealthCheck
This commit is contained in:
parent
ce1047e8ef
commit
43ef034aaa
1 changed files with 38 additions and 4 deletions
|
|
@ -1,9 +1,6 @@
|
|||
import { ref, toRaw, watch } from 'vue';
|
||||
import { defineStore } from 'pinia';
|
||||
import {
|
||||
CustomerBranchCreate,
|
||||
CustomerCreate,
|
||||
} from 'stores/customer/types';
|
||||
import { CustomerBranchCreate, CustomerCreate } from 'stores/customer/types';
|
||||
import { Employee, EmployeeCreate } from 'stores/employee/types';
|
||||
|
||||
import useMyBranch from 'stores/my-branch';
|
||||
|
|
@ -565,6 +562,40 @@ export const useEmployeeForm = defineStore('form-employee', () => {
|
|||
await assignFormDataEmployee(currentFromDataEmployee.value.id);
|
||||
}
|
||||
|
||||
async function deleteWorkHistory() {
|
||||
if (!currentFromDataEmployee.value.employeeWork) return;
|
||||
|
||||
const res = await employeeStore.deleteByIdWork({
|
||||
employeeId: currentFromDataEmployee.value.id || '',
|
||||
workId:
|
||||
currentFromDataEmployee.value.employeeWork[state.value.currentIndex]
|
||||
?.id,
|
||||
});
|
||||
|
||||
if (res) {
|
||||
await assignFormDataEmployee(currentFromDataEmployee.value.id);
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteHealthCheck() {
|
||||
if (!currentFromDataEmployee.value.employeeCheckup) return;
|
||||
|
||||
const res = await employeeStore.deleteByIdCheckUp({
|
||||
employeeId: currentFromDataEmployee.value.id || '',
|
||||
checkUpId:
|
||||
currentFromDataEmployee.value.employeeCheckup[state.value.currentIndex]
|
||||
?.id,
|
||||
});
|
||||
|
||||
if (res) {
|
||||
currentFromDataEmployee.value.employeeCheckup.splice(
|
||||
state.value.currentIndex,
|
||||
1,
|
||||
);
|
||||
}
|
||||
await assignFormDataEmployee(currentFromDataEmployee.value.id);
|
||||
}
|
||||
|
||||
async function submitWorkHistory() {
|
||||
if (!currentFromDataEmployee.value.employeeWork) return;
|
||||
|
||||
|
|
@ -789,6 +820,9 @@ export const useEmployeeForm = defineStore('form-employee', () => {
|
|||
submitPersonal,
|
||||
submitHealthCheck,
|
||||
|
||||
deleteWorkHistory,
|
||||
deleteHealthCheck,
|
||||
|
||||
resetFormDataEmployee,
|
||||
assignFormDataEmployee,
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue