ออกคำสั่ง ==> PDF

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-09-16 10:54:40 +07:00
parent 6048a46540
commit 02cc675c52

View file

@ -14,7 +14,7 @@ import DialogHeader from "@/components/DialogHeader.vue";
import { useCounterMixin } from "@/stores/mixin"; import { useCounterMixin } from "@/stores/mixin";
const $q = useQuasar(); const $q = useQuasar();
const { dialogConfirm } = useCounterMixin(); const { showLoader, hideLoader, messageError } = useCounterMixin();
const modal = defineModel<boolean>("modal", { required: true }); const modal = defineModel<boolean>("modal", { required: true });
const dataTemplateDetail = defineModel<any>("dataTemplateDetail", { const dataTemplateDetail = defineModel<any>("dataTemplateDetail", {
@ -27,6 +27,7 @@ const page = ref<number>(1);
const vuePDFRef = ref<any>(null); const vuePDFRef = ref<any>(null);
async function fetchPDF(type: string = "docx") { async function fetchPDF(type: string = "docx") {
showLoader();
await axios await axios
.post( .post(
config.API.reportTemplate + `/${type}`, config.API.reportTemplate + `/${type}`,
@ -61,23 +62,27 @@ async function fetchPDF(type: string = "docx") {
setTimeout(() => { setTimeout(() => {
pdfSrc.value = pdfData.pdf.value; pdfSrc.value = pdfData.pdf.value;
numOfPages.value = pdfData.pages.value; numOfPages.value = pdfData.pages.value;
hideLoader();
}, 1500); }, 1500);
}) })
.catch(async (e) => { .catch((e) => {
// messageError($q, e); messageError($q, e);
// hideLoader(); hideLoader();
}); });
} }
function onClose() { function onClose() {
modal.value = false; modal.value = false;
pdfSrc.value = undefined;
} }
onMounted(() => { watch(modal, () => {
setTimeout(() => { modal.value && fetchPDF();
fetchPDF();
}, 1000);
}); });
// onMounted(() => {
// setTimeout(() => {}, 1000);
// });
</script> </script>
<template> <template>
@ -86,7 +91,7 @@ onMounted(() => {
<DialogHeader :tittle="'ตัวอย่างคำสั่ง'" :close="onClose" /> <DialogHeader :tittle="'ตัวอย่างคำสั่ง'" :close="onClose" />
<q-separator /> <q-separator />
<q-card-section bordered class="card-pdf q-ma-md q-pa-md"> <q-card-section bordered class="scroll q-ma-md q-pa-md" style="height: 90%;">
<div class="justify-between items-center align-center q-pb-sm row"> <div class="justify-between items-center align-center q-pb-sm row">
<q-btn <q-btn
class="text-dark bg-grey-4" class="text-dark bg-grey-4"