From e7eb440ca6dcc0920914837fff4eaff863f29abd Mon Sep 17 00:00:00 2001 From: waruneeauy Date: Wed, 5 Mar 2025 23:19:48 +0700 Subject: [PATCH] fixing --- src/modules/21_report/views/02_reportRegistry.vue | 13 +++++++++---- src/stores/mixin.ts | 15 +++++++++++++++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/modules/21_report/views/02_reportRegistry.vue b/src/modules/21_report/views/02_reportRegistry.vue index 566ca13b7..3738266fd 100644 --- a/src/modules/21_report/views/02_reportRegistry.vue +++ b/src/modules/21_report/views/02_reportRegistry.vue @@ -38,8 +38,13 @@ const { fetchStructureTree } = useStructureTree(); const storeMenu = useMenuDataStore(); -const { messageError, showLoader, hideLoader, date2Thai, formatDatePosition } = - useCounterMixin(); +const { + messageError, + showLoader, + hideLoader, + date2Thai, + formatDatePositionReport, +} = useCounterMixin(); const loadingBtn = ref(false); const total = ref(0); @@ -560,13 +565,13 @@ async function onSearch() { dateAppoint: item.dateAppoint ?? "-", age: item.age ?? "-", positionDate: - formatDatePosition( + formatDatePositionReport( item.positionDate?.Years, item.positionDate?.Months, item.positionDate?.Days ) ?? "-", levelDate: - formatDatePosition( + formatDatePositionReport( item.levelDate?.posExecutiveYears, item.levelDate?.posExecutiveMonths, item.levelDate?.posExecutiveDays diff --git a/src/stores/mixin.ts b/src/stores/mixin.ts index 37b194cca..d85dced88 100644 --- a/src/stores/mixin.ts +++ b/src/stores/mixin.ts @@ -1163,6 +1163,20 @@ export const useCounterMixin = defineStore("mixin", () => { // return `${y} ปี ${m} เดือน ${d} วัน`; } + function formatDatePositionReport(year: string, month: string, day: string) { + const y = parseInt(year); + const m = parseInt(month); + const d = parseInt(day); + + const parts = []; + if (y > 0) parts.push(`${y} ปี`); + if (m > 0) parts.push(`${m} เดือน`); + if (d > 0) parts.push(`${d} วัน`); + + return parts.length > 0 ? parts.join(" ") : ""; // กรณีที่ทั้งหมดเป็น 0 + // return `${y} ปี ${m} เดือน ${d} วัน`; + } + return { calAge, date2Thai, @@ -1210,5 +1224,6 @@ export const useCounterMixin = defineStore("mixin", () => { onSearchDataTable, formatDatePosition, + formatDatePositionReport, }; });