From a95b8073f6ba1782c523c906515f931b1215b29e Mon Sep 17 00:00:00 2001 From: setthawutttty Date: Wed, 19 Feb 2025 18:22:06 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=A3=E0=B8=B2=E0=B8=A2=E0=B8=87=E0=B8=B2?= =?UTF-8?q?=E0=B8=99=E0=B8=97=E0=B8=B0=E0=B9=80=E0=B8=9A=E0=B8=B5=E0=B8=A2?= =?UTF-8?q?=E0=B8=99=E0=B8=9B=E0=B8=A3=E0=B8=B0=E0=B8=A7=E0=B8=B1=E0=B8=95?= =?UTF-8?q?=E0=B8=B4=20=E0=B8=A3=E0=B8=AD=E0=B8=9F=E0=B8=B4=E0=B8=A5=20?= =?UTF-8?q?=E0=B8=A3=E0=B8=B0=E0=B8=A2=E0=B8=B0=E0=B9=80=E0=B8=A7=E0=B8=A5?= =?UTF-8?q?=E0=B8=B2=E0=B8=94=E0=B8=B3=E0=B8=A3=E0=B8=87=E0=B8=95=E0=B8=B3?= =?UTF-8?q?=E0=B9=81=E0=B8=AB=E0=B8=99=E0=B9=88=E0=B8=87=E0=B8=9B=E0=B8=B1?= =?UTF-8?q?=E0=B8=88=E0=B8=88=E0=B8=B8=E0=B8=9A=E0=B8=B1=E0=B8=99/?= =?UTF-8?q?=E0=B8=A3=E0=B8=B0=E0=B8=A2=E0=B8=B0=E0=B9=80=E0=B8=A7=E0=B8=A5?= =?UTF-8?q?=E0=B8=B2=E0=B8=94=E0=B8=B3=E0=B8=A3=E0=B8=87=E0=B8=95=E0=B8=B3?= =?UTF-8?q?=E0=B9=81=E0=B8=AB=E0=B8=99=E0=B9=88=E0=B8=87=E0=B9=83=E0=B8=99?= =?UTF-8?q?=E0=B9=80=E0=B9=80=E0=B8=95=E0=B9=88=E0=B8=A5=E0=B8=B0=E0=B8=A3?= =?UTF-8?q?=E0=B8=B0=E0=B8=94=E0=B8=B1=E0=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 3 +- .../21_report/views/02_reportRegistry.vue | 111 +++++++++++++++--- 2 files changed, 94 insertions(+), 20 deletions(-) diff --git a/package.json b/package.json index 95358ca91..bb26ccfd3 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ "vue-currency-input": "^3.0.5", "vue-router": "^4.1.6", "vue3-datepicker": "^0.3.4", - "vue3-pdfjs": "^0.1.6" + "vue3-pdfjs": "^0.1.6", + "xlsx": "^0.18.5" }, "devDependencies": { "@quasar/vite-plugin": "^1.3.0", diff --git a/src/modules/21_report/views/02_reportRegistry.vue b/src/modules/21_report/views/02_reportRegistry.vue index 8e18c4c9c..cc87869c5 100644 --- a/src/modules/21_report/views/02_reportRegistry.vue +++ b/src/modules/21_report/views/02_reportRegistry.vue @@ -4,6 +4,7 @@ import { useQuasar, type QTableProps } from "quasar"; import { VuePDF, usePDF } from "@tato30/vue-pdf"; import axios from "axios"; import genReportXLSX from "@/plugins/genreportxlsx"; +import * as XLSX from "xlsx"; import http from "@/plugins/http"; import config from "@/app.config"; @@ -90,6 +91,7 @@ const org = ref(""); const isProbation = ref(false); const isRetire = ref(false); +const sortBy = ref("ASC"); const retireType = ref(""); const retireTypeOps = ref([]); const retireTypeOpsMain = ref([ @@ -115,7 +117,6 @@ const visibleColumns = ref([ "fullName", "posNo", "position", - "posPath", "posType", "posLevel", "org", @@ -123,7 +124,7 @@ const visibleColumns = ref([ "gender", "status", "education", - "date", + "dateAppoint", "age", "currentPosition", "lengthPosition", @@ -175,7 +176,7 @@ const columns = ref([ a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), }, { - name: "posPath", + name: "posType", align: "left", label: "ตำแหน่งประเภท", sortable: true, @@ -193,11 +194,6 @@ const columns = ref([ field: "posLevel", headerStyle: "font-size: 14px", style: "font-size: 14px", - format(val, row) { - return row.posTypeShortName - ? row.posTypeShortName + " " + row.posLevel - : row.posLevel; - }, sort: (a: string, b: string) => a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), }, @@ -257,11 +253,11 @@ const columns = ref([ a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), }, { - name: "date", + name: "dateAppoint", align: "left", label: "วันที่บรรจุ", sortable: true, - field: "date", + field: "dateAppoint", headerStyle: "font-size: 14px", style: "font-size: 14px", sort: (a: string, b: string) => @@ -482,7 +478,8 @@ async function onSearch() { loadingBtn.value = true; const queryParams = { - nodeId: storeReport.formFilter.nodeId, + node: storeReport.formFilter.node ?? null, + nodeId: storeReport.formFilter.nodeId ?? "", posType: posType.value, posLevel: posLevel.value, @@ -493,12 +490,14 @@ async function onSearch() { education: education.value, ageMin: rangeAge.value.min, ageMax: rangeAge.value.max, - dateStart: dateStart.value, - dateEnd: dateEnd.value, + dateStart: dateStart.value ?? "", + dateEnd: dateEnd.value ?? "", isProbation: isProbation.value, isRetire: isRetire.value, retireType: retireType.value, + sortBy: sortBy.value ? "dateAppoint" : "", + sort: sortBy.value ? sortBy.value : "ASC", }; showLoader(); await http @@ -509,20 +508,54 @@ async function onSearch() { { params: queryParams } ) .then(async (res) => { - const data = res.data.result; - rows.value = data; + const data = res.data.result.data; + total.value = res.data.result.total; + rows.value = data.map((item: any, index: number) => ({ + no: index + 1, + fullName: `${item.prefix ?? ""}${item.firstName ?? ""} ${ + item.lastName ?? "" + }`, + posNo: item.searchShortName ?? "-", + position: item.position ?? "-", + posType: item.posTypeName ?? "-", + posLevel: item.posLevelName ?? "-", + org: item.org ?? "-", + positionExecutive: item.posExecutiveName ?? "-", + gender: item.gender ?? "-", + status: item.relationship ?? "-", + education: item.degree ?? "-", + dateAppoint: item.dateAppoint ? date2Thai(item.dateAppoint) : "-", + age: item.age ?? "-", + currentPosition: item.currentPosition ?? "-", + lengthPosition: item.lengthPosition ?? "-", + })); }) .catch((e) => { messageError($q, e); hideLoader(); }) .finally(() => { + hideLoader(); setTimeout(() => { loadingBtn.value = false; }, 500); }); } +function exportToExcel() { + const headers = columns.value?.map((item: any) => item.label) || []; // หัวคอลัมน์ภาษาไทย + const worksheet = XLSX.utils.json_to_sheet(rows.value, { + header: visibleColumns.value, + }); + + //แทรกหัวคอลัมน์ภาษาไทย (ใช้ A1, B1, C1 แทน) + XLSX.utils.sheet_add_aoa(worksheet, [headers], { origin: "A1" }); + + const workbook = XLSX.utils.book_new(); + XLSX.utils.book_append_sheet(workbook, worksheet, "ข้อมูล"); //ชื่อไฟล เเละ ชื่อ sheet + XLSX.writeFile(workbook, "ข้อมูล.xlsx"); +} + onMounted(async () => { showLoader(); Promise.all([ @@ -602,9 +635,10 @@ onMounted(async () => { color="primary" icon="download" v-if="checkPermission($route)?.attrIsGet" - :disable="!org" + :disable="rows.length == 0" + @click="exportToExcel()" > - + @@ -1083,6 +1117,46 @@ onMounted(async () => { +
+ + + + + เรียงตามวันที่บรรจุเเต่งตั้ง + (ล่าสุด-เก่า) + + + + + + เรียงตามวันที่บรรจุเเต่งตั้ง + (เก่า-ล่าสุด) + + + + +
@@ -1116,7 +1190,6 @@ onMounted(async () => { >