แก้ชื่อเอกสารตอนดาวน์โหลดตามชื่อเอกสารที่แสดง

This commit is contained in:
AnandaTon 2023-09-22 14:43:47 +07:00
parent 6ad6b4bcab
commit 9aa0708c48
3 changed files with 21 additions and 26 deletions

View file

@ -68,14 +68,14 @@ const downloadFile = (response: any, filename: string) => {
link.click();
document.body.removeChild(link);
};
const fileDownload = async (no: number, type: string) => {
const fileDownload = async (no: number, type: string, fileName: string) => {
showLoader();
await http
.get(config.API.reportTransferFile(no, type, id.value), {
responseType: "blob",
})
.then(async (res) => {
downloadFile(res, `_ครั้งที่.${type}`);
downloadFile(res, `${fileName}.${type}`);
})
.catch((e) => {
messageError($q, e);
@ -463,7 +463,7 @@ onMounted(async () => {
round
color="red"
icon="picture_as_pdf"
@click="fileDownload(props.row.no, 'pdf')"
@click="fileDownload(props.row.no, 'pdf', props.row.fileName)"
>
<q-tooltip>ไฟล PDF</q-tooltip>
</q-btn>
@ -473,7 +473,7 @@ onMounted(async () => {
round
color="blue"
icon="mdi-file-word"
@click="fileDownload(props.row.no, 'docx')"
@click="fileDownload(props.row.no, 'docx', props.row.fileName)"
>
<q-tooltip>ไฟล WORD</q-tooltip>
</q-btn>