refactor: use ocr on font
This commit is contained in:
parent
547a4d4a5d
commit
9b38609d33
1 changed files with 70 additions and 24 deletions
|
|
@ -48,6 +48,7 @@ import SideMenu from 'components/SideMenu.vue';
|
|||
import TableEmpoloyee from 'src/components/03_customer-management/TableEmpoloyee.vue';
|
||||
import HistoryEditComponent from 'src/components/03_customer-management/HistoryEditComponent.vue';
|
||||
import { calculateAge, toISOStringWithTimezone } from 'src/utils/datetime';
|
||||
import { runOcr, parseResultMRZ } from 'src/utils/ocr';
|
||||
import {
|
||||
UploadFileGroup,
|
||||
FormTm6,
|
||||
|
|
@ -87,6 +88,7 @@ const employeeFormStore = useEmployeeForm();
|
|||
const optionStore = useOptionStore();
|
||||
const ocrStore = useOcrStore();
|
||||
|
||||
const mrz = ref<Awaited<ReturnType<typeof parseResultMRZ>>>();
|
||||
const tabFieldRequired = ref<{ [key: string]: (keyof CustomerBranchCreate)[] }>(
|
||||
{
|
||||
main: [],
|
||||
|
|
@ -2596,21 +2598,42 @@ const emptyCreateDialog = ref(false);
|
|||
:columns="columnsAttachment"
|
||||
:ocr="
|
||||
async (group, file) => {
|
||||
const res = await ocrStore.sendOcr({
|
||||
file: file,
|
||||
category: group,
|
||||
});
|
||||
if (group === 'passport') {
|
||||
mrz = await runOcr(file, parseResultMRZ);
|
||||
|
||||
if (res) {
|
||||
const tempValue = {
|
||||
status: true,
|
||||
group,
|
||||
meta: res.fields,
|
||||
};
|
||||
if (mrz !== null) {
|
||||
const mapMrz = Object.entries(mrz.result).map(
|
||||
([key, value]) => ({
|
||||
name: key,
|
||||
value: value,
|
||||
}),
|
||||
);
|
||||
const tempValue = {
|
||||
status: true,
|
||||
group,
|
||||
meta: mapMrz,
|
||||
};
|
||||
|
||||
return tempValue;
|
||||
return tempValue;
|
||||
}
|
||||
} else {
|
||||
const res = await ocrStore.sendOcr({
|
||||
file: file,
|
||||
category: group,
|
||||
});
|
||||
|
||||
if (res) {
|
||||
const tempValue = {
|
||||
status: true,
|
||||
group,
|
||||
meta: res.fields,
|
||||
};
|
||||
|
||||
return tempValue;
|
||||
}
|
||||
}
|
||||
return { status: false, group, meta: [] };
|
||||
|
||||
return { status: true, group, meta: [] };
|
||||
}
|
||||
"
|
||||
:auto-save="currentFromDataEmployee.id !== ''"
|
||||
|
|
@ -3824,21 +3847,43 @@ const emptyCreateDialog = ref(false);
|
|||
:columns="columnsAttachment"
|
||||
:ocr="
|
||||
async (group, file) => {
|
||||
const res = await ocrStore.sendOcr({
|
||||
file: file,
|
||||
category: group,
|
||||
});
|
||||
if (group === 'passport') {
|
||||
mrz = await runOcr(file, parseResultMRZ);
|
||||
|
||||
if (res) {
|
||||
const tempValue = {
|
||||
status: true,
|
||||
group,
|
||||
meta: res.fields,
|
||||
};
|
||||
if (mrz) {
|
||||
const mapMrz = Object.entries(mrz.result).map(
|
||||
([key, value]) => ({
|
||||
name: key,
|
||||
value: value,
|
||||
}),
|
||||
);
|
||||
|
||||
return tempValue;
|
||||
const tempValue = {
|
||||
status: true,
|
||||
group,
|
||||
meta: mapMrz,
|
||||
};
|
||||
|
||||
return tempValue;
|
||||
}
|
||||
} else {
|
||||
const res = await ocrStore.sendOcr({
|
||||
file: file,
|
||||
category: group,
|
||||
});
|
||||
|
||||
if (res) {
|
||||
const tempValue = {
|
||||
status: true,
|
||||
group,
|
||||
meta: res.fields,
|
||||
};
|
||||
|
||||
return tempValue;
|
||||
}
|
||||
}
|
||||
return { status: false, group, meta: [] };
|
||||
|
||||
return { status: true, group, meta: [] };
|
||||
}
|
||||
"
|
||||
:auto-save="currentFromDataEmployee.id !== ''"
|
||||
|
|
@ -3948,6 +3993,7 @@ const emptyCreateDialog = ref(false);
|
|||
v-model:last-name-en="meta.lastNameEN"
|
||||
v-model:address="meta.address"
|
||||
/>
|
||||
|
||||
<FormEmployeePassport
|
||||
v-if="mode === 'passport' && meta"
|
||||
prefix-id="drawer-info-employee"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue