fix download file log

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-11-19 09:32:32 +07:00
parent 1288a7b08f
commit 658fd6705e
3 changed files with 13 additions and 9 deletions

View file

@ -12,11 +12,15 @@ const { showLoader, hideLoader, messageError } = mixin;
async function generateTxt(data: any, fileName: string) {
showLoader();
await axios
.post(`${config.API.reportTemplate}/txt`, data, {
.post(`${config.API.reportTemplate}/docx`, data, {
headers: {
"Content-Type": "text/plain;charset=utf-8",
accept:
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"content-Type": "application/json",
// "Content-Type": "text/plain;charset=utf-8",
},
responseType: "blob",
// responseType: "blob",
responseType: "arraybuffer",
})
.then((res) => {
const data = res.data;
@ -30,7 +34,7 @@ async function generateTxt(data: any, fileName: string) {
// สร้างลิงก์เพื่อดาวน์โหลดไฟล์
const link = document.createElement("a");
link.href = url;
link.download = `${fileName}.txt`; // กำหนดชื่อไฟล์ที่จะดาวน์โหลด
link.download = `${fileName}.docx`; // กำหนดชื่อไฟล์ที่จะดาวน์โหลด
document.body.appendChild(link);
link.click();