แก้โหลดไฟล์ เป็น id
This commit is contained in:
parent
dd5c3a42f6
commit
232b5cf60d
5 changed files with 58 additions and 28 deletions
|
|
@ -1058,6 +1058,22 @@ export const useCounterMixin = defineStore("mixin", () => {
|
|||
}
|
||||
}
|
||||
|
||||
function downloadRenameFileByLink(link: string, fileName: string) {
|
||||
fetch(link)
|
||||
.then(response => response.blob())
|
||||
.then(blob => {
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
const a = document.createElement("a");
|
||||
a.href = url;
|
||||
a.download = fileName; // ชื่อไฟล์
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
window.URL.revokeObjectURL(url);
|
||||
document.body.removeChild(a);
|
||||
})
|
||||
.catch(error => console.error('ดาวน์โหลดไฟล์ไม่สำเร็จ:', error));
|
||||
}
|
||||
|
||||
return {
|
||||
calAge,
|
||||
date2Thai,
|
||||
|
|
@ -1099,5 +1115,6 @@ export const useCounterMixin = defineStore("mixin", () => {
|
|||
findOrgNameOld,
|
||||
findPosMasterNo,
|
||||
findPosMasterNoOld,
|
||||
downloadRenameFileByLink
|
||||
};
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue