From ca72fbd577f4931508c50293c6c303749706d0de Mon Sep 17 00:00:00 2001 From: setthawutttty Date: Tue, 10 Dec 2024 15:01:10 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=20=E0=B8=A3?= =?UTF-8?q?=E0=B8=B2=E0=B8=A2=E0=B8=87=E0=B8=B2=E0=B8=99=E0=B8=AA=E0=B8=96?= =?UTF-8?q?=E0=B8=B4=E0=B8=95=E0=B8=B4=E0=B8=AA=E0=B8=B3=E0=B8=AB=E0=B8=A3?= =?UTF-8?q?=E0=B8=B1=E0=B8=9A=E0=B8=81=E0=B8=B2=E0=B8=A3=E0=B8=AA=E0=B8=AD?= =?UTF-8?q?=E0=B8=9A=E0=B9=81=E0=B8=82=E0=B9=88=E0=B8=87=E0=B8=82=E0=B8=B1?= =?UTF-8?q?=E0=B8=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../views/01_compete/CompeteReport.vue | 70 +++++-------------- 1 file changed, 17 insertions(+), 53 deletions(-) diff --git a/src/modules/03_recruiting/views/01_compete/CompeteReport.vue b/src/modules/03_recruiting/views/01_compete/CompeteReport.vue index 2810ab940..33ca94d6e 100644 --- a/src/modules/03_recruiting/views/01_compete/CompeteReport.vue +++ b/src/modules/03_recruiting/views/01_compete/CompeteReport.vue @@ -10,15 +10,19 @@ import { checkPermission } from "@/utils/permissions"; import { useCounterMixin } from "@/stores/mixin"; import type { DataOption } from "@/modules/09_leave/interface/index/Main"; - +import genReportXLSX from "@/plugins/genreportxlsx"; /** use*/ +const isReport = ref(true); const mixin = useCounterMixin(); const $q = useQuasar(); const { showLoader, hideLoader, date2Thai, dateToISO, messageError } = mixin; const year = ref(new Date().getFullYear()); -const reportSelect = ref("report1"); +const reportSelect = ref({ + id: "", + name: "", +}); const reportSelectMain = ref([ { id: "report1", @@ -44,12 +48,14 @@ async function getReportRecruit() { showLoader(); await http .get( - config.API.reportRecruit(reportSelect.value) + `?year=${year.value + 543}` + config.API.reportRecruit(reportSelect.value.id) + + `?year=${year.value + 543}` ) .then(async (res) => { const data = res.data.result; data && (await genReport(data)); detailReport.value = data; + isReport.value = false; }) .catch((err) => { messageError($q, err); @@ -93,47 +99,6 @@ async function genReport(data: any) { }); } -/** - * function เรียกไฟล์ XLSX - * @param data ข้อมูลบัญชีวันลา - */ -async function genReportXLSX(data: any) { - await axios - .post(`${config.API.reportTemplate}/xlsx`, data, { - headers: { - accept: - "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", - "content-Type": "application/json", - }, - responseType: "blob", - }) - .then(async (res) => { - const blob = new Blob([res.data]); - downloadReport(blob, "xlsx"); - }) - .catch(async (e) => { - messageError($q, JSON.parse(await e.response.data.text())); - }) - .finally(() => { - hideLoader(); - }); -} - -/** - * function Download ไฟล์ - * @param data ข้อมูลบัญชีวันลา - * @param type นามสกุลไฟล์ - */ -async function downloadReport(data: any, type: string) { - const link = document.createElement("a"); - var fileName = "บัญชีแสดงวันลา"; - link.href = window.URL.createObjectURL(new Blob([data])); - link.setAttribute("download", `${fileName}.${type}`); - document.body.appendChild(link); - link.click(); - document.body.removeChild(link); -} - const splitterModel = ref(14); const numOfPages = ref(0); const page = ref(1); @@ -167,14 +132,10 @@ function filterFnOptions(val: any, update: Function) { ); }); } - -onMounted(() => { - getReportRecruit(); -});