diff --git a/src/pages/03_customer-management/components/employer/EmployerFormBranch.vue b/src/pages/03_customer-management/components/employer/EmployerFormBranch.vue index 947ea1b3..66b66b9a 100644 --- a/src/pages/03_customer-management/components/employer/EmployerFormBranch.vue +++ b/src/pages/03_customer-management/components/employer/EmployerFormBranch.vue @@ -7,12 +7,14 @@ import { CustomerCreate } from 'stores/customer/types'; import EmployerFormAbout from './EmployerFormAbout.vue'; import EmployerFormAuthorized from './EmployerFormAuthorized.vue'; import { useCustomerForm } from 'src/pages/03_customer-management/form'; - +import { waitAll } from 'src/stores/utils'; const customerFormStore = useCustomerForm(); import { FormCitizen } from 'components/upload-file/'; import useOcrStore from 'stores/ocr'; +import useCustomerStore from 'stores/customer'; +const customerStore = useCustomerStore(); const ocrStore = useOcrStore(); import { SaveButton, @@ -20,8 +22,8 @@ import { DeleteButton, UndoButton, } from 'components/button'; -import UploadFile from 'src/components/upload-file/UploadFile.vue'; -import { uploadFileListCustomer } from '../../constant'; +import { UploadFileGroup } from 'src/components/upload-file/'; +import { uploadFileListCustomer, columnsAttachment } from '../../constant'; const statusOcr = ref(false); @@ -211,100 +213,190 @@ withDefaults( /> - { + const res = await customerStore.delMeta({ + parentId: item.id || '', + group: obj.group, + metaId: obj._meta.id, }); 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'] || ''); + return true; } - - statusOcr = false; + return false; } " - @delete-file=" - (filename) => { - if (!item.id) return; + :save=" + async ( + group: + | 'citizen' + | 'house-registration' + | 'commercial-registration' + | 'vat-registration' + | 'power-of-attorney', + _meta: any, + file: File | undefined, + ) => { + if (file !== undefined && item.id) { + const res = await customerStore.postMeta({ + parentId: item.id || '', + group, + meta: _meta, + file, + }); - customerFormStore.deleteAttachment( - { branchId: item.id, customerId: item.customerId }, - filename, - ); + if (res) { + return true; + } + } else { + const { + customerBranchId, + id, + employeeId, + createdAt, + updatedAt, + middleName, + middleNameEN, + + ...payload + } = _meta; + const res = await customerStore.putMeta({ + parentId: item.id || '', + group, + metaId: _meta.id, + meta: payload, + file, + }); + if (res) { + return true; + } + } + + return false; + } + " + :get-file-list=" + async ( + group: + | 'citizen' + | 'house-registration' + | 'commercial-registration' + | 'vat-registration' + | 'power-of-attorney', + ) => { + if (!!item.id) { + const resMeta = await customerStore.getMetaList({ + parentId: item.id, + group, + }); + + const tempValue = resMeta.map(async (v: any) => { + return { + _meta: { ...v }, + name: v.id || '', + group: group, + url: await customerStore.getFile({ + parentId: item.id || '', + group, + fileId: v.id, + }), + file: undefined, + }; + }); + + return await waitAll(tempValue); + } + return []; } " > -