refactor(retirement): download retirementReport
This commit is contained in:
parent
5193720567
commit
1de3d35752
1 changed files with 26 additions and 12 deletions
|
|
@ -370,18 +370,32 @@ async function uploadFile(event: any, date: any) {
|
||||||
*/
|
*/
|
||||||
async function downloadAttachment(type: string, id: string) {
|
async function downloadAttachment(type: string, id: string) {
|
||||||
showLoader();
|
showLoader();
|
||||||
await http
|
try {
|
||||||
.get(config.API.reportRetireList(type, id))
|
const response = await http.get(
|
||||||
.then(async (res) => {
|
config.API.retirementReport + `/${type}/${id}`,
|
||||||
const data = res.data.result;
|
{
|
||||||
await genReport(data, `รายชื่อผู้เกษียณอายุราชการ`, type);
|
headers: {
|
||||||
})
|
accept:
|
||||||
.catch(async (e) => {
|
type === "pdf"
|
||||||
messageError($q, JSON.parse(await e.response.data.text()));
|
? "application/pdf"
|
||||||
})
|
: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
||||||
.finally(() => {
|
"content-Type": "application/json",
|
||||||
hideLoader();
|
},
|
||||||
});
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ยืนยันการแก้ไขข้อมูล
|
// ยืนยันการแก้ไขข้อมูล
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue