fix: download xlsx new api
This commit is contained in:
parent
e9e8e7e697
commit
de6ed189bd
2 changed files with 30 additions and 9 deletions
|
|
@ -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>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue