refactor: map treeFile
This commit is contained in:
parent
d839f41b24
commit
5d519dc20b
1 changed files with 37 additions and 1 deletions
|
|
@ -5,7 +5,9 @@ import EmployerFormBusiness from './EmployerFormBusiness.vue';
|
|||
import EmployerFormContact from './EmployerFormContact.vue';
|
||||
import { CustomerCreate } from 'stores/customer/types';
|
||||
import EmployerFormAbout from './EmployerFormAbout.vue';
|
||||
import { useCustomerForm } from 'src/pages/03_customer-management/form';
|
||||
|
||||
const customerFormStore = useCustomerForm();
|
||||
import { FormCitizen } from 'components/upload-file/';
|
||||
|
||||
import useOcrStore from 'stores/ocr';
|
||||
|
|
@ -21,11 +23,14 @@ import UploadFile from 'src/components/upload-file/UploadFile.vue';
|
|||
import { uploadFileListCustomer } from '../../constant';
|
||||
|
||||
const statusOcr = ref(false);
|
||||
|
||||
const customer = defineModel<CustomerCreate>('customer', { required: true });
|
||||
|
||||
const item = defineModel<NonNullable<CustomerCreate['customerBranch']>[number]>(
|
||||
'customerBranch',
|
||||
{ required: true },
|
||||
);
|
||||
|
||||
const tab = ref('main');
|
||||
|
||||
defineEmits<{
|
||||
|
|
@ -176,7 +181,38 @@ defineProps<{
|
|||
:dropdown-list="uploadFileListCustomer"
|
||||
v-model:status-ocr="statusOcr"
|
||||
v-model:file="item.file"
|
||||
:tree-file="treeFile"
|
||||
:tree-file="
|
||||
Object.values(
|
||||
item.file?.reduce<
|
||||
Record<string, { label: string; file: { label: string }[] }>
|
||||
>((a, c) => {
|
||||
const _group = c.group || 'other';
|
||||
console.log(c);
|
||||
|
||||
if (!a[_group]) {
|
||||
a[_group] = {
|
||||
label: $t(
|
||||
uploadFileListCustomer.find((v) => v.value === _group)
|
||||
?.label || _group,
|
||||
),
|
||||
file: [
|
||||
{
|
||||
label:
|
||||
c.name ||
|
||||
`${c.group}-${c.file?.name || Date.now()}`,
|
||||
},
|
||||
],
|
||||
};
|
||||
} else {
|
||||
a[_group].file.push({
|
||||
label:
|
||||
c.name || `${c.group}-${c.file?.name || Date.now()}`,
|
||||
});
|
||||
}
|
||||
return a;
|
||||
}, {}) || {},
|
||||
)
|
||||
"
|
||||
@send-ocr="
|
||||
async (v: any, f: any) => {
|
||||
const res = await ocrStore.sendOcr({ file: f });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue