feat: form ocr (#56)

* refactor: add i18n

* refactor: add id in type employee visa

* refactor: edit layout ui visa

* refactor: add menu visa

* refactor: add type visa

* refactor: by value visa

* refactor: add workerType in option

* refactor: add index visa

* feat: submit add  delete and assign value

* feat: use submitVisa

* fix: col not working

* refactor: handle mrz and remark can is null

* refactor: add i18n

* refactor: add option workerStatus

* refactor: edit layout input

* refactor: menu set sub true

* refactor: add visa at dialog add

* refactor: handle index visa

* refactor: add i18n

* refactor: add input entryCount and issueCountry

* refactor: add input entryCout and issueCountry
This commit is contained in:
Net 2024-11-11 09:39:43 +07:00 committed by GitHub
parent 5888f3a9dd
commit ce3d809bd9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 1664 additions and 336 deletions

View file

@ -589,6 +589,7 @@ export const useEmployeeForm = defineStore('form-employee', () => {
currentEmployee: Employee | null;
currentIndex: number;
currentIndexPassport: number;
currentIndexVisa: number;
profileUrl: string;
isEmployeeEdit: boolean;
profileSubmit: boolean;
@ -619,6 +620,7 @@ export const useEmployeeForm = defineStore('form-employee', () => {
isImageEdit: false,
currentIndexPassport: -1,
currentIndex: -1,
currentIndexVisa: -1,
statusSavePersonal: false,
drawerModal: false,
imageDialog: false,
@ -771,6 +773,7 @@ export const useEmployeeForm = defineStore('form-employee', () => {
function resetFormDataEmployee(clean = false) {
state.value.currentIndexPassport = -1;
state.value.currentIndexVisa = -1;
if (clean) {
state.value.currentTab = 'personalInfo';
state.value.formDataEmployeeOwner = undefined;
@ -836,6 +839,56 @@ export const useEmployeeForm = defineStore('form-employee', () => {
state.value.currentIndexPassport = -1;
}
async function submitVisa() {
if (
currentFromDataEmployee.value.employeeVisa?.[
state.value.currentIndexVisa
] === undefined
)
return;
if (
currentFromDataEmployee.value.employeeVisa?.[state.value.currentIndexVisa]
.id === undefined
) {
const res = await employeeStore.postMeta({
parentId: currentFromDataEmployee.value.id || '',
group: 'visa',
meta: currentFromDataEmployee.value.employeeVisa?.[
state.value.currentIndexVisa
],
});
if (res) {
currentFromDataEmployee.value.employeeVisa[
state.value.currentIndexVisa
].id = res.id;
}
}
if (
currentFromDataEmployee.value.employeeVisa?.[state.value.currentIndexVisa]
.id !== undefined
) {
const { id, ...payload } =
currentFromDataEmployee.value.employeeVisa?.[
state.value.currentIndexVisa
];
await employeeStore.putMeta({
parentId: currentFromDataEmployee.value.id || '',
group: 'visa',
metaId:
currentFromDataEmployee.value.employeeVisa?.[
state.value.currentIndexVisa
].id || '',
meta: payload,
});
}
await assignFormDataEmployee(currentFromDataEmployee.value.id);
state.value.currentIndexPassport = -1;
}
async function submitOther() {
if (!currentFromDataEmployee.value.employeeOtherInfo) return;
@ -881,6 +934,25 @@ export const useEmployeeForm = defineStore('form-employee', () => {
}
}
async function deleteVisa() {
const res = await employeeStore.delMeta({
parentId: currentFromDataEmployee.value.id || '',
group: 'visa',
metaId:
currentFromDataEmployee.value.employeeVisa?.[
state.value.currentIndexVisa
].id || '',
});
if (res) {
currentFromDataEmployee.value.employeeVisa?.splice(
state.value.currentIndexVisa,
1,
);
await assignFormDataEmployee(currentFromDataEmployee.value.id);
}
}
async function deleteWorkHistory() {
if (!currentFromDataEmployee.value.employeeWork) return;
@ -1085,6 +1157,22 @@ export const useEmployeeForm = defineStore('form-employee', () => {
})),
),
employeeVisa: structuredClone(
payload.employeeVisa?.length === 0
? defaultFormData.employeeVisa
: payload.employeeVisa?.map((item) => ({
id: item.id,
number: item.number,
type: item.type,
entryCount: item.entryCount,
issueCountry: item.issueCountry,
issuePlace: item.issuePlace,
issueDate: item.issueDate,
expireDate: item.expireDate,
mrz: item.mrz || undefined,
remark: item.remark || undefined,
})),
),
employeeCheckup: structuredClone(
payload.employeeCheckup?.length === 0
? defaultFormData.employeeCheckup
@ -1128,6 +1216,9 @@ export const useEmployeeForm = defineStore('form-employee', () => {
state.value.currentIndexPassport =
(currentFromDataEmployee.value.employeePassport?.length || 0) - 1;
state.value.currentIndexVisa =
(currentFromDataEmployee.value.employeeVisa?.length || 0) - 1;
if (
currentFromDataEmployee.value.employeePassport?.[
state.value.currentIndexPassport
@ -1135,6 +1226,15 @@ export const useEmployeeForm = defineStore('form-employee', () => {
) {
state.value.currentIndexPassport = -1;
}
if (
currentFromDataEmployee.value.employeeVisa?.[
state.value.currentIndexVisa
].id !== undefined
) {
state.value.currentIndexVisa = -1;
}
const foundBranch = await customerStore.fetchListCustomerBranchById(
payload.customerBranchId,
);
@ -1197,20 +1297,40 @@ export const useEmployeeForm = defineStore('form-employee', () => {
(currentFromDataEmployee.value.employeePassport?.length || 0) - 1;
}
function addVisa() {
currentFromDataEmployee.value.employeeVisa?.push({
number: '',
type: '',
entryCount: 0,
issueCountry: '',
issuePlace: '',
issueDate: new Date(),
expireDate: new Date(),
mrz: undefined,
remark: undefined,
});
state.value.currentIndexVisa =
(currentFromDataEmployee.value.employeeVisa?.length || 0) - 1;
}
return {
state,
currentFromDataEmployee,
resetEmployeeData,
addPassport,
addVisa,
submitPassport,
submitVisa,
submitOther,
submitWorkHistory,
submitPersonal,
submitHealthCheck,
deletePassport,
deleteVisa,
deleteWorkHistory,
deleteHealthCheck,