Merge branch 'develop' into dev
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m6s
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m6s
# Conflicts: # src/plugins/genreport.ts
This commit is contained in:
commit
92d0a6ff26
1 changed files with 0 additions and 28 deletions
|
|
@ -20,33 +20,6 @@ async function genReport(data: any, fileName: string, type: string = "docx") {
|
||||||
responseType: "arraybuffer",
|
responseType: "arraybuffer",
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
// const data = res.data;
|
|
||||||
// if (data) {
|
|
||||||
// // สร้าง Blob จาก array buffer
|
|
||||||
// const blob = new Blob([data], {
|
|
||||||
// type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
||||||
// });
|
|
||||||
|
|
||||||
// // สร้าง URL สำหรับไฟล์ Blob
|
|
||||||
// const url = URL.createObjectURL(blob);
|
|
||||||
|
|
||||||
// // 1. ตัดนามสกุลเดิมที่ติดมากับ fileName ออก (ถ้ามี)
|
|
||||||
// const baseName = fileName.replace(/\.[^/.]+$/, "");
|
|
||||||
|
|
||||||
// // 2. กำหนดนามสกุลใหม่ตามเงื่อนไข
|
|
||||||
// const extension = type === "docx" ? "docx" : "pdf";
|
|
||||||
|
|
||||||
// // สร้างลิงก์เพื่อดาวน์โหลดไฟล์
|
|
||||||
// const link = document.createElement("a");
|
|
||||||
// link.href = url;
|
|
||||||
// link.download = `${baseName}.${extension}`;
|
|
||||||
// // link.download = `${fileName}.${type === "docx" ? "docx" : "pdf"}`; // กำหนดชื่อไฟล์ที่จะดาวน์โหลด
|
|
||||||
// document.body.appendChild(link);
|
|
||||||
// link.click();
|
|
||||||
|
|
||||||
// // ลบ URL ที่สร้างขึ้นหลังจากใช้งาน
|
|
||||||
// URL.revokeObjectURL(url);
|
|
||||||
|
|
||||||
const responseData = res.data;
|
const responseData = res.data;
|
||||||
if (responseData) {
|
if (responseData) {
|
||||||
// --- ส่วนที่ปรับปรุง 1: กำหนด MIME Type ให้ตรงกับไฟล์ที่รับมาจริง ---
|
// --- ส่วนที่ปรับปรุง 1: กำหนด MIME Type ให้ตรงกับไฟล์ที่รับมาจริง ---
|
||||||
|
|
@ -78,7 +51,6 @@ async function genReport(data: any, fileName: string, type: string = "docx") {
|
||||||
URL.revokeObjectURL(url);
|
URL.revokeObjectURL(url);
|
||||||
}, 100);
|
}, 100);
|
||||||
}
|
}
|
||||||
// }
|
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue