fix/feat: type and update function
This commit is contained in:
parent
46a7f9ca96
commit
ad942e7035
2 changed files with 75 additions and 3 deletions
|
|
@ -2,7 +2,14 @@ import { ref } from 'vue';
|
||||||
import { defineStore } from 'pinia';
|
import { defineStore } from 'pinia';
|
||||||
import { Pagination } from '../types';
|
import { Pagination } from '../types';
|
||||||
import { api } from 'src/boot/axios';
|
import { api } from 'src/boot/axios';
|
||||||
import { Employee, EmployeeCreate, EmployeeUpdate } from './types';
|
import {
|
||||||
|
Employee,
|
||||||
|
EmployeeCheckup,
|
||||||
|
EmployeeCreate,
|
||||||
|
EmployeeOther,
|
||||||
|
EmployeeUpdate,
|
||||||
|
EmployeeWork,
|
||||||
|
} from './types';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
const useEmployeeStore = defineStore('api-employee', () => {
|
const useEmployeeStore = defineStore('api-employee', () => {
|
||||||
|
|
@ -84,7 +91,7 @@ const useEmployeeStore = defineStore('api-employee', () => {
|
||||||
|
|
||||||
async function editById(
|
async function editById(
|
||||||
id: string,
|
id: string,
|
||||||
data: EmployeeUpdate,
|
data: EmployeeCreate,
|
||||||
flow?: {
|
flow?: {
|
||||||
sessionId: string;
|
sessionId: string;
|
||||||
refTransactionId: string;
|
refTransactionId: string;
|
||||||
|
|
@ -137,6 +144,66 @@ const useEmployeeStore = defineStore('api-employee', () => {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function fetchCheckup(
|
||||||
|
id: string,
|
||||||
|
flow?: {
|
||||||
|
sessionId: string;
|
||||||
|
refTransactionId: string;
|
||||||
|
transactionId: string;
|
||||||
|
},
|
||||||
|
) {
|
||||||
|
const res = await api.get<EmployeeCheckup[]>(`/employee/${id}/checkup`, {
|
||||||
|
headers: {
|
||||||
|
'X-Session-Id': flow?.sessionId,
|
||||||
|
'X-Rtid': flow?.refTransactionId,
|
||||||
|
'X-Tid': flow?.transactionId,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (res && res.status === 200) {
|
||||||
|
return res.data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function fetchWork(
|
||||||
|
id: string,
|
||||||
|
flow?: {
|
||||||
|
sessionId: string;
|
||||||
|
refTransactionId: string;
|
||||||
|
transactionId: string;
|
||||||
|
},
|
||||||
|
) {
|
||||||
|
const res = await api.get<EmployeeWork[]>(`/employee/${id}/work`, {
|
||||||
|
headers: {
|
||||||
|
'X-Session-Id': flow?.sessionId,
|
||||||
|
'X-Rtid': flow?.refTransactionId,
|
||||||
|
'X-Tid': flow?.transactionId,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (res && res.status === 200) {
|
||||||
|
return res.data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function fetchOther(
|
||||||
|
id: string,
|
||||||
|
flow?: {
|
||||||
|
sessionId: string;
|
||||||
|
refTransactionId: string;
|
||||||
|
transactionId: string;
|
||||||
|
},
|
||||||
|
) {
|
||||||
|
const res = await api.get<EmployeeOther>(`/employee/${id}/other-info`, {
|
||||||
|
headers: {
|
||||||
|
'X-Session-Id': flow?.sessionId,
|
||||||
|
'X-Rtid': flow?.refTransactionId,
|
||||||
|
'X-Tid': flow?.transactionId,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (res && res.status === 200) {
|
||||||
|
return res.data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
data,
|
data,
|
||||||
globalOption,
|
globalOption,
|
||||||
|
|
@ -146,6 +213,9 @@ const useEmployeeStore = defineStore('api-employee', () => {
|
||||||
create,
|
create,
|
||||||
editById,
|
editById,
|
||||||
deleteById,
|
deleteById,
|
||||||
|
fetchCheckup,
|
||||||
|
fetchWork,
|
||||||
|
fetchOther,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ export type Employee = {
|
||||||
customerBranchId: string;
|
customerBranchId: string;
|
||||||
status: Status;
|
status: Status;
|
||||||
tm6Number: string;
|
tm6Number: string;
|
||||||
|
entryDate: Date;
|
||||||
createdAt: Date;
|
createdAt: Date;
|
||||||
createdBy: string;
|
createdBy: string;
|
||||||
updatedAt: Date;
|
updatedAt: Date;
|
||||||
|
|
@ -187,7 +188,7 @@ export type EmployeeWorkCreate = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export type EmployeeOther = {
|
export type EmployeeOther = {
|
||||||
birthPlace: string;
|
motherBirthPlace: string;
|
||||||
motherLastNameEN: string;
|
motherLastNameEN: string;
|
||||||
motherFirstNameEN: string;
|
motherFirstNameEN: string;
|
||||||
fatherLastNameEN: string;
|
fatherLastNameEN: string;
|
||||||
|
|
@ -196,6 +197,7 @@ export type EmployeeOther = {
|
||||||
motherFirstName: string;
|
motherFirstName: string;
|
||||||
fatherLastName: string;
|
fatherLastName: string;
|
||||||
fatherFirstName: string;
|
fatherFirstName: string;
|
||||||
|
fatherBirthPlace: string;
|
||||||
citizenId: string;
|
citizenId: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue