diff --git a/src/pages/03_customer-management/MainPage.vue b/src/pages/03_customer-management/MainPage.vue index 20efc016..b5920259 100644 --- a/src/pages/03_customer-management/MainPage.vue +++ b/src/pages/03_customer-management/MainPage.vue @@ -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>>(); 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" /> +