fix download file log
This commit is contained in:
parent
1288a7b08f
commit
658fd6705e
3 changed files with 13 additions and 9 deletions
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue