refactor(registry): downloadBlobFile
This commit is contained in:
parent
9eaa28711d
commit
f07cf25489
10 changed files with 103 additions and 138 deletions
|
|
@ -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 { DutyFormType } from "@/modules/10_registry/interface/index/Main";
|
||||
|
||||
|
|
@ -298,19 +299,10 @@ async function onDownloadFile(id: string, profileId: string) {
|
|||
showLoader();
|
||||
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 = `เอกสารปฏิบัติราชการพิเศษ`;
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
setTimeout(() => {
|
||||
document.body.removeChild(link);
|
||||
URL.revokeObjectURL(url);
|
||||
}, 100);
|
||||
await downloadBlobFile({
|
||||
downloadUrl: res.downloadUrl,
|
||||
fileName: `เอกสารปฏิบัติราชการพิเศษ`,
|
||||
});
|
||||
} catch (e) {
|
||||
messageError($q, e);
|
||||
} finally {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue