แก้รายงานออกคำสั่งวินัย และแก้ path url report-template
This commit is contained in:
parent
c49b528861
commit
defe861b55
4 changed files with 119 additions and 48 deletions
|
|
@ -8,7 +8,8 @@ import { useQuasar } from "quasar";
|
|||
import { useRoute } from "vue-router";
|
||||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
// import { aW } from "@fullcalendar/core/internal-common";
|
||||
import axios from "axios";
|
||||
import genReport from "@/plugins/genreport";
|
||||
|
||||
const mixin = useCounterMixin();
|
||||
const {
|
||||
|
|
@ -38,7 +39,7 @@ const fileTailer = ref<any>(null);
|
|||
const OrderPDFUpload = ref<string>("");
|
||||
const TailerPDFUpload = ref<string>("");
|
||||
|
||||
const orderCoverPdf = ref<string>("");
|
||||
const orderCoverPdf = ref<any>();
|
||||
const orderAttachmentPdf = ref<string>("");
|
||||
|
||||
const statusOrder = ref<string>();
|
||||
|
|
@ -79,6 +80,20 @@ const attachmentStatus = computed(() => {
|
|||
: false;
|
||||
});
|
||||
|
||||
// เช็คว่าต้องไป gen report ที่ server เพิ่มไหม code ที่เพิ่มคือคำสั่งใหม่ที่ต้องไป gen report อีกรอบ
|
||||
const genReportStatus = computed(() => {
|
||||
return code.value == "c-pm-25" ||
|
||||
code.value == "c-pm-26" ||
|
||||
code.value == "c-pm-27" ||
|
||||
code.value == "c-pm-28" ||
|
||||
code.value == "c-pm-29" ||
|
||||
code.value == "c-pm-30" ||
|
||||
code.value == "c-pm-31" ||
|
||||
code.value == "c-pm-32"
|
||||
? true
|
||||
: false;
|
||||
});
|
||||
|
||||
// เรียกข้อมูลคำสั่ง
|
||||
const getCommandDetail = async () => {
|
||||
await http
|
||||
|
|
@ -103,19 +118,33 @@ const getCommandDetail = async () => {
|
|||
// โหลดคำสั่ง
|
||||
const downloadCover = async (type: string) => {
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.fileCover(code.value, type, orderId.value), {
|
||||
responseType: "blob",
|
||||
})
|
||||
.then(async (res) => {
|
||||
downloadFile(res, `คำสั่ง ${orderName.value}.${type}`);
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
|
||||
if (!genReportStatus) {
|
||||
await http
|
||||
.get(config.API.fileCover(code.value, type, orderId.value), {
|
||||
responseType: "blob",
|
||||
})
|
||||
.then(async (res) => {
|
||||
downloadFile(res, `คำสั่ง ${orderName.value}.${type}`);
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
} else {
|
||||
const link = document.createElement("a");
|
||||
var fileName = `คำสั่ง ${orderName.value}.${
|
||||
type === "docx" ? "docx" : "pdf"
|
||||
}`;
|
||||
link.href = orderCoverPdf.value;
|
||||
link.setAttribute("download", fileName);
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
hideLoader();
|
||||
}
|
||||
};
|
||||
// โหลด เอกสารแนบท้าย
|
||||
const downloadAttachment = async (type: string) => {
|
||||
|
|
@ -137,15 +166,45 @@ const downloadAttachment = async (type: string) => {
|
|||
// เรียกไฟล์ คำสั่ง
|
||||
const fetchReportCover = async (type: string, orderId: string) => {
|
||||
await http
|
||||
.get(config.API.reportOrderCover(type, orderId, code.value), {
|
||||
responseType: "blob",
|
||||
})
|
||||
.then((res) => {
|
||||
const blob = new Blob([res.data]);
|
||||
const objectUrl = URL.createObjectURL(blob);
|
||||
orderCoverPdf.value = objectUrl;
|
||||
if (tab.value == "main") {
|
||||
viewPDF(orderCoverPdf.value);
|
||||
.get(
|
||||
config.API.reportOrderCover(type, orderId, code.value),
|
||||
!genReportStatus.value
|
||||
? {
|
||||
responseType: "blob",
|
||||
}
|
||||
: {}
|
||||
)
|
||||
.then(async (res: any) => {
|
||||
if (!genReportStatus.value) {
|
||||
const blob = new Blob([res.data]);
|
||||
const objectUrl = URL.createObjectURL(blob);
|
||||
orderCoverPdf.value = objectUrl;
|
||||
if (tab.value == "main") {
|
||||
viewPDF(orderCoverPdf.value);
|
||||
}
|
||||
} else {
|
||||
// report template
|
||||
await axios
|
||||
.post(`${config.API.reportTemplate}/docx`, res.data.result, {
|
||||
headers: {
|
||||
accept: "application/pdf",
|
||||
"content-Type": "application/json",
|
||||
},
|
||||
responseType: "blob",
|
||||
})
|
||||
.then((resReport) => {
|
||||
const data = resReport.data;
|
||||
if (data) {
|
||||
const blob = new Blob([data]);
|
||||
const objectUrl = URL.createObjectURL(blob);
|
||||
orderCoverPdf.value = objectUrl;
|
||||
viewPDF(orderCoverPdf.value);
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {});
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue