refactor(registry): downloadBlobFile

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2026-05-08 17:39:01 +07:00
parent 9eaa28711d
commit f07cf25489
10 changed files with 103 additions and 138 deletions

View file

@ -7,6 +7,7 @@ import config from "@/app.config";
import { useCounterMixin } from "@/stores/mixin";
import { useDataStore } from "@/stores/data";
import { useRegistryDataStore } from "@/modules/10_registry/store/Main";
import { downloadBlobFile } from "@/modules/10_registry/utils/downloadFile";
import type { NopaidFormType } from "@/modules/10_registry/interface/index/Main";
@ -280,18 +281,10 @@ async function onDownloadFile(id: string, profileId: string) {
try {
const res = await getPathUploadFlie(fileGroup.value, profileId, id);
const downloadUrl = res.downloadUrl;
const response = await fetch(downloadUrl);
const blob = await response.blob();
const url = URL.createObjectURL(blob);
const link = document.createElement("a");
link.href = url;
link.download = `บันทึกวันที่ไม่ได้รับ${salaryText.value}`;
document.body.appendChild(link);
link.click();
setTimeout(() => {
document.body.removeChild(link);
URL.revokeObjectURL(url);
}, 100);
await downloadBlobFile({
downloadUrl: downloadUrl,
fileName: `บันทึกวันที่ไม่ได้รับ${salaryText.value}`,
});
} catch (e) {
messageError($q, e);
} finally {