diff --git a/src/pages/03_customer-management/form.ts b/src/pages/03_customer-management/form.ts index 62491a1c..987a3219 100644 --- a/src/pages/03_customer-management/form.ts +++ b/src/pages/03_customer-management/form.ts @@ -48,7 +48,8 @@ export const useCustomerForm = defineStore('form-customer', () => { editCustomerId?: string; editCustomerCode?: string; editCustomerBranchId?: string; - treeFile: { lable: string; file: { lable: string }[] }[]; + treeFile: { label: string; file: { label: string }[] }[]; + formDataOcr: Record; }>({ dialogType: 'info', dialogOpen: false, @@ -63,6 +64,7 @@ export const useCustomerForm = defineStore('form-customer', () => { editCustomerBranchId: '', defaultCustomerImageUrl: '', treeFile: [], + formDataOcr: {}, }); watch( @@ -174,15 +176,15 @@ export const useCustomerForm = defineStore('form-customer', () => { if ( !state.value.treeFile.some( - (x) => x.lable === t(`customer.typeFile.${temp || ''}`), + (x) => x.label === t(`customer.typeFile.${temp || ''}`), ) ) { state.value.treeFile.push({ - lable: t(`customer.typeFile.${temp || ''}`), + label: t(`customer.typeFile.${temp || ''}`), file: r .filter((x) => x.includes(temp || '')) .map((x) => ({ - lable: x, + label: x, })), }); } diff --git a/src/stores/ocr/index.ts b/src/stores/ocr/index.ts index 96a4ce1d..bbf4ddf0 100644 --- a/src/stores/ocr/index.ts +++ b/src/stores/ocr/index.ts @@ -18,12 +18,19 @@ const useOcr = defineStore('useOcrStore', () => { }, ) { const res = await axios - .post(`${baseUrl}/`, payload.file, { + .post<{ + document: string; + fields: { name: string; value: string }[]; + result: string; + }>(`${baseUrl}/`, payload.file, { headers: { 'Content-Type': payload.file?.type }, onUploadProgress: (e) => console.log(e), }) .catch((e) => console.error(e)); - // ]); + + if (!res || res.status >= 400) return false; + + return res.data; } return {