diff --git a/apps/st/src/components/button/SumitButton.tsx b/apps/st/src/components/button/SumitButton.tsx index 0c0875ed2..5b0a5bc05 100644 --- a/apps/st/src/components/button/SumitButton.tsx +++ b/apps/st/src/components/button/SumitButton.tsx @@ -4,11 +4,16 @@ interface SubmitButtonProps { submitFunc: () => void; /** 버튼 문구 (기본: 제출) */ text?: string; + disabled?: boolean; } -const SubmitButton = ({ submitFunc, text = "제출" }: SubmitButtonProps) => { +const SubmitButton = ({ submitFunc, text = "제출", disabled = false }: SubmitButtonProps) => { return ( - diff --git a/apps/st/src/components/module/DataGrid.tsx b/apps/st/src/components/module/DataGrid.tsx index 7516fa3d5..b576c8cf6 100644 --- a/apps/st/src/components/module/DataGrid.tsx +++ b/apps/st/src/components/module/DataGrid.tsx @@ -253,7 +253,12 @@ declare module "realgrid" { setOptions(options: { footer?: { visible?: boolean }; summaryMode?: "aggregate" | "statistical" | "none"; - checkBar?: { visible?: boolean; exclusive?: boolean; syncHeadCheck?: boolean }; + checkBar?: { + visible?: boolean; + exclusive?: boolean; + syncHeadCheck?: boolean; + checkableOnly?: boolean; + }; }): void; } } @@ -432,6 +437,7 @@ type GridViewWithCheckApi = { checkEvent?: boolean, ) => void; setAllCheck?: (checked: boolean) => void; + setCheckable?: (itemIndex: number, checkable: boolean) => void; }; function isRowCheckedFlag(value: unknown): boolean { @@ -847,6 +853,7 @@ const DataGrid = ({ isExcelExport = true, fixedColumns, showHeaderCheckbox = false, + checkableCallback, rowData, setRowData, getGridDataRef, @@ -902,6 +909,7 @@ const DataGrid = ({ const onItemCheckedRef = useRef(onItemChecked); const onItemAllCheckedRef = useRef(onItemAllChecked); + const checkableCallbackRef = useRef(checkableCallback); const isSyncingChecksFromRowDataRef = useRef(false); const columnsFieldsSigRef = useRef(""); const emptyCellHoverKeyRef = useRef(""); @@ -923,6 +931,7 @@ const DataGrid = ({ onScrollToBottomRef.current = onScrollToBottom; onItemCheckedRef.current = onItemChecked; onItemAllCheckedRef.current = onItemAllChecked; + checkableCallbackRef.current = checkableCallback; onCellEditedRef.current = onCellEdited; onDataCellClickRef.current = onDataCellClick; @@ -1608,7 +1617,12 @@ useEffect(() => { // 헤더 체크박스 표시 여부 설정 gridView.setOptions({ - checkBar: { visible: showHeaderCheckbox, exclusive: false, syncHeadCheck: true }, + checkBar: { + visible: showHeaderCheckbox, + exclusive: false, + syncHeadCheck: true, + checkableOnly: true, + }, rowIndicator: { visible: false }, }); @@ -2272,6 +2286,17 @@ useEffect(() => { if (onItemChecked) { gridView.onItemChecked = (_grid, itemIndex, checked) => { if (isSyncingChecksFromRowDataRef.current) return; + const row = rowDataRef.current[itemIndex]; + if ( + row && + checkableCallbackRef.current && + !checkableCallbackRef.current(row, itemIndex) + ) { + if (checked) { + (_grid as GridViewWithCheckApi).checkItem?.(itemIndex, false, false); + } + return; + } onItemCheckedRef.current?.(itemIndex, checked); }; } else { @@ -2307,7 +2332,15 @@ useEffect(() => { gridView.checkAll?.(false, false, false, false); gridView.setAllCheck?.(false); rowData.forEach((row, itemIndex) => { - if (!isRowCheckedFlag((row as Record).__checked)) return; + const checkable = + checkableCallbackRef.current?.(row, itemIndex) ?? true; + gridView.setCheckable?.(itemIndex, checkable); + if ( + !checkable || + !isRowCheckedFlag((row as Record).__checked) + ) { + return; + } if (gridView.checkItem) { gridView.checkItem(itemIndex, true, false); return; diff --git a/apps/st/src/components/module/VerificationResultDialog.tsx b/apps/st/src/components/module/VerificationResultDialog.tsx index 60913eac0..dc99d8245 100644 --- a/apps/st/src/components/module/VerificationResultDialog.tsx +++ b/apps/st/src/components/module/VerificationResultDialog.tsx @@ -14,6 +14,10 @@ import { import type { RealGridReact } from "realgrid-react"; import { useAlertStore } from "@/shared/lib"; +import { + isJeonnamGwangjuHeadquartersOperableRow, + shouldRestrictFinanceVerificationToHeadquarters, +} from "@/entities/statistics"; import { statisticsApi } from "@/entities/statistics/api/statistics-service"; import type { VerificationResultListRequest, VerificationResultReportItem } from "@/entities/statistics/model/statistics-interface"; import { @@ -91,6 +95,14 @@ function verificationMthdCellStyle({ return undefined; } +function isResultRowOperable( + restrictHeadquarters: boolean, + row: { sewerBzmnCd?: string | number | null; admdstNm?: string | number | null }, +): boolean { + if (!restrictHeadquarters) return true; + return isJeonnamGwangjuHeadquartersOperableRow(row); +} + /** History와 동일 + 구분(검증유형) + 편집 가능한 처리의견(예외사유) */ const verificationSubmitResultColumnInfo: ColumnInfo = { columns: [ @@ -171,6 +183,12 @@ export function VerificationResultDialog({ const [loading, setLoading] = useState(false); const [errorMessage, setErrorMessage] = useState(null); + const restrictHeadquarters = shouldRestrictFinanceVerificationToHeadquarters( + stableQueryContext?.statsCd, + stableQueryContext?.sewerBzmnCd, + stableQueryContext?.sggNm, + ); + const [rows, setRows] = useState([]); const [checkedIndices, setCheckedIndices] = useState>(() => new Set()); @@ -180,6 +198,11 @@ export function VerificationResultDialog({ const onPrcsOpnnExplnEdited = useCallback((params: CellEditedCallbackParams) => { if (params.fieldName !== "prcsOpnnExpln") return; + const row = rows[params.itemIndex]; + if (row && !isResultRowOperable(restrictHeadquarters, row)) { + setRowCheckByItemIndex(gridRef, params.itemIndex, false); + return; + } const text = String(params.newValue ?? ""); const hasValue = text.trim().length > 0; setRowCheckByItemIndex(gridRef, params.itemIndex, hasValue); @@ -189,7 +212,7 @@ export function VerificationResultDialog({ else next.delete(params.itemIndex); return next; }); - }, []); + }, [restrictHeadquarters, rows]); const resetState = useCallback(() => { setPageIndex(0); @@ -206,6 +229,7 @@ export function VerificationResultDialog({ vrfcSn: item.vrfcSn, vrfcMthdCd, vrfcMthdNm: VRFC_MTHD_NAME_MAP[vrfcMthdCd] ?? item.vrfcMthdNm, + sewerBzmnCd: item.sewerBzmnCd ?? "", ctpvNm: item.ctpvNm, admdstNm: item.admdstNm ?? item.sggNm ?? "-", fcltNm: item.fcltNm ?? "-", @@ -307,6 +331,11 @@ export function VerificationResultDialog({ setCheckedIndices((prev) => { const next = new Set(prev); rows.forEach((row, itemIndex) => { + if (!isResultRowOperable(restrictHeadquarters, row)) { + setRowCheckByItemIndex(gridRef, itemIndex, false); + next.delete(itemIndex); + return; + } const has = String(row.prcsOpnnExpln ?? "").trim().length > 0; setRowCheckByItemIndex(gridRef, itemIndex, has); if (has) next.add(itemIndex); @@ -315,7 +344,7 @@ export function VerificationResultDialog({ }); }); return () => cancelAnimationFrame(id); - }, [rows, loading]); + }, [rows, loading, restrictHeadquarters]); const handleExceptionSubmitClick = useCallback(async () => { if (checkedIndices.size === 0) { @@ -326,6 +355,11 @@ export function VerificationResultDialog({ const gridRows = getGridDataRef.current?.() ?? []; const payload: VerificationExceptionSubmitItem[] = []; for (const idx of checkedIndices) { + const row = rows[idx] ?? gridRows[idx]; + if (row && !isResultRowOperable(restrictHeadquarters, row)) { + alert("전남광주통합특별시는 본청 데이터만 조작할 수 있습니다."); + return; + } const prcsOpnnExpln = String(gridRows[idx]?.prcsOpnnExpln ?? "").trim(); if (!prcsOpnnExpln) { alert("예외 제출 사유를 작성해주세요."); @@ -373,6 +407,7 @@ export function VerificationResultDialog({ rows, onExceptionSubmitted, onOpenChange, + restrictHeadquarters, stableQueryContext, ]); @@ -419,9 +454,30 @@ export function VerificationResultDialog({ getGridRef={gridRef} getGridDataRef={getGridDataRef} onCellEdited={onPrcsOpnnExplnEdited} - cellStyleCallback={verificationMthdCellStyle} + cellStyleCallback={(params) => { + const mthdStyle = verificationMthdCellStyle(params); + if (!isResultRowOperable(restrictHeadquarters, params.row)) { + const mthdName = + typeof mthdStyle === "string" ? mthdStyle : undefined; + return { + styleName: ["rg-cell-readonly", mthdName] + .filter(Boolean) + .join(" "), + editable: false, + readOnly: true, + }; + } + return mthdStyle; + }} + checkableCallback={(row) => + isResultRowOperable(restrictHeadquarters, row) + } cellTooltipCallback={cellContentTooltip} onItemChecked={(itemIndex, checked) => { + const row = rows[itemIndex]; + if (checked && row && !isResultRowOperable(restrictHeadquarters, row)) { + return; + } setCheckedIndices((prev) => { const next = new Set(prev); if (checked) next.add(itemIndex); @@ -431,7 +487,15 @@ export function VerificationResultDialog({ }} onItemAllChecked={(checked) => { setCheckedIndices( - checked ? new Set(rows.map((_, i) => i)) : new Set(), + checked + ? new Set( + rows.flatMap((row, i) => + isResultRowOperable(restrictHeadquarters, row) + ? [i] + : [], + ), + ) + : new Set(), ); }} /> diff --git a/apps/st/src/components/module/VerificationResultHistoryDialog.tsx b/apps/st/src/components/module/VerificationResultHistoryDialog.tsx index cd0ea4490..84b89fccf 100644 --- a/apps/st/src/components/module/VerificationResultHistoryDialog.tsx +++ b/apps/st/src/components/module/VerificationResultHistoryDialog.tsx @@ -14,6 +14,10 @@ import { import type { RealGridReact } from "realgrid-react"; import { useAlertStore } from "@/shared/lib"; +import { + isJeonnamGwangjuHeadquartersOperableRow, + shouldRestrictFinanceVerificationToHeadquarters, +} from "@/entities/statistics"; import { statisticsApi } from "@/entities/statistics/api/statistics-service"; import type { VerificationResultListRequest, VerificationResultReportItem } from "@/entities/statistics/model/statistics-interface"; import { @@ -137,6 +141,14 @@ function verificationPrcsYnNmCellStyle({ fieldName, row }: CellStyleCallbackPara return "rg-cell-vrf-prcs-ok"; } +function isHistoryRowOperable( + restrictHeadquarters: boolean, + row: { sewerBzmnCd?: string | number | null; admdstNm?: string | number | null }, +): boolean { + if (!restrictHeadquarters) return true; + return isJeonnamGwangjuHeadquartersOperableRow(row); +} + const verificationResultColumnInfo: ColumnInfo = { columns: [ { name: "ctpvNm", fieldName: "ctpvNm", header: { text: "시도" }, editable: false }, @@ -227,6 +239,12 @@ export function VerificationResultHistoryDialog({ const [resetSubmitting, setResetSubmitting] = useState(false); const [checkedVrfcByTab, setCheckedVrfcByTab] = useState(createEmptyCheckedVrfcByTab); + const restrictHeadquarters = shouldRestrictFinanceVerificationToHeadquarters( + stableQueryContext?.statsCd, + stableQueryContext?.sewerBzmnCd, + stableQueryContext?.sggNm, + ); + const nvGridRef = useRef(null); const imrGridRef = useRef(null); const hbGridRef = useRef(null); @@ -375,10 +393,12 @@ export function VerificationResultHistoryDialog({ (entries: VerificationResultReportItem[], checkedMap: Map): VerificationResultGridRow[] => entries.map((item) => { const vrfcSn = Number(item.vrfcSn); - const isChecked = Number.isFinite(vrfcSn) && checkedMap.has(vrfcSn); + const operable = isHistoryRowOperable(restrictHeadquarters, item); + const isChecked = operable && Number.isFinite(vrfcSn) && checkedMap.has(vrfcSn); return { vrfcSn: item.vrfcSn, __checked: isChecked ? 1 : 0, + sewerBzmnCd: item.sewerBzmnCd ?? "", ctpvNm: item.ctpvNm ?? "-", admdstNm: item.admdstNm ?? item.sggNm ?? "-", fcltNm: item.fcltNm ?? "-", @@ -395,7 +415,7 @@ export function VerificationResultHistoryDialog({ mdfcnDt: (item.mdfcnDt ?? "").slice(0, 16), }; }), - [], + [restrictHeadquarters], ); /** 페이지(entries) 변경 시에만 __checked 반영 — 클릭마다 rowData를 바꾸지 않아 체크 UI가 안정적 */ @@ -432,6 +452,13 @@ export function VerificationResultHistoryDialog({ return; } setCheckedVrfcByTab((prev) => ({ ...prev, [tab]: syncedMap })); + for (const vrfcSn of syncedMap.keys()) { + const onPage = currentEntries.find((e) => Number(e.vrfcSn) === vrfcSn); + if (onPage && !isHistoryRowOperable(restrictHeadquarters, onPage)) { + alert("전남광주통합특별시는 본청 데이터만 조작할 수 있습니다."); + return; + } + } const vrfcSnList = Array.from(syncedMap.keys()); let mdfrUuid: string; try { @@ -477,6 +504,7 @@ export function VerificationResultHistoryDialog({ entriesByTab, loadTabPage, onExceptionResetSubmitted, + restrictHeadquarters, stableQueryContext, tabPages, ]); @@ -487,6 +515,18 @@ export function VerificationResultHistoryDialog({ const { pageIndex, pageCount } = tabPages[tab]; const loading = loadingByTab[tab]; const gridRef = gridRefByTab[tab]; + const historyCellStyle = (params: CellStyleCallbackParams) => { + const statusStyle = verificationPrcsYnNmCellStyle(params); + if (!isHistoryRowOperable(restrictHeadquarters, params.row)) { + const statusName = typeof statusStyle === "string" ? statusStyle : undefined; + return { + styleName: ["rg-cell-readonly", statusName].filter(Boolean).join(" "), + editable: false, + readOnly: true, + }; + } + return statusStyle; + }; if (!loading && rows.length === 0) { return

{emptyMessage}

; @@ -504,13 +544,18 @@ export function VerificationResultHistoryDialog({ showHeaderCheckbox enableSort={false} getGridRef={gridRef} - cellStyleCallback={verificationPrcsYnNmCellStyle} + cellStyleCallback={historyCellStyle} + checkableCallback={(row) => isHistoryRowOperable(restrictHeadquarters, row)} cellTooltipCallback={cellContentTooltip} onItemChecked={(itemIndex, checked) => { const entry = entries[itemIndex]; if (!entry) return; const vrfcSn = Number(entry.vrfcSn); if (!Number.isFinite(vrfcSn)) return; + if (checked && !isHistoryRowOperable(restrictHeadquarters, entry)) { + uncheckGridRow(gridRef, itemIndex); + return; + } if (checked && !canExceptionReset(entry.vrfcSttsCd)) { alert(EXCEPTION_RESET_ONLY_PRCS_YN_2_MESSAGE); uncheckGridRow(gridRef, itemIndex); @@ -530,6 +575,10 @@ export function VerificationResultHistoryDialog({ map.delete(vrfcSn); return; } + if (!isHistoryRowOperable(restrictHeadquarters, entry)) { + uncheckGridRow(gridRef, itemIndex); + return; + } if (canExceptionReset(entry.vrfcSttsCd)) { map.set(vrfcSn, String(entry.vrfcSttsCd ?? "")); } else { diff --git a/apps/st/src/components/statistics/input/SewageExcretaRelatedInp.tsx b/apps/st/src/components/statistics/input/SewageExcretaRelatedInp.tsx index dab2b251c..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; } @@ -2021,10 +2123,23 @@ const SewageExcretaRelatedInp = () => { ARTICLE_EDIT_TAB_KEYS.has(activeTab) && showEnterableToolbarButtons; const gugunOk = buildGugunOkForToolbar(searchContextForToolbar, activeTab); const submitOk = buildSubmitOkForToolbar(searchContextForToolbar, activeTab); + const disableSubmit = + isJeonnamGwangjuSidoAllToolbarTab(activeTab) && + isJeonnamGwangjuSidoAllToolbarException( + sidoListRef.current, + searchContextForToolbar, + relatedToolbarUserIdRef.current, + ); 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 && @@ -2092,7 +2207,9 @@ const SewageExcretaRelatedInp = () => { void lastYearDataFunc()} /> - {submitOk && } + {submitOk && ( + + )} )} {activeTabStatus?.lclgvSbmsnSttsCd === "2" && submitOk && inputPeriodEnterable && ( diff --git a/apps/st/src/components/statistics/input/SewagePipeInp.tsx b/apps/st/src/components/statistics/input/SewagePipeInp.tsx index b7cf15409..8bb498347 100644 --- a/apps/st/src/components/statistics/input/SewagePipeInp.tsx +++ b/apps/st/src/components/statistics/input/SewagePipeInp.tsx @@ -71,7 +71,10 @@ import type { SearchFormValues } from "@/components/type/SearchForm.type"; import { FactInstallStatusInpColumn } from "@/components/util/column/input/sewagePipe/FactInstallStatusInpColumn"; import { ManholeStatusInpColumn } from "@/components/util/column/input/sewagePipe/ManholeStatusInpColumn"; import { PipeDiameterStatusInpColumn } from "@/components/util/column/input/sewagePipe/PipeDiameterStatusInpColumn"; -import { PipeTypeStatusInpColumn } from "@/components/util/column/input/sewagePipe/PipeTypeStatusInpColumn"; +import { + getPipeTypeStatusInpColumn, + resolvePipeTypeColumnEndYear, +} from "@/components/util/column/input/sewagePipe/PipeTypeStatusInpColumn"; import { RegionalFactStatusInpColumn } from "@/components/util/column/input/sewagePipe/RegionalFactStatusInpColumn"; import { SewagePipeInpColumnInfoList } from "@/components/util/column/input/sewagePipe/SewagePipeInpColumn"; import { fetchColumnGuidesRecord } from "@/components/util/grid/columnGuides"; @@ -119,11 +122,6 @@ function buildSewagePipeSearchParam( }; } -const getPipeTypeLastDataYear = () => { - const lastDataYear = new Date().getFullYear() - 1; - return Math.max(1995, lastDataYear); -}; - const PIPE_TYPE_STATUS_TAB_KEY = "ST00020003"; /** 조회 연도(statsYr)에 해당하는 연도 (y{year}* 필드용) */ @@ -131,7 +129,7 @@ const resolvePipeTypeEditableYear = (statsYr: string | null | undefined): number if (!statsYr) return null; const year = Number(statsYr); if (!Number.isFinite(year)) return null; - return Math.min(getPipeTypeLastDataYear(), Math.max(1995, year)); + return Math.min(resolvePipeTypeColumnEndYear(statsYr), Math.max(1995, year)); }; /** 조회 연도(statsYr)에 해당하는 연도별 매설연장 필드명 (y{year}LyngPrlg) */ @@ -257,8 +255,9 @@ function getSewagePipeRowVerificationErrors( function normalizePipeTypeStatusRow( row: SeweragePipeInputPipeTypeStatusItem, ctpvNm: string, + statsYr?: string | number | null, ): Record { - const lastDataYear = getPipeTypeLastDataYear(); + const lastDataYear = resolvePipeTypeColumnEndYear(statsYr); const { yearlyStatList, lyngPrlgWhol, @@ -276,8 +275,8 @@ function normalizePipeTypeStatusRow( for (const y of yearlyStatList ?? []) { const year = Number(y.lyngYr); - if (!Number.isFinite(year)) continue; - const targetYear = Math.min(lastDataYear, Math.max(1995, year)); + if (!Number.isFinite(year) || year > lastDataYear) continue; + const targetYear = Math.max(1995, year); yearFields[`y${targetYear}PrlgWhol`] = (yearFields[`y${targetYear}PrlgWhol`] ?? 0) + Number(y.pipeWholPrlg ?? 0); yearFields[`y${targetYear}LyngPrlg`] = @@ -614,10 +613,14 @@ const SewagePipeInp = () => { }; }); return SewagePipeInpColumnInfoList.map((tab: ColumnInfoList) => { - const canEdit = - (computeTabEnterable(tabStatusInfoMap.get(tab.tabKey) ?? null, inputPeriodEnterable) || isAdminInfo) && inputPeriodEnterable; - const applyEditable = (cols: ColumnConfig[] | undefined) => + const sourceTab = tab.tabKey === PIPE_TYPE_STATUS_TAB_KEY + ? getPipeTypeStatusInpColumn(lastSearchedYear) + : tab; + const canEdit = + (computeTabEnterable(tabStatusInfoMap.get(sourceTab.tabKey) ?? null, inputPeriodEnterable) || isAdminInfo) && inputPeriodEnterable; + const applyEditable = (cols: ColumnConfig[] | undefined) => + sourceTab.tabKey === PIPE_TYPE_STATUS_TAB_KEY ? applyPipeTypeStatusEditableColumns( cols, canEdit, @@ -635,20 +638,20 @@ const SewagePipeInp = () => { }, ); - if (tab.left && tab.right) { + if (sourceTab.left && sourceTab.right) { return { - ...tab, - left: { ...tab.left, columns: applyColumnGuides(applyEditable(tab.left.columns), tab.tabKey) }, - right: { ...tab.right, columns: applyColumnGuides(applyEditable(tab.right.columns), tab.tabKey) }, + ...sourceTab, + left: { ...sourceTab.left, columns: applyColumnGuides(applyEditable(sourceTab.left.columns), sourceTab.tabKey) }, + right: { ...sourceTab.right, columns: applyColumnGuides(applyEditable(sourceTab.right.columns), sourceTab.tabKey) }, }; } return { - ...tab, - columns: applyColumnGuides(applyEditable(tab.columns), tab.tabKey), - ...(tab.tabKey === PIPE_TYPE_STATUS_TAB_KEY && tab.columnLayout + ...sourceTab, + columns: applyColumnGuides(applyEditable(sourceTab.columns), sourceTab.tabKey), + ...(sourceTab.tabKey === PIPE_TYPE_STATUS_TAB_KEY && sourceTab.columnLayout ? { columnLayout: applyPipeTypeStatusColumnLayout( - tab.columnLayout, + sourceTab.columnLayout, shouldHidePipeTypeEditableYearDmltn( canEdit, inputPeriodEnterable, @@ -807,7 +810,11 @@ const SewagePipeInp = () => { if (response.status === 'success') { const commonInfo = response.data.commonInfo; const convertedData = filterFetched(response.data.pipeTypeStatusList).map((d) => - normalizePipeTypeStatusRow(d, commonInfo.ctpvNm), + normalizePipeTypeStatusRow( + d, + commonInfo.ctpvNm, + searchParam.statsYr ?? values.year, + ), ); applyRowMap((m) => m.set('ST00020003', toGridRows(convertedData))); setTabStatusInfoMap((prev) => new Map(prev).set(tabKey, response.data.statusInfo)); @@ -1320,7 +1327,7 @@ const SewagePipeInp = () => { return; } const columnFormatMap = new Map(); - PipeTypeStatusInpColumn.columns.forEach((col) => { + getPipeTypeStatusInpColumn(values.year).columns.forEach((col) => { if (col.fieldName && col.dataFormat) columnFormatMap.set(col.fieldName, col.dataFormat); }); const formatNumber = (value: string | number | null | undefined, fieldName: string): number => { @@ -1332,7 +1339,7 @@ const SewagePipeInp = () => { const decimalPlaces = format.match(/\.(\d+)/)?.[1]?.length ?? 0; return decimalPlaces > 0 ? parseFloat(num.toFixed(decimalPlaces)) : Math.round(num); }; - const lastDataYear = getPipeTypeLastDataYear(); + const lastDataYear = resolvePipeTypeColumnEndYear(values.year); const submitList = currentData.map((d) => { const yearlyStatList = []; for (let year = 1995; year <= lastDataYear; year++) { @@ -1803,7 +1810,7 @@ const SewagePipeInp = () => { } const columnFormatMap = new Map(); - PipeTypeStatusInpColumn.columns.forEach((col) => { + getPipeTypeStatusInpColumn(values.year).columns.forEach((col) => { if (col.fieldName && col.dataFormat) { columnFormatMap.set(col.fieldName, col.dataFormat); } @@ -1819,7 +1826,7 @@ const SewagePipeInp = () => { return decimalPlaces > 0 ? parseFloat(num.toFixed(decimalPlaces)) : Math.round(num); }; - const lastDataYear = getPipeTypeLastDataYear(); + const lastDataYear = resolvePipeTypeColumnEndYear(values.year); const saveList = currentData.map((d) => { const yearlyStatList = []; @@ -2193,7 +2200,11 @@ const SewagePipeInp = () => { return ( { const { showSaveInToolbar, showEnterableToolbarButtons, showActionToolbarCard } = activeTabToolbar; const submitOk = buildSubmitOkForToolbar(searchContextForToolbar); + const disableSubmit = isJeonnamGwangjuSidoAllToolbarException( + sidoListRef.current, + searchContextForToolbar, + financeToolbarUserIdRef.current, + ); const verificationCellStyle = ({ fieldName, @@ -1303,7 +1308,9 @@ const SewerageFinanceInp = () => { void lastYearDataFunc()} /> - {submitOk && } + {submitOk && ( + + )} )} {activeTabStatus?.lclgvSbmsnSttsCd === "2" && submitOk && inputPeriodEnterable && ( diff --git a/apps/st/src/components/util/column/input/sewagePipe/PipeTypeStatusInpColumn.ts b/apps/st/src/components/util/column/input/sewagePipe/PipeTypeStatusInpColumn.ts index fb09bbf19..91d6fff82 100644 --- a/apps/st/src/components/util/column/input/sewagePipe/PipeTypeStatusInpColumn.ts +++ b/apps/st/src/components/util/column/input/sewagePipe/PipeTypeStatusInpColumn.ts @@ -1,19 +1,26 @@ import { ValueType } from "realgrid"; -import type { ColumnConfig, ColumnLayoutItem } from "@/components/type/DataGrid.type"; +import type { ColumnConfig, ColumnInfoList, ColumnLayoutItem } from "@/components/type/DataGrid.type"; import { footerDecimal2 } from "@/components/util/grid/footerSummary"; // 하수도 통계 관리 > 02.하수관로 > tab 3. 관종별 현황 // SeweragePipeInputPipeTypeStatusItem + commonInfo.ctpvNm (그리드 행에 병합) // // 연도 그룹: y1995 = 1996년 이전, y1996 = 1996년 … -// 표시 구간: 1996년 ~ (현재 연도 − 1) 까지. +// 표시 구간: 1996년 ~ 조회 연도(statsYr) 까지. -/** 이 모듈이 로드될 때의 “데이터 기준 마지막 연도” (현재 연도 − 1) */ -const lastDataYear = new Date().getFullYear() - 1; const firstGroupedYear = 1995; const firstVisibleYear = 1996; +/** 조회 연도까지 연도 컬럼을 그림. 조회 전이면 현재 연도 − 1. */ +export function resolvePipeTypeColumnEndYear(statsYr?: string | number | null): number { + const parsed = Number(statsYr); + if (Number.isFinite(parsed) && parsed > 0) { + return Math.max(firstGroupedYear, Math.floor(parsed)); + } + return Math.max(firstGroupedYear, new Date().getFullYear() - 1); +} + const yearField = (year: number, suffix: "PrlgWhol" | "LyngPrlg" | "DmltnPrlg") => `y${year}${suffix}`; @@ -61,17 +68,25 @@ const yearCols = ( ]; }; -const visibleYears = - lastDataYear < firstVisibleYear - ? [] - : Array.from( - { length: lastDataYear - firstVisibleYear + 1 }, - (_, i) => firstVisibleYear + i, - ); +function buildVisibleYears(lastDataYear: number): number[] { + if (lastDataYear < firstVisibleYear) return []; + return Array.from( + { length: lastDataYear - firstVisibleYear + 1 }, + (_, i) => firstVisibleYear + i, + ); +} -const yearLayoutItems: ColumnLayoutItem[] = []; -for (const y of visibleYears) { - yearLayoutItems.push({ +export type PipeTypeStatusInpColumnConfig = ColumnInfoList & { + columns: ColumnConfig[]; + columnLayout: ColumnLayoutItem[]; +}; + +export function getPipeTypeStatusInpColumn( + statsYr?: string | number | null, +): PipeTypeStatusInpColumnConfig { + const lastDataYear = resolvePipeTypeColumnEndYear(statsYr); + const visibleYears = buildVisibleYears(lastDataYear); + const yearLayoutItems: ColumnLayoutItem[] = visibleYears.map((y) => ({ name: `year${y}`, hideChildHeaders: false, header: { text: `${y}년` }, @@ -80,145 +95,147 @@ for (const y of visibleYears) { yearField(y, "LyngPrlg"), yearField(y, "DmltnPrlg"), ], - }); + })); + + return { + columns: [ + { + name: "ctpvNm", + fieldName: "ctpvNm", + header: { text: "시도" }, + footer: { text: "합계" }, + editable: false, + styleName: "rg-cell-readonly", + }, + { + name: "sggNm", + fieldName: "sggNm", + header: { text: "시군구" }, + editable: false, + styleName: "rg-cell-readonly", + }, + { + name: "pipeSeNm", + fieldName: "pipeSeNm", + header: { text: "관종" }, + footer: { text: "합계" }, + editable: false, + styleName: "rg-cell-readonly", + }, + { + name: "admdstNm", + fieldName: "admdstNm", + header: { text: "행정구역명" }, + editable: false, + styleName: "rg-cell-readonly", + }, + { + name: "pipeByPrstWhol", + fieldName: "pipeByPrstWhol", + header: { text: "계" }, + styleName: "rg-cell-total", + footer: footerDecimal2, + editable: false, + valueType: ValueType.NUMBER, + dataFormat: "#,##0.00", + computed: { + minuendFields: [ + yearField(firstGroupedYear, "LyngPrlg"), + ...visibleYears.map((year) => yearField(year, "LyngPrlg")), + ], + subtrahendFields: [ + yearField(firstGroupedYear, "DmltnPrlg"), + ...visibleYears.map((year) => yearField(year, "DmltnPrlg")), + ], + type: "differenceOfSums" as const, + }, + }, + { + name: "lyngPrlg", + fieldName: "lyngPrlg", + header: { text: "매설연장(m)" }, + styleName: "rg-cell-total", + footer: footerDecimal2, + editable: false, + valueType: ValueType.NUMBER, + dataFormat: "#,##0.00", + }, + { + name: "dmltnPrlg", + fieldName: "dmltnPrlg", + header: { text: "철거연장(m)" }, + styleName: "rg-cell-total", + footer: footerDecimal2, + editable: false, + valueType: ValueType.NUMBER, + dataFormat: "#,##0.00", + computed: { + fields: [ + yearField(firstGroupedYear, "DmltnPrlg"), + ...visibleYears.map((year) => yearField(year, "DmltnPrlg")), + ], + type: "sum" as const, + }, + }, + ...yearCols(firstGroupedYear, { footer: footerDecimal2 }), + ...visibleYears.map((year) => + yearCols(year, { + footer: footerDecimal2, + }), + ).flat(), + { name: "rmrk", fieldName: "rmrk", header: { text: "비고" } }, + { + name: "admdstCd", + fieldName: "admdstCd", + header: { text: "행정구역코드" }, + visible: false, + editable: false, + styleName: "rg-cell-readonly", + }, + { + name: "pipeSeCd", + fieldName: "pipeSeCd", + header: { text: "관종코드" }, + visible: false, + editable: false, + styleName: "rg-cell-readonly", + }, + ] as ColumnConfig[], + columnLayout: [ + { + name: "adminArea", + hideChildHeaders: false, + header: { text: "행정구역" }, + items: [{ column: "ctpvNm", footerUserSpans: [{ colspan: 2 }] }, "sggNm"], + }, + "pipeSeNm", + "admdstNm", + { + name: "totalGroup", + hideChildHeaders: false, + header: { text: "총계" }, + items: ["pipeByPrstWhol", "lyngPrlg", "dmltnPrlg"], + }, + { + name: "year1996Before", + hideChildHeaders: false, + header: { text: "1996년 이전" }, + items: [ + yearField(firstGroupedYear, "PrlgWhol"), + yearField(firstGroupedYear, "LyngPrlg"), + yearField(firstGroupedYear, "DmltnPrlg"), + ], + }, + ...yearLayoutItems, + "rmrk", + "admdstCd", + "pipeSeCd", + ] as ColumnLayoutItem[], + rowStartNum: 2, + fixedColumns: 2, + tabKey: "ST00020003", + tabLabel: "관종별 현황", + }; } -export const PipeTypeStatusInpColumn = { - columns: [ - { - name: "ctpvNm", - fieldName: "ctpvNm", - header: { text: "시도" }, - footer: { text: "합계" }, - editable: false, - styleName: "rg-cell-readonly", - }, - { - name: "sggNm", - fieldName: "sggNm", - header: { text: "시군구" }, - editable: false, - styleName: "rg-cell-readonly", - }, - { - name: "pipeSeNm", - fieldName: "pipeSeNm", - header: { text: "관종" }, - footer: { text: "합계" }, - editable: false, - styleName: "rg-cell-readonly", - }, - { - name: "admdstNm", - fieldName: "admdstNm", - header: { text: "행정구역명" }, - editable: false, - styleName: "rg-cell-readonly", - }, - { - name: "pipeByPrstWhol", - fieldName: "pipeByPrstWhol", - header: { text: "계" }, - styleName: "rg-cell-total", - footer: footerDecimal2, - editable: false, - valueType: ValueType.NUMBER, - dataFormat: "#,##0.00", - computed: { - minuendFields: [ - yearField(firstGroupedYear, "LyngPrlg"), - ...visibleYears.map((year) => yearField(year, "LyngPrlg")), - ], - subtrahendFields: [ - yearField(firstGroupedYear, "DmltnPrlg"), - ...visibleYears.map((year) => yearField(year, "DmltnPrlg")), - ], - type: "differenceOfSums" as const, - }, - }, - { - name: "lyngPrlg", - fieldName: "lyngPrlg", - header: { text: "매설연장(m)" }, - styleName: "rg-cell-total", - footer: footerDecimal2, - editable: false, - valueType: ValueType.NUMBER, - dataFormat: "#,##0.00", - }, - { - name: "dmltnPrlg", - fieldName: "dmltnPrlg", - header: { text: "철거연장(m)" }, - styleName: "rg-cell-total", - footer: footerDecimal2, - editable: false, - valueType: ValueType.NUMBER, - dataFormat: "#,##0.00", - computed: { - fields: [ - yearField(firstGroupedYear, "DmltnPrlg"), - ...visibleYears.map((year) => yearField(year, "DmltnPrlg")), - ], - type: "sum" as const, - }, - }, - ...yearCols(firstGroupedYear, { footer: footerDecimal2 }), - ...visibleYears.map((year) => - yearCols(year, { - footer: footerDecimal2, - }), - ).flat(), - { name: "rmrk", fieldName: "rmrk", header: { text: "비고" } }, - { - name: "admdstCd", - fieldName: "admdstCd", - header: { text: "행정구역코드" }, - visible: false, - editable: false, - styleName: "rg-cell-readonly", - }, - { - name: "pipeSeCd", - fieldName: "pipeSeCd", - header: { text: "관종코드" }, - visible: false, - editable: false, - styleName: "rg-cell-readonly", - }, - ] as ColumnConfig[], - columnLayout: [ - { - name: "adminArea", - hideChildHeaders: false, - header: { text: "행정구역" }, - items: [{ column: "ctpvNm", footerUserSpans: [{ colspan: 2 }] }, "sggNm"], - }, - "pipeSeNm", - "admdstNm", - { - name: "totalGroup", - hideChildHeaders: false, - header: { text: "총계" }, - items: ["pipeByPrstWhol", "lyngPrlg", "dmltnPrlg"], - }, - { - name: "year1996Before", - hideChildHeaders: false, - header: { text: "1996년 이전" }, - items: [ - yearField(firstGroupedYear, "PrlgWhol"), - yearField(firstGroupedYear, "LyngPrlg"), - yearField(firstGroupedYear, "DmltnPrlg"), - ], - }, - ...yearLayoutItems, - 'rmrk', - 'admdstCd', - 'pipeSeCd' - ] as ColumnLayoutItem[], - rowStartNum: 2, - fixedColumns: 2, - tabKey: "ST00020003", - tabLabel: "관종별 현황", -}; +export const PipeTypeStatusInpColumn = getPipeTypeStatusInpColumn(); diff --git a/apps/st/src/entities/statistics/index.ts b/apps/st/src/entities/statistics/index.ts index 138273938..b0cb0f7bf 100644 --- a/apps/st/src/entities/statistics/index.ts +++ b/apps/st/src/entities/statistics/index.ts @@ -11,9 +11,16 @@ export { useScheduleInfo } from "./api/dashboard/schedule-info-queries"; export { scheduleInfoApi } from "./api/dashboard/schedule-info-service"; 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, + shouldRestrictFinanceVerificationToHeadquarters, } from "./lib/jeonnam-gwangju-sido-all-toolbar"; export { filterBySelectedAdmdstCd, 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 28f1eff3a..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 @@ -5,6 +5,39 @@ import type { Sido } from "../model/statistics-interface"; /** 전남광주통합특별시 — 도 목록에 있어 시군구 전체 조회 시 버튼이 숨겨짐 */ 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", + "ST00090002", + "ST00090003", + "ST00090004", +]); + +/** 입력 12-1, 12-2 */ +export const SEWAGE_EXCRETA_RELATED_PUBLIC_STATS_CD_SET = new Set([ + "ST00120001", + "ST00120002", +]); + export const SIDO_ALL_TOOLBAR_USER_IDS = new Set(["CLEANWATER", "S3291"]); function isEmptyOrAllGugun(values: SidoGugunLookup | null | undefined): boolean { @@ -43,3 +76,39 @@ export function isJeonnamGwangjuSidoAllToolbarException( } return isJeonnamGwangjuSidoAllSearch(sidoList, values); } + +export function isSewerageFinanceStatsCd(statsCd: string | null | undefined): boolean { + return SEWERAGE_FINANCE_STATS_CD_SET.has((statsCd ?? "").trim()); +} + +export function isSewageExcretaRelatedPublicStatsCd( + statsCd: string | null | undefined, +): boolean { + return SEWAGE_EXCRETA_RELATED_PUBLIC_STATS_CD_SET.has((statsCd ?? "").trim()); +} + +/** 9-1~4·12-1·12-2 + 전남광주(1200000000) 시군구 전체 조회 시, 검증 결과에서 본청만 조작 */ +export function shouldRestrictFinanceVerificationToHeadquarters( + statsCd: string | null | undefined, + sewerBzmnCd: string | null | undefined, + sggNm?: string | null, +): boolean { + const sgg = String(sggNm ?? "").trim(); + const isAllSgg = !sgg || sgg === "ALL"; + return ( + (isSewerageFinanceStatsCd(statsCd) || + isSewageExcretaRelatedPublicStatsCd(statsCd)) && + String(sewerBzmnCd ?? "").trim() === JEONNAM_GWANGJU_UNIFIED_SIDO_CD && + isAllSgg + ); +} + +export function isJeonnamGwangjuHeadquartersOperableRow(row: { + sewerBzmnCd?: string | number | null; + admdstNm?: string | number | null; +}): boolean { + return ( + String(row.sewerBzmnCd ?? "").trim() === JEONNAM_GWANGJU_UNIFIED_SIDO_CD && + String(row.admdstNm ?? "").trim() === JEONNAM_GWANGJU_HEADQUARTERS_ADMDST_NM + ); +}