ออกคำสั่ง PreViewPDF

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-09-26 12:10:15 +07:00
parent 26a4bd17f2
commit 307bfc67c0
3 changed files with 119 additions and 11 deletions

View file

@ -9,6 +9,10 @@ import { useCommandDetail } from "@/modules/18_command/store/DetailStore";
import http from "@/plugins/http";
import config from "@/app.config";
import type { DataFileDownload } from "@/modules/18_command/interface/response/Main";
import PerviewPDF from "@/modules/18_command/components/Step/PerviewPDF.vue";
const $q = useQuasar();
const route = useRoute();
const store = useCommandDetail();
@ -42,6 +46,7 @@ const fileOrder = ref<any>(null); //ไฟล์คำสั่ง
const fileTailer = ref<any>(null); //
const isLoad = ref<boolean>(false); //
const modalPerView = ref<boolean>(false);
/**
* งกนยนยนการสงใหอำนาจลงนามอน
@ -178,11 +183,12 @@ async function fetchDoc(group: string) {
});
}
const dataFile = ref<DataFileDownload>();
/**
* ดาวนโหลดลงกไฟล
* @param fileName file name
*/
function downloadFile(file: any, group: string) {
function downloadFile(file: any, group: string, isView: boolean = false) {
let type = group === "order" ? "คำสั่ง" : "แนบท้าย";
showLoader();
http
@ -195,8 +201,13 @@ function downloadFile(file: any, group: string) {
)
)
.then((res) => {
const data = res.data.downloadUrl;
window.open(data, "_blank");
const data = res.data;
dataFile.value = data;
if (isView) {
modalPerView.value = true;
} else {
window.open(data.downloadUrl, "_blank");
}
})
.catch((e) => {
messageError($q, e);
@ -326,6 +337,17 @@ onMounted(async () => {
>
คำส
<q-space />
<q-btn
v-if="fileOrder"
rounded
flat
dense
color="primary"
icon="mdi-eye"
@click.prevent="downloadFile(fileOrder, 'order', true)"
>
<q-tooltip>ไฟลคำส</q-tooltip>
</q-btn>
<q-btn
v-if="fileOrder"
rounded
@ -379,6 +401,17 @@ onMounted(async () => {
>
เอกสารแนบทาย
<q-space />
<q-btn
v-if="fileTailer"
rounded
flat
dense
color="primary"
icon="mdi-eye"
@click.prevent="downloadFile(fileTailer, 'tailer', true)"
>
<q-tooltip>ไฟลเอกสารแนบทาย</q-tooltip>
</q-btn>
<q-btn
v-if="fileTailer"
rounded
@ -388,7 +421,7 @@ onMounted(async () => {
icon="mdi-download"
@click.prevent="downloadFile(fileTailer, 'tailer')"
>
<q-tooltip>ดาวนโหลดไฟลคำส</q-tooltip>
<q-tooltip>ดาวนโหลดไฟลแนบทาย</q-tooltip>
</q-btn>
</div>
<div class="col-12"><q-separator /></div>
@ -493,6 +526,11 @@ onMounted(async () => {
</div>
</span>
</div>
<PerviewPDF
v-model:modal="modalPerView"
v-model:data-file="dataFile as DataFileDownload"
/>
</template>
<style lang="scss" scoped>