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