step 4 ออกคำสั่ง

This commit is contained in:
Warunee Tamkoo 2023-08-26 18:37:58 +07:00
parent 27340c9ca8
commit e8a4294ea1
8 changed files with 236 additions and 769 deletions

View file

@ -38,19 +38,14 @@ const OrderPDFUpload = ref<string>("");
const TailerPDFUpload = ref<string>("");
const orderCoverPdf = ref<string>("");
const orderCoverDocs = ref<string>("");
const orderAttachmentPdf = ref<string>("");
const orderAttachmentXlsx = ref<string>("");
const statusOrder = ref<string>();
const orderName = ref<string>("")
const orderId = ref<string>(orderId_params.toString());
onMounted(async () => {
if (orderId.value) {
fetchReportCover("pdf", orderId.value);
fetchReportCover("docx", orderId.value);
fetchReportAttachment("pdf", orderId.value);
fetchReportAttachment("xlsx", orderId.value);
fetchAttachment(orderId.value);
fecthstatusOrder(orderId.value);
getType();
@ -65,6 +60,11 @@ const getType = async () => {
const data = res.data.result;
const orderTypeCode = data.orderTypeCode;
code.value = orderTypeCode ?? "";
orderName.value = res.data.result.orderTitle
fetchReportCover("pdf", orderId.value);
fetchReportAttachment("pdf", orderId.value);
})
.catch((e) => {
messageError($q, e);
@ -77,9 +77,11 @@ const getType = async () => {
const downloadCover = async (type: string) => {
showLoader();
await http
.get(config.API.fileCover(code.value, type, orderId.value))
.get(config.API.fileCover(code.value, type, orderId.value), {
responseType: "blob",
})
.then(async (res) => {
downloadFile(res, `คำสั่ง.${type}`);
downloadFile(res, `คำสั่ง ${orderName.value}.${type}`);
})
.catch((e) => {
messageError($q, e);
@ -92,9 +94,11 @@ const downloadCover = async (type: string) => {
const downloadAttachment = async (type: string) => {
showLoader();
await http
.get(config.API.fileCover(code.value, type, orderId.value))
.get(config.API.fileAttachment(code.value, type, orderId.value), {
responseType: "blob",
})
.then(async (res) => {
downloadFile(res, `เอกสารแนบท้าย.${type}`);
downloadFile(res, `เอกสารแนบท้าย ${orderName.value}.${type}`);
})
.catch((e) => {
messageError($q, e);
@ -107,14 +111,14 @@ const downloadAttachment = async (type: string) => {
const fetchReportCover = async (type: string, orderId: string) => {
showLoader();
await http
.get(config.API.reportOrderCover(type, orderId))
.get(config.API.reportOrderCover(type, orderId, code.value), {
responseType: "blob",
})
.then(async (res) => {
if (type == "pdf") {
orderCoverPdf.value = res.data.result;
viewPDF(orderCoverPdf.value);
} else {
orderCoverDocs.value = res.data.result;
}
const blob = new Blob([res.data]);
const objectUrl = URL.createObjectURL(blob);
orderCoverPdf.value = objectUrl;
viewPDF(orderCoverPdf.value);
})
.catch((e) => {
// messageError($q, e);
@ -127,13 +131,13 @@ const fetchReportCover = async (type: string, orderId: string) => {
const fetchReportAttachment = async (type: string, orderId: string) => {
showLoader();
await http
.get(config.API.reportOrderAttachment(type, orderId))
.get(config.API.reportOrderAttachment(type, orderId, code.value), {
responseType: "blob",
})
.then(async (res) => {
if (type == "pdf") {
orderAttachmentPdf.value = res.data.result;
} else {
orderAttachmentXlsx.value = res.data.result;
}
const blob = new Blob([res.data]);
const objectUrl = URL.createObjectURL(blob);
orderAttachmentPdf.value = objectUrl;
})
.catch((e) => {
// messageError($q, e);
@ -347,50 +351,28 @@ const viewFileUpload = async (url: string) => {
<template>
<div>
<div style="min-height: 70vh">
<q-splitter
v-model="splitterModel"
style="height: 70vh"
@update:model-value="onchangePage"
>
<q-splitter v-model="splitterModel" style="height: 70vh" @update:model-value="onchangePage">
<template v-slot:before>
<div class="space">
<div @click="setTab('main')" :class="getClass(tab == 'main')">
<div class="q-pr-sm">คำส</div>
<q-btn
size="12px"
flat
dense
icon="mdi-download"
:disable="tab !== 'main'"
:color="tab !== 'main' ? 'grey' : 'add'"
>
<q-btn size="12px" flat dense icon="mdi-download" :disable="tab !== 'main'"
:color="tab !== 'main' ? 'grey' : 'add'">
<q-tooltip>ดาวนโหลด</q-tooltip>
<q-menu>
<q-list style="min-width: 150px">
<q-item
clickable
v-close-popup
@click="downloadCover('pdf')"
>
<q-item clickable v-close-popup @click="downloadCover('pdf')">
<!-- type="a"
:href="orderCoverPdf"
target="_blank" -->
<q-item-section avatar
><q-icon color="red" name="mdi-file-pdf"
/></q-item-section>
<q-item-section avatar><q-icon color="red" name="mdi-file-pdf" /></q-item-section>
<q-item-section>ไฟล .PDF</q-item-section>
</q-item>
<q-item
clickable
v-close-popup
@click="downloadCover('docx')"
>
<q-item clickable v-close-popup @click="downloadCover('docx')">
<!-- type="a"
:href="orderCoverDocs"
target="_blank" -->
<q-item-section avatar
><q-icon color="blue" name="mdi-file-word"
/></q-item-section>
<q-item-section avatar><q-icon color="blue" name="mdi-file-word" /></q-item-section>
<q-item-section>ไฟล .docx</q-item-section>
</q-item>
</q-list>
@ -399,41 +381,23 @@ const viewFileUpload = async (url: string) => {
</div>
<div @click="setTab('second')" :class="getClass(tab == 'second')">
<div class="q-pr-sm">เอกสารแนบทาย</div>
<q-btn
size="12px"
flat
dense
:color="tab !== 'second' ? 'grey' : 'add'"
icon="mdi-download"
:disable="tab !== 'second'"
>
<q-btn size="12px" flat dense :color="tab !== 'second' ? 'grey' : 'add'" icon="mdi-download"
:disable="tab !== 'second'">
<q-tooltip>ดาวนโหลด</q-tooltip>
<q-menu>
<q-list style="min-width: 150px">
<q-item
clickable
v-close-popup
@click="downloadAttachment('pdf')"
>
<q-item clickable v-close-popup @click="downloadAttachment('pdf')">
<!-- type="a"
:href="orderAttachmentPdf"
target="_blank" -->
<q-item-section avatar
><q-icon color="red" name="mdi-file-pdf"
/></q-item-section>
<q-item-section avatar><q-icon color="red" name="mdi-file-pdf" /></q-item-section>
<q-item-section>ไฟล .PDF</q-item-section>
</q-item>
<q-item
clickable
v-close-popup
@click="downloadAttachment('xlsx')"
>
<q-item clickable v-close-popup @click="downloadAttachment('xlsx')">
<!-- type="a"
:href="orderAttachmentXlsx"
target="_blank" -->
<q-item-section avatar
><q-icon color="green-7" name="mdi-file-excel"
/></q-item-section>
<q-item-section avatar><q-icon color="green-7" name="mdi-file-excel" /></q-item-section>
<q-item-section>ไฟล .xls</q-item-section>
</q-item>
</q-list>
@ -441,24 +405,12 @@ const viewFileUpload = async (url: string) => {
</q-btn>
</div>
<q-space />
<q-btn
class="text-dark"
flat
dense
icon="mdi-fullscreen"
color="add"
@click="dialog = true"
/>
<q-btn class="text-dark" flat dense icon="mdi-fullscreen" color="add" @click="dialog = true" />
</div>
<q-separator style="margin-top: -1px; z-index: 1" />
<q-card bordered class="card-pdf q-ma-md q-pa-md">
<div class="justify-between items-center align-center q-pb-sm row">
<q-btn
class="text-dark bg-grey-4"
flat
dense
@click="page = page > 1 ? page - 1 : page"
>
<q-btn class="text-dark bg-grey-4" flat dense @click="page = page > 1 ? page - 1 : page">
<q-icon name="mdi-chevron-left" />
</q-btn>
@ -466,12 +418,7 @@ const viewFileUpload = async (url: string) => {
หนาท {{ page }} จาก {{ numOfPages }}
</span>
<q-btn
class="text-dark bg-grey-4"
flat
dense
@click="page = page < numOfPages ? page + 1 : page"
>
<q-btn class="text-dark bg-grey-4" flat dense @click="page = page < numOfPages ? page + 1 : page">
<q-icon name="mdi-chevron-right" />
</q-btn>
</div>
@ -480,12 +427,7 @@ const viewFileUpload = async (url: string) => {
<!-- <VuePdf :key="page" :src="pdfSrc" :page="page" /> -->
</div>
<div class="justify-between items-center align-center q-pt-sm row">
<q-btn
class="text-dark bg-grey-4"
flat
dense
@click="page = page > 1 ? page - 1 : page"
>
<q-btn class="text-dark bg-grey-4" flat dense @click="page = page > 1 ? page - 1 : page">
<q-icon name="mdi-chevron-left" />
</q-btn>
@ -493,12 +435,7 @@ const viewFileUpload = async (url: string) => {
หนาท {{ page }} จาก {{ numOfPages }}
</span>
<q-btn
class="text-dark bg-grey-4"
flat
dense
@click="page = page < numOfPages ? page + 1 : page"
>
<q-btn class="text-dark bg-grey-4" flat dense @click="page = page < numOfPages ? page + 1 : page">
<q-icon name="mdi-chevron-right" />
</q-btn>
</div>
@ -506,12 +443,7 @@ const viewFileUpload = async (url: string) => {
</template>
<template v-slot:separator>
<q-avatar
color="primary"
text-color="white"
size="30px"
icon="drag_indicator"
/>
<q-avatar color="primary" text-color="white" size="30px" icon="drag_indicator" />
</template>
<template v-slot:after>
@ -523,39 +455,17 @@ const viewFileUpload = async (url: string) => {
<div>
<label class="text-file">คำส</label>
<div class="text-right">
<q-btn
size="12px"
flat
dense
color="primary"
icon="mdi-eye"
@click="viewFileUpload(OrderPDFUpload)"
>
<q-btn size="12px" flat dense color="primary" icon="mdi-eye"
@click="viewFileUpload(OrderPDFUpload)">
<q-tooltip>ไฟลคำส</q-tooltip>
</q-btn>
<q-btn
type="a"
:href="OrderPDFUpload"
size="12px"
flat
dense
color="red"
icon="mdi-download"
target="_blank"
>
<q-btn type="a" :href="OrderPDFUpload" size="12px" flat dense color="red" icon="mdi-download"
target="_blank">
<q-tooltip>ดาวนโหลดเอกสารแนบทาย</q-tooltip>
</q-btn>
</div>
<q-file
outlined
dense
v-model="fileOrder"
label="เลือกไฟล์คำสั่ง"
hide-bottom-space
lazy-rules
:rules="[(val) => val || 'กรุณาเลือกไฟล์เอกสารแนบท้าย']"
accept=".pdf"
>
<q-file outlined dense v-model="fileOrder" label="เลือกไฟล์คำสั่ง" hide-bottom-space lazy-rules
:rules="[(val) => val || 'กรุณาเลือกไฟล์เอกสารแนบท้าย']" accept=".pdf">
<template v-slot:prepend>
<q-icon name="attach_file" />
</template>
@ -564,40 +474,18 @@ const viewFileUpload = async (url: string) => {
<div>
<label class="text-file">เอกสารแนบทาย</label>
<div class="text-right">
<q-btn
size="12px"
flat
dense
color="primary"
icon="mdi-eye"
@click="viewFileUpload(TailerPDFUpload)"
>
<q-btn size="12px" flat dense color="primary" icon="mdi-eye"
@click="viewFileUpload(TailerPDFUpload)">
<q-tooltip>ไฟลคำส</q-tooltip>
</q-btn>
<q-btn
type="a"
:href="TailerPDFUpload"
size="12px"
flat
dense
color="red"
icon="mdi-download"
target="_blank"
>
<q-btn type="a" :href="TailerPDFUpload" size="12px" flat dense color="red" icon="mdi-download"
target="_blank">
<q-tooltip>ดาวนโหลดเอกสารแนบทาย</q-tooltip>
</q-btn>
</div>
<q-file
outlined
dense
v-model="fileTailer"
label="เลือกไฟล์เอกสารแนบท้าย"
hide-bottom-space
lazy-rules
:rules="[(val) => val || 'กรุณาเลือกไฟล์เอกสารแนบท้าย']"
accept=".pdf"
>
<q-file outlined dense v-model="fileTailer" label="เลือกไฟล์เอกสารแนบท้าย" hide-bottom-space
lazy-rules :rules="[(val) => val || 'กรุณาเลือกไฟล์เอกสารแนบท้าย']" accept=".pdf">
<template v-slot:prepend>
<q-icon name="attach_file" />
</template>
@ -611,51 +499,24 @@ const viewFileUpload = async (url: string) => {
<div class="q-gutter-y-md q-mb-md">
<div>
<label class="text-file">เลขทคำส</label>
<q-input
:outlined="true"
dense
lazy-rules
:readonly="!true"
:borderless="!true"
v-model="order"
:rules="[(val) => !!val || `${'กรุณากรอกเลขที่คำสั่ง'}`]"
hide-bottom-space
:label="`${'เลขที่คำสั่ง'}`"
/>
<q-input :outlined="true" dense lazy-rules :readonly="!true" :borderless="!true" v-model="order"
:rules="[(val) => !!val || `${'กรุณากรอกเลขที่คำสั่ง'}`]" hide-bottom-space
:label="`${'เลขที่คำสั่ง'}`" />
</div>
<div>
<label class="text-file">ออกคำส</label>
<datepicker
menu-class-name="modalfix"
v-model="years"
:locale="'th'"
autoApply
year-picker
:enableTimePicker="false"
week-start="0"
>
<datepicker menu-class-name="modalfix" v-model="years" :locale="'th'" autoApply year-picker
:enableTimePicker="false" week-start="0">
<template #year="{ year }">{{ year + 543 }}</template>
<template #year-overlay-value="{ value }">{{
parseInt(value + 543)
}}</template>
<template #trigger>
<q-input
outlined
dense
lazy-rules
:model-value="years + 543"
:rules="[
(val) => !!val || `${'กรุณาเลือกปีที่ออกคำสั่ง'}`,
]"
hide-bottom-space
:label="`${'ปีที่ออกคำสั่ง'}`"
>
<q-input outlined dense lazy-rules :model-value="years + 543" :rules="[
(val) => !!val || `${'กรุณาเลือกปีที่ออกคำสั่ง'}`,
]" hide-bottom-space :label="`${'ปีที่ออกคำสั่ง'}`">
<template v-slot:prepend>
<q-icon
name="event"
class="cursor-pointer"
style="color: var(--q-grey)"
>
<q-icon name="event" class="cursor-pointer" style="color: var(--q-grey)">
</q-icon>
</template>
</q-input>
@ -664,15 +525,8 @@ const viewFileUpload = async (url: string) => {
</div>
<div>
<label class="text-file">นทลงนาม</label>
<datepicker
menu-class-name="modalfix"
v-model="date"
:locale="'th'"
autoApply
borderless
:enableTimePicker="false"
week-start="0"
>
<datepicker menu-class-name="modalfix" v-model="date" :locale="'th'" autoApply borderless
:enableTimePicker="false" week-start="0">
<template #year="{ year }">
{{ year + 543 }}
</template>
@ -680,23 +534,12 @@ const viewFileUpload = async (url: string) => {
{{ parseInt(value + 543) }}
</template>
<template #trigger>
<q-input
outlined
dense
class="full-width datepicker"
hide-bottom-space
:model-value="date != null ? date2Thai(date) : null"
:label="`${'วันที่ลงนาม'}`"
:rules="[
<q-input outlined dense class="full-width datepicker" hide-bottom-space
:model-value="date != null ? date2Thai(date) : null" :label="`${'วันที่ลงนาม'}`" :rules="[
(val) => !!val || `${'กรุณาเลือกวันที่ลงนาม'}`,
]"
>
]">
<template v-slot:prepend>
<q-icon
name="event"
class="cursor-pointer"
style="color: var(--q-grey)"
>
<q-icon name="event" class="cursor-pointer" style="color: var(--q-grey)">
</q-icon>
</template>
</q-input>
@ -706,20 +549,9 @@ const viewFileUpload = async (url: string) => {
</div>
</fieldset>
<div class="flex justify-around">
<q-btn
unelevated
label="ออกคำสั่ง"
:color="validateForm() ? 'public' : 'grey'"
:disable="statusOrder == 'N'"
@click="clickExecute(orderId)"
/>
<q-btn
class="text-dark"
unelevated
label="ส่งไปลงนาม"
color="grey"
:disable="statusOrder == 'N'"
/>
<q-btn unelevated label="ออกคำสั่ง" :color="validateForm() ? 'public' : 'grey'"
:disable="statusOrder == 'N'" @click="clickExecute(orderId)" />
<q-btn class="text-dark" unelevated label="ส่งไปลงนาม" color="grey" :disable="statusOrder == 'N'" />
</div>
</div>
</q-form>
@ -728,53 +560,23 @@ const viewFileUpload = async (url: string) => {
</div>
<q-separator />
<div class="flex justify-end q-pa-sm q-gutter-sm">
<q-btn
dense
outline
color="primary"
icon="chevron_left"
@click="previous"
class="q-pr-md"
label="เลือกรายชื่อส่งสำเนา"
>
<q-btn dense outline color="primary" icon="chevron_left" @click="previous" class="q-pr-md"
label="เลือกรายชื่อส่งสำเนา">
</q-btn>
<q-btn
unelevated
label="บันทึก"
:color="validateForm() ? 'public' : 'grey'"
:disable="!validateForm()"
@click="save"
>
<q-btn unelevated label="บันทึก" :color="validateForm() ? 'public' : 'grey'" :disable="!validateForm()"
@click="save">
</q-btn>
</div>
<q-dialog
v-model="dialog"
persistent
:maximized="true"
transition-show="slide-up"
transition-hide="slide-down"
>
<q-dialog v-model="dialog" persistent :maximized="true" transition-show="slide-up" transition-hide="slide-down">
<q-card class="bg-white text-white">
<div class="flex justify-end items-center align-center q-mr-md q-mt-sm">
<q-btn
icon="close"
unelevated
round
dense
style="color: #ff8080; background-color: #ffdede"
size="12px"
v-close-popup
/>
<q-btn icon="close" unelevated round dense style="color: #ff8080; background-color: #ffdede" size="12px"
v-close-popup />
</div>
<q-card-section bordered class="card-pdf q-ma-md q-pa-md">
<div class="justify-between items-center align-center q-pb-sm row">
<q-btn
class="text-dark bg-grey-4"
flat
dense
@click="page = page > 1 ? page - 1 : page"
>
<q-btn class="text-dark bg-grey-4" flat dense @click="page = page > 1 ? page - 1 : page">
<q-icon name="mdi-chevron-left" />
</q-btn>
@ -782,32 +584,16 @@ const viewFileUpload = async (url: string) => {
หนาท {{ page }} จาก {{ numOfPages }}
</span>
<q-btn
class="text-dark bg-grey-4"
flat
dense
@click="page = page < numOfPages ? page + 1 : page"
>
<q-btn class="text-dark bg-grey-4" flat dense @click="page = page < numOfPages ? page + 1 : page">
<q-icon name="mdi-chevron-right" />
</q-btn>
</div>
<div class="pdfWidth">
<VuePDF
ref="vuePDFRef"
:pdf="pdfSrc"
:page="page"
fit-parent
:scale="0.1"
/>
<VuePDF ref="vuePDFRef" :pdf="pdfSrc" :page="page" fit-parent :scale="0.1" />
<!-- <VuePdf :key="page" :src="pdfSrc" :page="page" /> -->
</div>
<div class="justify-between items-center align-center q-pt-sm row">
<q-btn
class="text-dark bg-grey-4"
flat
dense
@click="page = page > 1 ? page - 1 : page"
>
<q-btn class="text-dark bg-grey-4" flat dense @click="page = page > 1 ? page - 1 : page">
<q-icon name="mdi-chevron-left" />
</q-btn>
@ -815,12 +601,7 @@ const viewFileUpload = async (url: string) => {
หนาท {{ page }} จาก {{ numOfPages }}
</span>
<q-btn
class="text-dark bg-grey-4"
flat
dense
@click="page = page < numOfPages ? page + 1 : page"
>
<q-btn class="text-dark bg-grey-4" flat dense @click="page = page < numOfPages ? page + 1 : page">
<q-icon name="mdi-chevron-right" />
</q-btn>
</div>
@ -828,33 +609,16 @@ const viewFileUpload = async (url: string) => {
</q-card>
</q-dialog>
<q-dialog
v-model="dialogFileUpload"
persistent
:maximized="true"
transition-show="slide-up"
transition-hide="slide-down"
>
<q-dialog v-model="dialogFileUpload" persistent :maximized="true" transition-show="slide-up"
transition-hide="slide-down">
<q-card class="bg-white text-white">
<div class="flex justify-end items-center align-center q-mr-md q-mt-sm">
<q-btn
icon="close"
unelevated
round
dense
style="color: #ff8080; background-color: #ffdede"
size="12px"
v-close-popup
/>
<q-btn icon="close" unelevated round dense style="color: #ff8080; background-color: #ffdede" size="12px"
v-close-popup />
</div>
<q-card-section bordered class="card-pdf q-ma-md q-pa-md">
<div class="justify-between items-center align-center q-pb-sm row">
<q-btn
class="text-dark bg-grey-4"
flat
dense
@click="page = page > 1 ? page - 1 : page"
>
<q-btn class="text-dark bg-grey-4" flat dense @click="page = page > 1 ? page - 1 : page">
<q-icon name="mdi-chevron-left" />
</q-btn>
@ -862,32 +626,16 @@ const viewFileUpload = async (url: string) => {
หนาท {{ page }} จาก {{ numOfPages }}
</span>
<q-btn
class="text-dark bg-grey-4"
flat
dense
@click="page = page < numOfPages ? page + 1 : page"
>
<q-btn class="text-dark bg-grey-4" flat dense @click="page = page < numOfPages ? page + 1 : page">
<q-icon name="mdi-chevron-right" />
</q-btn>
</div>
<div class="pdfWidth">
<VuePDF
ref="vuePDFRef"
:pdf="pdfFileUploadSrc"
:page="page"
fit-parent
:scale="0.1"
/>
<VuePDF ref="vuePDFRef" :pdf="pdfFileUploadSrc" :page="page" fit-parent :scale="0.1" />
<!-- <VuePdf :key="page" :src="pdfSrc" :page="page" /> -->
</div>
<div class="justify-between items-center align-center q-pt-sm row">
<q-btn
class="text-dark bg-grey-4"
flat
dense
@click="page = page > 1 ? page - 1 : page"
>
<q-btn class="text-dark bg-grey-4" flat dense @click="page = page > 1 ? page - 1 : page">
<q-icon name="mdi-chevron-left" />
</q-btn>
@ -895,12 +643,7 @@ const viewFileUpload = async (url: string) => {
หนาท {{ page }} จาก {{ numOfPages }}
</span>
<q-btn
class="text-dark bg-grey-4"
flat
dense
@click="page = page < numOfPages ? page + 1 : page"
>
<q-btn class="text-dark bg-grey-4" flat dense @click="page = page < numOfPages ? page + 1 : page">
<q-icon name="mdi-chevron-right" />
</q-btn>
</div>