refactor: edit type

This commit is contained in:
Net 2024-08-27 19:37:30 +07:00 committed by Methapon Metanipat
parent 381f1c18e6
commit d1133d0bc2
2 changed files with 15 additions and 6 deletions

View file

@ -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<string, any>;
}>({
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,
})),
});
}

View file

@ -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 {