refactor: by data

This commit is contained in:
Net 2024-08-27 19:36:59 +07:00 committed by Methapon Metanipat
parent 51fd9e0c84
commit 22fae293e3

View file

@ -19,6 +19,7 @@ import {
import UploadFile from 'src/components/upload-file/UploadFile.vue'; import UploadFile from 'src/components/upload-file/UploadFile.vue';
import { uploadFileListCustomer } from '../../constant'; import { uploadFileListCustomer } from '../../constant';
const customer = defineModel<CustomerCreate>('customer', { required: true });
const item = defineModel<NonNullable<CustomerCreate['customerBranch']>[number]>( const item = defineModel<NonNullable<CustomerCreate['customerBranch']>[number]>(
'customerBranch', 'customerBranch',
{ required: true }, { required: true },
@ -174,23 +175,47 @@ defineProps<{
:tree-file="treeFile" :tree-file="treeFile"
@send-ocr=" @send-ocr="
async (v: any, f: any) => { async (v: any, f: any) => {
await ocrStore.sendOcr({ file: f }); const res = await ocrStore.sendOcr({ file: f });
}
" if (res) {
@save=" const map = res.fields.reduce<Record<string, string>>(
(group: any, file: any) => { (a, c) => {
// const ext = file.name.split('.').at(-1); a[c.name] = c.value;
// let filename = group + '-' + new Date().getTime(); return a;
// if (ext) filename += `.${ext}`; },
// customerFormStore.putAttachment({ {},
// branchId: item.id || '', );
// file, if (!item.citizenId) item.citizenId = map['citizen_id'] || '';
// filename, 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) => {}"
> >
<template #form></template> <template #form>
<FormCitizen
orc
v-model:citizen-id="item.citizenId"
v-model:birth-date="customer.birthDate"
v-model:first-name="customer.firstName"
v-model:first-name-en="customer.firstNameEN"
v-model:last-name="customer.lastName"
v-model:last-name-en="customer.lastNameEN"
v-model:address="item.address"
/>
</template>
</UploadFile> </UploadFile>
<!-- <EmployerFormAttachment <!-- <EmployerFormAttachment