feat: 09, 11 => handle file upload & url on create

This commit is contained in:
puriphatt 2025-01-20 14:04:44 +07:00
parent 684a97cef3
commit 44476f8535
2 changed files with 55 additions and 11 deletions

View file

@ -490,6 +490,10 @@ async function getFileList(creditNoteId: string, slip?: boolean) {
));
}
function fileToUrl(file: File) {
return URL.createObjectURL(file);
}
onMounted(async () => {
initTheme();
initLang();
@ -653,8 +657,12 @@ onMounted(async () => {
v-model:file-data="attachmentData"
:transform-url="
async (url: string) => {
const result = await api.get<string>(url);
return result.data;
if (!creditNoteData?.id) {
return url;
} else {
const result = await api.get<string>(url);
return result.data;
}
}
"
@fetch-file-list="
@ -675,6 +683,7 @@ onMounted(async () => {
loaded: 0,
total: el.size,
placeholder: true,
url: fileToUrl(el),
});
});