refactor:(genreport) : import downloadBlobFile

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2026-05-11 09:24:23 +07:00
parent ebd514a33a
commit 9bee07eb7c

View file

@ -2,6 +2,7 @@ import axios from "axios";
import config from "@/app.config";
import { useCounterMixin } from "@/stores/mixin";
import { downloadBlobFile } from "@/modules/10_registry/utils/downloadFile";
const mixin = useCounterMixin();
const { showLoader, hideLoader } = mixin;
@ -19,7 +20,7 @@ async function genReport(data: any, fileName: string, type: string = "docx") {
},
responseType: "arraybuffer",
})
.then((res) => {
.then(async (res) => {
const responseData = res.data;
if (responseData) {
const mimeType =
@ -31,18 +32,11 @@ async function genReport(data: any, fileName: string, type: string = "docx") {
const url = URL.createObjectURL(blob);
const baseName = fileName.trim();
const extension = type === "docx" ? "docx" : "pdf";
const link = document.createElement("a");
link.href = url;
link.download = `${baseName}.${extension}`;
document.body.appendChild(link);
link.click();
setTimeout(() => {
document.body.removeChild(link);
URL.revokeObjectURL(url);
}, 100);
// const extension = type === "docx" ? "docx" : "pdf";
await downloadBlobFile({
downloadUrl: url,
fileName: baseName,
});
}
})
.catch((err) => {