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(
-
+
+
+
+
+