diff --git a/src/modules/21_report/views/02_reportRegistry.vue b/src/modules/21_report/views/02_reportRegistry.vue index 3e9850572..400374095 100644 --- a/src/modules/21_report/views/02_reportRegistry.vue +++ b/src/modules/21_report/views/02_reportRegistry.vue @@ -21,7 +21,6 @@ import type { DataOption, OptionExecutive, ResOptionPerson, - DataEducationLevel, } from "@/modules/21_report/interface/Main"; import type { DataRoles } from "@/interface/response/main"; import type { DataStructureTree } from "@/interface/main"; @@ -44,6 +43,7 @@ const { hideLoader, date2Thai, formatDatePositionReport, + convertDateToAPI, } = useCounterMixin(); const loadingBtn = ref(false); @@ -530,11 +530,11 @@ async function onSearch() { education: education.value.trim(), educationLevel: educationLevel.value.trim(), field: field.value.trim(), - positionArea: education.value.trim(), + positionArea: positionArea.value.trim(), ageMin: rangeAge.value.min, ageMax: rangeAge.value.max, - dateStart: dateStart.value ?? null, - dateEnd: dateEnd.value ?? null, + dateStart: convertDateToAPI(dateStart.value) ?? null, + dateEnd: convertDateToAPI(dateEnd.value) ?? null, isProbation: isProbation.value, isRetire: isRetire.value, retireType: retireType.value, @@ -555,22 +555,7 @@ async function onSearch() { ) .then(async (res) => { const data = res.data.result.data; - const Educations = [ - { - field: "", - degree: "วิทยาศาสตร์บัณฑิต", - isHigh: null, - isEducation: 1, - educationLevel: "", - }, - { - field: "", - degree: "วิทยาศาสตร์บัณฑิต2", - isHigh: null, - isEducation: 1, - educationLevel: "ปริญญาตรี", - }, - ]; + total.value = res.data.result.total; rows.value = data.map((item: any, index: number) => ({ profileId: item.profileId, @@ -587,10 +572,17 @@ async function onSearch() { gender: item.gender ?? "-", status: item.relationship ?? "-", education: - Educations.length > 0 ? Educations.map((e) => e.degree) : "-", + item.Educations.length > 0 + ? item.Educations.map((e: any) => e.degree) + : [], educationLevel: - Educations.length > 0 ? Educations.map((e) => e.educationLevel) : "-", - field: Educations.length > 0 ? Educations.map((e) => e.field) : "-", + item.Educations.length > 0 + ? item.Educations.map((e: any) => e.educationLevel) + : [], + field: + item.Educations.length > 0 + ? item.Educations.map((e: any) => e.field) + : [], dateAppoint: item.dateAppoint ?? "-", age: item.age ?? "-", @@ -630,8 +622,8 @@ function exportToExcel() { dateAppoint: date2Thai(e.dateAppoint), dateRetireLaw: date2Thai(e.dateRetireLaw), education: e.education.map((e: string) => `${e}`).join(", "), - educationLevel: e.education.map((e: string) => `${e}`).join(", "), - feild: e.education.map((e: string) => `${e}`).join(", "), + educationLevel: e.educationLevel.map((e: string) => `${e}`).join(", "), + field: e.field.map((e: string) => `${e}`).join(", "), }; }); @@ -781,11 +773,22 @@ onMounted(async () => { }); function formatEducation(value: any) { - return Array.isArray(value) && value.length > 0 - ? value - .map((e, index) => (e ? `- ${e}` : index > 0 ? "
" : "")) - .join("
") - : "-"; + if (!Array.isArray(value) || value.length === 0) { + return "-"; + } + + // ตรวจสอบว่าทุกค่าว่างทั้งหมดหรือไม่ + const allEmpty = value.every((e) => !e?.toString().trim()); + + if (allEmpty) { + return "-"; + } + + return value + .map((e, index) => + e?.toString().trim() ? `- ${e}` : index > 0 ? "
" : "" + ) + .join("
"); } watch(