From c72c48e9dc720939d84f0415a29a0c7fe184933a Mon Sep 17 00:00:00 2001 From: rsone001 Date: Wed, 2 Dec 2026 16:51:51 +0900 Subject: [PATCH] =?UTF-8?q?[ST]=20-=20fix:=2012-1,2=20=EC=A0=84=EB=82=A8?= =?UTF-8?q?=EA=B4=91=EC=A3=BC=20=EB=B3=B8=EC=B2=AD=20=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=84=B0=20=EA=B4=80=EB=A0=A8=20=EC=A0=80=EC=9E=A5&=EC=A0=9C?= =?UTF-8?q?=EC=B6=9C=20=EC=A1=B0=EA=B1=B4=20=EB=A1=9C=EC=A7=81=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../input/SewageExcretaRelatedInp.tsx | 132 ++++++++++++++++-- apps/st/src/entities/statistics/index.ts | 2 + .../lib/jeonnam-gwangju-sido-all-toolbar.ts | 17 +++ 3 files changed, 139 insertions(+), 12 deletions(-) diff --git a/apps/st/src/components/statistics/input/SewageExcretaRelatedInp.tsx b/apps/st/src/components/statistics/input/SewageExcretaRelatedInp.tsx index 8a78c884c..e3549dd99 100644 --- a/apps/st/src/components/statistics/input/SewageExcretaRelatedInp.tsx +++ b/apps/st/src/components/statistics/input/SewageExcretaRelatedInp.tsx @@ -42,9 +42,11 @@ import type { import { filterBySelectedAdmdstCd, isGugunOkForToolbar, + isJeonnamGwangjuSggNotApplicableSearch, isJeonnamGwangjuSidoAllSearch, isJeonnamGwangjuSidoAllToolbarException, isSubmitOkForToolbar, + JEONNAM_GWANGJU_HEADQUARTERS_ADMDST_NM, JEONNAM_GWANGJU_SIDO_ALL_SAVE_SUBMIT_MESSAGE, resolveNoApplicableForRequest, toInputSearchRegion, @@ -183,6 +185,47 @@ function isJeonnamGwangjuSidoAllToolbarTab(tabKey: string | null | undefined): b return Boolean(tabKey && ARTICLE_EDIT_TAB_KEYS.has(tabKey)); } +function isJeonnamGwangjuHeadquartersGridRow( + row: Record, +): boolean { + return ( + String(row.admdstNm ?? "").trim() === JEONNAM_GWANGJU_HEADQUARTERS_ADMDST_NM || + String(row.sggNm ?? "").trim() === JEONNAM_GWANGJU_HEADQUARTERS_ADMDST_NM + ); +} + +function hasJeonnamGwangjuHeadquartersGridRows( + rows: readonly Record[], +): boolean { + return rows.some(isJeonnamGwangjuHeadquartersGridRow); +} + +function isOnlyJeonnamGwangjuHeadquartersGridRows( + rows: readonly Record[], +): boolean { + return rows.length > 0 && rows.every(isJeonnamGwangjuHeadquartersGridRow); +} + +function isJeonnamGwangjuSggHeadquartersOnlyNotApplicable( + searchContext: SearchFormValues | null, + rows: readonly Record[], +): boolean { + return ( + isJeonnamGwangjuSggNotApplicableSearch(searchContext) && + isOnlyJeonnamGwangjuHeadquartersGridRows(rows) + ); +} + +function isEmptyForNotApplicable( + searchContext: SearchFormValues | null, + rows: readonly Record[], +): boolean { + return ( + rows.length === 0 || + isJeonnamGwangjuSggHeadquartersOnlyNotApplicable(searchContext, rows) + ); +} + function buildGugunOkForToolbar( values: SearchFormValues | null, tabKey?: string | null, @@ -221,7 +264,9 @@ function buildNoApplicableForRequest( values: SearchFormValues | null, checked: boolean, isSaveListEmpty: boolean, + tabKey?: string | null, ): boolean { + if (buildSubmitOkForToolbar(values, tabKey)) return checked; return resolveNoApplicableForRequest(sidoListRef.current, values, checked, isSaveListEmpty); } @@ -748,11 +793,29 @@ const SewageExcretaRelatedInp = () => { tabKey: string, hasRows: boolean, statusInfo: SewerageStatusInfo | null | undefined, - ): boolean => - NOT_APPLICABLE_TAB_KEYS.has(tabKey) && - hasSearched && - !hasRows && - computeTabEnterable(statusInfo, inputPeriodEnterable); + rows: readonly Record[] = [], + searchContext: SearchFormValues | null = null, + ): boolean => { + if ( + !NOT_APPLICABLE_TAB_KEYS.has(tabKey) || + !hasSearched || + !computeTabEnterable(statusInfo, inputPeriodEnterable) + ) { + return false; + } + if (!hasRows) return true; + if ( + ARTICLE_EDIT_TAB_KEYS.has(tabKey) && + isJeonnamGwangjuSggHeadquartersOnlyNotApplicable(searchContext, rows) + ) { + return true; + } + return ( + ARTICLE_EDIT_TAB_KEYS.has(tabKey) && + isJeonnamGwangjuSidoAllSearch(sidoListRef.current, searchContext) && + !hasJeonnamGwangjuHeadquartersGridRows(rows) + ); + }; const setIsNotApplicableForTab = useCallback((tabKey: string, nextValue: boolean) => { setIsNotApplicableByTab((prev) => { @@ -1330,10 +1393,17 @@ const SewageExcretaRelatedInp = () => { } commitActiveGrid(); - const noApplicable = buildNoApplicableForRequest(searchContextByTab.get(tabKey) ?? lastSearchedValues, isNotApplicableByTab.get(tabKey) ?? false, getTabGridRows(tabKey).length === 0); + const noApplicable = buildNoApplicableForRequest(searchContextByTab.get(tabKey) ?? lastSearchedValues, isNotApplicableByTab.get(tabKey) ?? false, getTabGridRows(tabKey).length === 0, tabKey); const currentData = getTabGridRows(tabKey); if (NOT_APPLICABLE_TAB_KEYS.has(tabKey)) { - if (!noApplicable && currentData.length === 0 && buildSubmitOkForToolbar(searchContextByTab.get(tabKey) ?? lastSearchedValues, tabKey)) { + if ( + !noApplicable && + isEmptyForNotApplicable( + searchContextByTab.get(tabKey) ?? lastSearchedValues, + currentData, + ) && + buildSubmitOkForToolbar(searchContextByTab.get(tabKey) ?? lastSearchedValues, tabKey) + ) { alert("해당사항 없음을 체크해주세요."); return; } @@ -1372,7 +1442,7 @@ const SewageExcretaRelatedInp = () => { const isDistrictRowTab = DISTRICT_ROW_TAB_KEYS.has(tabKey); const isPublicInstitutionTab = ARTICLE_EDIT_TAB_KEYS.has(tabKey); - const noApplicable = buildNoApplicableForRequest(searchContextByTab.get(tabKey) ?? lastSearchedValues, isNotApplicableByTab.get(tabKey) ?? false, getTabGridRows(tabKey).length === 0); + const noApplicable = buildNoApplicableForRequest(searchContextByTab.get(tabKey) ?? lastSearchedValues, isNotApplicableByTab.get(tabKey) ?? false, getTabGridRows(tabKey).length === 0, tabKey); const currentData = getTabGridRows(tabKey); const mapRows = rowDataMap.get(tabKey) ?? []; @@ -1443,7 +1513,15 @@ const SewageExcretaRelatedInp = () => { ) .map((row) => buildPublicInstitutionIndustrySaveItem(row, list)); - if (!noApplicable && submitList.length === 0 && buildSubmitOkForToolbar(searchContextByTab.get(tabKey) ?? lastSearchedValues, tabKey)) { + if ( + !noApplicable && + (submitList.length === 0 || + isJeonnamGwangjuSggHeadquartersOnlyNotApplicable( + searchContextByTab.get(tabKey) ?? lastSearchedValues, + currentData, + )) && + buildSubmitOkForToolbar(searchContextByTab.get(tabKey) ?? lastSearchedValues, tabKey) + ) { alert("해당사항 없음을 체크해주세요."); return; } @@ -1640,7 +1718,8 @@ const SewageExcretaRelatedInp = () => { const isDistrictRowTab = DISTRICT_ROW_TAB_KEYS.has(tabKey); const isPublicInstitutionTab = ARTICLE_EDIT_TAB_KEYS.has(tabKey); - const noApplicable = buildNoApplicableForRequest(searchContextByTab.get(tabKey) ?? lastSearchedValues, isNotApplicableByTab.get(tabKey) ?? false, getTabGridRows(tabKey).length === 0); + const notApplicableChecked = isNotApplicableByTab.get(tabKey) ?? false; + const noApplicable = buildNoApplicableForRequest(searchContextByTab.get(tabKey) ?? lastSearchedValues, notApplicableChecked, getTabGridRows(tabKey).length === 0, tabKey); const currentData = getTabGridRows(tabKey); const mapRows = rowDataMap.get(tabKey) ?? []; @@ -1730,7 +1809,30 @@ const SewageExcretaRelatedInp = () => { ) .map((row) => buildPublicInstitutionIndustrySaveItem(row, list)); - if (!noApplicable && saveList.length === 0 && buildSubmitOkForToolbar(searchContextByTab.get(tabKey) ?? lastSearchedValues, tabKey)) { + if ( + isJeonnamGwangjuSidoAllSearch( + sidoListRef.current, + lastSearchedValues, + ) && + !notApplicableChecked && + !hasJeonnamGwangjuHeadquartersGridRows(currentData) + ) { + alert("본청 데이터 제거 시 해당사항 없음을 체크해주세요."); + return; + } + + if ( + !noApplicable && + (saveList.length === 0 || + isJeonnamGwangjuSggHeadquartersOnlyNotApplicable( + searchContextByTab.get(tabKey) ?? lastSearchedValues, + currentData, + )) && + buildSubmitOkForToolbar( + searchContextByTab.get(tabKey) ?? lastSearchedValues, + tabKey, + ) + ) { alert("해당사항 없음을 체크해주세요."); return; } @@ -2031,7 +2133,13 @@ const SewageExcretaRelatedInp = () => { const showNotApplicableForActiveTab = NOT_APPLICABLE_TAB_KEYS.has(activeTab) && loadedTabKeys.has(activeTab) && - shouldShowNotApplicable(activeTab, activeTabHasRowData, activeTabStatus) && + shouldShowNotApplicable( + activeTab, + activeTabHasRowData, + activeTabStatus, + rowDataMap.get(activeTab) ?? [], + searchContextForToolbar, + ) && submitOk; const showSecondaryToolbarCard = hasSearched && diff --git a/apps/st/src/entities/statistics/index.ts b/apps/st/src/entities/statistics/index.ts index 2f4a8b2b5..b0cb0f7bf 100644 --- a/apps/st/src/entities/statistics/index.ts +++ b/apps/st/src/entities/statistics/index.ts @@ -13,8 +13,10 @@ export { imrApi } from "./api/imr-api"; export { JEONNAM_GWANGJU_HEADQUARTERS_ADMDST_NM, JEONNAM_GWANGJU_SIDO_ALL_SAVE_SUBMIT_MESSAGE, + JEONNAM_GWANGJU_SGG_NOT_APPLICABLE_SEWER_BZMN_CD_SET, JEONNAM_GWANGJU_UNIFIED_SIDO_CD, isJeonnamGwangjuHeadquartersOperableRow, + isJeonnamGwangjuSggNotApplicableSearch, isJeonnamGwangjuSidoAllSearch, isJeonnamGwangjuSidoAllToolbarException, isSewerageFinanceStatsCd, diff --git a/apps/st/src/entities/statistics/lib/jeonnam-gwangju-sido-all-toolbar.ts b/apps/st/src/entities/statistics/lib/jeonnam-gwangju-sido-all-toolbar.ts index b44ba0428..a040427c6 100644 --- a/apps/st/src/entities/statistics/lib/jeonnam-gwangju-sido-all-toolbar.ts +++ b/apps/st/src/entities/statistics/lib/jeonnam-gwangju-sido-all-toolbar.ts @@ -7,6 +7,23 @@ export const JEONNAM_GWANGJU_UNIFIED_SIDO_CD = "1200000000"; export const JEONNAM_GWANGJU_HEADQUARTERS_ADMDST_NM = "본청"; +/** 12-1·12-2 — 본청만 남아도 해당사항 없음 조건을 적용하는 전남광주 시군구 */ +export const JEONNAM_GWANGJU_SGG_NOT_APPLICABLE_SEWER_BZMN_CD_SET = new Set([ + "1221000000", + "1224000000", + "1227000000", + "1230000000", + "1233000000", +]); + +export function isJeonnamGwangjuSggNotApplicableSearch( + values: SidoGugunLookup | null | undefined, +): boolean { + return JEONNAM_GWANGJU_SGG_NOT_APPLICABLE_SEWER_BZMN_CD_SET.has( + (values?.bsnmCd ?? "").trim(), + ); +} + /** 입력 9-1 ~ 9-4 */ export const SEWERAGE_FINANCE_STATS_CD_SET = new Set([ "ST00090001",