fix ==> ปุ่มดาวน์โหลดไฟล์คำสั่ง

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2025-08-29 14:13:15 +07:00
parent d95042ba0e
commit 9f3ef65f13
2 changed files with 15 additions and 12 deletions

View file

@ -2,6 +2,7 @@ interface attachments {
name: string;
url: string;
isReport: boolean;
isTemplate: boolean;
}
interface ResponseInbox {
body: string;
@ -30,4 +31,4 @@ interface DataInbox {
isOpen: boolean;
}
export type { ResponseInbox, DataInbox };
export type { ResponseInbox, DataInbox, attachments };

View file

@ -11,6 +11,7 @@ import PopupReplyInbox from "@/components/Dialogs/PopupReplyInbox.vue";
import type {
ResponseInbox,
DataInbox,
attachments,
} from "@/interface/response/dashboard/dashboard";
const $q = useQuasar();
@ -114,14 +115,18 @@ const removeData = async (id: string) => {
hideLoader();
});
};
const fileOpen = (url: string, isReport: boolean, fileName: string) => {
if (isReport) {
const fileOpen = async (attachmentsData: attachments) => {
if (attachmentsData.isReport) {
showLoader();
http
.get(url)
await http
.get(attachmentsData.url)
.then(async (res) => {
const data = res.data.result;
await genReport(data, fileName, "pdf");
const result = res.data;
if (attachmentsData.isTemplate) {
await genReport(result.result, attachmentsData.name, "pdf");
} else {
window.open(result.downloadUrl, "_blank");
}
})
.catch((err) => {
messageError($q, err);
@ -130,7 +135,7 @@ const fileOpen = (url: string, isReport: boolean, fileName: string) => {
hideLoader();
});
} else {
window.open(url, "_blank");
window.open(attachmentsData.url, "_blank");
}
};
@ -363,10 +368,7 @@ const thaiOptions: Intl.DateTimeFormatOptions = {
v-for="(link, num) in d.payload.attachments"
:key="num"
>
<q-item
clickable
@click="fileOpen(link.url, link.isReport, link.name)"
>
<q-item clickable @click="fileOpen(link)">
<q-item-section>{{ link.name }}</q-item-section>
</q-item>
<q-separator />