fix: download xlsx new api

This commit is contained in:
setthawutttty 2025-09-09 09:51:05 +07:00
parent e9e8e7e697
commit de6ed189bd
2 changed files with 30 additions and 9 deletions

View file

@ -248,11 +248,34 @@ async function clickPassExam(id: string) {
async function clickCandidateList(id: string) {
showLoader();
await http
.get(config.API.exportCandidateListNew(id))
.get(config.API.reportCandidateListNew(id), {
headers: {
accept:
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"content-Type": "application/json",
},
responseType: "blob",
})
.then(async (res) => {
const data = res.data.result;
data.reportName = `CandidateList`;
await genReport(data, "รายชื่อผู้มีสิทธิ์สอบ", "pdf");
const data = res.data;
if (data) {
// Blob array buffer
const blob = new Blob([data]);
// URL Blob
const url = URL.createObjectURL(blob);
//
const link = document.createElement("a");
link.href = url;
link.download = `CandidateList.xlsx`; //
document.body.appendChild(link);
link.click();
// URL
URL.revokeObjectURL(url);
}
})
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
@ -705,9 +728,7 @@ onMounted(async () => {
"
>
<q-icon name="mdi-file-excel-outline" size="20px" />
<q-tooltip
>นำเขาไฟลผลการสอบ (ญชรายช)</q-tooltip
>
<q-tooltip>นำเขาไฟลผลการสอบ (ญชรายช)</q-tooltip>
</q-btn>
<div v-else>
{{ props.row.score.resultCount }}
@ -722,8 +743,7 @@ onMounted(async () => {
icon="mdi-file-excel-outline"
>
<q-tooltip
>นำเขาไฟลผลการสอบ (ญชรายช)
กคร</q-tooltip
>นำเขาไฟลผลการสอบ (ญชรายช) กคร</q-tooltip
>
</q-btn>