ผูก API ประเมินในส่วนของเอกสารต้นแบบใน step 2 #110
This commit is contained in:
parent
d71b2a172f
commit
d335632e59
4 changed files with 104 additions and 27 deletions
|
|
@ -1,7 +1,3 @@
|
|||
import env from "../index";
|
||||
|
||||
const report = `${env.API_GEN_REPORT}`;
|
||||
|
||||
export default {
|
||||
reportTemplate: () => `${report}/report-template/docx`,
|
||||
};
|
||||
export default {};
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ const config = ref<any>({
|
|||
// API_URI: "https://localhost:7260/api",
|
||||
API_URI: "https://bma-ehr.frappet.synology.me/api/v1",
|
||||
MEET_URI: "meet.frappet.com",
|
||||
API_GEN_REPORT: "https://report-server.frappet.synology.me/api/v1",
|
||||
},
|
||||
test: {
|
||||
API_URI: "http://localhost:5010/api/v1",
|
||||
|
|
@ -27,12 +26,10 @@ const config = ref<any>({
|
|||
|
||||
const API_URI = ref<string>(config.value[env.value].API_URI);
|
||||
const MEET_URI = ref<string>(config.value[env.value].MEET_URI);
|
||||
const API_GEN_REPORT = ref<string>(config.value[env.value].API_GEN_REPORT);
|
||||
|
||||
export default {
|
||||
env: env.value,
|
||||
config: config.value,
|
||||
API_URI: API_URI.value,
|
||||
MEET_URI: MEET_URI.value,
|
||||
API_GEN_REPORT: API_GEN_REPORT.value,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import { ref, onMounted } from "vue";
|
|||
import keycloak from "@/plugins/keycloak";
|
||||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
import genReport from "@/plugins/genreport";
|
||||
import { useQuasar } from "quasar";
|
||||
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
|
|
@ -47,7 +48,11 @@ function backPage() {
|
|||
}
|
||||
}
|
||||
|
||||
async function onClickDowloadFile(tp: string, templateName: string) {
|
||||
async function onClickDowloadFile(
|
||||
tp: string,
|
||||
templateName: string,
|
||||
fileName: string
|
||||
) {
|
||||
showLoader();
|
||||
const data = Object.assign(
|
||||
{ fullName: fullName.value },
|
||||
|
|
@ -61,17 +66,7 @@ async function onClickDowloadFile(tp: string, templateName: string) {
|
|||
data: data,
|
||||
};
|
||||
console.log(body);
|
||||
await http
|
||||
.post(config.API.reportTemplate(), body)
|
||||
.then((res) => {
|
||||
console.log(res);
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q,err)
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
await genReport(body, fileName);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
@ -94,7 +89,13 @@ async function onClickDowloadFile(tp: string, templateName: string) {
|
|||
icon="download"
|
||||
label="ดาวน์โหลดต้นแบบ"
|
||||
color="primary"
|
||||
@click="onClickDowloadFile('EV1_005', 'template-1')"
|
||||
@click="
|
||||
onClickDowloadFile(
|
||||
'EV1_005',
|
||||
'template-1',
|
||||
'แบบพิจารณาคุณสมบัติบุคคล'
|
||||
)
|
||||
"
|
||||
>
|
||||
<q-tooltip> ดาวน์โหลดต้นแบบ </q-tooltip></q-btn
|
||||
>
|
||||
|
|
@ -156,7 +157,13 @@ async function onClickDowloadFile(tp: string, templateName: string) {
|
|||
icon="download"
|
||||
label="ดาวน์โหลดต้นแบบ"
|
||||
color="primary"
|
||||
@click="onClickDowloadFile('EV1_006', 'template-2')"
|
||||
@click="
|
||||
onClickDowloadFile(
|
||||
'EV1_006',
|
||||
'template-2',
|
||||
'แบบแสดงรายละเอียดการเสนอผลงาน'
|
||||
)
|
||||
"
|
||||
>
|
||||
<q-tooltip> ดาวน์โหลดต้นแบบ </q-tooltip></q-btn
|
||||
>
|
||||
|
|
@ -216,7 +223,13 @@ async function onClickDowloadFile(tp: string, templateName: string) {
|
|||
icon="download"
|
||||
label="ดาวน์โหลดต้นแบบ"
|
||||
color="primary"
|
||||
@click="onClickDowloadFile('EV1_007', 'template-3')"
|
||||
@click="
|
||||
onClickDowloadFile(
|
||||
'EV1_007',
|
||||
'template-3',
|
||||
'แบบตรวจสอบความถูกต้องครบถ้วนของข้อมูลเพื่อประกอบการคัดเลือกบุคคล'
|
||||
)
|
||||
"
|
||||
>
|
||||
<q-tooltip> ดาวน์โหลดต้นแบบ </q-tooltip></q-btn
|
||||
>
|
||||
|
|
@ -276,7 +289,13 @@ async function onClickDowloadFile(tp: string, templateName: string) {
|
|||
icon="download"
|
||||
label="ดาวน์โหลดต้นแบบ"
|
||||
color="primary"
|
||||
@click="onClickDowloadFile('EV1_008', 'template-4')"
|
||||
@click="
|
||||
onClickDowloadFile(
|
||||
'EV1_008',
|
||||
'template-4',
|
||||
'แบบประเมินคุณลักษณะบุคคล'
|
||||
)
|
||||
"
|
||||
>
|
||||
<q-tooltip> ดาวน์โหลดต้นแบบ </q-tooltip></q-btn
|
||||
>
|
||||
|
|
@ -336,7 +355,13 @@ async function onClickDowloadFile(tp: string, templateName: string) {
|
|||
icon="download"
|
||||
label="ดาวน์โหลดต้นแบบ"
|
||||
color="primary"
|
||||
@click="onClickDowloadFile('EV1_009', 'template-5')"
|
||||
@click="
|
||||
onClickDowloadFile(
|
||||
'EV1_009',
|
||||
'template-5',
|
||||
'แบบสรุปข้อมูลของผู้ขอรับการคัดเลือก'
|
||||
)
|
||||
"
|
||||
>
|
||||
<q-tooltip> ดาวน์โหลดต้นแบบ </q-tooltip></q-btn
|
||||
>
|
||||
|
|
@ -349,7 +374,6 @@ async function onClickDowloadFile(tp: string, templateName: string) {
|
|||
icon="visibility"
|
||||
label="ดูไฟล์เอกสาร"
|
||||
color="primary"
|
||||
@click="onClickDowloadFile('EV1_009', 'template-5')"
|
||||
>
|
||||
<q-tooltip> ดูไฟล์เอกสาร </q-tooltip></q-btn
|
||||
>
|
||||
|
|
@ -397,7 +421,13 @@ async function onClickDowloadFile(tp: string, templateName: string) {
|
|||
icon="download"
|
||||
label="ดาวน์โหลดต้นแบบ"
|
||||
color="primary"
|
||||
@click="onClickDowloadFile('EV1_010', 'template-6')"
|
||||
@click="
|
||||
onClickDowloadFile(
|
||||
'EV1_010',
|
||||
'template-6',
|
||||
'ผลงานที่จะส่งประเมิน'
|
||||
)
|
||||
"
|
||||
>
|
||||
<q-tooltip> ดาวน์โหลดต้นแบบ </q-tooltip></q-btn
|
||||
>
|
||||
|
|
|
|||
54
src/plugins/genreport.ts
Normal file
54
src/plugins/genreport.ts
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
import axios from "axios";
|
||||
import { useQuasar } from "quasar";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
|
||||
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) {
|
||||
showLoader();
|
||||
await axios
|
||||
.post(apiGenReport, data, {
|
||||
headers: {
|
||||
accept:
|
||||
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
||||
"content-Type": "application/json",
|
||||
},
|
||||
responseType: "arraybuffer",
|
||||
})
|
||||
.then((res) => {
|
||||
const data = res.data;
|
||||
if (data) {
|
||||
// สร้าง Blob จาก array buffer
|
||||
const blob = new Blob([data], {
|
||||
type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
||||
});
|
||||
|
||||
// สร้าง URL สำหรับไฟล์ Blob
|
||||
const url = URL.createObjectURL(blob);
|
||||
|
||||
// สร้างลิงก์เพื่อดาวน์โหลดไฟล์
|
||||
const link = document.createElement("a");
|
||||
link.href = url;
|
||||
link.download = `${fileName}.docx`; // กำหนดชื่อไฟล์ที่จะดาวน์โหลด
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
|
||||
// ลบ URL ที่สร้างขึ้นหลังจากใช้งาน
|
||||
URL.revokeObjectURL(url);
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
export default genReport;
|
||||
Loading…
Add table
Add a link
Reference in a new issue