From 6dcace3135ce5c56b8884b08c5eb3d9358e8bd4e Mon Sep 17 00:00:00 2001 From: SeongHyun Kim Date: Wed, 17 Dec 2025 17:04:45 +0900 Subject: [PATCH] =?UTF-8?q?fix(RepeaterTable):=20=EC=88=AB=EC=9E=90=20?= =?UTF-8?q?=ED=95=84=EB=93=9C=20=ED=8F=AC=EB=A7=B7=ED=8C=85=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 정수/소수점 자동 구분 처리 - 천 단위 구분자(toLocaleString) 적용 - null/undefined/NaN 예외 처리 추가 --- .../modal-repeater-table/RepeaterTable.tsx | 32 ++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/frontend/lib/registry/components/modal-repeater-table/RepeaterTable.tsx b/frontend/lib/registry/components/modal-repeater-table/RepeaterTable.tsx index 4d6c9086..9604e7d2 100644 --- a/frontend/lib/registry/components/modal-repeater-table/RepeaterTable.tsx +++ b/frontend/lib/registry/components/modal-repeater-table/RepeaterTable.tsx @@ -347,12 +347,23 @@ export function RepeaterTable({ // 계산 필드는 편집 불가 if (column.calculated || !column.editable) { + // 숫자 포맷팅 함수: 정수/소수점 자동 구분 + const formatNumber = (val: any): string => { + if (val === undefined || val === null || val === "") return "0"; + const num = typeof val === "number" ? val : parseFloat(val); + if (isNaN(num)) return "0"; + // 정수면 소수점 없이, 소수면 소수점 유지 + if (Number.isInteger(num)) { + return num.toLocaleString("ko-KR"); + } else { + return num.toLocaleString("ko-KR"); + } + }; + return (
{column.type === "number" - ? typeof value === "number" - ? value.toLocaleString() - : value || "0" + ? formatNumber(value) : value || "-"}
); @@ -361,10 +372,23 @@ export function RepeaterTable({ // 편집 가능한 필드 switch (column.type) { case "number": + // 숫자 표시: 정수/소수점 자동 구분 + const displayValue = (() => { + if (value === undefined || value === null || value === "") return ""; + const num = typeof value === "number" ? value : parseFloat(value); + if (isNaN(num)) return ""; + // 정수면 소수점 없이, 소수면 소수점 유지 + if (Number.isInteger(num)) { + return num.toString(); + } else { + return num.toString(); + } + })(); + return ( handleCellEdit(rowIndex, column.field, parseFloat(e.target.value) || 0) }