[ST] - fix: 12-1,2 전남광주 본청 데이터 관련 저장&제출 조건 로직 수정

This commit is contained in:
2026-12-02 16:51:51 +09:00
parent d1c7da0a8c
commit c72c48e9dc
3 changed files with 139 additions and 12 deletions
@@ -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<string, string | number>,
): 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<string, string | number>[],
): boolean {
return rows.some(isJeonnamGwangjuHeadquartersGridRow);
}
function isOnlyJeonnamGwangjuHeadquartersGridRows(
rows: readonly Record<string, string | number>[],
): boolean {
return rows.length > 0 && rows.every(isJeonnamGwangjuHeadquartersGridRow);
}
function isJeonnamGwangjuSggHeadquartersOnlyNotApplicable(
searchContext: SearchFormValues | null,
rows: readonly Record<string, string | number>[],
): boolean {
return (
isJeonnamGwangjuSggNotApplicableSearch(searchContext) &&
isOnlyJeonnamGwangjuHeadquartersGridRows(rows)
);
}
function isEmptyForNotApplicable(
searchContext: SearchFormValues | null,
rows: readonly Record<string, string | number>[],
): 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<string, string | number>[] = [],
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 &&
+2
View File
@@ -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,
@@ -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",