refactor: add api Checkup , Work , Other Info
This commit is contained in:
parent
f557fe3d4f
commit
355a30074c
1 changed files with 171 additions and 0 deletions
|
|
@ -95,6 +95,168 @@ const useEmployeeStore = defineStore('api-employee', () => {
|
|||
return res.data;
|
||||
}
|
||||
|
||||
async function createEmployeeCheckup(
|
||||
employeeId: string,
|
||||
data: EmployeeCreate,
|
||||
flow?: {
|
||||
sessionId?: string;
|
||||
refTransactionId?: string;
|
||||
transactionId?: string;
|
||||
},
|
||||
) {
|
||||
const { code, image, ...payload } = data;
|
||||
const res = await api.post<Employee>(
|
||||
`/employee/${employeeId}/checkup`,
|
||||
{ ...payload.employeeCheckup },
|
||||
{
|
||||
headers: {
|
||||
'X-Session-Id': flow?.sessionId,
|
||||
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
|
||||
'X-Tid': flow?.transactionId,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
if (!res) return false;
|
||||
|
||||
return res.data;
|
||||
}
|
||||
|
||||
async function createEmployeeWork(
|
||||
employeeId: string,
|
||||
data: EmployeeCreate,
|
||||
flow?: {
|
||||
sessionId?: string;
|
||||
refTransactionId?: string;
|
||||
transactionId?: string;
|
||||
},
|
||||
) {
|
||||
const { code, image, ...payload } = data;
|
||||
const res = await api.post<Employee>(
|
||||
`/employee/${employeeId}/work`,
|
||||
{ ...payload.employeeWork },
|
||||
{
|
||||
headers: {
|
||||
'X-Session-Id': flow?.sessionId,
|
||||
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
|
||||
'X-Tid': flow?.transactionId,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
if (!res) return false;
|
||||
|
||||
return res.data;
|
||||
}
|
||||
|
||||
async function createEmployeeOtherInfo(
|
||||
employeeId: string,
|
||||
data: EmployeeCreate,
|
||||
flow?: {
|
||||
sessionId?: string;
|
||||
refTransactionId?: string;
|
||||
transactionId?: string;
|
||||
},
|
||||
) {
|
||||
const { code, image, ...payload } = data;
|
||||
const res = await api.post<Employee>(
|
||||
`/employee/${employeeId}/other-info`,
|
||||
{ ...payload.employeeOtherInfo },
|
||||
{
|
||||
headers: {
|
||||
'X-Session-Id': flow?.sessionId,
|
||||
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
|
||||
'X-Tid': flow?.transactionId,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
if (!res) return false;
|
||||
|
||||
return res.data;
|
||||
}
|
||||
|
||||
async function editByIdEmployeeCheckup(
|
||||
employeeId: string,
|
||||
data: Partial<EmployeeCreate>,
|
||||
flow?: {
|
||||
sessionId?: string;
|
||||
refTransactionId?: string;
|
||||
transactionId?: string;
|
||||
},
|
||||
) {
|
||||
const { code, image, ...payload } = data;
|
||||
const res = await api.put<Employee>(
|
||||
`/employee/${employeeId}/checkup}`,
|
||||
{ ...payload.employeeCheckup },
|
||||
{
|
||||
headers: {
|
||||
'X-Session-Id': flow?.sessionId,
|
||||
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
|
||||
'X-Tid': flow?.transactionId,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
if (!res) return false;
|
||||
|
||||
return res.data;
|
||||
}
|
||||
|
||||
async function editByIdEmployeeWork(
|
||||
employeeId: string,
|
||||
data: Partial<EmployeeCreate>,
|
||||
flow?: {
|
||||
sessionId?: string;
|
||||
refTransactionId?: string;
|
||||
transactionId?: string;
|
||||
},
|
||||
) {
|
||||
const { code, image, ...payload } = data;
|
||||
const res = await api.put<Employee>(
|
||||
`/employee/${employeeId}/work}`,
|
||||
{ ...payload.employeeWork },
|
||||
{
|
||||
headers: {
|
||||
'X-Session-Id': flow?.sessionId,
|
||||
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
|
||||
'X-Tid': flow?.transactionId,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
if (!res) return false;
|
||||
|
||||
return res.data;
|
||||
}
|
||||
|
||||
async function editByIdEmployeeOtherInfo(
|
||||
employeeId: string,
|
||||
data: Partial<EmployeeCreate>,
|
||||
flow?: {
|
||||
sessionId?: string;
|
||||
refTransactionId?: string;
|
||||
transactionId?: string;
|
||||
},
|
||||
) {
|
||||
const { code, image, ...payload } = data;
|
||||
const res = await api.put<Employee>(
|
||||
`/employee/${employeeId}/other-info}`,
|
||||
{ ...payload.employeeWork },
|
||||
{
|
||||
headers: {
|
||||
'X-Session-Id': flow?.sessionId,
|
||||
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
|
||||
'X-Tid': flow?.transactionId,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
if (!res) return false;
|
||||
|
||||
return res.data;
|
||||
}
|
||||
|
||||
async function editById(
|
||||
id: string,
|
||||
data: Partial<EmployeeCreate>,
|
||||
|
|
@ -304,6 +466,15 @@ const useEmployeeStore = defineStore('api-employee', () => {
|
|||
getStatsEmployee,
|
||||
getStatsEmployeeGender,
|
||||
getEditHistory,
|
||||
|
||||
createEmployeeCheckup,
|
||||
editByIdEmployeeCheckup,
|
||||
|
||||
createEmployeeWork,
|
||||
editByIdEmployeeWork,
|
||||
|
||||
createEmployeeOtherInfo,
|
||||
editByIdEmployeeOtherInfo,
|
||||
};
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue