From 9b53c1ae084713b7ce5dc7551bfe702e41a92fc8 Mon Sep 17 00:00:00 2001 From: rsone001 Date: Thu, 27 Aug 2026 13:07:33 +0900 Subject: [PATCH 1/4] =?UTF-8?q?[ST]=20-=20fix:=20=EC=9D=BC=EB=B0=98?= =?UTF-8?q?=EA=B2=80=EC=A6=9D=20=ED=95=AD=EB=AA=A9=20=EA=B4=80=EB=A6=AC,?= =?UTF-8?q?=20=EC=B0=B8=EC=A1=B0=20=EC=A7=80=ED=91=9C(=EC=BB=AC=EB=9F=BC)?= =?UTF-8?q?=20=EC=98=A4=EB=A5=98=20=EB=A1=9C=EC=A7=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../generalVerification/DetailComponent.tsx | 4 +- .../generalVerification/FomulaDialog.tsx | 79 +++++++++++++++---- 2 files changed, 65 insertions(+), 18 deletions(-) diff --git a/apps/st/src/components/statistics/verification/generalVerification/DetailComponent.tsx b/apps/st/src/components/statistics/verification/generalVerification/DetailComponent.tsx index 97953a441..77d051584 100644 --- a/apps/st/src/components/statistics/verification/generalVerification/DetailComponent.tsx +++ b/apps/st/src/components/statistics/verification/generalVerification/DetailComponent.tsx @@ -632,6 +632,7 @@ const DetailComponent = ({ selectedVrfcRow }: DetailComponentProps) => { kornArtopnEqtnCn: string; engArtopnEqtnCn: string; refStatsCd: string | null; + refStatsNm: string | null; }) => { setRuleBlocks((prev) => { const i = prev.findIndex( @@ -650,11 +651,12 @@ const DetailComponent = ({ selectedVrfcRow }: DetailComponentProps) => { kornArtopnEqtnCn: payload.kornArtopnEqtnCn, engArtopnEqtnCn: payload.engArtopnEqtnCn, refStatsCd: payload.refStatsCd, + refStatsNm: payload.refStatsNm, } : { vrfcDtlSn: null, refStatsCd: payload.refStatsCd, - refStatsNm: null, + refStatsNm: payload.refStatsNm, kornArtopnEqtnCn: payload.kornArtopnEqtnCn, engArtopnEqtnCn: payload.engArtopnEqtnCn, cmprOpert: null, diff --git a/apps/st/src/components/statistics/verification/generalVerification/FomulaDialog.tsx b/apps/st/src/components/statistics/verification/generalVerification/FomulaDialog.tsx index 956eb6f7a..1fbe87806 100644 --- a/apps/st/src/components/statistics/verification/generalVerification/FomulaDialog.tsx +++ b/apps/st/src/components/statistics/verification/generalVerification/FomulaDialog.tsx @@ -1,9 +1,12 @@ import { useEffect, useRef, useState } from "react"; +import { useQuery } from "@tanstack/react-query"; + import { useAlertStore } from "@/shared/lib"; -import { CodeSelect } from "@/entities/code"; +import { ENDPOINT } from "@/shared/config"; +import { CodeApi } from "@/entities/code"; import { generalverificationApiService } from "@/entities/statistics/api/general-verification-service"; -import type { SelectedVerifyColumnListResponseData,VerifyColumnListResponseData, VerifyDetailResponseDto } from "@/entities/statistics/model/general-verification-interface"; +import type { SelectedVerifyColumnListResponseData, VerifyColumnListResponseData, VerifyDetailResponseDto } from "@/entities/statistics/model/general-verification-interface"; import { Button, Checkbox, @@ -14,6 +17,11 @@ import { DialogHeader, DialogTitle, Input, + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, Skeleton, Textarea, } from "@common/components"; @@ -21,8 +29,10 @@ import { export interface FomulaDialogConfirmPayload { kornArtopnEqtnCn: string; engArtopnEqtnCn: string; - /** 참조 통계코드 (선택 안 했으면 null) */ + /** 참조 통계코드 (수식에 참조 컬럼이 없으면 null) */ refStatsCd: string | null; + /** 참조 통계명 (수식에 참조 컬럼이 없으면 null) */ + refStatsNm: string | null; } interface FomulaDialogProps { @@ -63,6 +73,11 @@ const FomulaDialog = ({ open, onOpenChange, data, trgtStatsCd, trgtStatsNm, allo const isUserDirectInputMode = allowLikeDirectInput && userDirectInput; const { setMessage: alert } = useAlertStore((state) => state); + const { data: statsItemCodes } = useQuery({ + queryKey: [ENDPOINT.CMS_SERVICE.CODE, "STITEM"], + queryFn: () => CodeApi.getCode("STITEM"), + enabled: open, + }); /** 다이얼로그에서 쓰는 기호 → 제출용 value. 백엔드 규격에 맞게 수정 가능 */ const OPERATOR_SYMBOL_TO_VALUE: Record = { @@ -375,6 +390,7 @@ const FomulaDialog = ({ open, onOpenChange, data, trgtStatsCd, trgtStatsNm, allo const handleChangeRefStatsCd = (next: string) => { if (!open) return; + if (trgtStatsCd && next === trgtStatsCd) return; // 현재 refStatsCdLocal에 해당하는 참조 컬럼이 수식에 포함돼 있으면 변경을 막고 안내만 표시 const currentRefCols = refColList ?? []; @@ -404,6 +420,26 @@ const FomulaDialog = ({ open, onOpenChange, data, trgtStatsCd, trgtStatsNm, allo /** 참조 컬럼: 선택한 참조 통계로 조회한 목록이 있으면 사용, 없으면 getVerifyColumnList 결과 사용 */ const refColList = selectedColumnInfo?.targetColumnInfo?.colList ?? columnInfo?.refColumnInfo?.colList ?? []; + const formulaUsesRefColumn = (): boolean => { + const engSet = new Set(refColList.map((c) => c.engColNm).filter(Boolean)); + if (engSet.size === 0) return false; + return formulaValueSegments.some((seg) => engSet.has(seg)); + }; + + const resolveRefStatsForConfirm = (isEmptyFormula: boolean): { + refStatsCd: string | null; + refStatsNm: string | null; + } => { + if (isEmptyFormula || !formulaUsesRefColumn() || !refStatsCdLocal) { + return { refStatsCd: null, refStatsNm: null }; + } + const refStatsNm = + statsItemCodes?.find((item) => item.lwpoCd === refStatsCdLocal)?.lwpoCdNm + ?? data?.refStatsNm + ?? null; + return { refStatsCd: refStatsCdLocal, refStatsNm }; + }; + const handleOpenChange = (nextOpen: boolean) => { if (!nextOpen) { setFormulaDisplaySegments([]); @@ -528,11 +564,10 @@ const FomulaDialog = ({ open, onOpenChange, data, trgtStatsCd, trgtStatsNm, allo )}