ออกคำสั่ง 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

@ -11,8 +11,10 @@ import config from "@/app.config";
import type { QTableProps } from "quasar";
import type { DataOption } from "@/modules/18_command/interface/index/Main";
import type { DataFileDownload } from "@/modules/18_command/interface/response/Main";
import DialogHeader from "@/components/DialogHeader.vue";
import PerviewPDF from "@/modules/18_command/components/Step/PerviewPDF.vue";
const $q = useQuasar();
const route = useRoute();
@ -110,20 +112,23 @@ const isCheckOrder = ref<boolean>(true); //เช็ครอออกคำส
const isLoad = ref<boolean>(false); //
const isPersonSign = ref<boolean>(false); //
const modalPerView = ref<boolean>(false);
/**
* งกนยนยนการสงใหอำนาจลงนามอน
*/
function onConfirmDraft() {
if (
store?.dataCommand?.commandNo !== "" &&
store?.dataCommand?.commandAffectDate !== null &&
store?.dataCommand?.commandExcecuteDate !== null
) {
modalSelect.value = true;
} else {
dialogMessageNotify(
$q,
"ไม่สามารถดำเนินการต่อได้ กรุณากรอกเลขที่คำสั่ง วันที่ลงนาม และวันที่คำสั่งมีผลให้ครบ"
"ไม่สามารถดำเนินการต่อได้ กรุณากรอกเลขที่คำสั่ง และวันที่คำสั่งมีผลให้ครบ"
);
}
}
@ -174,6 +179,7 @@ function onSubmitComment() {
function onCloseDialog() {
modalSelect.value = false;
modalComment.value = false;
isPersonSign.value = false;
}
async function fetchDoc(group: string) {
@ -253,11 +259,13 @@ async function uploadFileDoc(uploadUrl: string, file: any, 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
@ -270,8 +278,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);
@ -317,6 +330,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
@ -370,6 +394,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
@ -379,7 +414,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>
@ -650,6 +685,10 @@ onMounted(async () => {
</template>
</d-table>
</div>
<div class="col-12">
<q-checkbox v-model="isPersonSign" label="ผู้มีอำนาจลงนาม" />
</div>
</div>
</q-card-section>
<q-separator />
@ -694,6 +733,11 @@ onMounted(async () => {
</q-form>
</q-card>
</q-dialog>
<PerviewPDF
v-model:modal="modalPerView"
v-model:data-file="dataFile as DataFileDownload"
/>
</template>
<style lang="scss" scoped>

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>