diff --git a/src/pages/03_customer-management/components/employer/EmployerFormBranch.vue b/src/pages/03_customer-management/components/employer/EmployerFormBranch.vue index 233675e8..f4196efc 100644 --- a/src/pages/03_customer-management/components/employer/EmployerFormBranch.vue +++ b/src/pages/03_customer-management/components/employer/EmployerFormBranch.vue @@ -19,6 +19,7 @@ import { import UploadFile from 'src/components/upload-file/UploadFile.vue'; import { uploadFileListCustomer } from '../../constant'; +const customer = defineModel('customer', { required: true }); const item = defineModel[number]>( 'customerBranch', { required: true }, @@ -174,23 +175,47 @@ defineProps<{ :tree-file="treeFile" @send-ocr=" async (v: any, f: any) => { - await ocrStore.sendOcr({ file: f }); - } - " - @save=" - (group: any, file: any) => { - // const ext = file.name.split('.').at(-1); - // let filename = group + '-' + new Date().getTime(); - // if (ext) filename += `.${ext}`; - // customerFormStore.putAttachment({ - // branchId: item.id || '', - // file, - // filename, - // }); + const res = await ocrStore.sendOcr({ file: f }); + + if (res) { + const map = res.fields.reduce>( + (a, c) => { + a[c.name] = c.value; + return a; + }, + {}, + ); + if (!item.citizenId) item.citizenId = map['citizen_id'] || ''; + if (!item.address) item.address = map['address'] || ''; + if (!customer.firstName) + customer.firstName = map['firstname'] || ''; + if (!customer.lastName) + customer.lastName = map['lastname'] || ''; + if (!customer.firstNameEN) + customer.firstNameEN = map['firstname_en'] || ''; + if (!customer.lastNameEN) + customer.lastNameEN = map['lastname_en'] || ''; + if (!customer.birthDate) + customer.birthDate = new Date(map['birth_date'] || ''); + } + + statusOcr = false; } " + @save="(group: any, file: any) => {}" > - +