Compare commits

...

3 commits

Author SHA1 Message Date
DESKTOP-1R2VSQH\Lenovo ThinkPad E490
c6bb8fffe2 Merge branch 'dev' of https://forgejo.chamomind.com/hrms-bangkok/hrms-mgt into dev
All checks were successful
Build & Deploy on Dev / build (push) Successful in 2m58s
2026-04-21 14:15:06 +07:00
DESKTOP-1R2VSQH\Lenovo ThinkPad E490
34cf21da65 Merge branch 'develop' into dev 2026-04-21 14:14:59 +07:00
DESKTOP-1R2VSQH\Lenovo ThinkPad E490
1de3d35752 refactor(retirement): download retirementReport 2026-04-21 14:14:38 +07:00

View file

@ -370,18 +370,32 @@ async function uploadFile(event: any, date: any) {
*/
async function downloadAttachment(type: string, id: string) {
showLoader();
await http
.get(config.API.reportRetireList(type, id))
.then(async (res) => {
const data = res.data.result;
await genReport(data, `รายชื่อผู้เกษียณอายุราชการ`, type);
})
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
})
.finally(() => {
hideLoader();
});
try {
const response = await http.get(
config.API.retirementReport + `/${type}/${id}`,
{
headers: {
accept:
type === "pdf"
? "application/pdf"
: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"content-Type": "application/json",
},
responseType: "blob",
}
);
const blob = response.data;
const url = URL.createObjectURL(blob);
const link = document.createElement("a");
link.href = url;
link.download = `รายชื่อผู้เกษียณอายุราชการ.${type}`;
link.click();
URL.revokeObjectURL(url);
} catch (e) {
messageError($q, e);
} finally {
hideLoader();
}
}
//