แก้รายงานออกคำสั่งวินัย และแก้ path url report-template

This commit is contained in:
Warunee Tamkoo 2024-01-08 12:19:14 +07:00
parent c49b528861
commit defe861b55
4 changed files with 119 additions and 48 deletions

View file

@ -32,6 +32,8 @@ const config = ref<any>({
// API_PROBATION_URI: "http://192.168.1.151:7776/v1", // API_PROBATION_URI: "http://192.168.1.151:7776/v1",
API_REPORT2_URI: "https://bma-ehr.frappet.synology.me/api/v2", API_REPORT2_URI: "https://bma-ehr.frappet.synology.me/api/v2",
LINK_EVALUATE_PUBLISH: "https://bma-ehr-publish.frappet.synology.me", 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: { test: {
API_URI: "http://localhost:5010/api/v1", 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_PROBATION_URI: `${window.location.protocol}//${window.location.host}/api/v1/probation`,
API_REPORT2_URI: `${window.location.protocol}//${window.location.host}/api/v2`, API_REPORT2_URI: `${window.location.protocol}//${window.location.host}/api/v2`,
LINK_EVALUATE_PUBLISH: "https://bma-ehr-publish.frappet.synology.me", 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 config.value[env.value].API_PROBATION_URI
); );
const API_REPORT2_URI = ref<string>(config.value[env.value].API_REPORT2_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 { export default {
env: env.value, env: env.value,
@ -102,4 +111,5 @@ export default {
API_PROBATION_URI: API_PROBATION_URI.value, API_PROBATION_URI: API_PROBATION_URI.value,
API_REPORT2_URI: API_REPORT2_URI.value, API_REPORT2_URI: API_REPORT2_URI.value,
LINK_EVALUATE_PUBLISH: LINK_EVALUATE_PUBLISH.value, LINK_EVALUATE_PUBLISH: LINK_EVALUATE_PUBLISH.value,
API_REPORT_TEMPLATE_URI: API_REPORT_TEMPLATE_URI.value,
}; };

View file

@ -8,6 +8,7 @@ const reportProbation = `${env.API_REPORT2_URI}/report/probation`;
const reportResign = `${env.API_REPORT2_URI}/report/resign/33`; const reportResign = `${env.API_REPORT2_URI}/report/resign/33`;
const reportTransfer = `${env.API_REPORT2_URI}/report/transfer`; const reportTransfer = `${env.API_REPORT2_URI}/report/transfer`;
const reportDeceased = `${env.API_REPORT2_URI}/report/deceased`; const reportDeceased = `${env.API_REPORT2_URI}/report/deceased`;
const reportTemplate = `${env.API_REPORT_TEMPLATE_URI}`;
export default { export default {
reportOrderCover: (fileType: string, id: string, commandCode: string) => reportOrderCover: (fileType: string, id: string, commandCode: string) =>
@ -16,7 +17,7 @@ export default {
`${reportOrder}/${commandCode}/attachment/${fileType}/${id}`, `${reportOrder}/${commandCode}/attachment/${fileType}/${id}`,
reportRetireList: (fileType: string, id: string) => reportRetireList: (fileType: string, id: string) =>
`${reportRetire}/${fileType}/${id}`, `${reportRetire}/${fileType}/${id}`,
reportResignList: (fileType: string, id: string) => reportResignList: (fileType: string, id: string) =>
`${reportResign}/${fileType}/${id}`, `${reportResign}/${fileType}/${id}`,
fileCover: (format: string, fileType: string, id: string) => fileCover: (format: string, fileType: string, id: string) =>
@ -24,23 +25,25 @@ export default {
fileAttachment: (format: string, fileType: string, id: string) => fileAttachment: (format: string, fileType: string, id: string) =>
`${reportOrder}/${format}/attachment/${fileType}/${id}`, `${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}`,
//ระบบทดลองงาน //filetransfer
reportAssign:(type:string, id:string) => `${reportProbation}/13/${type}/${id}`, reportTransferFile: (no: number, type: string, id: string) =>
reportEvaluateRecord1:(type:string, id:string) => `${reportProbation}/14/${type}/${id}`, `${reportTransfer}/${no}/${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 DeceasedReport: (type: string, id: string) =>
reportTransferFile:(no:number,type:string,id:string) => `${reportTransfer}/${no}/${type}/${id}`, `${reportDeceased}/36/${type}/${id}`,
reportTemplate,
DeceasedReport:(type:string,id:string) => `${reportDeceased}/36/${type}/${id}` };
};

View file

@ -8,7 +8,8 @@ import { useQuasar } from "quasar";
import { useRoute } from "vue-router"; import { useRoute } from "vue-router";
import http from "@/plugins/http"; import http from "@/plugins/http";
import config from "@/app.config"; 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 mixin = useCounterMixin();
const { const {
@ -38,7 +39,7 @@ const fileTailer = ref<any>(null);
const OrderPDFUpload = ref<string>(""); const OrderPDFUpload = ref<string>("");
const TailerPDFUpload = ref<string>(""); const TailerPDFUpload = ref<string>("");
const orderCoverPdf = ref<string>(""); const orderCoverPdf = ref<any>();
const orderAttachmentPdf = ref<string>(""); const orderAttachmentPdf = ref<string>("");
const statusOrder = ref<string>(); const statusOrder = ref<string>();
@ -79,6 +80,20 @@ const attachmentStatus = computed(() => {
: false; : 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 () => { const getCommandDetail = async () => {
await http await http
@ -103,19 +118,33 @@ const getCommandDetail = async () => {
// //
const downloadCover = async (type: string) => { const downloadCover = async (type: string) => {
showLoader(); showLoader();
await http
.get(config.API.fileCover(code.value, type, orderId.value), { if (!genReportStatus) {
responseType: "blob", await http
}) .get(config.API.fileCover(code.value, type, orderId.value), {
.then(async (res) => { responseType: "blob",
downloadFile(res, `คำสั่ง ${orderName.value}.${type}`); })
}) .then(async (res) => {
.catch((e) => { downloadFile(res, `คำสั่ง ${orderName.value}.${type}`);
messageError($q, e); })
}) .catch((e) => {
.finally(() => { messageError($q, e);
hideLoader(); })
}); .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) => { const downloadAttachment = async (type: string) => {
@ -137,15 +166,45 @@ const downloadAttachment = async (type: string) => {
// //
const fetchReportCover = async (type: string, orderId: string) => { const fetchReportCover = async (type: string, orderId: string) => {
await http await http
.get(config.API.reportOrderCover(type, orderId, code.value), { .get(
responseType: "blob", config.API.reportOrderCover(type, orderId, code.value),
}) !genReportStatus.value
.then((res) => { ? {
const blob = new Blob([res.data]); responseType: "blob",
const objectUrl = URL.createObjectURL(blob); }
orderCoverPdf.value = objectUrl; : {}
if (tab.value == "main") { )
viewPDF(orderCoverPdf.value); .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) => { .catch((e) => {

View file

@ -1,4 +1,6 @@
import axios from "axios"; import axios from "axios";
import config from "@/app.config";
import { useQuasar } from "quasar"; import { useQuasar } from "quasar";
import { useCounterMixin } from "@/stores/mixin"; import { useCounterMixin } from "@/stores/mixin";
@ -7,13 +9,10 @@ const $q = useQuasar();
const mixin = useCounterMixin(); const mixin = useCounterMixin();
const { showLoader, hideLoader, messageError } = mixin; 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") { async function genReport(data: any, fileName: string, type: string = "docx") {
showLoader(); showLoader();
await axios await axios
.post(apiGenReport, data, { .post(`${config.API.reportTemplate}/docx`, data, {
headers: headers:
type == "docx" type == "docx"
? { ? {