fix ==> โหลดไฟล์คำสั่งรายการแจ้งเตือน

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2025-08-29 15:06:58 +07:00
parent d39753fbde
commit 31755747da
2 changed files with 42 additions and 5 deletions

View file

@ -1,8 +1,18 @@
<script setup lang="ts">
import { ref, reactive, watch } from "vue";
import { useQuasar } from "quasar";
import http from "@/plugins/http";
import genReport from "@/plugins/genreport";
import { useCounterMixin } from "@/stores/mixin";
import PopupReplyInbox from "@/components/PopupReplyInbox.vue";
import type { Attachments } from "@/modules/01_dashboard/interface/Main";
const $q = useQuasar();
const { showLoader, hideLoader, messageError } = useCounterMixin();
const props = defineProps({
modal: {
type: Boolean,
@ -60,9 +70,29 @@ watch(
const modalReply = ref<boolean>(false);
function fileOpen(url: string) {
window.open(url, "_blank");
}
const fileOpen = async (attachmentsData: Attachments) => {
if (attachmentsData.isReport) {
showLoader();
await http
.get(attachmentsData.url)
.then(async (res) => {
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);
})
.finally(() => {
hideLoader();
});
} else {
window.open(attachmentsData.url, "_blank");
}
};
</script>
<template>
<q-dialog v-model="modal">
@ -116,7 +146,7 @@ function fileOpen(url: string) {
v-for="(item, index) in detail.payload.attachments"
:key="index"
>
<q-item clickable v-close-popup @click.stop="fileOpen(item.url)">
<q-item clickable v-close-popup @click.stop="fileOpen(item)">
<q-item-section>{{ item.name }}</q-item-section>
</q-item>
<q-separator />

View file

@ -31,4 +31,11 @@ interface MenuMainList {
active: boolean;
}
export type { InboxList, InboxDetail, MenuMainList };
interface Attachments {
name: string;
url: string;
isReport: boolean;
isTemplate: boolean;
}
export type { InboxList, InboxDetail, MenuMainList, Attachments };