refactor: handle put attachment

This commit is contained in:
Thanaphon Frappet 2024-11-12 16:01:04 +07:00
parent ae83a574e0
commit 22f19ca8cc
2 changed files with 196 additions and 89 deletions

View file

@ -21,7 +21,7 @@ import {
calculateDaysUntilExpire,
dialog,
} from 'src/stores/utils';
import useEmployeeStore from 'stores/employee';
import { useInvoice, useReceipt } from 'stores/payment';
import useCustomerStore from 'stores/customer';
import useOptionStore from 'stores/options';
@ -98,6 +98,7 @@ type Node = {
type ProductGroupId = string;
const employeeStore = useEmployeeStore();
const route = useRoute();
const useReceiptStore = useReceipt();
const configStore = useConfigStore();
@ -2243,7 +2244,8 @@ async function getInvoiceCodeFullPay() {
return tempValue;
}
} else {
}
if (group === 'visa') {
const res = await ocrStore.sendOcr({
file: file,
category: group,
@ -2269,25 +2271,48 @@ async function getInvoiceCodeFullPay() {
}
"
:get-file-list="
async (group: 'passport' | 'visa') => {
if (formDataEmployee.attachment !== undefined) {
const resMeta = formDataEmployee.attachment.filter(
(v) => v.group === group,
);
async (group: 'passport' | 'visa' | 'attachment') => {
if (!!currentFromDataEmployee.id && group !== 'attachment') {
const resMeta = await employeeStore.getMetaList({
parentId: currentFromDataEmployee.id,
group,
});
const tempValue = resMeta.map(async (i: any) => {
return {
_meta: { ...i._meta },
name: i.id || '',
_meta: { ...i },
name: `${group}-${dateFormat(i.expireDate)}` || '',
group: group,
url: i.url,
url: await employeeStore.getFile({
parentId: currentFromDataEmployee.id || '',
group,
fileId: i.id,
}),
file: undefined,
};
});
return await waitAll(tempValue);
} else {
const res = await employeeStore.listAttachment({
parentId: currentFromDataEmployee.id || '',
});
const tempValue = (res as string[]).map(async (i: any) => {
return {
_meta: { id: i, name: i },
name: i || '',
group: group,
url: await employeeStore.getAttachment({
parentId: currentFromDataEmployee.id || '',
name: i,
}),
file: undefined,
};
});
return await waitAll(tempValue);
}
return [];
}
"
>