diff --git a/src/interface/response/dashboard/dashboard.ts b/src/interface/response/dashboard/dashboard.ts index dad38b36a..e62164b33 100644 --- a/src/interface/response/dashboard/dashboard.ts +++ b/src/interface/response/dashboard/dashboard.ts @@ -1,6 +1,7 @@ interface attachments { name: string; url: string; + isReport: boolean; } interface ResponseInbox { body: string; diff --git a/src/views/Dashboard.vue b/src/views/Dashboard.vue index 09bb224d8..2dfe7d1f6 100644 --- a/src/views/Dashboard.vue +++ b/src/views/Dashboard.vue @@ -5,6 +5,7 @@ import { useCounterMixin } from "@/stores/mixin"; import http from "@/plugins/http"; import config from "@/app.config"; +import genReport from "@/plugins/genreport"; import PopupReplyInbox from "@/components/Dialogs/PopupReplyInbox.vue"; import type { @@ -90,7 +91,6 @@ const deleteData = (id: string) => { dialogRemove($q, () => removeData(id)); }; -//รอ api ลบ const removeData = async (id: string) => { showLoader(); await http @@ -114,8 +114,24 @@ const removeData = async (id: string) => { hideLoader(); }); }; -const fileOpen = (url: string) => { - window.open(url, "_blank"); +const fileOpen = (url: string, isReport: boolean, fileName: string) => { + if (isReport) { + showLoader(); + http + .get(url) + .then(async (res) => { + const data = res.data; + await genReport(data, fileName, "pdf"); + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); + } else { + window.open(url, "_blank"); + } }; // Dialog Reply @@ -347,7 +363,10 @@ const thaiOptions: Intl.DateTimeFormatOptions = { v-for="(link, num) in d.payload.attachments" :key="num" > - + {{ link.name }}