feat: remove flow from store
This commit is contained in:
parent
0c3eeef35e
commit
98b4771a52
1 changed files with 12 additions and 85 deletions
|
|
@ -19,7 +19,6 @@ import useFlowStore from '../flow';
|
|||
import { baseUrl, manageFile, manageMeta } from '../utils';
|
||||
|
||||
const useEmployeeStore = defineStore('api-employee', () => {
|
||||
const flowStore = useFlowStore();
|
||||
const data = ref<Pagination<Employee[]>>();
|
||||
const globalOption = ref();
|
||||
const ownerOption = ref<CustomerBranch[]>();
|
||||
|
|
@ -62,21 +61,8 @@ const useEmployeeStore = defineStore('api-employee', () => {
|
|||
return false;
|
||||
}
|
||||
|
||||
async function fetchImageListById(
|
||||
id: string,
|
||||
flow?: {
|
||||
sessionId?: string;
|
||||
refTransactionId?: string;
|
||||
transactionId?: string;
|
||||
},
|
||||
) {
|
||||
const res = await api.get(`/employee/${id}/image`, {
|
||||
headers: {
|
||||
'X-Session-Id': flow?.sessionId,
|
||||
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
|
||||
'X-Tid': flow?.transactionId,
|
||||
},
|
||||
});
|
||||
async function fetchImageListById(id: string) {
|
||||
const res = await api.get(`/employee/${id}/image`);
|
||||
|
||||
if (!res) return false;
|
||||
if (res.status === 200) return res.data;
|
||||
|
|
@ -96,22 +82,8 @@ const useEmployeeStore = defineStore('api-employee', () => {
|
|||
return name;
|
||||
}
|
||||
|
||||
async function deleteImageByName(
|
||||
id: string,
|
||||
name: string,
|
||||
flow?: {
|
||||
sessionId?: string;
|
||||
refTransactionId?: string;
|
||||
transactionId?: string;
|
||||
},
|
||||
) {
|
||||
const res = await api.delete(`/employee/${id}/image/${name}`, {
|
||||
headers: {
|
||||
'X-Session-Id': flow?.sessionId,
|
||||
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
|
||||
'X-Tid': flow?.transactionId,
|
||||
},
|
||||
});
|
||||
async function deleteImageByName(id: string, name: string) {
|
||||
const res = await api.delete(`/employee/${id}/image/${name}`);
|
||||
|
||||
if (!res) return false;
|
||||
}
|
||||
|
|
@ -137,13 +109,7 @@ const useEmployeeStore = defineStore('api-employee', () => {
|
|||
} = data;
|
||||
const res = await api.post<
|
||||
Employee & { profileImageUrl: string; profileImageUploadUrl: string }
|
||||
>(
|
||||
'/employee',
|
||||
{ ...payload, selectedImage: imgList.selectedImage },
|
||||
{
|
||||
headers: { 'X-Rtid': flowStore.rtid },
|
||||
},
|
||||
);
|
||||
>('/employee', { ...payload, selectedImage: imgList.selectedImage });
|
||||
|
||||
if (!res) return false;
|
||||
|
||||
|
|
@ -197,7 +163,6 @@ const useEmployeeStore = defineStore('api-employee', () => {
|
|||
const res = await api.post<EmployeeCheckupCreate>(
|
||||
`/employee/${employeeId}/checkup`,
|
||||
{ ...payload },
|
||||
{ headers: { 'X-Rtid': flowStore.rtid } },
|
||||
);
|
||||
|
||||
if (!res) return false;
|
||||
|
|
@ -213,7 +178,6 @@ const useEmployeeStore = defineStore('api-employee', () => {
|
|||
const res = await api.post<EmployeeWorkCreate>(
|
||||
`/employee/${employeeId}/work`,
|
||||
{ ...payload },
|
||||
{ headers: { 'X-Rtid': flowStore.rtid } },
|
||||
);
|
||||
|
||||
if (!res) return false;
|
||||
|
|
@ -229,9 +193,6 @@ const useEmployeeStore = defineStore('api-employee', () => {
|
|||
const res = await api.post<EmployeeOtherCreate>(
|
||||
`/employee/${employeeId}/other-info`,
|
||||
{ ...payload },
|
||||
{
|
||||
headers: { 'X-Rtid': flowStore.rtid },
|
||||
},
|
||||
);
|
||||
|
||||
if (!res) return false;
|
||||
|
|
@ -256,7 +217,6 @@ const useEmployeeStore = defineStore('api-employee', () => {
|
|||
const res = await api.put<EmployeeCheckupCreate>(
|
||||
`/employee/${employeeOfId}/checkup/${id}`,
|
||||
{ ...payload },
|
||||
{ headers: { 'X-Rtid': flowStore.rtid } },
|
||||
);
|
||||
|
||||
if (!res) return false;
|
||||
|
|
@ -281,7 +241,6 @@ const useEmployeeStore = defineStore('api-employee', () => {
|
|||
const res = await api.put<EmployeeWorkCreate>(
|
||||
`/employee/${employeeOfId}/work/${id}`,
|
||||
{ ...payload },
|
||||
{ headers: { 'X-Rtid': flowStore.rtid } },
|
||||
);
|
||||
|
||||
if (!res) return false;
|
||||
|
|
@ -307,7 +266,6 @@ const useEmployeeStore = defineStore('api-employee', () => {
|
|||
const res = await api.put<EmployeeOtherCreate>(
|
||||
`/employee/${employeeOfId}/other-info/${id}`,
|
||||
{ ...payload },
|
||||
{ headers: { 'X-Rtid': flowStore.rtid } },
|
||||
);
|
||||
|
||||
if (!res) return false;
|
||||
|
|
@ -330,9 +288,7 @@ const useEmployeeStore = defineStore('api-employee', () => {
|
|||
|
||||
const res = await api.put<
|
||||
Employee & { imageUrl: string; profileImageUploadUrl: string }
|
||||
>(`/employee/${employeeId}`, payload, {
|
||||
headers: { 'X-Rtid': flowStore.rtid },
|
||||
});
|
||||
>(`/employee/${employeeId}`, payload);
|
||||
|
||||
if (!res) return false;
|
||||
|
||||
|
|
@ -361,7 +317,6 @@ const useEmployeeStore = defineStore('api-employee', () => {
|
|||
}) {
|
||||
const res = await api.delete<Employee>(
|
||||
`/employee/${opts.employeeId}/checkup/${opts.checkUpId}`,
|
||||
{ headers: { 'X-Rtid': flowStore.rtid } },
|
||||
);
|
||||
|
||||
if (!res) return false;
|
||||
|
|
@ -373,9 +328,6 @@ const useEmployeeStore = defineStore('api-employee', () => {
|
|||
async function deleteByIdWork(opts: { employeeId: string; workId?: string }) {
|
||||
const res = await api.delete<Employee>(
|
||||
`/employee/${opts.employeeId}/work/${opts.workId}`,
|
||||
{
|
||||
headers: { 'X-Rtid': flowStore.rtid },
|
||||
},
|
||||
);
|
||||
|
||||
if (!res) return false;
|
||||
|
|
@ -385,9 +337,7 @@ const useEmployeeStore = defineStore('api-employee', () => {
|
|||
}
|
||||
|
||||
async function deleteById(id: string) {
|
||||
const res = await api.delete<Employee>(`/employee/${id}`, {
|
||||
headers: { 'X-Rtid': flowStore.rtid },
|
||||
});
|
||||
const res = await api.delete<Employee>(`/employee/${id}`);
|
||||
|
||||
if (!res) return false;
|
||||
if (res.status === 200) return res.data;
|
||||
|
|
@ -396,27 +346,21 @@ const useEmployeeStore = defineStore('api-employee', () => {
|
|||
}
|
||||
|
||||
async function fetchCheckup(id: string) {
|
||||
const res = await api.get<EmployeeCheckup[]>(`/employee/${id}/checkup`, {
|
||||
headers: { 'X-Rtid': flowStore.rtid },
|
||||
});
|
||||
const res = await api.get<EmployeeCheckup[]>(`/employee/${id}/checkup`);
|
||||
if (res && res.status === 200) {
|
||||
return res.data;
|
||||
}
|
||||
}
|
||||
|
||||
async function fetchWork(id: string) {
|
||||
const res = await api.get<EmployeeWork[]>(`/employee/${id}/work`, {
|
||||
headers: { 'X-Rtid': flowStore.rtid },
|
||||
});
|
||||
const res = await api.get<EmployeeWork[]>(`/employee/${id}/work`);
|
||||
if (res && res.status === 200) {
|
||||
return res.data;
|
||||
}
|
||||
}
|
||||
|
||||
async function fetchOther(id: string) {
|
||||
const res = await api.get<EmployeeOther>(`/employee/${id}/other-info`, {
|
||||
headers: { 'X-Rtid': flowStore.rtid },
|
||||
});
|
||||
const res = await api.get<EmployeeOther>(`/employee/${id}/other-info`);
|
||||
if (res && res.status === 200) {
|
||||
return res.data;
|
||||
}
|
||||
|
|
@ -425,9 +369,6 @@ const useEmployeeStore = defineStore('api-employee', () => {
|
|||
async function getStatsEmployee(customerBranchId?: string) {
|
||||
const res = await api.get(
|
||||
`/employee/stats${customerBranchId ? '?customerBranchId=' + customerBranchId : ''}/`,
|
||||
{
|
||||
headers: { 'X-Rtid': flowStore.rtid },
|
||||
},
|
||||
);
|
||||
if (res && res.status === 200) {
|
||||
return res.data;
|
||||
|
|
@ -449,9 +390,6 @@ const useEmployeeStore = defineStore('api-employee', () => {
|
|||
|
||||
const res = await api.get(
|
||||
`/employee/stats/gender${(params && '?'.concat(query)) || ''}`,
|
||||
{
|
||||
headers: { 'X-Rtid': flowStore.rtid },
|
||||
},
|
||||
);
|
||||
if (res && res.status === 200) {
|
||||
return res.data;
|
||||
|
|
@ -459,9 +397,7 @@ const useEmployeeStore = defineStore('api-employee', () => {
|
|||
}
|
||||
|
||||
async function getEditHistory(employeeId: string) {
|
||||
const res = await api.get(`/employee/${employeeId}/edit-history`, {
|
||||
headers: { 'X-Rtid': flowStore.rtid },
|
||||
});
|
||||
const res = await api.get(`/employee/${employeeId}/edit-history`);
|
||||
if (res && res.status === 200) {
|
||||
return res.data;
|
||||
}
|
||||
|
|
@ -501,12 +437,6 @@ const useEmployeeStore = defineStore('api-employee', () => {
|
|||
const res = await api.put(
|
||||
`/employee/${employeeId}/attachment/${filename || file.name}`,
|
||||
file,
|
||||
{
|
||||
headers: {
|
||||
'X-Rtid': flowStore.rtid,
|
||||
'Content-Type': file.type,
|
||||
},
|
||||
},
|
||||
);
|
||||
return !(!res || res.status >= 400);
|
||||
}
|
||||
|
|
@ -514,7 +444,6 @@ const useEmployeeStore = defineStore('api-employee', () => {
|
|||
async function deleteAttachment(employeeId: string, filename: string) {
|
||||
const res = await api.delete(
|
||||
`/employee/${employeeId}/attachment/${filename}`,
|
||||
{ headers: { 'X-Rtid': flowStore.rtid } },
|
||||
);
|
||||
return !(!res || res.status >= 400);
|
||||
}
|
||||
|
|
@ -532,9 +461,7 @@ const useEmployeeStore = defineStore('api-employee', () => {
|
|||
}
|
||||
|
||||
async function listPassport(employeeId: string) {
|
||||
const res = await api.get(`/employee/${employeeId}/passport`, {
|
||||
headers: { 'X-Rtid': flowStore.rtid },
|
||||
});
|
||||
const res = await api.get(`/employee/${employeeId}/passport`);
|
||||
|
||||
if (res && res.status < 400) return res.data;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue