From d7f2a62d7e59011b655c7e86aa2e4a7efef6b750 Mon Sep 17 00:00:00 2001 From: waruneeauy Date: Tue, 24 Jun 2025 13:24:15 +0700 Subject: [PATCH 1/2] fix report & export to excel of registry system --- .../21_report/views/02_reportRegistry.vue | 44 ++++++++++++++----- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/src/modules/21_report/views/02_reportRegistry.vue b/src/modules/21_report/views/02_reportRegistry.vue index fe89e9a45..1b3963df7 100644 --- a/src/modules/21_report/views/02_reportRegistry.vue +++ b/src/modules/21_report/views/02_reportRegistry.vue @@ -342,7 +342,10 @@ const columns = computed(() => { { name: "positionDate", align: "left", - label: "ระยะเวลาดำรงตำแหน่ง (สายงาน) ปัจจุบัน", + label: + employeeClass.value === "officer" + ? "ระยะเวลาดำรงตำแหน่ง (สายงาน) ปัจจุบัน" + : "ระยะเวลาดำรงตำแหน่งปัจจุบัน", sortable: true, field: "positionDate", headerStyle: "font-size: 14px", @@ -379,7 +382,10 @@ const visibleColumns = computed(() => { return employeeClass.value === "officer" ? visibleColumnsBase.value : visibleColumnsBase.value.filter( - (e: string) => e !== "positionExecutive" && e !== "positionArea" + (e: string) => + e !== "positionExecutive" && + e !== "positionArea" && + e !== "posExecutiveDate" ); }); @@ -649,7 +655,14 @@ async function onSearch() { function exportToExcel() { const newData = rows.value.map((e: any) => { - const { profileId, empType, positionArea, positionExecutive, ...rest } = e; + const { + profileId, + empType, + positionArea, + positionExecutive, + posExecutiveDate, + ...rest + } = e; return { ...rest, dateAppoint: date2Thai(e.dateAppoint), @@ -661,12 +674,17 @@ function exportToExcel() { }); const headers = - columns.value - ?.filter( - (x: any) => - x.field !== "positionExecutive" && x.field !== "positionArea" - ) - .map((item: any) => item.label) || []; // หัวคอลัมน์ภาษาไทย + employeeClass.value === "officer" + ? columns.value?.map((item: any) => item.label) || [] + : columns.value + ?.filter( + (x: any) => + x.field !== "positionExecutive" && + x.field !== "positionArea" && + x.field !== "posExecutiveDate" + ) + .map((item: any) => item.label) || []; // หัวคอลัมน์ภาษาไทย + const worksheet = XLSX.utils.json_to_sheet(newData, { header: visibleColumns.value, }); @@ -1544,7 +1562,11 @@ watch( @@ -1556,6 +1578,7 @@ watch( class="text-grey-8" /> + Date: Tue, 24 Jun 2025 15:32:31 +0700 Subject: [PATCH 2/2] fix map field education display in excel --- .../21_report/views/02_reportRegistry.vue | 100 +++++++++++++----- 1 file changed, 72 insertions(+), 28 deletions(-) diff --git a/src/modules/21_report/views/02_reportRegistry.vue b/src/modules/21_report/views/02_reportRegistry.vue index 1b3963df7..f43973ddb 100644 --- a/src/modules/21_report/views/02_reportRegistry.vue +++ b/src/modules/21_report/views/02_reportRegistry.vue @@ -604,17 +604,26 @@ async function onSearch() { gender: item.gender ?? "-", status: item.relationship ?? "-", education: - item.Educations.length > 0 - ? item.Educations.map((e: any) => e.degree) - : [], + item.Educations.length > 0 && + item.Educations.filter((e: any) => e.degree != null) + ? item.Educations.filter((e: any) => e.degree != null).map( + (e: any) => e.degree + ) + : null, educationLevel: - item.Educations.length > 0 - ? item.Educations.map((e: any) => e.educationLevel) - : [], + item.Educations.length > 0 && + item.Educations.filter((e: any) => e.educationLevel != null) + ? item.Educations.filter((e: any) => e.educationLevel != null).map( + (e: any) => e.educationLevel + ) + : null, field: - item.Educations.length > 0 - ? item.Educations.map((e: any) => e.field) - : [], + item.Educations.length > 0 && + item.Educations.filter((e: any) => e.field != null) + ? item.Educations.filter((e: any) => e.field != null).map( + (e: any) => e.field + ) + : null, dateAppoint: item.dateAppoint ?? "-", age: item.age ?? "-", @@ -654,24 +663,55 @@ async function onSearch() { } function exportToExcel() { - const newData = rows.value.map((e: any) => { - const { - profileId, - empType, - positionArea, - positionExecutive, - posExecutiveDate, - ...rest - } = e; - return { - ...rest, - dateAppoint: date2Thai(e.dateAppoint), - dateRetireLaw: date2Thai(e.dateRetireLaw), - education: e.education.map((e: string) => `${e}`).join(", "), - educationLevel: e.educationLevel.map((e: string) => `${e}`).join(", "), - field: e.field.map((e: string) => `${e}`).join(", "), - }; - }); + const newData = + employeeClass.value === "officer" + ? rows.value.map((e: any) => { + const { profileId, empType, ...rest } = e; + return { + ...rest, + dateAppoint: date2Thai(e.dateAppoint), + dateRetireLaw: date2Thai(e.dateRetireLaw), + education: + e.education && e.education.length > 0 + ? e.education.map((e: string) => `${e}`).join(", ") + : "-", + educationLevel: + e.educationLevel && e.educationLevel.length > 0 + ? e.educationLevel.map((e: string) => `${e}`).join(", ") + : "-", + field: + e.field && e.field.length > 0 + ? e.field.map((e: string) => `${e}`).join(", ") + : "-", + }; + }) + : rows.value.map((e: any) => { + const { + profileId, + empType, + positionArea, + positionExecutive, + posExecutiveDate, + ...rest + } = e; + return { + ...rest, + dateAppoint: date2Thai(e.dateAppoint), + dateRetireLaw: date2Thai(e.dateRetireLaw), + education: + e.education && e.education.length > 0 + ? e.education.map((e: string) => `${e}`).join(", ") + : "-", + educationLevel: + e.educationLevel && e.educationLevel.length > 0 + ? e.educationLevel.map((e: string) => `${e}`).join(", ") + : "-", + field: + e.field && e.field.length > 0 + ? e.field.map((e: string) => `${e}`).join(", ") + : "-", + }; + }); const headers = employeeClass.value === "officer" @@ -1558,7 +1598,7 @@ watch(
-
+
+
+
+
+