add type generate report

This commit is contained in:
Warunee Tamkoo 2023-12-20 16:30:38 +07:00
parent 624f9cbd47
commit a34a6f96c2

View file

@ -10,15 +10,21 @@ const { showLoader, hideLoader, messageError } = mixin;
const apiGenReport = const apiGenReport =
"https://report-server.frappet.synology.me/api/v1/report-template/docx"; "https://report-server.frappet.synology.me/api/v1/report-template/docx";
async function genReport(data: any, fileName: string) { async function genReport(data: any, fileName: string, type: string = "docx") {
showLoader(); showLoader();
await axios await axios
.post(apiGenReport, data, { .post(apiGenReport, data, {
headers: { headers:
accept: type == "docx"
"application/vnd.openxmlformats-officedocument.wordprocessingml.document", ? {
"content-Type": "application/json", accept:
}, "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"content-Type": "application/json",
}
: {
accept: "application/pdf",
"content-Type": "application/json",
},
responseType: "arraybuffer", responseType: "arraybuffer",
}) })
.then((res) => { .then((res) => {