แก้รายงานออกคำสั่งวินัย และแก้ path url report-template
This commit is contained in:
parent
c49b528861
commit
defe861b55
4 changed files with 119 additions and 48 deletions
|
|
@ -32,6 +32,8 @@ const config = ref<any>({
|
|||
// API_PROBATION_URI: "http://192.168.1.151:7776/v1",
|
||||
API_REPORT2_URI: "https://bma-ehr.frappet.synology.me/api/v2",
|
||||
LINK_EVALUATE_PUBLISH: "https://bma-ehr-publish.frappet.synology.me",
|
||||
API_REPORT_TEMPLATE_URI:
|
||||
"https://report-server.frappet.synology.me/api/v1/report-template",
|
||||
},
|
||||
test: {
|
||||
API_URI: "http://localhost:5010/api/v1",
|
||||
|
|
@ -55,6 +57,8 @@ const config = ref<any>({
|
|||
API_PROBATION_URI: `${window.location.protocol}//${window.location.host}/api/v1/probation`,
|
||||
API_REPORT2_URI: `${window.location.protocol}//${window.location.host}/api/v2`,
|
||||
LINK_EVALUATE_PUBLISH: "https://bma-ehr-publish.frappet.synology.me",
|
||||
API_REPORT_TEMPLATE_URI:
|
||||
"https://report-server.frappet.synology.me/api/v1/report-template",
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -84,7 +88,12 @@ const API_PROBATION_URI = ref<string>(
|
|||
config.value[env.value].API_PROBATION_URI
|
||||
);
|
||||
const API_REPORT2_URI = ref<string>(config.value[env.value].API_REPORT2_URI);
|
||||
const LINK_EVALUATE_PUBLISH = ref<string>(config.value[env.value].LINK_EVALUATE_PUBLISH);
|
||||
const LINK_EVALUATE_PUBLISH = ref<string>(
|
||||
config.value[env.value].LINK_EVALUATE_PUBLISH
|
||||
);
|
||||
const API_REPORT_TEMPLATE_URI = ref<string>(
|
||||
config.value[env.value].API_REPORT_TEMPLATE_URI
|
||||
);
|
||||
|
||||
export default {
|
||||
env: env.value,
|
||||
|
|
@ -102,4 +111,5 @@ export default {
|
|||
API_PROBATION_URI: API_PROBATION_URI.value,
|
||||
API_REPORT2_URI: API_REPORT2_URI.value,
|
||||
LINK_EVALUATE_PUBLISH: LINK_EVALUATE_PUBLISH.value,
|
||||
API_REPORT_TEMPLATE_URI: API_REPORT_TEMPLATE_URI.value,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ const reportProbation = `${env.API_REPORT2_URI}/report/probation`;
|
|||
const reportResign = `${env.API_REPORT2_URI}/report/resign/33`;
|
||||
const reportTransfer = `${env.API_REPORT2_URI}/report/transfer`;
|
||||
const reportDeceased = `${env.API_REPORT2_URI}/report/deceased`;
|
||||
const reportTemplate = `${env.API_REPORT_TEMPLATE_URI}`;
|
||||
|
||||
export default {
|
||||
reportOrderCover: (fileType: string, id: string, commandCode: string) =>
|
||||
|
|
@ -16,7 +17,7 @@ export default {
|
|||
`${reportOrder}/${commandCode}/attachment/${fileType}/${id}`,
|
||||
reportRetireList: (fileType: string, id: string) =>
|
||||
`${reportRetire}/${fileType}/${id}`,
|
||||
reportResignList: (fileType: string, id: string) =>
|
||||
reportResignList: (fileType: string, id: string) =>
|
||||
`${reportResign}/${fileType}/${id}`,
|
||||
|
||||
fileCover: (format: string, fileType: string, id: string) =>
|
||||
|
|
@ -24,23 +25,25 @@ export default {
|
|||
fileAttachment: (format: string, fileType: string, id: string) =>
|
||||
`${reportOrder}/${format}/attachment/${fileType}/${id}`,
|
||||
|
||||
//ระบบทดลองงาน
|
||||
reportAssign: (type: string, id: string) =>
|
||||
`${reportProbation}/13/${type}/${id}`,
|
||||
reportEvaluateRecord1: (type: string, id: string) =>
|
||||
`${reportProbation}/14/${type}/${id}`,
|
||||
// reportEvaluateRecord2:(type:string, id:string) => `${reportProbation}/15/${type}/${id}`,
|
||||
reportEvaluate: (type: string, id: string) =>
|
||||
`${reportProbation}/16/${type}/${id}`,
|
||||
reportEvaluateChairman: (type: string, id: string) =>
|
||||
`${reportProbation}/17/${type}/${id}`,
|
||||
reportEvaluateResult: (type: string, id: string) =>
|
||||
`${reportProbation}/19/${type}/${id}`,
|
||||
// reportSurvey:(type:string, id:string) => `${reportProbation}/19/${type}/${id}`,
|
||||
|
||||
//ระบบทดลองงาน
|
||||
reportAssign:(type:string, id:string) => `${reportProbation}/13/${type}/${id}`,
|
||||
reportEvaluateRecord1:(type:string, id:string) => `${reportProbation}/14/${type}/${id}`,
|
||||
// reportEvaluateRecord2:(type:string, id:string) => `${reportProbation}/15/${type}/${id}`,
|
||||
reportEvaluate:(type:string, id:string) => `${reportProbation}/16/${type}/${id}`,
|
||||
reportEvaluateChairman:(type:string, id:string) => `${reportProbation}/17/${type}/${id}`,
|
||||
reportEvaluateResult:(type:string, id:string) => `${reportProbation}/19/${type}/${id}`,
|
||||
// reportSurvey:(type:string, id:string) => `${reportProbation}/19/${type}/${id}`,
|
||||
//filetransfer
|
||||
reportTransferFile: (no: number, type: string, id: string) =>
|
||||
`${reportTransfer}/${no}/${type}/${id}`,
|
||||
|
||||
//filetransfer
|
||||
reportTransferFile:(no:number,type:string,id:string) => `${reportTransfer}/${no}/${type}/${id}`,
|
||||
|
||||
DeceasedReport:(type:string,id:string) => `${reportDeceased}/36/${type}/${id}`
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
DeceasedReport: (type: string, id: string) =>
|
||||
`${reportDeceased}/36/${type}/${id}`,
|
||||
reportTemplate,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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) => {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
import axios from "axios";
|
||||
import config from "@/app.config";
|
||||
|
||||
import { useQuasar } from "quasar";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
|
||||
|
|
@ -7,13 +9,10 @@ const $q = useQuasar();
|
|||
const mixin = useCounterMixin();
|
||||
const { showLoader, hideLoader, messageError } = mixin;
|
||||
|
||||
const apiGenReport =
|
||||
"https://report-server.frappet.synology.me/api/v1/report-template/docx";
|
||||
|
||||
async function genReport(data: any, fileName: string, type: string = "docx") {
|
||||
showLoader();
|
||||
await axios
|
||||
.post(apiGenReport, data, {
|
||||
.post(`${config.API.reportTemplate}/docx`, data, {
|
||||
headers:
|
||||
type == "docx"
|
||||
? {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue