From 6848973db3230f00026eae11099c4991a33aced7 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Thu, 3 Apr 2025 14:22:03 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=82=E0=B8=AB=E0=B8=A5=E0=B8=94=E0=B9=84?= =?UTF-8?q?=E0=B8=9F=E0=B8=A5=E0=B9=8C=20=E0=B8=AB=E0=B8=99=E0=B8=B1?= =?UTF-8?q?=E0=B8=87=E0=B8=AA=E0=B8=B4=E0=B8=AD=E0=B9=80=E0=B8=A7=E0=B8=B5?= =?UTF-8?q?=E0=B8=A2=E0=B8=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/interface/response/dashboard/dashboard.ts | 1 + src/views/Dashboard.vue | 27 ++++++++++++++++--- 2 files changed, 24 insertions(+), 4 deletions(-) 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 }}