refactor: by data
This commit is contained in:
parent
51fd9e0c84
commit
22fae293e3
1 changed files with 39 additions and 14 deletions
|
|
@ -19,6 +19,7 @@ import {
|
|||
import UploadFile from 'src/components/upload-file/UploadFile.vue';
|
||||
import { uploadFileListCustomer } from '../../constant';
|
||||
|
||||
const customer = defineModel<CustomerCreate>('customer', { required: true });
|
||||
const item = defineModel<NonNullable<CustomerCreate['customerBranch']>[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<Record<string, string>>(
|
||||
(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) => {}"
|
||||
>
|
||||
<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>
|
||||
|
||||
<!-- <EmployerFormAttachment
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue