[ST] input 특광역시 로직 수정, 일반검증 엑셀 다운로드 추가, 모든 number 타입 컬럼에 footer 추가

This commit is contained in:
2026-08-28 17:08:20 +09:00
parent 37ac927c45
commit e8b309460e
52 changed files with 1344 additions and 728 deletions
@@ -12,7 +12,7 @@ import { useConfirm } from "@frontend-opensource/use-react-hooks";
import { ValueType } from "realgrid";
import type { RealGridReact } from "realgrid-react";
import { useAlertStore, useGlobalProgressStore, useStatisticsInputToolbarGroupGate } from "@/shared/lib";
import { useAlertStore, useGlobalProgressStore, useStatisticsInputToolbarGroupGate, useSearchConditionSidoList } from "@/shared/lib";
import { STATISTICS_INPUT_URL_PATH } from "@/shared/lib/stats-cd-input-navigation";
import { useStatisticsInputPendingNavigation } from "@/shared/lib/use-statistics-input-pending-navigation";
import { ConfirmDialog } from "@/shared/ui/confirm-dialog";
@@ -35,7 +35,16 @@ import type {
ImrStatusResponse,
SewerageStatusInfo,
Sgg,
Sido,
} from "@/entities/statistics/model/statistics-interface";
import {
filterBySelectedAdmdstCd,
isGugunOkForToolbar,
isSubmitOkForToolbar,
resolveNoApplicableForRequest,
toInputSearchRegion,
} from "@/entities/statistics";
import { LoadingWithAnimation } from "@common/components";
import { getUserInfo } from "../../../../../../packages/common/components/src/api";
@@ -61,7 +70,6 @@ import type {
ColumnConfig,
} from "@/components/type/DataGrid.type";
import type { SearchFormValues } from "@/components/type/SearchForm.type";
import { doList } from "@/components/util/column/input/DoList";
import { ExcretaTreatFactInpColumn } from "@/components/util/column/input/ExcretaTreatFactInpColumn";
import { toGridRows } from "@/components/util/grid/gridFunction";
import { formatCompactYmdForGrid, toCompactYmdOrNull } from "@/components/util/grid/ymdFormat";
@@ -94,10 +102,22 @@ const computeTabEnterable = (
return periodEnterable;
};
const sidoListRef: { current: Sido[] } = { current: [] };
function buildGugunOkForToolbar(values: SearchFormValues | null): boolean {
return doList.includes(values?.bsnmCd || "")
? Boolean(values?.gugun && values.gugun !== "ALL")
: true;
return isGugunOkForToolbar(sidoListRef.current, values);
}
function buildSubmitOkForToolbar(values: SearchFormValues | null): boolean {
return isSubmitOkForToolbar(sidoListRef.current, values);
}
function buildNoApplicableForRequest(
values: SearchFormValues | null,
checked: boolean,
isSaveListEmpty: boolean,
): boolean {
return resolveNoApplicableForRequest(sidoListRef.current, values, checked, isSaveListEmpty);
}
function computeTabToolbarSnapshot(
@@ -131,9 +151,8 @@ function buildExcretaTreatmentFacilitySearchParam(
const fcltNm = values.fctName?.trim();
return {
statsYr: values.year,
sewerBzmnCd: values.bsnmCd,
ctpvNm: values.sido,
sggNm: values.gugun === "ALL" ? "" : values.gugun,
...toInputSearchRegion(sidoListRef.current, values),
...(fcltNm ? { fcltNm } : {}),
...(overrides?.mode ? { mode: overrides.mode } : {}),
};
@@ -315,6 +334,8 @@ const EXCRETA_TREATMENT_FACILITY_NAME_GUIDE_MESSAGE =
// 하수도 통계 관리 > 07. 분뇨처리시설
const ExcretaTreatmentFacilityInp = () => {
const { sidoList } = useSearchConditionSidoList({ isInput: true });
sidoListRef.current = sidoList;
const { setMessage: alert } = useAlertStore((state) => state);
const { confirm } = useConfirm();
const { isAdminInfo } = useAdminStore();
@@ -470,7 +491,11 @@ const ExcretaTreatmentFacilityInp = () => {
statusInfo: nextStatusInfo,
excretaTreatmentFacilityList,
} = response.data;
const list = excretaTreatmentFacilityList ?? [];
const list = filterBySelectedAdmdstCd(
excretaTreatmentFacilityList ?? [],
sidoListRef.current,
values,
);
const gridRows = mapExcretaTreatmentFacilityListToGridRows(list, commonInfo.ctpvNm);
setRowData(gridRows);
@@ -587,12 +612,8 @@ const ExcretaTreatmentFacilityInp = () => {
const userInfo = await getUserInfo();
const requestData: cancelSubmitRequest = {
sewerBzmnCd: lastSearchedValues.bsnmCd ?? "",
...toInputSearchRegion(sidoListRef.current, lastSearchedValues),
ctpvNm: lastSearchedValues.sido ?? "",
sggNm:
lastSearchedValues.gugun === "ALL"
? ""
: (lastSearchedValues.gugun ?? ""),
statsYr: lastSearchedValues.year ?? "",
mdfrId: userInfo.userUnqId,
statsCd: statsCd || EXCRETA_TREATMENT_FACILITY_STATS_CD,
@@ -628,7 +649,7 @@ const ExcretaTreatmentFacilityInp = () => {
if (!(await confirm("저장 하시겠습니까?"))) return;
commitGrid();
const noApplicable = isNotApplicable;
const noApplicable = buildNoApplicableForRequest(lastSearchedValues, isNotApplicable, getCurrentRows().length === 0);
const currentData = getCurrentRows();
const saveList = noApplicable
? []
@@ -639,7 +660,7 @@ const ExcretaTreatmentFacilityInp = () => {
.filter((row) => String(row.fcltSn ?? "").trim() !== "")
.map((row) => buildExcretaTreatmentFacilitySaveItem(row, sggOptions));
if (!noApplicable && saveList.length === 0) {
if (!noApplicable && saveList.length === 0 && buildSubmitOkForToolbar(lastSearchedValues)) {
alert("해당사항 없음을 체크해주세요.");
return;
}
@@ -652,11 +673,7 @@ const ExcretaTreatmentFacilityInp = () => {
{
statsYr: lastSearchedValues.year ?? "",
ctpvNm: lastSearchedValues.sido ?? "",
sggNm:
lastSearchedValues.gugun === "ALL"
? ""
: (lastSearchedValues.gugun ?? ""),
sewerBzmnCd: lastSearchedValues.bsnmCd ?? "",
...toInputSearchRegion(sidoListRef.current, lastSearchedValues),
userId: userInfo.userUnqId,
...(isAdminInfo ? { superAdmin: "superAdmin" } : {}),
noApplicable,
@@ -692,9 +709,9 @@ const ExcretaTreatmentFacilityInp = () => {
return;
}
const noApplicable = isNotApplicable;
const noApplicable = buildNoApplicableForRequest(lastSearchedValues, isNotApplicable, getCurrentRows().length === 0);
const currentData = getCurrentRows();
if (!noApplicable && currentData.length === 0) {
if (!noApplicable && currentData.length === 0 && buildSubmitOkForToolbar(lastSearchedValues)) {
alert("해당사항 없음을 체크해주세요.");
return;
}
@@ -719,7 +736,7 @@ const ExcretaTreatmentFacilityInp = () => {
}
commitGrid();
const noApplicable = isNotApplicable;
const noApplicable = buildNoApplicableForRequest(lastSearchedValues, isNotApplicable, getCurrentRows().length === 0);
const currentData = getCurrentRows();
const submitList = noApplicable
? []
@@ -730,19 +747,15 @@ const ExcretaTreatmentFacilityInp = () => {
.filter((row) => String(row.fcltSn ?? "").trim() !== "")
.map((row) => buildExcretaTreatmentFacilitySaveItem(row, sggOptions));
if (!noApplicable && submitList.length === 0) {
if (!noApplicable && submitList.length === 0 && buildSubmitOkForToolbar(lastSearchedValues)) {
alert("해당사항 없음을 체크해주세요.");
return;
}
const statsCdForSubmit = statsCd || EXCRETA_TREATMENT_FACILITY_STATS_CD;
const verificationQuery = {
sewerBzmnCd: lastSearchedValues.bsnmCd ?? "",
...toInputSearchRegion(sidoListRef.current, lastSearchedValues),
ctpvNm: lastSearchedValues.sido ?? "",
sggNm:
lastSearchedValues.gugun === "ALL"
? ""
: (lastSearchedValues.gugun ?? ""),
statsYr: lastSearchedValues.year ?? "",
statsCd: statsCdForSubmit,
};
@@ -761,11 +774,7 @@ const ExcretaTreatmentFacilityInp = () => {
{
statsYr: lastSearchedValues.year ?? "",
ctpvNm: lastSearchedValues.sido ?? "",
sggNm:
lastSearchedValues.gugun === "ALL"
? ""
: (lastSearchedValues.gugun ?? ""),
sewerBzmnCd: lastSearchedValues.bsnmCd ?? "",
...toInputSearchRegion(sidoListRef.current, lastSearchedValues),
userId: userInfo.userUnqId,
laePicNm: submitInfo.laePicNm,
laePicTelNo: submitInfo.laePicTelNo,
@@ -795,7 +804,7 @@ const ExcretaTreatmentFacilityInp = () => {
setGlobalProgressLabel("시계열 검증 진행 중...");
const imrParam = {
user_id: userInfo.userUnqId,
sewer_bzmn_cd: lastSearchedValues.bsnmCd ?? "",
sewer_bzmn_cd: lastSearchedValues?.bsnmCd ?? "",
stats_cd: statsCdForSubmit,
stats_yr: lastSearchedValues.year ?? "",
lae_sbmsn_stts_cd:
@@ -959,7 +968,7 @@ const ExcretaTreatmentFacilityInp = () => {
}
};
const searchContextForToolbar = lastSearchedValues ?? searchValues;
const searchContextForToolbar = lastSearchedValues;
const toolbarSnapshot = computeTabToolbarSnapshot(
statusInfo,
rowData.length > 0,
@@ -979,23 +988,23 @@ const ExcretaTreatmentFacilityInp = () => {
hasSearched &&
toolbarGroupAllowed &&
(showSaveInToolbar || showEnterableToolbarButtons);
const tabEnterableForGrid =
(computeTabEnterable(statusInfo, inputPeriodEnterable) || isAdminInfo) && inputPeriodEnterable;
const gugunOk = buildGugunOkForToolbar(searchContextForToolbar);
const submitOk = buildSubmitOkForToolbar(searchContextForToolbar);
const showNotApplicable =
searchLoaded &&
hasSearched &&
rowData.length === 0 &&
computeTabEnterable(statusInfo, inputPeriodEnterable);
const tabEnterableForGrid =
(computeTabEnterable(statusInfo, inputPeriodEnterable) || isAdminInfo) && inputPeriodEnterable;
const gugunOk = buildGugunOkForToolbar(lastSearchedValues);
computeTabEnterable(statusInfo, inputPeriodEnterable) &&
submitOk;
const verificationQueryContext = (() => {
const ctx = lastSearchedValues ?? searchValues;
if (!ctx?.year || !ctx?.sido || !ctx?.bsnmCd || !statsCd) return null;
return {
sewerBzmnCd: ctx.bsnmCd,
...toInputSearchRegion(sidoListRef.current, ctx),
ctpvNm: ctx.sido,
sggNm: ctx.gugun === "ALL" ? "" : (ctx.gugun ?? ""),
statsYr: ctx.year,
statsCd,
};
@@ -1011,6 +1020,7 @@ const ExcretaTreatmentFacilityInp = () => {
<>
<div className="relative">
<SearchForm
isInput
key={searchFormRemountKey}
defaultValues={verificationSearchDefaults ?? undefined}
fctName={true}
@@ -1030,10 +1040,10 @@ const ExcretaTreatmentFacilityInp = () => {
<LastYearDataButton
getLastYearDataFunc={() => void getLastYearDataFunc()}
/>
<SubmitButton submitFunc={submitFunc} />
{submitOk && <SubmitButton submitFunc={submitFunc} />}
</>
)}
{statusInfo?.laeSbmsnSttsCd === "2" && (
{statusInfo?.laeSbmsnSttsCd === "2" && submitOk && (
<CancelSubmitButton cnacelSubmitFunc={cnacelSubmitFunc} />
)}
{showSaveInToolbar && <SaveButton saveFunc={saveFunc} />}
@@ -2,7 +2,7 @@ import { useEffect, useMemo, useRef, useState } from "react";
import { useConfirm } from "@frontend-opensource/use-react-hooks";
import { useAlertStore, useGlobalProgressStore } from "@/shared/lib";
import { useAlertStore, useGlobalProgressStore, useSearchConditionSidoList } from "@/shared/lib";
import { STATISTICS_INPUT_URL_PATH } from "@/shared/lib/stats-cd-input-navigation";
import { useStatisticsInputPendingNavigation } from "@/shared/lib/use-statistics-input-pending-navigation";
import { ConfirmDialog } from "@/shared/ui/confirm-dialog";
@@ -31,7 +31,15 @@ import type {
cancelSubmitRequest,
ImrStatusResponse,
SewerageStatusInfo,
Sido,
} from "@/entities/statistics/model/statistics-interface";
import {
filterBySelectedAdmdstCd,
isGugunOkForToolbar,
isSubmitOkForToolbar,
toInputSearchRegion,
} from "@/entities/statistics";
import { LoadingWithAnimation, Tabs, TabsContent, TabsList, TabsTrigger } from "@common/components";
import { getUserInfo } from "../../../../../../packages/common/components/src/api";
@@ -50,7 +58,6 @@ import { VerificationResultDialog } from "@/components/module/VerificationResult
import { VerificationResultHistoryDialog } from "@/components/module/VerificationResultHistoryDialog";
import type { ColumnConfig, ColumnInfo } from "@/components/type/DataGrid.type";
import type { SearchFormValues } from "@/components/type/SearchForm.type";
import { doList } from "@/components/util/column/input/DoList";
import { PrivateSewageDesigStatusInpColumn } from "@/components/util/column/input/privateSewageFacility/PrivateSewageDesigStatusInpColumn";
import { SepticTankStatusInpColumn } from "@/components/util/column/input/privateSewageFacility/SepticTankStatusInpColumn";
import { SewageTreatFactStatusInpColumn } from "@/components/util/column/input/privateSewageFacility/SewageTreatFactStatusInpColumn";
@@ -102,9 +109,8 @@ function buildPrivateSewageFacilitySearchParam(
): SewageTreatFactStatusRequestParams {
return {
statsYr: values.year,
sewerBzmnCd: values.bsnmCd,
ctpvNm: values.sido,
sggNm: values.gugun === "ALL" ? "" : values.gugun,
...toInputSearchRegion(sidoListRef.current, values),
...(overrides?.mode ? { mode: overrides.mode } : {}),
};
}
@@ -122,10 +128,14 @@ const computeTabEnterable = (
return periodEnterable;
};
const sidoListRef: { current: Sido[] } = { current: [] };
function buildGugunOkForToolbar(values: SearchFormValues | null): boolean {
return doList.includes(values?.bsnmCd || "")
? Boolean(values?.gugun && values.gugun !== "ALL")
: true;
return isGugunOkForToolbar(sidoListRef.current, values);
}
function buildSubmitOkForToolbar(values: SearchFormValues | null): boolean {
return isSubmitOkForToolbar(sidoListRef.current, values);
}
function computeTabToolbarSnapshot(
@@ -161,8 +171,8 @@ function tabRowDataExists(
function mapRegionalListToGridRows<
T extends { verificationResult?: PrivateSewageFacilityVerificationResult },
>(list: T[], ctpvNm: string): GridRowWithVerification[] {
return list.map((item) => {
>(list: T[], ctpvNm: string, values?: SearchFormValues | null): GridRowWithVerification[] {
return filterBySelectedAdmdstCd(list, sidoListRef.current, values).map((item) => {
const { verificationResult, ...rest } = item;
const row = toGridRows([{ ctpvNm, ...rest }])[0] as GridRowWithVerification;
if (verificationResult) row.verificationResult = verificationResult;
@@ -314,6 +324,8 @@ function resolvePrivateSewageFacilityTab(tabKey: string) {
// 하수도 통계 관리 > 08. 개인하수처리시설
const PrivateSewageFacilityInp = () => {
const { sidoList } = useSearchConditionSidoList({ isInput: true });
sidoListRef.current = sidoList;
const { setMessage: alert } = useAlertStore((state) => state);
const { confirm } = useConfirm();
const { isAdminInfo } = useAdminStore();
@@ -340,9 +352,12 @@ const PrivateSewageFacilityInp = () => {
const [footerVerificationByTab, setFooterVerificationByTab] = useState<
Map<string, VerificationResultLikeMap | null>
>(new Map());
const [toolbarSnapshotByTab, setToolbarSnapshotByTab] = useState<
const [_toolbarSnapshotByTab, setToolbarSnapshotByTab] = useState<
Map<string, TabToolbarSnapshot>
>(new Map());
const [searchContextByTab, setSearchContextByTab] = useState<Map<string, SearchFormValues>>(
() => new Map(),
);
const [verificationHistoryOpen, setVerificationHistoryOpen] = useState(false);
const [verificationResultDialogOpen, setVerificationResultDialogOpen] = useState(false);
const [showSubmitDialog, setShowSubmitDialog] = useState(false);
@@ -403,6 +418,13 @@ const PrivateSewageFacilityInp = () => {
);
return next;
});
if (searchContext) {
setSearchContextByTab((prev) => {
const next = new Map(prev);
next.set(tabKey, searchContext);
return next;
});
}
};
const applyRowMap = (
@@ -445,6 +467,7 @@ const PrivateSewageFacilityInp = () => {
const gridRows = mapRegionalListToGridRows(
(sewageTreatFactStatusList ?? []) as SewageTreatFactStatusItem[],
commonInfo.ctpvNm,
searchContext,
);
applyRowMap(mergeIntoExistingMap, (m) => {
@@ -476,6 +499,7 @@ const PrivateSewageFacilityInp = () => {
const gridRows = mapRegionalListToGridRows(
(septicTankStatusList ?? []) as SepticTankStatusItem[],
commonInfo.ctpvNm,
searchContext,
);
applyRowMap(mergeIntoExistingMap, (m) => {
@@ -507,6 +531,7 @@ const PrivateSewageFacilityInp = () => {
const gridRows = mapRegionalListToGridRows(
(privateSewageDesigStatusList ?? []) as PrivateSewageDesigStatusItem[],
commonInfo.ctpvNm,
searchContext,
);
applyRowMap(mergeIntoExistingMap, (m) => {
@@ -539,6 +564,7 @@ const PrivateSewageFacilityInp = () => {
setIsVerificationFailedByTab(new Map());
setFooterVerificationByTab(new Map());
setToolbarSnapshotByTab(new Map());
setSearchContextByTab(new Map());
setActiveTab(firstTabKey);
activeTabRef.current = firstTabKey;
setLastSearchedValues(null);
@@ -582,6 +608,7 @@ const PrivateSewageFacilityInp = () => {
setIsVerificationFailedByTab(new Map());
setFooterVerificationByTab(new Map());
setToolbarSnapshotByTab(new Map());
setSearchContextByTab(new Map());
activeTabRef.current = firstTabKey;
setActiveTab(firstTabKey);
}
@@ -691,12 +718,8 @@ const PrivateSewageFacilityInp = () => {
}
const requestData: cancelSubmitRequest = {
sewerBzmnCd: lastSearchedValues.bsnmCd ?? "",
...toInputSearchRegion(sidoListRef.current, lastSearchedValues),
ctpvNm: lastSearchedValues.sido ?? "",
sggNm:
lastSearchedValues.gugun === "ALL"
? ""
: (lastSearchedValues.gugun ?? ""),
statsYr: lastSearchedValues.year ?? "",
mdfrId: userInfo.userUnqId,
statsCd: statsCdForTab,
@@ -779,11 +802,7 @@ const PrivateSewageFacilityInp = () => {
const submitInfoBase = {
statsYr: lastSearchedValues.year ?? "",
ctpvNm: lastSearchedValues.sido ?? "",
sggNm:
lastSearchedValues.gugun === "ALL"
? ""
: (lastSearchedValues.gugun ?? ""),
sewerBzmnCd: lastSearchedValues.bsnmCd ?? "",
...toInputSearchRegion(sidoListRef.current, lastSearchedValues),
laePicNm: submitInfo.laePicNm,
laePicTelNo: submitInfo.laePicTelNo,
laeKbrdrDeptNm: submitInfo.laeKbrdrDeptNm,
@@ -795,12 +814,8 @@ const PrivateSewageFacilityInp = () => {
};
const verificationQuery = {
sewerBzmnCd: lastSearchedValues.bsnmCd ?? "",
...toInputSearchRegion(sidoListRef.current, lastSearchedValues),
ctpvNm: lastSearchedValues.sido ?? "",
sggNm:
lastSearchedValues.gugun === "ALL"
? ""
: (lastSearchedValues.gugun ?? ""),
statsYr: lastSearchedValues.year ?? "",
statsCd: statsCdForTab,
};
@@ -868,7 +883,7 @@ const PrivateSewageFacilityInp = () => {
setGlobalProgressLabel("시계열 검증 진행 중...");
const imrParam = {
user_id: userInfo.userUnqId,
sewer_bzmn_cd: lastSearchedValues.bsnmCd ?? "",
sewer_bzmn_cd: lastSearchedValues?.bsnmCd ?? "",
stats_cd: statsCdForTab,
stats_yr: lastSearchedValues.year ?? "",
lae_sbmsn_stts_cd: activeTabStatus?.laeSbmsnSttsCd === "4" ? "4" : "2",
@@ -956,11 +971,7 @@ const PrivateSewageFacilityInp = () => {
const baseRequest = {
statsYr: lastSearchedValues.year ?? "",
ctpvNm: lastSearchedValues.sido ?? "",
sggNm:
lastSearchedValues.gugun === "ALL"
? ""
: (lastSearchedValues.gugun ?? ""),
sewerBzmnCd: lastSearchedValues.bsnmCd ?? "",
...toInputSearchRegion(sidoListRef.current, lastSearchedValues),
};
try {
@@ -1062,9 +1073,8 @@ const PrivateSewageFacilityInp = () => {
const statsCd = tabStatsCdMap.get(activeTab);
if (!ctx?.year || !ctx?.sido || !ctx?.bsnmCd || !statsCd) return null;
return {
sewerBzmnCd: ctx.bsnmCd,
...toInputSearchRegion(sidoListRef.current, ctx),
ctpvNm: ctx.sido,
sggNm: ctx.gugun === "ALL" ? "" : (ctx.gugun ?? ""),
statsYr: ctx.year,
statsCd,
};
@@ -1095,19 +1105,20 @@ const PrivateSewageFacilityInp = () => {
return map;
}, [tabStatusInfoMap, inputPeriodEnterable, isAdminInfo, columnGuidesByTab]);
const searchContextForToolbar = searchContextByTab.get(activeTab) ?? lastSearchedValues;
const activeTabStatus = tabStatusInfoMap.get(activeTab) ?? null;
const activeTabToolbar =
toolbarSnapshotByTab.get(activeTab) ??
computeTabToolbarSnapshot(
activeTabStatus,
tabRowDataExists(rowDataMap, activeTab),
hasSearched,
lastSearchedValues,
searchContextForToolbar,
inputPeriodEnterable,
isAdminInfo,
);
const { showSaveInToolbar, showEnterableToolbarButtons, showActionToolbarCard } =
activeTabToolbar;
const submitOk = buildSubmitOkForToolbar(searchContextForToolbar);
const verificationCellStyle = ({
fieldName,
@@ -1166,6 +1177,7 @@ const PrivateSewageFacilityInp = () => {
<>
<div className="relative">
<SearchForm
isInput
key={searchFormRemountKey}
defaultValues={verificationSearchDefaults ?? undefined}
onSubmit={handleSearch}
@@ -1186,10 +1198,10 @@ const PrivateSewageFacilityInp = () => {
<LastYearDataButton
getLastYearDataFunc={() => void lastYearDataFunc()}
/>
<SubmitButton submitFunc={submitFunc} />
{submitOk && <SubmitButton submitFunc={submitFunc} />}
</>
)}
{activeTabStatus?.laeSbmsnSttsCd === "2" && (
{activeTabStatus?.laeSbmsnSttsCd === "2" && submitOk && (
<CancelSubmitButton cnacelSubmitFunc={cnacelSubmitFunc} />
)}
{showSaveInToolbar && <SaveButton saveFunc={saveFunc} />}
@@ -1225,7 +1237,7 @@ const PrivateSewageFacilityInp = () => {
tabStatusInfoMap.get(tabKey) ?? null,
inputPeriodEnterable,
) || isAdminInfo) && inputPeriodEnterable;
const gugunOk = buildGugunOkForToolbar(lastSearchedValues);
const gugunOk = buildGugunOkForToolbar(searchContextForToolbar);
const tabStatusInfo = tabStatusInfoMap.get(tabKey) ?? null;
return (
@@ -2,7 +2,7 @@
import { useConfirm } from '@frontend-opensource/use-react-hooks';
import { useAlertStore, useGlobalProgressStore, useStatisticsInputToolbarGroupGate } from '@/shared/lib';
import { useAlertStore, useGlobalProgressStore, useStatisticsInputToolbarGroupGate, useSearchConditionSidoList } from '@/shared/lib';
import { STATISTICS_INPUT_URL_PATH } from '@/shared/lib/stats-cd-input-navigation';
import { useStatisticsInputPendingNavigation } from '@/shared/lib/use-statistics-input-pending-navigation';
import { statisticsInputSewSupplyRateApi } from '@/entities/statistics/api/input/statistics-input-sew-supply-rate-service';
@@ -23,7 +23,9 @@ import {
type SewerageSupplyRateVerificationResult,
} from '@/entities/statistics/model/input/statistics-sewage-supply-rate-input-interface';
import type { StatisticsInputSubmitInfoFormData } from '@/entities/statistics/model/statistics-input-submit-info-schema';
import type { cancelSubmitRequest, ImrStatusResponse, SewerageStatusInfo } from '@/entities/statistics/model/statistics-interface';
import type { cancelSubmitRequest, ImrStatusResponse, SewerageStatusInfo, Sido } from '@/entities/statistics/model/statistics-interface';
import { filterBySelectedAdmdstCd, isGugunOkForToolbar, isSubmitOkForToolbar, resolveNoApplicableForRequest, toInputSearchRegion } from '@/entities/statistics';
import { LoadingWithAnimation, Tabs, TabsContent, TabsList, TabsTrigger } from '@common/components';
import { getUserInfo } from '../../../../../../packages/common/components/src/api';
@@ -45,7 +47,6 @@ import { VerificationResultDialog } from '@/components/module/VerificationResult
import { VerificationResultHistoryDialog } from '@/components/module/VerificationResultHistoryDialog';
import type { CellStyleCallbackParams, ColumnInfo, ColumnInfoList } from '@/components/type/DataGrid.type';
import type { SearchFormValues } from '@/components/type/SearchForm.type';
import { doList } from '@/components/util/column/input/DoList';
import { PublicSewageFactInpColumnList } from '@/components/util/column/input/PublicSewageFactInpColumn/PublicSewageFactInpColumn';
import { fetchColumnGuidesRecord } from '@/components/util/grid/columnGuides';
import { toGridRows } from '@/components/util/grid/gridFunction';
@@ -66,10 +67,22 @@ type TabToolbarSnapshot = {
showActionToolbarCard: boolean;
};
const sidoListRef: { current: Sido[] } = { current: [] };
function buildGugunOkForToolbar(values: SearchFormValues | null): boolean {
return doList.includes(values?.bsnmCd || '')
? Boolean(values?.gugun && values.gugun !== 'ALL')
: true;
return isGugunOkForToolbar(sidoListRef.current, values);
}
function buildSubmitOkForToolbar(values: SearchFormValues | null): boolean {
return isSubmitOkForToolbar(sidoListRef.current, values);
}
function buildNoApplicableForRequest(
values: SearchFormValues | null,
checked: boolean,
isSaveListEmpty: boolean,
): boolean {
return resolveNoApplicableForRequest(sidoListRef.current, values, checked, isSaveListEmpty);
}
const computeTabEnterable = (
@@ -181,6 +194,8 @@ function validatePrxyCtrtCnInRows(rows: Record<string, string | number>[]): stri
// 하수도 통계 관리 > 06. 공공하수처리시설
const PublicSewageFacilityInp = () => {
const { sidoList } = useSearchConditionSidoList({ isInput: true });
sidoListRef.current = sidoList;
const { setMessage: alert } = useAlertStore((state) => state);
const { confirm } = useConfirm();
const { isAdminInfo } = useAdminStore();
@@ -209,6 +224,9 @@ const PublicSewageFacilityInp = () => {
/** 탭키별 `engColNm -> columnGuide` 캐시 */
const [columnGuidesByTab, setColumnGuidesByTab] = useState<Record<string, Record<string, string>>>({});
const [_toolbarSnapshotByTab, setToolbarSnapshotByTab] = useState<Map<string, TabToolbarSnapshot>>(() => new Map());
const [searchContextByTab, setSearchContextByTab] = useState<Map<string, SearchFormValues>>(
() => new Map(),
);
const [inputPeriodEnterable, setInputPeriodEnterable] = useState(true);
const [periodCheckList, setPeriodCheckList] = useState<CheckInputPeriodItem[]>([]);
const [showDailog, setShowDailog] = useState<boolean>(false);
@@ -247,10 +265,10 @@ const PublicSewageFacilityInp = () => {
alert('먼저 조회를 진행해주세요.');
return;
}
const treatAsNoApplicable = getNoApplicableForRequest() || isNotApplicable;
const treatAsNoApplicable = getNoApplicableForRequest();
const currentData =
st60001GridGetRowsRef.current?.() ?? rowDataMap.get('ST00060001') ?? [];
if (!treatAsNoApplicable && (!currentData || currentData.length === 0)) {
if (!treatAsNoApplicable && (!currentData || currentData.length === 0) && buildSubmitOkForToolbar(searchContextByTab.get(activeTab) ?? lastSearchedValues)) {
alert('해당사항 없음을 체크해주세요.');
return;
}
@@ -298,13 +316,14 @@ const PublicSewageFacilityInp = () => {
};
const getNoApplicableForRequest = (): boolean => {
const activeTabStatus = tabStatusInfoMap.get(activeTab) ?? null;
const searchContextForToolbar = lastSearchedValues ?? searchValues;
const gugunOk = buildGugunOkForToolbar(searchContextForToolbar);
const enterable = computeTabEnterable(activeTabStatus, inputPeriodEnterable);
const showEnterableToolbarButtons = enterable && gugunOk;
const noApplicableVisible = showEnterableToolbarButtons && showIsNotApplicable;
return noApplicableVisible ? Boolean(isNotApplicable) : false;
const searchContextForToolbar = searchContextByTab.get(activeTab) ?? lastSearchedValues;
const currentData =
st60001GridGetRowsRef.current?.() ?? rowDataMap.get('ST00060001') ?? [];
return buildNoApplicableForRequest(
searchContextForToolbar,
Boolean(isNotApplicable),
buildFacilitySaveList(currentData).length === 0,
);
};
const isCheckedRow = (row: Record<string, string | number>): boolean => {
@@ -349,7 +368,7 @@ const PublicSewageFacilityInp = () => {
return;
}
const noApplicable = getNoApplicableForRequest();
const treatAsNoApplicable = noApplicable || isNotApplicable;
const treatAsNoApplicable = noApplicable;
const currentData =
st60001GridGetRowsRef.current?.() ?? rowDataMap.get('ST00060001') ?? [];
@@ -360,7 +379,7 @@ const PublicSewageFacilityInp = () => {
}
const submitList = treatAsNoApplicable ? [] : buildFacilitySaveList(currentData);
if (!treatAsNoApplicable && submitList.length === 0) {
if (!treatAsNoApplicable && submitList.length === 0 && buildSubmitOkForToolbar(searchContextByTab.get(activeTab) ?? lastSearchedValues)) {
alert('해당사항 없음을 체크해주세요.');
return;
}
@@ -373,8 +392,7 @@ const PublicSewageFacilityInp = () => {
const requestData = {
statsYr: lastSearchedValues.year ?? '',
ctpvNm: lastSearchedValues.sido ?? '',
sggNm: lastSearchedValues.gugun === 'ALL' ? '' : lastSearchedValues.gugun ?? '',
sewerBzmnCd: lastSearchedValues.bsnmCd ?? '',
...toInputSearchRegion(sidoListRef.current, lastSearchedValues),
userId: userInfo.userUnqId,
noApplicable,
laePicNm: submitInfo.laePicNm,
@@ -407,7 +425,7 @@ const PublicSewageFacilityInp = () => {
setGlobalProgressLabel('시계열 검증 진행 중...');
const imrParam = {
user_id: userInfo.userUnqId,
sewer_bzmn_cd: lastSearchedValues.bsnmCd ?? '',
sewer_bzmn_cd: lastSearchedValues?.bsnmCd ?? '',
stats_cd: statsCdForTab,
stats_yr: lastSearchedValues.year ?? '',
lae_sbmsn_stts_cd: activeTabStatus?.laeSbmsnSttsCd === '4' ? '4' : '2',
@@ -435,9 +453,8 @@ const PublicSewageFacilityInp = () => {
);
await openVerificationResultDialogIfNeeded(
{
sewerBzmnCd: lastSearchedValues.bsnmCd ?? '',
...toInputSearchRegion(sidoListRef.current, lastSearchedValues),
ctpvNm: lastSearchedValues.sido ?? '',
sggNm: lastSearchedValues.gugun === 'ALL' ? '' : (lastSearchedValues.gugun ?? ''),
statsYr: lastSearchedValues.year ?? '',
statsCd: statsCdForTab,
},
@@ -452,9 +469,8 @@ const PublicSewageFacilityInp = () => {
);
await openVerificationResultDialogIfNeeded(
{
sewerBzmnCd: lastSearchedValues.bsnmCd ?? '',
...toInputSearchRegion(sidoListRef.current, lastSearchedValues),
ctpvNm: lastSearchedValues.sido ?? '',
sggNm: lastSearchedValues.gugun === 'ALL' ? '' : (lastSearchedValues.gugun ?? ''),
statsYr: lastSearchedValues.year ?? '',
statsCd: statsCdForTab,
},
@@ -476,9 +492,8 @@ const PublicSewageFacilityInp = () => {
);
await openVerificationResultDialogIfNeeded(
{
sewerBzmnCd: lastSearchedValues.bsnmCd ?? '',
...toInputSearchRegion(sidoListRef.current, lastSearchedValues),
ctpvNm: lastSearchedValues.sido ?? '',
sggNm: lastSearchedValues.gugun === 'ALL' ? '' : (lastSearchedValues.gugun ?? ''),
statsYr: lastSearchedValues.year ?? '',
statsCd: statsCdForTab,
},
@@ -508,7 +523,7 @@ const PublicSewageFacilityInp = () => {
if (activeTab === 'ST00060002') {
const statusCodeResponse = await statisticsApi.CheckStatusCode({
sewerBzmnCd: lastSearchedValues.bsnmCd ?? '',
sewerBzmnCd: toInputSearchRegion(sidoListRef.current, lastSearchedValues).sewerBzmnCd,
statsCd: 'ST00060001',
statsYr: lastSearchedValues.year ?? ''
});
@@ -585,7 +600,7 @@ const PublicSewageFacilityInp = () => {
mainFacilityMappingSaveDraftRef.current = {
statsYr: lastSearchedValues.year ?? '',
sewerBzmnCd: lastSearchedValues.bsnmCd ?? '',
sewerBzmnCd: toInputSearchRegion(sidoListRef.current, lastSearchedValues).sewerBzmnCd,
admdstCd: String(selectedMain.admdstCd ?? ''),
admdstNm: String(selectedMain.admdstNm ?? ''),
mainFcltSn: String(selectedMain.fcltSn ?? ''),
@@ -616,7 +631,7 @@ const PublicSewageFacilityInp = () => {
if (activeTab === 'ST00060001') {
const noApplicable = getNoApplicableForRequest();
const treatAsNoApplicable = noApplicable || isNotApplicable;
const treatAsNoApplicable = noApplicable;
const currentData =
st60001GridGetRowsRef.current?.() ?? rowDataMap.get('ST00060001') ?? [];
const prxyCtrtCnError = validatePrxyCtrtCnInRows(currentData);
@@ -625,7 +640,7 @@ const PublicSewageFacilityInp = () => {
return;
}
const saveList = treatAsNoApplicable ? [] : buildFacilitySaveList(currentData);
if (!treatAsNoApplicable && saveList.length === 0) {
if (!treatAsNoApplicable && saveList.length === 0 && buildSubmitOkForToolbar(searchContextByTab.get(activeTab) ?? lastSearchedValues)) {
alert('해당사항 없음을 체크해주세요.');
return;
}
@@ -636,8 +651,7 @@ const PublicSewageFacilityInp = () => {
const param: PublicSewageFacilitySaveRequest = {
statsYr: lastSearchedValues.year ?? '',
ctpvNm: lastSearchedValues.sido ?? '',
sggNm: lastSearchedValues.gugun === 'ALL' ? '' : lastSearchedValues.gugun ?? '',
sewerBzmnCd: lastSearchedValues.bsnmCd ?? '',
...toInputSearchRegion(sidoListRef.current, lastSearchedValues),
userId: userInfo.userUnqId,
...(isAdminInfo ? { superAdmin: 'superAdmin' } : {}),
noApplicable,
@@ -724,12 +738,18 @@ const PublicSewageFacilityInp = () => {
);
return next;
});
if (searchContext) {
setSearchContextByTab((prev) => {
const next = new Map(prev);
next.set(tabKey, searchContext);
return next;
});
}
};
const buildPublicSewageFacilityParams = (values: SearchFormValues): PublicSewageFacilityRequestParams => ({
ctpvNm: values.sido,
sggNm: values.gugun === 'ALL' ? '' : values.gugun,
sewerBzmnCd: values.bsnmCd,
...toInputSearchRegion(sidoListRef.current, values),
fcltNm: values.fctName,
statsYr: values.year,
});
@@ -759,7 +779,11 @@ const PublicSewageFacilityInp = () => {
const statusInfo = response.data.statusInfo ?? null;
const statsCd = response.data.commonInfo.statsCd || tabKey;
const commonInfo = response.data.commonInfo;
const list = response.data.publicSewageFacilityList ?? [];
const list = filterBySelectedAdmdstCd(
response.data.publicSewageFacilityList ?? [],
sidoListRef.current,
searchContext,
);
const convertedData = list.map((item) => ({
ctpvNm: commonInfo.ctpvNm,
...item,
@@ -872,8 +896,7 @@ const PublicSewageFacilityInp = () => {
const request = {
statsYr: lastSearchedValues.year ?? '',
ctpvNm: lastSearchedValues.sido ?? '',
sggNm: lastSearchedValues.gugun === 'ALL' ? '' : lastSearchedValues.gugun ?? '',
sewerBzmnCd: lastSearchedValues.bsnmCd ?? '',
...toInputSearchRegion(sidoListRef.current, lastSearchedValues),
userId: userInfo.userUnqId,
};
@@ -1005,6 +1028,7 @@ const PublicSewageFacilityInp = () => {
setIsVerificationFailedByTab(new Map());
setFooterVerificationByTab(new Map());
setToolbarSnapshotByTab(new Map());
setSearchContextByTab(new Map());
activeTabRef.current = firstTabKey;
setActiveTab(firstTabKey);
}
@@ -1069,6 +1093,7 @@ const PublicSewageFacilityInp = () => {
setIsVerificationFailedByTab(new Map());
setFooterVerificationByTab(new Map());
setToolbarSnapshotByTab(new Map());
setSearchContextByTab(new Map());
setInputPeriodEnterable(true);
periodEnterableRef.current = true;
@@ -1095,9 +1120,8 @@ const PublicSewageFacilityInp = () => {
const userInfo = await getUserInfo();
const statsCdForCancel = tabStatsCdMap.get(activeTab) ?? activeTab;
const requestData: cancelSubmitRequest = {
sewerBzmnCd: lastSearchedValues?.bsnmCd ?? '',
...toInputSearchRegion(sidoListRef.current, lastSearchedValues),
ctpvNm: lastSearchedValues?.sido ?? '',
sggNm: lastSearchedValues?.gugun === 'ALL' ? '' : lastSearchedValues?.gugun ?? '',
statsYr: lastSearchedValues?.year ?? '',
mdfrId: userInfo.userUnqId,
statsCd: statsCdForCancel,
@@ -1155,7 +1179,9 @@ const PublicSewageFacilityInp = () => {
const param: PublicSewageMappingTargetsRequestParams = {
sewerBzmnCd: searchParamRef.current.sewerBzmnCd ?? '',
ctpvNm: searchParamRef.current.ctpvNm ?? '',
sggNm: searchParamRef.current.sggNm ?? '',
...(searchParamRef.current.sggNm != null
? { sggNm: searchParamRef.current.sggNm }
: {}),
statsYr: searchParamRef.current.statsYr ?? '',
fcltSn,
};
@@ -1195,8 +1221,9 @@ const PublicSewageFacilityInp = () => {
return String(row.fcltSn ?? '') === selectedMainFacilitySn ? 'rg-cell-selected-row' : undefined;
};
const searchContextForToolbar = lastSearchedValues ?? searchValues;
const searchContextForToolbar = searchContextByTab.get(activeTab) ?? lastSearchedValues;
const gugunOkOrNotDoList = buildGugunOkForToolbar(searchContextForToolbar);
const submitOk = buildSubmitOkForToolbar(searchContextForToolbar);
const activeTabStatus = tabStatusInfoMap.get(activeTab) ?? null;
const activeTabToolbar = computeTabToolbarSnapshot(
activeTabStatus,
@@ -1241,9 +1268,8 @@ const PublicSewageFacilityInp = () => {
const statsCd = tabStatsCdMap.get(activeTab) ?? activeTab;
if (!ctx?.year || !ctx?.sido || !ctx?.bsnmCd || !statsCd) return null;
return {
sewerBzmnCd: ctx.bsnmCd,
...toInputSearchRegion(sidoListRef.current, ctx),
ctpvNm: ctx.sido,
sggNm: ctx.gugun === 'ALL' ? '' : (ctx.gugun ?? ''),
statsYr: ctx.year,
statsCd,
};
@@ -1264,6 +1290,7 @@ const PublicSewageFacilityInp = () => {
<>
<div className="relative">
<SearchForm
isInput
key={searchFormRemountKey}
defaultValues={verificationSearchDefaults ?? undefined}
fctName={true}
@@ -1284,12 +1311,12 @@ const PublicSewageFacilityInp = () => {
)}
{showEnterableToolbarButtons && !isMainFacilityTab && (
<>
{showIsNotApplicable && <NotApplicableCheckButton isCheck={isNotApplicable} setIsCheck={setIsNotApplicable} />}
{showIsNotApplicable && submitOk && <NotApplicableCheckButton isCheck={isNotApplicable} setIsCheck={setIsNotApplicable} />}
<UpdateOperateDataButton updateOperateDataButtonFunc={updateOperateDataButtonFunc} />
<SubmitButton submitFunc={submitFunc} />
{submitOk && <SubmitButton submitFunc={submitFunc} />}
</>
)}
{!isMainFacilityTab && activeTabStatus?.laeSbmsnSttsCd === '2' && (
{!isMainFacilityTab && activeTabStatus?.laeSbmsnSttsCd === '2' && submitOk && (
<CancelSubmitButton cnacelSubmitFunc={cnacelSubmitFunc} />
)}
{showSaveInToolbar && <SaveButton saveFunc={saveFunc} />}
@@ -12,7 +12,7 @@ import { useConfirm } from "@frontend-opensource/use-react-hooks";
import { ValueType } from "realgrid";
import type { RealGridReact } from "realgrid-react";
import { useAlertStore, useGlobalProgressStore, useStatisticsInputToolbarGroupGate } from "@/shared/lib";
import { useAlertStore, useGlobalProgressStore, useStatisticsInputToolbarGroupGate, useSearchConditionSidoList } from "@/shared/lib";
import { STATISTICS_INPUT_URL_PATH } from "@/shared/lib/stats-cd-input-navigation";
import { useStatisticsInputPendingNavigation } from "@/shared/lib/use-statistics-input-pending-navigation";
import { ConfirmDialog } from "@/shared/ui/confirm-dialog";
@@ -35,7 +35,16 @@ import type {
ImrStatusResponse,
SewerageStatusInfo,
Sgg,
Sido,
} from "@/entities/statistics/model/statistics-interface";
import {
filterBySelectedAdmdstCd,
isGugunOkForToolbar,
isSubmitOkForToolbar,
resolveNoApplicableForRequest,
toInputSearchRegion,
} from "@/entities/statistics";
import { LoadingWithAnimation } from "@common/components";
import { getUserInfo } from "../../../../../../packages/common/components/src/api";
@@ -61,7 +70,6 @@ import type {
ColumnConfig,
} from "@/components/type/DataGrid.type";
import type { SearchFormValues } from "@/components/type/SearchForm.type";
import { doList } from "@/components/util/column/input/DoList";
import { PumpingStationInpColumn } from "@/components/util/column/input/PumpingStationInpColumn";
import { toGridRows } from "@/components/util/grid/gridFunction";
import { formatCompactYmdForGrid, toCompactYmdOrNull } from "@/components/util/grid/ymdFormat";
@@ -94,10 +102,22 @@ const computeTabEnterable = (
return periodEnterable;
};
const sidoListRef: { current: Sido[] } = { current: [] };
function buildGugunOkForToolbar(values: SearchFormValues | null): boolean {
return doList.includes(values?.bsnmCd || "")
? Boolean(values?.gugun && values.gugun !== "ALL")
: true;
return isGugunOkForToolbar(sidoListRef.current, values);
}
function buildSubmitOkForToolbar(values: SearchFormValues | null): boolean {
return isSubmitOkForToolbar(sidoListRef.current, values);
}
function buildNoApplicableForRequest(
values: SearchFormValues | null,
checked: boolean,
isSaveListEmpty: boolean,
): boolean {
return resolveNoApplicableForRequest(sidoListRef.current, values, checked, isSaveListEmpty);
}
function computeTabToolbarSnapshot(
@@ -131,9 +151,8 @@ function buildPumpingStationSearchParam(
const fcltNm = values.fctName?.trim();
return {
statsYr: values.year,
sewerBzmnCd: values.bsnmCd,
ctpvNm: values.sido,
sggNm: values.gugun === "ALL" ? "" : values.gugun,
...toInputSearchRegion(sidoListRef.current, values),
...(fcltNm ? { fcltNm } : {}),
...(overrides?.mode ? { mode: overrides.mode } : {}),
};
@@ -309,6 +328,8 @@ const PUMPING_STATION_FACILITY_NAME_GUIDE_MESSAGE =
// 하수도 통계 관리 > 05. 펌프장 (SewageReservoirPumpInp 단일 탭 패턴)
const PumpingStationInp = () => {
const { sidoList } = useSearchConditionSidoList({ isInput: true });
sidoListRef.current = sidoList;
const { setMessage: alert } = useAlertStore((state) => state);
const { confirm } = useConfirm();
const { isAdminInfo } = useAdminStore();
@@ -460,7 +481,11 @@ const PumpingStationInp = () => {
const { commonInfo, statusInfo: nextStatusInfo, pumpingStationList } =
response.data;
const list = pumpingStationList ?? [];
const list = filterBySelectedAdmdstCd(
pumpingStationList ?? [],
sidoListRef.current,
values,
);
const gridRows = mapPumpingStationListToGridRows(list, commonInfo.ctpvNm);
setPumpingStationDeleteList([]);
@@ -578,12 +603,8 @@ const PumpingStationInp = () => {
const userInfo = await getUserInfo();
const requestData: cancelSubmitRequest = {
sewerBzmnCd: lastSearchedValues.bsnmCd ?? "",
...toInputSearchRegion(sidoListRef.current, lastSearchedValues),
ctpvNm: lastSearchedValues.sido ?? "",
sggNm:
lastSearchedValues.gugun === "ALL"
? ""
: (lastSearchedValues.gugun ?? ""),
statsYr: lastSearchedValues.year ?? "",
mdfrId: userInfo.userUnqId,
statsCd: statsCd || PUMPING_STATION_STATS_CD,
@@ -618,9 +639,9 @@ const PumpingStationInp = () => {
return;
}
const noApplicable = isNotApplicable;
const noApplicable = buildNoApplicableForRequest(lastSearchedValues, isNotApplicable, getCurrentRows().length === 0);
const currentData = getCurrentRows();
if (!noApplicable && currentData.length === 0) {
if (!noApplicable && currentData.length === 0 && buildSubmitOkForToolbar(lastSearchedValues)) {
alert("해당사항 없음을 체크해주세요.");
return;
}
@@ -647,7 +668,7 @@ const PumpingStationInp = () => {
if (!(await confirm("저장 하시겠습니까?"))) return;
commitGrid();
const noApplicable = isNotApplicable;
const noApplicable = buildNoApplicableForRequest(lastSearchedValues, isNotApplicable, getCurrentRows().length === 0);
const currentData = getCurrentRows();
const saveList = noApplicable
? []
@@ -658,7 +679,7 @@ const PumpingStationInp = () => {
.filter((row) => String(row.fcltSn ?? "").trim() !== "")
.map((row) => buildPumpingStationSaveItem(row, sggOptions));
if (!noApplicable && saveList.length === 0) {
if (!noApplicable && saveList.length === 0 && buildSubmitOkForToolbar(lastSearchedValues)) {
alert("해당사항 없음을 체크해주세요.");
return;
}
@@ -669,11 +690,7 @@ const PumpingStationInp = () => {
const response = await statisticsInputPumpingStationApi.savePumpingStationList({
statsYr: lastSearchedValues.year ?? "",
ctpvNm: lastSearchedValues.sido ?? "",
sggNm:
lastSearchedValues.gugun === "ALL"
? ""
: (lastSearchedValues.gugun ?? ""),
sewerBzmnCd: lastSearchedValues.bsnmCd ?? "",
...toInputSearchRegion(sidoListRef.current, lastSearchedValues),
userId: userInfo.userUnqId,
...(isAdminInfo ? { superAdmin: "superAdmin" } : {}),
noApplicable,
@@ -707,7 +724,7 @@ const PumpingStationInp = () => {
}
commitGrid();
const noApplicable = isNotApplicable;
const noApplicable = buildNoApplicableForRequest(lastSearchedValues, isNotApplicable, getCurrentRows().length === 0);
const currentData = getCurrentRows();
const submitList = noApplicable
? []
@@ -716,19 +733,15 @@ const PumpingStationInp = () => {
.filter((row) => String(row.fcltSn ?? "").trim() !== "")
.map((row) => buildPumpingStationSaveItem(row, sggOptions));
if (!noApplicable && submitList.length === 0) {
if (!noApplicable && submitList.length === 0 && buildSubmitOkForToolbar(lastSearchedValues)) {
alert("해당사항 없음을 체크해주세요.");
return;
}
const statsCdForSubmit = statsCd || PUMPING_STATION_STATS_CD;
const verificationQuery = {
sewerBzmnCd: lastSearchedValues.bsnmCd ?? "",
...toInputSearchRegion(sidoListRef.current, lastSearchedValues),
ctpvNm: lastSearchedValues.sido ?? "",
sggNm:
lastSearchedValues.gugun === "ALL"
? ""
: (lastSearchedValues.gugun ?? ""),
statsYr: lastSearchedValues.year ?? "",
statsCd: statsCdForSubmit,
};
@@ -745,11 +758,7 @@ const PumpingStationInp = () => {
const response = await statisticsInputPumpingStationApi.submitPumpingStationList({
statsYr: lastSearchedValues.year ?? "",
ctpvNm: lastSearchedValues.sido ?? "",
sggNm:
lastSearchedValues.gugun === "ALL"
? ""
: (lastSearchedValues.gugun ?? ""),
sewerBzmnCd: lastSearchedValues.bsnmCd ?? "",
...toInputSearchRegion(sidoListRef.current, lastSearchedValues),
userId: userInfo.userUnqId,
laePicNm: submitInfo.laePicNm,
laePicTelNo: submitInfo.laePicTelNo,
@@ -778,7 +787,7 @@ const PumpingStationInp = () => {
setGlobalProgressLabel("시계열 검증 진행 중...");
const imrParam = {
user_id: userInfo.userUnqId,
sewer_bzmn_cd: lastSearchedValues.bsnmCd ?? "",
sewer_bzmn_cd: lastSearchedValues?.bsnmCd ?? "",
stats_cd: statsCdForSubmit,
stats_yr: lastSearchedValues.year ?? "",
lae_sbmsn_stts_cd:
@@ -942,7 +951,7 @@ const PumpingStationInp = () => {
}
};
const searchContextForToolbar = lastSearchedValues ?? searchValues;
const searchContextForToolbar = lastSearchedValues;
const toolbarSnapshot = computeTabToolbarSnapshot(
statusInfo,
rowData.length > 0,
@@ -962,23 +971,23 @@ const PumpingStationInp = () => {
hasSearched &&
toolbarGroupAllowed &&
(showSaveInToolbar || showEnterableToolbarButtons);
const tabEnterableForGrid =
(computeTabEnterable(statusInfo, inputPeriodEnterable) || isAdminInfo) && inputPeriodEnterable;
const gugunOk = buildGugunOkForToolbar(searchContextForToolbar);
const submitOk = buildSubmitOkForToolbar(searchContextForToolbar);
const showNotApplicable =
searchLoaded &&
hasSearched &&
rowData.length === 0 &&
computeTabEnterable(statusInfo, inputPeriodEnterable);
const tabEnterableForGrid =
(computeTabEnterable(statusInfo, inputPeriodEnterable) || isAdminInfo) && inputPeriodEnterable;
const gugunOk = buildGugunOkForToolbar(lastSearchedValues);
computeTabEnterable(statusInfo, inputPeriodEnterable) &&
submitOk;
const verificationQueryContext = (() => {
const ctx = lastSearchedValues ?? searchValues;
if (!ctx?.year || !ctx?.sido || !ctx?.bsnmCd || !statsCd) return null;
return {
sewerBzmnCd: ctx.bsnmCd,
...toInputSearchRegion(sidoListRef.current, ctx),
ctpvNm: ctx.sido,
sggNm: ctx.gugun === "ALL" ? "" : (ctx.gugun ?? ""),
statsYr: ctx.year,
statsCd,
};
@@ -994,6 +1003,7 @@ const PumpingStationInp = () => {
<>
<div className="relative">
<SearchForm
isInput
key={searchFormRemountKey}
defaultValues={verificationSearchDefaults ?? undefined}
fctName={true}
@@ -1013,10 +1023,10 @@ const PumpingStationInp = () => {
<LastYearDataButton
getLastYearDataFunc={() => void getLastYearDataFunc()}
/>
<SubmitButton submitFunc={submitFunc} />
{submitOk && <SubmitButton submitFunc={submitFunc} />}
</>
)}
{statusInfo?.laeSbmsnSttsCd === "2" && (
{statusInfo?.laeSbmsnSttsCd === "2" && submitOk && (
<CancelSubmitButton cnacelSubmitFunc={cnacelSubmitFunc} />
)}
{showSaveInToolbar && <SaveButton saveFunc={saveFunc} />}
@@ -5,7 +5,7 @@ import { useConfirm } from "@frontend-opensource/use-react-hooks";
import { ValueType } from "realgrid";
import type { RealGridReact } from "realgrid-react";
import { useAlertStore, useGlobalProgressStore, useStatisticsInputToolbarGroupGate } from "@/shared/lib";
import { useAlertStore, useGlobalProgressStore, useStatisticsInputToolbarGroupGate, useSearchConditionSidoList } from "@/shared/lib";
import { STATISTICS_INPUT_URL_PATH } from "@/shared/lib/stats-cd-input-navigation";
import { useStatisticsInputPendingNavigation } from "@/shared/lib/use-statistics-input-pending-navigation";
import { ConfirmDialog } from "@/shared/ui/confirm-dialog";
@@ -34,7 +34,16 @@ import type {
ImrStatusResponse,
SewerageStatusInfo,
Sgg,
Sido,
} from "@/entities/statistics/model/statistics-interface";
import {
filterBySelectedAdmdstCd,
isGugunOkForToolbar,
isSubmitOkForToolbar,
resolveNoApplicableForRequest,
toInputSearchRegion,
} from "@/entities/statistics";
import { LoadingWithAnimation, Tabs, TabsContent, TabsList, TabsTrigger } from "@common/components";
import { getUserInfo } from "../../../../../../packages/common/components/src/api";
@@ -63,7 +72,6 @@ import type {
ColumnInfo,
} from "@/components/type/DataGrid.type";
import type { SearchFormValues } from "@/components/type/SearchForm.type";
import { doList } from "@/components/util/column/input/DoList";
import { ExcretaRelatedIndustryInpColumn } from "@/components/util/column/input/sewageExcretaRelated/ExcretaRelatedIndustryInpColumn";
import { PrivateSewageTreatRelatedIndustryInpColumn } from "@/components/util/column/input/sewageExcretaRelated/PrivateSewageTreatRelatedIndustryInpColumn";
import { PublicInstitutionExcretaIndustryInpColumn } from "@/components/util/column/input/sewageExcretaRelated/PublicInstitutionExcretaIndustryInpColumn";
@@ -158,10 +166,22 @@ const computeTabEnterable = (
return periodEnterable;
};
const sidoListRef: { current: Sido[] } = { current: [] };
function buildGugunOkForToolbar(values: SearchFormValues | null): boolean {
return doList.includes(values?.bsnmCd || "")
? Boolean(values?.gugun && values.gugun !== "ALL")
: true;
return isGugunOkForToolbar(sidoListRef.current, values);
}
function buildSubmitOkForToolbar(values: SearchFormValues | null): boolean {
return isSubmitOkForToolbar(sidoListRef.current, values);
}
function buildNoApplicableForRequest(
values: SearchFormValues | null,
checked: boolean,
isSaveListEmpty: boolean,
): boolean {
return resolveNoApplicableForRequest(sidoListRef.current, values, checked, isSaveListEmpty);
}
function computeTabToolbarSnapshot(
@@ -543,9 +563,8 @@ function buildSewageExcretaRelatedSearchParam(
): SewageExcretaRelatedRequestParams {
return {
statsYr: values.year,
sewerBzmnCd: values.bsnmCd,
ctpvNm: values.sido,
sggNm: values.gugun === "ALL" ? "" : values.gugun,
...toInputSearchRegion(sidoListRef.current, values),
...(overrides?.mode ? { mode: overrides.mode } : {}),
};
}
@@ -553,8 +572,9 @@ function buildSewageExcretaRelatedSearchParam(
function mapListToGridRows<T extends { verificationResult?: SewageExcretaRelatedVerificationResult }>(
list: T[] | undefined,
ctpvNm: string,
values?: SearchFormValues | null,
): GridRowWithVerification[] {
return (list ?? []).map((item) => {
return filterBySelectedAdmdstCd(list, sidoListRef.current, values).map((item) => {
const row = toGridRows([{ ctpvNm, ...item }])[0] as GridRowWithVerification;
if (item.verificationResult) {
row.verificationResult = item.verificationResult;
@@ -590,6 +610,8 @@ async function waitForImrJobCompleted(
// 하수도 통계 관리 > 12. 하수 및 분뇨관련산업
const SewageExcretaRelatedInp = () => {
const { sidoList } = useSearchConditionSidoList({ isInput: true });
sidoListRef.current = sidoList;
const { setMessage: alert } = useAlertStore((state) => state);
const { confirm } = useConfirm();
const isAdminInfo = useAdminStore((state) => state.isAdminInfo);
@@ -606,7 +628,7 @@ const SewageExcretaRelatedInp = () => {
const [tabStatusInfoMap, setTabStatusInfoMap] = useState<
Map<string, SewerageStatusInfo | null>
>(new Map());
const [toolbarSnapshotByTab, setToolbarSnapshotByTab] = useState<
const [_toolbarSnapshotByTab, setToolbarSnapshotByTab] = useState<
Map<string, TabToolbarSnapshot>
>(new Map());
const [columnGuidesByTab, setColumnGuidesByTab] = useState<
@@ -616,6 +638,9 @@ const SewageExcretaRelatedInp = () => {
const [lastSearchedValues, setLastSearchedValues] = useState<SearchFormValues | null>(
null,
);
const [searchContextByTab, setSearchContextByTab] = useState<Map<string, SearchFormValues>>(
() => new Map(),
);
const [hasSearched, setHasSearched] = useState(false);
const [isLoading, setIsLoading] = useState(false);
const [inputPeriodEnterable, setInputPeriodEnterable] = useState(true);
@@ -739,6 +764,13 @@ const SewageExcretaRelatedInp = () => {
);
return next;
});
if (searchContext) {
setSearchContextByTab((prev) => {
const next = new Map(prev);
next.set(tabKey, searchContext);
return next;
});
}
};
const markTabLoaded = (tabKey: string) => {
@@ -854,6 +886,7 @@ const SewageExcretaRelatedInp = () => {
const gridRows = mapListToGridRows(
publicInstitutionSewerIndustryList,
commonInfo.ctpvNm,
searchContext,
);
syncPublicInstitutionArticleTracking(
tabKey,
@@ -900,6 +933,7 @@ const SewageExcretaRelatedInp = () => {
const gridRows = mapListToGridRows(
publicInstitutionExcretaIndustryList,
commonInfo.ctpvNm,
searchContext,
);
syncPublicInstitutionArticleTracking(
tabKey,
@@ -942,7 +976,7 @@ const SewageExcretaRelatedInp = () => {
return false;
}
const { commonInfo, statusInfo, excretaRelatedIndustryList } = response.data;
const gridRows = mapListToGridRows(excretaRelatedIndustryList, commonInfo.ctpvNm);
const gridRows = mapListToGridRows(excretaRelatedIndustryList, commonInfo.ctpvNm, searchContext);
applyRowMap(mergeIntoExistingMap, (m) => {
m.set(ExcretaRelatedIndustryInpColumn.tabKey, gridRows);
});
@@ -979,6 +1013,7 @@ const SewageExcretaRelatedInp = () => {
const gridRows = mapListToGridRows(
privateSewageTreatRelatedIndustryList,
commonInfo.ctpvNm,
searchContext,
);
applyRowMap(mergeIntoExistingMap, (m) => {
m.set(PrivateSewageTreatRelatedIndustryInpColumn.tabKey, gridRows);
@@ -1010,6 +1045,7 @@ const SewageExcretaRelatedInp = () => {
setRowDataMap(new Map());
setTabStatusInfoMap(new Map());
setToolbarSnapshotByTab(new Map());
setSearchContextByTab(new Map());
setActiveTab(firstTabKey);
activeTabRef.current = firstTabKey;
setLastSearchedValues(null);
@@ -1075,6 +1111,7 @@ const SewageExcretaRelatedInp = () => {
setIsVerificationFailedByTab(new Map());
setFooterVerificationByTab(new Map());
setToolbarSnapshotByTab(new Map());
setSearchContextByTab(new Map());
setIsNotApplicableByTab(new Map());
setDeleteListByTab(new Map());
clearArticleOgnzSnTracking(
@@ -1139,9 +1176,8 @@ const SewageExcretaRelatedInp = () => {
const statsCdForTab = tabStatsCdMap.get(tabKey) ?? tabKey;
const requestData: cancelSubmitRequest = {
sewerBzmnCd: ctx.bsnmCd ?? "",
...toInputSearchRegion(sidoListRef.current, ctx),
ctpvNm: ctx.sido ?? "",
sggNm: ctx.gugun === "ALL" ? "" : (ctx.gugun ?? ""),
statsYr: ctx.year ?? "",
mdfrId: userInfo.userUnqId,
statsCd: statsCdForTab,
@@ -1232,10 +1268,10 @@ const SewageExcretaRelatedInp = () => {
}
commitActiveGrid();
const noApplicable = isNotApplicableByTab.get(tabKey) ?? false;
const noApplicable = buildNoApplicableForRequest(searchContextByTab.get(tabKey) ?? lastSearchedValues, isNotApplicableByTab.get(tabKey) ?? false, getTabGridRows(tabKey).length === 0);
const currentData = getTabGridRows(tabKey);
if (NOT_APPLICABLE_TAB_KEYS.has(tabKey)) {
if (!noApplicable && currentData.length === 0) {
if (!noApplicable && currentData.length === 0 && buildSubmitOkForToolbar(searchContextByTab.get(tabKey) ?? lastSearchedValues)) {
alert("해당사항 없음을 체크해주세요.");
return;
}
@@ -1269,18 +1305,14 @@ const SewageExcretaRelatedInp = () => {
const isDistrictRowTab = DISTRICT_ROW_TAB_KEYS.has(tabKey);
const isPublicInstitutionTab = ARTICLE_EDIT_TAB_KEYS.has(tabKey);
const noApplicable = isNotApplicableByTab.get(tabKey) ?? false;
const noApplicable = buildNoApplicableForRequest(searchContextByTab.get(tabKey) ?? lastSearchedValues, isNotApplicableByTab.get(tabKey) ?? false, getTabGridRows(tabKey).length === 0);
const currentData = getTabGridRows(tabKey);
const mapRows = rowDataMap.get(tabKey) ?? [];
const searchContextBase = {
statsYr: lastSearchedValues.year ?? "",
ctpvNm: lastSearchedValues.sido ?? "",
sggNm:
lastSearchedValues.gugun === "ALL"
? ""
: (lastSearchedValues.gugun ?? ""),
sewerBzmnCd: lastSearchedValues.bsnmCd ?? "",
...toInputSearchRegion(sidoListRef.current, lastSearchedValues),
};
let submitList:
@@ -1341,7 +1373,7 @@ const SewageExcretaRelatedInp = () => {
)
.map((row) => buildPublicInstitutionIndustrySaveItem(row, list));
if (!noApplicable && submitList.length === 0) {
if (!noApplicable && submitList.length === 0 && buildSubmitOkForToolbar(searchContextByTab.get(tabKey) ?? lastSearchedValues)) {
alert("해당사항 없음을 체크해주세요.");
return;
}
@@ -1448,7 +1480,7 @@ const SewageExcretaRelatedInp = () => {
setGlobalProgressLabel("시계열 검증 진행 중...");
const imrParam = {
user_id: userInfo.userUnqId,
sewer_bzmn_cd: lastSearchedValues.bsnmCd ?? "",
sewer_bzmn_cd: lastSearchedValues?.bsnmCd ?? "",
stats_cd: statsCdForTab,
stats_yr: lastSearchedValues.year ?? "",
lae_sbmsn_stts_cd:
@@ -1527,18 +1559,14 @@ const SewageExcretaRelatedInp = () => {
const isDistrictRowTab = DISTRICT_ROW_TAB_KEYS.has(tabKey);
const isPublicInstitutionTab = ARTICLE_EDIT_TAB_KEYS.has(tabKey);
const noApplicable = isNotApplicableByTab.get(tabKey) ?? false;
const noApplicable = buildNoApplicableForRequest(searchContextByTab.get(tabKey) ?? lastSearchedValues, isNotApplicableByTab.get(tabKey) ?? false, getTabGridRows(tabKey).length === 0);
const currentData = getTabGridRows(tabKey);
const mapRows = rowDataMap.get(tabKey) ?? [];
const baseSaveRequest = {
statsYr: lastSearchedValues.year ?? "",
ctpvNm: lastSearchedValues.sido ?? "",
sggNm:
lastSearchedValues.gugun === "ALL"
? ""
: (lastSearchedValues.gugun ?? ""),
sewerBzmnCd: lastSearchedValues.bsnmCd ?? "",
...toInputSearchRegion(sidoListRef.current, lastSearchedValues),
...(isPublicInstitutionTab && noApplicable
? { noApplicable: true as const }
: {}),
@@ -1621,7 +1649,7 @@ const SewageExcretaRelatedInp = () => {
)
.map((row) => buildPublicInstitutionIndustrySaveItem(row, list));
if (!noApplicable && saveList.length === 0) {
if (!noApplicable && saveList.length === 0 && buildSubmitOkForToolbar(searchContextByTab.get(tabKey) ?? lastSearchedValues)) {
alert("해당사항 없음을 체크해주세요.");
return;
}
@@ -1885,11 +1913,10 @@ const SewageExcretaRelatedInp = () => {
[publicInstitutionArticleCellStyleCallback],
);
const searchContextForToolbar = lastSearchedValues ?? searchValues;
const searchContextForToolbar = searchContextByTab.get(activeTab) ?? lastSearchedValues;
const activeTabStatus = tabStatusInfoMap.get(activeTab) ?? null;
const activeTabHasRowData = tabRowDataExists(rowDataMap, activeTab);
const activeTabToolbar =
toolbarSnapshotByTab.get(activeTab) ??
computeTabToolbarSnapshot(
activeTabStatus,
activeTabHasRowData,
@@ -1907,10 +1934,13 @@ const SewageExcretaRelatedInp = () => {
(activeTabToolbar.showActionToolbarCard || (hasSearched && loadedTabKeys.has(activeTab)));
const showArticleEditButtons =
ARTICLE_EDIT_TAB_KEYS.has(activeTab) && showEnterableToolbarButtons;
const gugunOk = buildGugunOkForToolbar(searchContextForToolbar);
const submitOk = buildSubmitOkForToolbar(searchContextForToolbar);
const showNotApplicableForActiveTab =
NOT_APPLICABLE_TAB_KEYS.has(activeTab) &&
loadedTabKeys.has(activeTab) &&
shouldShowNotApplicable(activeTab, activeTabHasRowData, activeTabStatus);
shouldShowNotApplicable(activeTab, activeTabHasRowData, activeTabStatus) &&
submitOk;
const showSecondaryToolbarCard =
hasSearched &&
toolbarGroupAllowed &&
@@ -1928,16 +1958,14 @@ const SewageExcretaRelatedInp = () => {
},
[isNotApplicableByTab, setIsNotApplicableForTab],
);
const gugunOk = buildGugunOkForToolbar(lastSearchedValues);
const verificationQueryContext = (() => {
const ctx = lastSearchedValues ?? searchValues;
const statsCd = tabStatsCdMap.get(activeTab) ?? activeTab;
if (!ctx?.year || !ctx?.sido || !ctx?.bsnmCd || !statsCd) return null;
return {
sewerBzmnCd: ctx.bsnmCd,
...toInputSearchRegion(sidoListRef.current, ctx),
ctpvNm: ctx.sido,
sggNm: ctx.gugun === "ALL" ? "" : (ctx.gugun ?? ""),
statsYr: ctx.year,
statsCd,
};
@@ -1958,6 +1986,7 @@ const SewageExcretaRelatedInp = () => {
<>
<div className="relative">
<SearchForm
isInput
key={searchFormRemountKey}
defaultValues={verificationSearchDefaults ?? undefined}
onSubmit={handleSearch}
@@ -1978,10 +2007,10 @@ const SewageExcretaRelatedInp = () => {
<LastYearDataButton
getLastYearDataFunc={() => void lastYearDataFunc()}
/>
<SubmitButton submitFunc={submitFunc} />
{submitOk && <SubmitButton submitFunc={submitFunc} />}
</>
)}
{activeTabStatus?.laeSbmsnSttsCd === "2" && (
{activeTabStatus?.laeSbmsnSttsCd === "2" && submitOk && (
<CancelSubmitButton cnacelSubmitFunc={cnacelSubmitFunc} />
)}
{showSaveInToolbar && <SaveButton saveFunc={saveFunc} />}
@@ -13,7 +13,7 @@ import { useConfirm } from "@frontend-opensource/use-react-hooks";
import { ValueType } from "realgrid";
import type { RealGridReact } from "realgrid-react";
import { useAlertStore, useGlobalProgressStore, useStatisticsInputToolbarGroupGate } from "@/shared/lib";
import { useAlertStore, useGlobalProgressStore, useStatisticsInputToolbarGroupGate, useSearchConditionSidoList } from "@/shared/lib";
import { STATISTICS_INPUT_URL_PATH } from "@/shared/lib/stats-cd-input-navigation";
import { useStatisticsInputPendingNavigation } from "@/shared/lib/use-statistics-input-pending-navigation";
import { ConfirmDialog } from "@/shared/ui/confirm-dialog";
@@ -37,7 +37,15 @@ import {
} from "@/entities/statistics/model/input/statistics-input-sewage-excreta-slurge-interface";
import { isInputPeriodCurrent } from "@/entities/statistics/model/input/statistics-sewage-supply-rate-input-interface";
import type { StatisticsInputSubmitInfoFormData } from "@/entities/statistics/model/statistics-input-submit-info-schema";
import type { ApiResponse, cancelSubmitRequest, ImrStatusResponse, SewerageStatusInfo, Sgg } from "@/entities/statistics/model/statistics-interface";
import type { ApiResponse, cancelSubmitRequest, ImrStatusResponse, SewerageStatusInfo, Sgg, Sido } from "@/entities/statistics/model/statistics-interface";
import {
filterBySelectedAdmdstCd,
isGugunOkForToolbar,
isSubmitOkForToolbar,
resolveNoApplicableForRequest,
toInputSearchRegion,
} from "@/entities/statistics";
import { LoadingWithAnimation, Tabs, TabsContent, TabsList, TabsTrigger } from "@common/components";
import { getUserInfo } from "../../../../../../packages/common/components/src/api";
@@ -67,7 +75,6 @@ import type {
ColumnInfo,
} from "@/components/type/DataGrid.type";
import type { SearchFormValues } from "@/components/type/SearchForm.type";
import { doList } from "@/components/util/column/input/DoList";
import {
DIGESTOR_OPERATING_STATUS_EN_YN_FIELD,
DigestorOperatingStatusInpColumn,
@@ -163,9 +170,8 @@ function buildSewageExcretaSlurgeSearchParam(
): SewageExcretaSlurgeRequestParams {
return {
statsYr: values.year,
sewerBzmnCd: values.bsnmCd,
ctpvNm: values.sido,
sggNm: values.gugun === "ALL" ? "" : values.gugun,
...toInputSearchRegion(sidoListRef.current, values),
fcltNm: values.fctName?.trim() || undefined,
...(overrides?.mode ? { mode: overrides.mode } : {}),
};
@@ -174,8 +180,9 @@ function buildSewageExcretaSlurgeSearchParam(
function mapListToGridRows<T extends { verificationResult?: SewageExcretaSlurgeVerificationResult }>(
list: T[] | undefined,
ctpvNm: string,
values?: SearchFormValues | null,
): GridRowWithVerification[] {
return (list ?? []).map((item) => {
return filterBySelectedAdmdstCd(list, sidoListRef.current, values).map((item) => {
const row = toGridRows([{ ctpvNm, ...item }])[0] as GridRowWithVerification;
if (item.verificationResult) {
row.verificationResult = item.verificationResult;
@@ -345,10 +352,22 @@ const computeTabEnterable = (
return periodEnterable;
};
const sidoListRef: { current: Sido[] } = { current: [] };
function buildGugunOkForToolbar(values: SearchFormValues | null): boolean {
return doList.includes(values?.bsnmCd || "")
? Boolean(values?.gugun && values.gugun !== "ALL")
: true;
return isGugunOkForToolbar(sidoListRef.current, values);
}
function buildSubmitOkForToolbar(values: SearchFormValues | null): boolean {
return isSubmitOkForToolbar(sidoListRef.current, values);
}
function buildNoApplicableForRequest(
values: SearchFormValues | null,
checked: boolean,
isSaveListEmpty: boolean,
): boolean {
return resolveNoApplicableForRequest(sidoListRef.current, values, checked, isSaveListEmpty);
}
function computeTabToolbarSnapshot(
@@ -491,7 +510,7 @@ function buildSlurgeProcessingFacStatusSaveItem(
itslfTs1AltdQnt: toGridNumber(row.itslfTs1AltdQnt),
itslfTs1DryQnt: toGridNumber(row.itslfTs1DryQnt),
itslfTs1FuelQnt: toGridNumber(row.itslfTs1FuelQnt),
itslfTs2CmpstgQnt: toGridNumber(row.itslfTs2CmpstgQnt),
itslfTs1CmpstgQnt: toGridNumber(row.itslfTs1CmpstgQnt),
cmpsPrcsFcltBzentyNm: nullableTrimmedString(row.cmpsPrcsFcltBzentyNm),
incnrPrcsLfvlm: toGridNumber(row.incnrPrcsLfvlm),
incnrPrcsPrdctRmtrlQnt: toGridNumber(row.incnrPrcsPrdctRmtrlQnt),
@@ -644,6 +663,8 @@ async function waitForImrJobCompleted(
// 하수도 통계 관리 > 11. 하수 및 분뇨찌꺼기(슬러지)처리
const SewageExcretaSlurgeInp = () => {
const { sidoList } = useSearchConditionSidoList({ isInput: true });
sidoListRef.current = sidoList;
const { isAdminInfo } = useAdminStore();
const { confirm } = useConfirm();
const { setMessage: alert } = useAlertStore((state) => state);
@@ -678,6 +699,9 @@ const SewageExcretaSlurgeInp = () => {
const [_toolbarSnapshotByTab, setToolbarSnapshotByTab] = useState<
Map<string, TabToolbarSnapshot>
>(new Map());
const [searchContextByTab, setSearchContextByTab] = useState<Map<string, SearchFormValues>>(
() => new Map(),
);
const [sggOptions, setSggOptions] = useState<Sgg[]>([]);
const [loadedTabKeys, setLoadedTabKeys] = useState<Set<string>>(() => new Set());
const [verificationHistoryOpen, setVerificationHistoryOpen] = useState(false);
@@ -790,6 +814,13 @@ const SewageExcretaSlurgeInp = () => {
);
return next;
});
if (searchContext) {
setSearchContextByTab((prev) => {
const next = new Map(prev);
next.set(tabKey, searchContext);
return next;
});
}
};
const getTabGridRows = (tabKey: string): Record<string, string | number>[] =>
@@ -923,7 +954,7 @@ const SewageExcretaSlurgeInp = () => {
return false;
}
const { commonInfo, statusInfo, slurgeProcessingFacStatusList } = response.data;
const gridRows = mapListToGridRows(slurgeProcessingFacStatusList, commonInfo.ctpvNm);
const gridRows = mapListToGridRows(slurgeProcessingFacStatusList, commonInfo.ctpvNm, searchContext);
syncSlurgeFacStatusArticleFcltSnTracking(gridRows, fromPreYear);
applyRowMap(mergeIntoExistingMap, (m) => {
m.set(SlurgeProcessingFacStatusInpColumn.tabKey, gridRows);
@@ -958,7 +989,7 @@ const SewageExcretaSlurgeInp = () => {
return false;
}
const { commonInfo, statusInfo, digestorOperatingStatusList } = response.data;
const gridRows = mapListToGridRows(digestorOperatingStatusList, commonInfo.ctpvNm);
const gridRows = mapListToGridRows(digestorOperatingStatusList, commonInfo.ctpvNm, searchContext);
if (!fromPreYear) {
publicSewageFacilitiesAvailableRef.current = gridRows.length > 0;
if (gridRows.length === 0 && overrides?.alertIfDigestorEmpty) {
@@ -1002,6 +1033,7 @@ const SewageExcretaSlurgeInp = () => {
const gridRows = mapListToGridRows(
sewageSlurgeProcessingFacStatusList,
commonInfo.ctpvNm,
searchContext,
);
applyRowMap(mergeIntoExistingMap, (m) => {
m.set(SewageSlurgeProcessingFacStatusInpColumn.tabKey, gridRows);
@@ -1039,6 +1071,7 @@ const SewageExcretaSlurgeInp = () => {
const gridRows = mapListToGridRows(
excretaSlurgeProcessingStatusList,
commonInfo.ctpvNm,
searchContext,
);
if (!fromPreYear) {
excretaTreatmentFacilitiesAvailableRef.current = gridRows.length > 0;
@@ -1080,6 +1113,7 @@ const SewageExcretaSlurgeInp = () => {
setIsVerificationFailedByTab(new Map());
setFooterVerificationByTab(new Map());
setToolbarSnapshotByTab(new Map());
setSearchContextByTab(new Map());
setActiveTab(firstTabKey);
activeTabRef.current = firstTabKey;
setLastSearchedValues(null);
@@ -1139,6 +1173,7 @@ const SewageExcretaSlurgeInp = () => {
setIsVerificationFailedByTab(new Map());
setFooterVerificationByTab(new Map());
setToolbarSnapshotByTab(new Map());
setSearchContextByTab(new Map());
loadedTabKeysRef.current.clear();
setLoadedTabKeys(new Set());
setDeleteListByTab(new Map());
@@ -1247,9 +1282,9 @@ const SewageExcretaSlurgeInp = () => {
}
commitActiveGrid();
const noApplicable = isNotApplicableByTab.get(tabKey) ?? false;
const noApplicable = buildNoApplicableForRequest(searchContextByTab.get(tabKey) ?? lastSearchedValues, isNotApplicableByTab.get(tabKey) ?? false, getTabGridRows(tabKey).length === 0);
const currentData = getTabGridRows(tabKey);
if (!noApplicable && currentData.length === 0) {
if (!noApplicable && currentData.length === 0 && buildSubmitOkForToolbar(searchContextByTab.get(tabKey) ?? lastSearchedValues)) {
alert("해당사항 없음을 체크해주세요.");
return;
}
@@ -1277,7 +1312,7 @@ const SewageExcretaSlurgeInp = () => {
commitActiveGrid();
const noApplicable = isNotApplicableByTab.get(tabKey) ?? false;
const noApplicable = buildNoApplicableForRequest(searchContextByTab.get(tabKey) ?? lastSearchedValues, isNotApplicableByTab.get(tabKey) ?? false, getTabGridRows(tabKey).length === 0);
const currentData = getTabGridRows(tabKey);
const mapRows = rowDataMap.get(tabKey) ?? [];
@@ -1335,6 +1370,7 @@ const SewageExcretaSlurgeInp = () => {
if (
!noApplicable &&
buildSubmitOkForToolbar(searchContextByTab.get(tabKey) ?? lastSearchedValues) &&
((isSlurgeFacTab && slurgeSubmitList.length === 0) ||
(isDigestorTab && digestorSubmitList.length === 0) ||
(isSewageSlurgeFacTab && sewageSlurgeFacSubmitList.length === 0) ||
@@ -1356,12 +1392,8 @@ const SewageExcretaSlurgeInp = () => {
: SEWAGE_EXCRETA_SLURGE_PROCESSING_FAC_STATUS_STATS_CD);
const verificationQuery = {
sewerBzmnCd: lastSearchedValues.bsnmCd ?? "",
...toInputSearchRegion(sidoListRef.current, lastSearchedValues),
ctpvNm: lastSearchedValues.sido ?? "",
sggNm:
lastSearchedValues.gugun === "ALL"
? ""
: (lastSearchedValues.gugun ?? ""),
statsYr: lastSearchedValues.year ?? "",
statsCd: statsCdForSubmit,
};
@@ -1390,11 +1422,7 @@ const SewageExcretaSlurgeInp = () => {
const submitRequestBase = {
statsYr: lastSearchedValues.year ?? "",
ctpvNm: lastSearchedValues.sido ?? "",
sggNm:
lastSearchedValues.gugun === "ALL"
? ""
: (lastSearchedValues.gugun ?? ""),
sewerBzmnCd: lastSearchedValues.bsnmCd ?? "",
...toInputSearchRegion(sidoListRef.current, lastSearchedValues),
userId: "",
laePicNm: submitInfo.laePicNm,
laePicTelNo: submitInfo.laePicTelNo,
@@ -1455,7 +1483,7 @@ const SewageExcretaSlurgeInp = () => {
setGlobalProgressLabel("시계열 검증 진행 중...");
const imrParam = {
user_id: userInfo.userUnqId,
sewer_bzmn_cd: lastSearchedValues.bsnmCd ?? "",
sewer_bzmn_cd: lastSearchedValues?.bsnmCd ?? "",
stats_cd: statsCdForSubmit,
stats_yr: lastSearchedValues.year ?? "",
lae_sbmsn_stts_cd:
@@ -1532,12 +1560,8 @@ const SewageExcretaSlurgeInp = () => {
}
const requestData: cancelSubmitRequest = {
sewerBzmnCd: lastSearchedValues.bsnmCd ?? "",
...toInputSearchRegion(sidoListRef.current, lastSearchedValues),
ctpvNm: lastSearchedValues.sido ?? "",
sggNm:
lastSearchedValues.gugun === "ALL"
? ""
: (lastSearchedValues.gugun ?? ""),
statsYr: lastSearchedValues.year ?? "",
mdfrId: userInfo.userUnqId,
statsCd: statsCdForTab,
@@ -1585,7 +1609,7 @@ const SewageExcretaSlurgeInp = () => {
commitActiveGrid();
const noApplicable = isNotApplicableByTab.get(tabKey) ?? false;
const noApplicable = buildNoApplicableForRequest(searchContextByTab.get(tabKey) ?? lastSearchedValues, isNotApplicableByTab.get(tabKey) ?? false, getTabGridRows(tabKey).length === 0);
const currentData = getTabGridRows(tabKey);
const mapRows = rowDataMap.get(tabKey) ?? [];
@@ -1603,11 +1627,7 @@ const SewageExcretaSlurgeInp = () => {
const baseSaveRequest = {
statsYr: lastSearchedValues.year ?? "",
ctpvNm: lastSearchedValues.sido ?? "",
sggNm:
lastSearchedValues.gugun === "ALL"
? ""
: (lastSearchedValues.gugun ?? ""),
sewerBzmnCd: lastSearchedValues.bsnmCd ?? "",
...toInputSearchRegion(sidoListRef.current, lastSearchedValues),
...(noApplicable ? { noApplicable: true } : {}),
};
@@ -1638,7 +1658,7 @@ const SewageExcretaSlurgeInp = () => {
.filter((row) => isPersistedArticleRowForTab(tabKey, row))
.map((row) => buildSlurgeProcessingFacStatusSaveItem(row, list));
if (!noApplicable && saveList.length === 0) {
if (!noApplicable && saveList.length === 0 && buildSubmitOkForToolbar(searchContextByTab.get(tabKey) ?? lastSearchedValues)) {
alert("해당사항 없음을 체크해주세요.");
return;
}
@@ -1665,7 +1685,7 @@ const SewageExcretaSlurgeInp = () => {
buildDigestorOperatingStatusSaveItem(row, list),
);
if (!noApplicable && saveList.length === 0) {
if (!noApplicable && saveList.length === 0 && buildSubmitOkForToolbar(searchContextByTab.get(tabKey) ?? lastSearchedValues)) {
alert("해당사항 없음을 체크해주세요.");
return;
}
@@ -1691,7 +1711,7 @@ const SewageExcretaSlurgeInp = () => {
.filter((row) => isPersistedArticleRowForTab(tabKey, row))
.map((row) => buildSewageSlurgeProcessingFacStatusSaveItem(row, list));
if (!noApplicable && saveList.length === 0) {
if (!noApplicable && saveList.length === 0 && buildSubmitOkForToolbar(searchContextByTab.get(tabKey) ?? lastSearchedValues)) {
alert("해당사항 없음을 체크해주세요.");
return;
}
@@ -1718,7 +1738,7 @@ const SewageExcretaSlurgeInp = () => {
buildExcretaSlurgeProcessingStatusSaveItem(row, list),
);
if (!noApplicable && saveList.length === 0) {
if (!noApplicable && saveList.length === 0 && buildSubmitOkForToolbar(searchContextByTab.get(tabKey) ?? lastSearchedValues)) {
alert("해당사항 없음을 체크해주세요.");
return;
}
@@ -1977,7 +1997,7 @@ const SewageExcretaSlurgeInp = () => {
[digestorOperatingCellStyleCallback],
);
const searchContextForToolbar = lastSearchedValues ?? searchValues;
const searchContextForToolbar = searchContextByTab.get(activeTab) ?? lastSearchedValues;
const activeTabStatus = tabStatusInfoMap.get(activeTab) ?? null;
const activeTabHasRowData = tabRowDataExists(rowDataMap, activeTab);
const activeTabToolbar = computeTabToolbarSnapshot(
@@ -1998,6 +2018,7 @@ const SewageExcretaSlurgeInp = () => {
const showSaveInToolbar = baseShowSaveInToolbar && toolbarGroupAllowed;
const showEnterableToolbarButtons =
baseShowEnterableToolbarButtons && toolbarGroupAllowed;
const submitOk = buildSubmitOkForToolbar(searchContextForToolbar);
const showActionToolbarCard =
toolbarGroupAllowed &&
(baseShowActionToolbarCard || (hasSearched && loadedTabKeys.has(activeTab)));
@@ -2005,7 +2026,8 @@ const SewageExcretaSlurgeInp = () => {
ARTICLE_EDIT_TAB_KEYS.has(activeTab) && showEnterableToolbarButtons;
const showNotApplicableForActiveTab =
loadedTabKeys.has(activeTab) &&
shouldShowNotApplicable(activeTabHasRowData, activeTabStatus);
shouldShowNotApplicable(activeTabHasRowData, activeTabStatus) &&
submitOk;
const showSecondaryToolbarCard =
hasSearched &&
toolbarGroupAllowed &&
@@ -2039,9 +2061,8 @@ const SewageExcretaSlurgeInp = () => {
const statsCd = tabStatsCdMap.get(activeTab);
if (!ctx?.year || !ctx?.sido || !ctx?.bsnmCd || !statsCd) return null;
return {
sewerBzmnCd: ctx.bsnmCd,
...toInputSearchRegion(sidoListRef.current, ctx),
ctpvNm: ctx.sido,
sggNm: ctx.gugun === "ALL" ? "" : (ctx.gugun ?? ""),
statsYr: ctx.year,
statsCd,
};
@@ -2062,6 +2083,7 @@ const SewageExcretaSlurgeInp = () => {
<>
<div className="relative">
<SearchForm
isInput
key={searchFormRemountKey}
defaultValues={verificationSearchDefaults ?? undefined}
fctName
@@ -2083,10 +2105,10 @@ const SewageExcretaSlurgeInp = () => {
<LastYearDataButton
getLastYearDataFunc={() => void lastYearDataFunc()}
/>
<SubmitButton submitFunc={submitFunc} />
{submitOk && <SubmitButton submitFunc={submitFunc} />}
</>
)}
{activeTabStatus?.laeSbmsnSttsCd === "2" && (
{activeTabStatus?.laeSbmsnSttsCd === "2" && submitOk && (
<CancelSubmitButton cnacelSubmitFunc={cnacelSubmitFunc} />
)}
{showSaveInToolbar && <SaveButton saveFunc={saveFunc} />}
@@ -2,7 +2,7 @@ import { useEffect, useLayoutEffect,useMemo, useRef, useState } from "react";
import { useConfirm } from "@frontend-opensource/use-react-hooks";
import { useAlertStore, useGlobalProgressStore, useStatisticsInputToolbarGroupGate } from "@/shared/lib";
import { useAlertStore, useGlobalProgressStore, useStatisticsInputToolbarGroupGate, useSearchConditionSidoList } from "@/shared/lib";
import {
STATISTICS_INPUT_URL_PATH,
verificationSearchToFormValues,
@@ -40,7 +40,15 @@ import type {
ImrStatusResponse,
SewerageStatusInfo,
SubmitExceptionRequest,
Sido,
} from "@/entities/statistics/model/statistics-interface";
import {
filterBySelectedAdmdstCd,
isGugunOkForToolbar,
isSubmitOkForToolbar,
toInputSearchRegion,
} from "@/entities/statistics";
import { LoadingWithAnimation, Tabs, TabsContent, TabsList, TabsTrigger } from "@common/components";
import { getUserInfo } from "../../../../../../packages/common/components/src/api";
@@ -61,7 +69,6 @@ import { VerificationResultDialog } from "@/components/module/VerificationResult
import { VerificationResultHistoryDialog } from "@/components/module/VerificationResultHistoryDialog";
import type { ColumnConfig, ColumnInfo, ColumnInfoList, ColumnLayoutItem } from "@/components/type/DataGrid.type";
import type { SearchFormValues } from "@/components/type/SearchForm.type";
import { doList } from "@/components/util/column/input/DoList";
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";
@@ -101,9 +108,8 @@ function buildSewagePipeSearchParam(
): SeweragePipeRequestParams {
return {
statsYr: values.year,
sewerBzmnCd: values.bsnmCd,
ctpvNm: values.sido,
sggNm: values.gugun === "ALL" ? "" : values.gugun,
...toInputSearchRegion(sidoListRef.current, values),
...(overrides?.mode ? { mode: overrides.mode } : {}),
};
}
@@ -431,10 +437,14 @@ type TabToolbarSnapshot = {
showActionToolbarCard: boolean;
};
const sidoListRef: { current: Sido[] } = { current: [] };
function buildGugunOkForToolbar(values: SearchFormValues | null): boolean {
return doList.includes(values?.bsnmCd || "")
? Boolean(values?.gugun && values.gugun !== "ALL")
: true;
return isGugunOkForToolbar(sidoListRef.current, values);
}
function buildSubmitOkForToolbar(values: SearchFormValues | null): boolean {
return isSubmitOkForToolbar(sidoListRef.current, values);
}
/**
@@ -466,6 +476,8 @@ function computeTabToolbarSnapshot(
// 하수도 통계 관리 > 02. 하수관로
const SewagePipeInp = () => {
const { sidoList, isReady } = useSearchConditionSidoList({ isInput: true });
sidoListRef.current = sidoList;
const [rowDataMap, setRowDataMap] = useState<Map<string, Record<string, string | number>[]>>(new Map());
const { setMessage: alert } = useAlertStore((state) => state);
const [activeTab, setActiveTab] = useState<string>(SewagePipeInpColumnInfoList[0]?.tabKey ?? "ST00020001");
@@ -494,7 +506,10 @@ const SewagePipeInp = () => {
/** checkInputPeriod — columnInfo useMemo가 입력기간 변경을 반영하도록 state로도 유지 */
const [inputPeriodEnterable, setInputPeriodEnterable] = useState(true);
/** 탭별 조회 시점의 상단 버튼 노출 조건(해당 탭을 다시 조회할 때만 그 탭 항목 갱신) */
const [toolbarSnapshotByTab, setToolbarSnapshotByTab] = useState<Map<string, TabToolbarSnapshot>>(
const [_toolbarSnapshotByTab, setToolbarSnapshotByTab] = useState<Map<string, TabToolbarSnapshot>>(
() => new Map(),
);
const [searchContextByTab, setSearchContextByTab] = useState<Map<string, SearchFormValues>>(
() => new Map(),
);
const { confirm } = useConfirm();
@@ -539,6 +554,7 @@ const SewagePipeInp = () => {
const inputFocusNonce = useStatisticsInputFocusStore((s) => s.nonce);
useLayoutEffect(() => {
if (activeTabId !== STATISTICS_INPUT_URL_PATH.SEWAGE_PIPE) return;
if (!isReady) return;
const pending = useStatisticsInputFocusStore
.getState()
.takePendingForUrl(STATISTICS_INPUT_URL_PATH.SEWAGE_PIPE);
@@ -547,12 +563,12 @@ const SewagePipeInp = () => {
activeTabRef.current = tabKey;
setActiveTab(tabKey);
if (search) {
const values = verificationSearchToFormValues(search);
const values = verificationSearchToFormValues(search, sidoList);
setVerificationSearchDefaults(values);
postVerificationSearchRef.current = { values, tabKey };
setSearchFormRemountKey((k) => k + 1);
}
}, [activeTabId, inputFocusNonce]);
}, [activeTabId, inputFocusNonce, isReady, sidoList]);
useEffect(() => {
if (activeTabId !== STATISTICS_INPUT_URL_PATH.SEWAGE_PIPE) return;
@@ -592,6 +608,7 @@ const SewagePipeInp = () => {
setHasSearched(false);
setInputPeriodEnterable(true);
setToolbarSnapshotByTab(new Map());
setSearchContextByTab(new Map());
searchParamRef.current = null;
searchDoneRef.current = false;
lazyTabLoggedRef.current.clear();
@@ -681,6 +698,13 @@ const SewagePipeInp = () => {
);
return next;
});
if (searchContext) {
setSearchContextByTab((prev) => {
const next = new Map(prev);
next.set(tabKey, searchContext);
return next;
});
}
};
/** mergeIntoExistingMap: true면 기존 맵에 병합(다른 탭 rowData·검색 후 다른 탭 캐시 유지). false면 맵 전체 교체 */
@@ -694,7 +718,7 @@ const SewagePipeInp = () => {
const searchConditionKey = JSON.stringify({
statsYr: searchParam.statsYr ?? "",
ctpvNm: searchParam.ctpvNm ?? "",
sggNm: searchParam.sggNm ?? "",
sggNm: values?.gugun === "ALL" ? "" : (values?.gugun ?? searchParam.sggNm ?? ""),
sewerBzmnCd: searchParam.sewerBzmnCd ?? "",
});
const applyRowMap = (apply: (m: Map<string, Record<string, string | number>[]>) => void) => {
@@ -710,12 +734,14 @@ const SewagePipeInp = () => {
setRowDataMap(next);
}
};
const filterFetched = <T,>(list: readonly T[] | null | undefined) =>
filterBySelectedAdmdstCd(list, sidoListRef.current, values);
if (tabKey === 'ST00020001') {
const response = await statisticsInputSewPipeApiService.getRegionalFactStatus(searchParam);
if (response.status === 'success') {
const commonInfo = response.data.commonInfo;
const convertedData = (response.data.regionalFactStatusList ?? []).map((d) => ({
const convertedData = filterFetched(response.data.regionalFactStatusList).map((d) => ({
ctpvNm: commonInfo.ctpvNm,
...d,
}));
@@ -745,7 +771,7 @@ const SewagePipeInp = () => {
const response = await statisticsInputSewPipeApiService.getFactInstallStatus(searchParam);
if (response.status === 'success') {
const commonInfo = response.data.commonInfo;
const convertedData = (response.data.factInstallStatusList ?? []).map((d) => ({
const convertedData = filterFetched(response.data.factInstallStatusList).map((d) => ({
ctpvNm: commonInfo.ctpvNm,
...d,
}));
@@ -792,7 +818,7 @@ const SewagePipeInp = () => {
const response = await statisticsInputSewPipeApiService.getPipeTypeStatus(searchParam);
if (response.status === 'success') {
const commonInfo = response.data.commonInfo;
const convertedData = (response.data.pipeTypeStatusList ?? []).map((d) =>
const convertedData = filterFetched(response.data.pipeTypeStatusList).map((d) =>
normalizePipeTypeStatusRow(d, commonInfo.ctpvNm),
);
applyRowMap((m) => m.set('ST00020003', toGridRows(convertedData)));
@@ -825,7 +851,7 @@ const SewagePipeInp = () => {
const response = await statisticsInputSewPipeApiService.getPipeDiameterStatus(searchParam);
if (response.status === 'success') {
const commonInfo = response.data.commonInfo;
const convertedData = (response.data.pipeDiameterStatusList ?? []).map((d) => ({
const convertedData = filterFetched(response.data.pipeDiameterStatusList).map((d) => ({
ctpvNm: commonInfo.ctpvNm,
...d,
}));
@@ -855,7 +881,7 @@ const SewagePipeInp = () => {
const response = await statisticsInputSewPipeApiService.getManholeStatus(searchParam);
if (response.status === 'success') {
const commonInfo = response.data.commonInfo;
const convertedData = (response.data.manholeStatusList ?? []).map((d) =>
const convertedData = filterFetched(response.data.manholeStatusList).map((d) =>
normalizeManholeStatusRow(d, commonInfo.ctpvNm),
);
applyRowMap((m) => m.set('ST00020005', toGridRows(convertedData)));
@@ -884,10 +910,10 @@ const SewagePipeInp = () => {
const response = await statisticsInputSewPipeApiService.getConnectionStatus(searchParam);
if (response.status === 'success') {
const commonInfo = response.data.commonInfo;
const facilityConvertedData = (response.data.facilityConnectionList ?? []).map((d) => ({
const facilityConvertedData = filterFetched(response.data.facilityConnectionList).map((d) => ({
...d,
}));
const adminConvertedData = (response.data.adminAreaConnectionList ?? []).map((d) => ({
const adminConvertedData = filterFetched(response.data.adminAreaConnectionList).map((d) => ({
...d,
ctpvNm: d.ctpvNm || commonInfo.ctpvNm,
}));
@@ -958,6 +984,7 @@ const SewagePipeInp = () => {
setFooterVerificationByTab(new Map());
setStatsCd("");
setToolbarSnapshotByTab(new Map());
setSearchContextByTab(new Map());
}
lazyTabLoggedRef.current.clear();
@@ -1119,9 +1146,8 @@ const SewagePipeInp = () => {
const params: SubmitExceptionRequest = {
...submitInfo,
sewerBzmnCd: searchValues?.bsnmCd ?? "",
...toInputSearchRegion(sidoListRef.current, searchValues),
ctpvNm: searchValues?.sido ?? "",
sggNm: searchValues?.gugun === "ALL" ? "" : (searchValues?.gugun ?? ""),
statsYr: searchValues?.year ?? "",
userId: userInfo.userUnqId,
statsCd: statsCdForTab,
@@ -1204,8 +1230,7 @@ const SewagePipeInp = () => {
const submitBase = {
statsYr: values.year ?? "",
ctpvNm: values.sido ?? "",
sggNm: values.gugun === "ALL" ? "" : (values.gugun ?? ""),
sewerBzmnCd: values.bsnmCd ?? "",
...toInputSearchRegion(sidoListRef.current, values),
userId: userInfo.userUnqId,
laePicNm: submitInfo.laePicNm,
laeKbrdrJbgdNm: submitInfo.laeKbrdrJbgdNm,
@@ -1463,7 +1488,7 @@ const SewagePipeInp = () => {
setGlobalProgressLabel("시계열 검증 진행 중...");
const imrParam = {
user_id: userInfo.userUnqId,
sewer_bzmn_cd: values.bsnmCd ?? "",
sewer_bzmn_cd: values?.bsnmCd ?? '',
stats_cd: statsCdForTab,
stats_yr: values.year ?? "",
lae_sbmsn_stts_cd: statusForTab?.laeSbmsnSttsCd === "4" ? "4" : "2",
@@ -1493,9 +1518,8 @@ const SewagePipeInp = () => {
);
await openVerificationResultDialogIfNeeded(
{
sewerBzmnCd: values.bsnmCd ?? "",
...toInputSearchRegion(sidoListRef.current, values),
ctpvNm: values.sido ?? "",
sggNm: values.gugun === "ALL" ? "" : (values.gugun ?? ""),
statsYr: values.year ?? "",
statsCd: statsCdForTab,
},
@@ -1512,9 +1536,8 @@ const SewagePipeInp = () => {
);
await openVerificationResultDialogIfNeeded(
{
sewerBzmnCd: values.bsnmCd ?? "",
...toInputSearchRegion(sidoListRef.current, values),
ctpvNm: values.sido ?? "",
sggNm: values.gugun === "ALL" ? "" : (values.gugun ?? ""),
statsYr: values.year ?? "",
statsCd: statsCdForTab,
},
@@ -1538,9 +1561,8 @@ const SewagePipeInp = () => {
);
await openVerificationResultDialogIfNeeded(
{
sewerBzmnCd: values.bsnmCd ?? "",
...toInputSearchRegion(sidoListRef.current, values),
ctpvNm: values.sido ?? "",
sggNm: values.gugun === "ALL" ? "" : (values.gugun ?? ""),
statsYr: values.year ?? "",
statsCd: statsCdForTab,
},
@@ -1567,9 +1589,8 @@ const SewagePipeInp = () => {
const userInfo = await getUserInfo();
const requestData: cancelSubmitRequest = {
sewerBzmnCd: searchValues?.bsnmCd ?? '',
...toInputSearchRegion(sidoListRef.current, searchValues),
ctpvNm: searchValues?.sido ?? '',
sggNm: searchValues?.gugun === "ALL" ? "" : (searchValues?.gugun ?? ""),
statsYr: searchValues?.year ?? '',
mdfrId: userInfo.userUnqId,
statsCd: tabStatsCdMap.get(activeTab) ?? statsCd,
@@ -1699,8 +1720,7 @@ const SewagePipeInp = () => {
const param: SeweragePipeInputRegionalFactStatusSaveRequest = {
statsYr: values.year ?? "",
ctpvNm: values.sido ?? "",
sggNm: values.gugun === "ALL" ? "" : (values.gugun ?? ""),
sewerBzmnCd: values.bsnmCd ?? "",
...toInputSearchRegion(sidoListRef.current, values),
userId: userInfo.userUnqId,
...(isAdminInfo ? { superAdmin: "superAdmin" } : {}),
saveList,
@@ -1779,8 +1799,7 @@ const SewagePipeInp = () => {
const param: SeweragePipeInputFactInstallStatusSaveRequest = {
statsYr: values.year ?? "",
ctpvNm: values.sido ?? "",
sggNm: values.gugun === "ALL" ? "" : (values.gugun ?? ""),
sewerBzmnCd: values.bsnmCd ?? "",
...toInputSearchRegion(sidoListRef.current, values),
userId: userInfo.userUnqId,
...(isAdminInfo ? { superAdmin: "superAdmin" } : {}),
saveList,
@@ -1864,8 +1883,7 @@ const SewagePipeInp = () => {
const param: SeweragePipeInputPipeTypeStatusSaveRequest = {
statsYr: values.year ?? "",
ctpvNm: values.sido ?? "",
sggNm: values.gugun === "ALL" ? "" : (values.gugun ?? ""),
sewerBzmnCd: values.bsnmCd ?? "",
...toInputSearchRegion(sidoListRef.current, values),
userId: userInfo.userUnqId,
...(isAdminInfo ? { superAdmin: "superAdmin" } : {}),
saveList,
@@ -1927,8 +1945,7 @@ const SewagePipeInp = () => {
const param: SeweragePipeInputPipeDiameterStatusSaveRequest = {
statsYr: values.year ?? "",
ctpvNm: values.sido ?? "",
sggNm: values.gugun === "ALL" ? "" : (values.gugun ?? ""),
sewerBzmnCd: values.bsnmCd ?? "",
...toInputSearchRegion(sidoListRef.current, values),
userId: userInfo.userUnqId,
...(isAdminInfo ? { superAdmin: "superAdmin" } : {}),
saveList,
@@ -2006,8 +2023,7 @@ const SewagePipeInp = () => {
const param: SeweragePipeInputManholeStatusSaveRequest = {
statsYr: values.year ?? "",
ctpvNm: values.sido ?? "",
sggNm: values.gugun === "ALL" ? "" : (values.gugun ?? ""),
sewerBzmnCd: values.bsnmCd ?? "",
...toInputSearchRegion(sidoListRef.current, values),
userId: userInfo.userUnqId,
...(isAdminInfo ? { superAdmin: "superAdmin" } : {}),
saveList,
@@ -2036,12 +2052,12 @@ const SewagePipeInp = () => {
}
};
const gugunOkOrNotDoList = buildGugunOkForToolbar(lastSearchedValues);
const searchContextForToolbar = searchContextByTab.get(activeTab) ?? lastSearchedValues;
const gugunOkOrNotDoList = buildGugunOkForToolbar(searchContextForToolbar);
const submitOk = buildSubmitOkForToolbar(searchContextForToolbar);
const searchContextForToolbar = lastSearchedValues ?? searchValues;
const activeTabStatus = tabStatusInfoMap.get(activeTab) ?? null;
const activeTabToolbar =
toolbarSnapshotByTab.get(activeTab) ??
computeTabToolbarSnapshot(
activeTabStatus,
tabRowDataExists(rowDataMap, activeTab),
@@ -2067,6 +2083,7 @@ const SewagePipeInp = () => {
return (
<>
<SearchForm
isInput
key={searchFormRemountKey}
defaultValues={verificationSearchDefaults ?? undefined}
onSubmit={handleSearch}
@@ -2085,10 +2102,10 @@ const SewagePipeInp = () => {
{showEnterableToolbarButtons && (
<>
{activeTab !== 'ST00020002' && <LastYearDataButton getLastYearDataFunc={() => void getLastYearDataFunc()} />}
<SubmitButton submitFunc={() => void submitFunc(false)} />
{submitOk && <SubmitButton submitFunc={() => void submitFunc(false)} />}
</>
)}
{activeTabStatus?.laeSbmsnSttsCd === "2" && (
{activeTabStatus?.laeSbmsnSttsCd === "2" && submitOk && (
<CancelSubmitButton cnacelSubmitFunc={cnacelSubmitFunc} />
)}
{showSaveInToolbar && <SaveButton saveFunc={saveFunc} />}
@@ -2306,9 +2323,8 @@ const SewagePipeInp = () => {
searchValues?.bsnmCd &&
(tabStatsCdMap.get(activeTab) ?? statsCd)
? {
sewerBzmnCd: searchValues.bsnmCd,
...toInputSearchRegion(sidoListRef.current, searchValues),
ctpvNm: searchValues.sido,
sggNm: searchValues.gugun === "ALL" ? "" : (searchValues.gugun ?? ""),
statsYr: searchValues.year,
statsCd: tabStatsCdMap.get(activeTab) ?? statsCd,
}
@@ -2342,9 +2358,8 @@ const SewagePipeInp = () => {
searchValues?.bsnmCd &&
(tabStatsCdMap.get(activeTab) ?? statsCd)
? {
sewerBzmnCd: searchValues.bsnmCd,
...toInputSearchRegion(sidoListRef.current, searchValues),
ctpvNm: searchValues.sido,
sggNm: searchValues.gugun === "ALL" ? "" : (searchValues.gugun ?? ""),
statsYr: searchValues.year,
statsCd: tabStatsCdMap.get(activeTab) ?? statsCd,
}
@@ -2,7 +2,7 @@ import { useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
import { useConfirm } from "@frontend-opensource/use-react-hooks";
import { useAlertStore, useGlobalProgressStore, useStatisticsInputToolbarGroupGate } from "@/shared/lib";
import { useAlertStore, useGlobalProgressStore, useStatisticsInputToolbarGroupGate, useSearchConditionSidoList } from "@/shared/lib";
import {
STATISTICS_INPUT_URL_PATH,
verificationSearchToFormValues,
@@ -27,7 +27,15 @@ import type {
cancelSubmitRequest,
ImrStatusResponse,
SewerageStatusInfo,
Sido,
} from "@/entities/statistics/model/statistics-interface";
import {
filterBySelectedAdmdstCd,
isGugunOkForToolbar,
isSubmitOkForToolbar,
toInputSearchRegion,
} from "@/entities/statistics";
import {
LoadingWithAnimation,
Tabs,
@@ -52,7 +60,6 @@ import { VerificationResultDialog } from "@/components/module/VerificationResult
import { VerificationResultHistoryDialog } from "@/components/module/VerificationResultHistoryDialog";
import type { ColumnInfo } from "@/components/type/DataGrid.type";
import type { SearchFormValues } from "@/components/type/SearchForm.type";
import { doList } from "@/components/util/column/input/DoList";
import { PipeDredgingStatusInpColumn } from "@/components/util/column/input/sewagePipeMaintain/PipeDredgingStatusInpColumn";
import { RepairStatusInpColumn } from "@/components/util/column/input/sewagePipeMaintain/RepairStatusInpColumn";
import { fetchColumnGuidesRecord } from "@/components/util/grid/columnGuides";
@@ -74,9 +81,8 @@ function buildSewagePipeMaintainSearchParam(
): SewagePipeMaintainRequestParams {
return {
statsYr: values.year,
sewerBzmnCd: values.bsnmCd,
ctpvNm: values.sido,
sggNm: values.gugun === "ALL" ? "" : values.gugun,
...toInputSearchRegion(sidoListRef.current, values),
...(overrides?.mode ? { mode: overrides.mode } : {}),
};
}
@@ -116,10 +122,14 @@ const computeTabEnterable = (
return periodEnterable;
};
const sidoListRef: { current: Sido[] } = { current: [] };
function buildGugunOkForToolbar(values: SearchFormValues | null): boolean {
return doList.includes(values?.bsnmCd || "")
? Boolean(values?.gugun && values.gugun !== "ALL")
: true;
return isGugunOkForToolbar(sidoListRef.current, values);
}
function buildSubmitOkForToolbar(values: SearchFormValues | null): boolean {
return isSubmitOkForToolbar(sidoListRef.current, values);
}
function computeTabToolbarSnapshot(
@@ -263,6 +273,8 @@ function buildDredgingRowList(
// 하수도 통계 관리 > 03. 하수관로 유지관리
const SewagePipeMaintainInp = () => {
const { sidoList, isReady } = useSearchConditionSidoList({ isInput: true });
sidoListRef.current = sidoList;
const { setMessage: alert } = useAlertStore((state) => state);
const { isAdminInfo } = useAdminStore();
const toolbarGroupAllowed = useStatisticsInputToolbarGroupGate();
@@ -288,9 +300,12 @@ const SewagePipeMaintainInp = () => {
const [footerVerificationByTab, setFooterVerificationByTab] = useState<
Map<string, VerificationResultLikeMap | null>
>(new Map());
const [toolbarSnapshotByTab, setToolbarSnapshotByTab] = useState<
const [_toolbarSnapshotByTab, setToolbarSnapshotByTab] = useState<
Map<string, TabToolbarSnapshot>
>(new Map());
const [searchContextByTab, setSearchContextByTab] = useState<Map<string, SearchFormValues>>(
() => new Map(),
);
const [verificationHistoryOpen, setVerificationHistoryOpen] = useState(false);
const [verificationResultDialogOpen, setVerificationResultDialogOpen] = useState(false);
const [showSubmitDialog, setShowSubmitDialog] = useState(false);
@@ -320,6 +335,7 @@ const SewagePipeMaintainInp = () => {
useLayoutEffect(() => {
if (activeTabId !== STATISTICS_INPUT_URL_PATH.SEWAGE_PIPE_MAINTAIN) return;
if (!isReady) return;
const pending = useStatisticsInputFocusStore
.getState()
.takePendingForUrl(STATISTICS_INPUT_URL_PATH.SEWAGE_PIPE_MAINTAIN);
@@ -327,12 +343,12 @@ const SewagePipeMaintainInp = () => {
const { tabKey, search } = pending;
setActiveTab(tabKey);
if (search) {
const values = verificationSearchToFormValues(search);
const values = verificationSearchToFormValues(search, sidoList);
setVerificationSearchDefaults(values);
postVerificationSearchRef.current = { values, tabKey };
setSearchFormRemountKey((k) => k + 1);
}
}, [activeTabId, inputFocusNonce]);
}, [activeTabId, inputFocusNonce, isReady, sidoList]);
useEffect(() => {
if (activeTabId !== STATISTICS_INPUT_URL_PATH.SEWAGE_PIPE_MAINTAIN) return;
@@ -377,6 +393,13 @@ const SewagePipeMaintainInp = () => {
);
return next;
});
if (searchContext) {
setSearchContextByTab((prev) => {
const next = new Map(prev);
next.set(tabKey, searchContext);
return next;
});
}
};
const applyRowMap = (
@@ -418,7 +441,11 @@ const SewagePipeMaintainInp = () => {
return false;
}
const { commonInfo, statusInfo, repairStatusList } = response.data;
const convertedData = (repairStatusList ?? []).map((d) => ({
const convertedData = filterBySelectedAdmdstCd(
repairStatusList ?? [],
sidoListRef.current,
searchContext,
).map((d) => ({
ctpvNm: commonInfo.ctpvNm,
...d,
}));
@@ -457,7 +484,11 @@ const SewagePipeMaintainInp = () => {
return false;
}
const { commonInfo, statusInfo, pipeDredgingStatusList } = response.data;
const convertedData = (pipeDredgingStatusList ?? []).map((d) => ({
const convertedData = filterBySelectedAdmdstCd(
pipeDredgingStatusList ?? [],
sidoListRef.current,
searchContext,
).map((d) => ({
ctpvNm: commonInfo.ctpvNm,
...d,
}));
@@ -581,11 +612,7 @@ const SewagePipeMaintainInp = () => {
const submitInfoBase = {
statsYr: lastSearchedValues.year ?? "",
ctpvNm: lastSearchedValues.sido ?? "",
sggNm:
lastSearchedValues.gugun === "ALL"
? ""
: (lastSearchedValues.gugun ?? ""),
sewerBzmnCd: lastSearchedValues.bsnmCd ?? "",
...toInputSearchRegion(sidoListRef.current, lastSearchedValues),
laePicNm: submitInfo.laePicNm,
laeKbrdrJbgdNm: submitInfo.laeKbrdrJbgdNm,
laeKbrdrDeptNm: submitInfo.laeKbrdrDeptNm,
@@ -597,12 +624,8 @@ const SewagePipeMaintainInp = () => {
};
const verificationQuery = {
sewerBzmnCd: lastSearchedValues.bsnmCd ?? "",
...toInputSearchRegion(sidoListRef.current, lastSearchedValues),
ctpvNm: lastSearchedValues.sido ?? "",
sggNm:
lastSearchedValues.gugun === "ALL"
? ""
: (lastSearchedValues.gugun ?? ""),
statsYr: lastSearchedValues.year ?? "",
statsCd: statsCdForTab,
};
@@ -647,7 +670,7 @@ const SewagePipeMaintainInp = () => {
setGlobalProgressLabel("시계열 검증 진행 중...");
const imrParam = {
user_id: userInfo.userUnqId,
sewer_bzmn_cd: lastSearchedValues.bsnmCd ?? "",
sewer_bzmn_cd: lastSearchedValues?.bsnmCd ?? "",
stats_cd: statsCdForTab,
stats_yr: lastSearchedValues.year ?? "",
lae_sbmsn_stts_cd: activeTabStatus?.laeSbmsnSttsCd === "4" ? "4" : "2",
@@ -727,11 +750,7 @@ const SewagePipeMaintainInp = () => {
const baseRequest = {
statsYr: lastSearchedValues.year ?? "",
ctpvNm: lastSearchedValues.sido ?? "",
sggNm:
lastSearchedValues.gugun === "ALL"
? ""
: (lastSearchedValues.gugun ?? ""),
sewerBzmnCd: lastSearchedValues.bsnmCd ?? "",
...toInputSearchRegion(sidoListRef.current, lastSearchedValues),
};
try {
@@ -833,12 +852,8 @@ const SewagePipeMaintainInp = () => {
const statsCdForTab = tabStatsCdMap.get(tabKey) ?? tabKey;
const requestData: cancelSubmitRequest = {
sewerBzmnCd: lastSearchedValues.bsnmCd ?? "",
...toInputSearchRegion(sidoListRef.current, lastSearchedValues),
ctpvNm: lastSearchedValues.sido ?? "",
sggNm:
lastSearchedValues.gugun === "ALL"
? ""
: (lastSearchedValues.gugun ?? ""),
statsYr: lastSearchedValues.year ?? "",
mdfrId: userInfo.userUnqId,
statsCd: statsCdForTab,
@@ -871,6 +886,7 @@ const SewagePipeMaintainInp = () => {
setIsVerificationFailedByTab(new Map());
setFooterVerificationByTab(new Map());
setToolbarSnapshotByTab(new Map());
setSearchContextByTab(new Map());
setActiveTab(firstTabKey);
setLastSearchedValues(null);
setHasSearched(false);
@@ -917,6 +933,7 @@ const SewagePipeMaintainInp = () => {
setIsVerificationFailedByTab(new Map());
setFooterVerificationByTab(new Map());
setToolbarSnapshotByTab(new Map());
setSearchContextByTab(new Map());
activeTabRef.current = firstTabKey;
setActiveTab(firstTabKey);
}
@@ -1012,10 +1029,9 @@ const SewagePipeMaintainInp = () => {
return map;
}, [tabStatusInfoMap, inputPeriodEnterable, isAdminInfo, columnGuidesByTab]);
const searchContextForToolbar = lastSearchedValues ?? searchValues;
const searchContextForToolbar = searchContextByTab.get(activeTab) ?? lastSearchedValues;
const activeTabStatus = tabStatusInfoMap.get(activeTab) ?? null;
const activeTabToolbar =
toolbarSnapshotByTab.get(activeTab) ??
computeTabToolbarSnapshot(
activeTabStatus,
tabRowDataExists(rowDataMap, activeTab),
@@ -1036,6 +1052,7 @@ const SewagePipeMaintainInp = () => {
baseShowEnterableToolbarButtons && toolbarGroupAllowed;
const showActionToolbarCard =
baseShowActionToolbarCard && toolbarGroupAllowed;
const submitOk = buildSubmitOkForToolbar(searchContextForToolbar);
const openVerificationHistoryDialog = () => {
const ctx = lastSearchedValues ?? searchValues;
@@ -1052,9 +1069,8 @@ const SewagePipeMaintainInp = () => {
const statsCd = tabStatsCdMap.get(activeTab);
if (!ctx?.year || !ctx?.sido || !ctx?.bsnmCd || !statsCd) return null;
return {
sewerBzmnCd: ctx.bsnmCd,
...toInputSearchRegion(sidoListRef.current, ctx),
ctpvNm: ctx.sido,
sggNm: ctx.gugun === "ALL" ? "" : (ctx.gugun ?? ""),
statsYr: ctx.year,
statsCd,
};
@@ -1102,6 +1118,7 @@ const SewagePipeMaintainInp = () => {
<>
<div className="relative">
<SearchForm
isInput
key={searchFormRemountKey}
defaultValues={verificationSearchDefaults ?? undefined}
onSubmit={handleSearch}
@@ -1122,10 +1139,10 @@ const SewagePipeMaintainInp = () => {
<LastYearDataButton
getLastYearDataFunc={() => void getLastYearDataFunc()}
/>
<SubmitButton submitFunc={submitFunc} />
{submitOk && <SubmitButton submitFunc={submitFunc} />}
</>
)}
{activeTabStatus?.laeSbmsnSttsCd === "2" && (
{activeTabStatus?.laeSbmsnSttsCd === "2" && submitOk && (
<CancelSubmitButton cnacelSubmitFunc={cnacelSubmitFunc} />
)}
{showSaveInToolbar && <SaveButton saveFunc={saveFunc} />}
@@ -1161,7 +1178,7 @@ const SewagePipeMaintainInp = () => {
tabStatusInfoMap.get(tabKey) ?? null,
inputPeriodEnterable,
) || isAdminInfo) && inputPeriodEnterable;
const gugunOk = buildGugunOkForToolbar(lastSearchedValues);
const gugunOk = buildGugunOkForToolbar(searchContextForToolbar);
const tabStatusInfo = tabStatusInfoMap.get(tabKey) ?? null;
return (
@@ -13,7 +13,7 @@ import { useConfirm } from "@frontend-opensource/use-react-hooks";
import { ValueType } from "realgrid";
import type { RealGridReact } from "realgrid-react";
import { useAlertStore, useGlobalProgressStore, useStatisticsInputToolbarGroupGate } from "@/shared/lib";
import { useAlertStore, useGlobalProgressStore, useStatisticsInputToolbarGroupGate, useSearchConditionSidoList } from "@/shared/lib";
import { STATISTICS_INPUT_URL_PATH } from "@/shared/lib/stats-cd-input-navigation";
import { useStatisticsInputPendingNavigation } from "@/shared/lib/use-statistics-input-pending-navigation";
import { ConfirmDialog } from "@/shared/ui/confirm-dialog";
@@ -38,7 +38,16 @@ import type {
ImrStatusResponse,
SewerageStatusInfo,
Sgg,
Sido,
} from "@/entities/statistics/model/statistics-interface";
import {
filterBySelectedAdmdstCd,
isGugunOkForToolbar,
isSubmitOkForToolbar,
resolveNoApplicableForRequest,
toInputSearchRegion,
} from "@/entities/statistics";
import { LoadingWithAnimation, Tabs, TabsContent, TabsList, TabsTrigger } from "@common/components";
import { getUserInfo } from "../../../../../../packages/common/components/src/api";
@@ -66,7 +75,6 @@ import type {
ColumnInfoList,
} from "@/components/type/DataGrid.type";
import type { SearchFormValues } from "@/components/type/SearchForm.type";
import { doList } from "@/components/util/column/input/DoList";
import { RainfallPumpStationInpColumn } from "@/components/util/column/input/sewageReservoirPump/RainfallPumpStationInpColumn";
import { SewageReservoirInpColumn } from "@/components/util/column/input/sewageReservoirPump/SewageReservoirInpColumn";
import { fetchColumnGuidesRecord } from "@/components/util/grid/columnGuides";
@@ -126,10 +134,22 @@ const computeTabEnterable = (
return periodEnterable;
};
const sidoListRef: { current: Sido[] } = { current: [] };
function buildGugunOkForToolbar(values: SearchFormValues | null): boolean {
return doList.includes(values?.bsnmCd || "")
? Boolean(values?.gugun && values.gugun !== "ALL")
: true;
return isGugunOkForToolbar(sidoListRef.current, values);
}
function buildSubmitOkForToolbar(values: SearchFormValues | null): boolean {
return isSubmitOkForToolbar(sidoListRef.current, values);
}
function buildNoApplicableForRequest(
values: SearchFormValues | null,
checked: boolean,
isSaveListEmpty: boolean,
): boolean {
return resolveNoApplicableForRequest(sidoListRef.current, values, checked, isSaveListEmpty);
}
function computeTabToolbarSnapshot(
@@ -171,9 +191,8 @@ function buildSewageReservoirSearchParam(
const fcltNm = values.fctName?.trim();
return {
statsYr: values.year,
sewerBzmnCd: values.bsnmCd,
ctpvNm: values.sido,
sggNm: values.gugun === "ALL" ? "" : values.gugun,
...toInputSearchRegion(sidoListRef.current, values),
...(fcltNm ? { fcltNm } : {}),
...(overrides?.mode ? { mode: overrides.mode } : {}),
};
@@ -246,8 +265,9 @@ function buildSggNmColumn(
function mapSewageReservoirListToGridRows(
list: SewageReservoirItem[],
ctpvNm: string,
values?: SearchFormValues | null,
): GridRowWithVerification[] {
return list.map((item) => {
return filterBySelectedAdmdstCd(list, sidoListRef.current, values).map((item) => {
const row = toGridRows([
{
...item,
@@ -399,8 +419,9 @@ function buildRainfallPumpStationSaveItem(
function mapRainfallPumpStationListToGridRows(
list: RainfallPumpStationItem[],
ctpvNm: string,
values?: SearchFormValues | null,
): GridRowWithVerification[] {
return list.map((item) => {
return filterBySelectedAdmdstCd(list, sidoListRef.current, values).map((item) => {
const row = toGridRows([
{
...item,
@@ -447,6 +468,8 @@ async function waitForImrJobCompleted(
// 하수도 통계 관리 > 04. 하수저류 시설 및 빗물 펌프장
const SewageReservoirPumpInp = () => {
const { sidoList } = useSearchConditionSidoList({ isInput: true });
sidoListRef.current = sidoList;
const { setMessage: alert } = useAlertStore((state) => state);
const { confirm } = useConfirm();
const { isAdminInfo } = useAdminStore();
@@ -478,9 +501,9 @@ const SewageReservoirPumpInp = () => {
alert("시군구를 선택해주세요.");
return;
}
const noApplicable = isNotApplicableByTab.get(tabKey) ?? false;
const noApplicable = buildNoApplicableForRequest(searchContextByTab.get(tabKey) ?? lastSearchedValues, isNotApplicableByTab.get(tabKey) ?? false, getCurrentRowsForTab(tabKey).length === 0);
const currentData = getCurrentRowsForTab(tabKey);
if (!noApplicable && currentData.length === 0) {
if (!noApplicable && currentData.length === 0 && buildSubmitOkForToolbar(searchContextByTab.get(tabKey) ?? lastSearchedValues)) {
alert("해당사항 없음을 체크해주세요.");
return;
}
@@ -505,12 +528,8 @@ const SewageReservoirPumpInp = () => {
const userInfo = await getUserInfo();
const requestData: cancelSubmitRequest = {
sewerBzmnCd: lastSearchedValues.bsnmCd ?? "",
...toInputSearchRegion(sidoListRef.current, lastSearchedValues),
ctpvNm: lastSearchedValues.sido ?? "",
sggNm:
lastSearchedValues.gugun === "ALL"
? ""
: (lastSearchedValues.gugun ?? ""),
statsYr: lastSearchedValues.year ?? "",
mdfrId: userInfo.userUnqId,
statsCd: statsCdForTab,
@@ -663,7 +682,7 @@ const SewageReservoirPumpInp = () => {
if (!(await confirm("저장 하시겠습니까?"))) return;
commitGridForTab(tabKey);
const noApplicable = isNotApplicableByTab.get(tabKey) ?? false;
const noApplicable = buildNoApplicableForRequest(searchContextByTab.get(tabKey) ?? lastSearchedValues, isNotApplicableByTab.get(tabKey) ?? false, getCurrentRowsForTab(tabKey).length === 0);
const currentData = getCurrentRowsForTab(tabKey);
const isReservoirTab = tabKey === SEWAGE_RESERVOIR_STATS_CD;
const saveList = noApplicable
@@ -682,7 +701,7 @@ const SewageReservoirPumpInp = () => {
: rainfallPumpStationDeleteList
.filter((row) => String(row.fcltSn ?? "").trim() !== "")
.map((row) => buildRainfallPumpStationSaveItem(row, sggOptions));
if (!noApplicable && saveList.length === 0) {
if (!noApplicable && saveList.length === 0 && buildSubmitOkForToolbar(searchContextByTab.get(tabKey) ?? lastSearchedValues)) {
alert("해당사항 없음을 체크해주세요.");
return;
}
@@ -690,11 +709,7 @@ const SewageReservoirPumpInp = () => {
const requestBase = {
statsYr: lastSearchedValues.year ?? "",
ctpvNm: lastSearchedValues.sido ?? "",
sggNm:
lastSearchedValues.gugun === "ALL"
? ""
: (lastSearchedValues.gugun ?? ""),
sewerBzmnCd: lastSearchedValues.bsnmCd ?? "",
...toInputSearchRegion(sidoListRef.current, lastSearchedValues),
...(isAdminInfo ? { superAdmin: "superAdmin" } : {}),
...(noApplicable ? { noApplicable: true } : {}),
};
@@ -754,7 +769,7 @@ const SewageReservoirPumpInp = () => {
}
commitGridForTab(tabKey);
const noApplicable = isNotApplicableByTab.get(tabKey) ?? false;
const noApplicable = buildNoApplicableForRequest(searchContextByTab.get(tabKey) ?? lastSearchedValues, isNotApplicableByTab.get(tabKey) ?? false, getCurrentRowsForTab(tabKey).length === 0);
const currentData = getCurrentRowsForTab(tabKey);
const isReservoirTab = tabKey === SEWAGE_RESERVOIR_STATS_CD;
const submitList = noApplicable
@@ -773,12 +788,8 @@ const SewageReservoirPumpInp = () => {
const activeTabStatus = tabStatusInfoMap.get(tabKey) ?? null;
const statsCdForTab = tabStatsCdMap.get(tabKey) ?? tabKey;
const verificationQuery = {
sewerBzmnCd: lastSearchedValues.bsnmCd ?? "",
...toInputSearchRegion(sidoListRef.current, lastSearchedValues),
ctpvNm: lastSearchedValues.sido ?? "",
sggNm:
lastSearchedValues.gugun === "ALL"
? ""
: (lastSearchedValues.gugun ?? ""),
statsYr: lastSearchedValues.year ?? "",
statsCd: statsCdForTab,
};
@@ -792,7 +803,7 @@ const SewageReservoirPumpInp = () => {
await loadActiveTabData(tabKey, lastSearchedValues, true, false);
};
if (!noApplicable && submitList.length === 0) {
if (!noApplicable && submitList.length === 0 && buildSubmitOkForToolbar(searchContextByTab.get(tabKey) ?? lastSearchedValues)) {
alert("해당사항 없음을 체크해주세요.");
return;
}
@@ -800,11 +811,7 @@ const SewageReservoirPumpInp = () => {
const submitRequestBase = {
statsYr: lastSearchedValues.year ?? "",
ctpvNm: lastSearchedValues.sido ?? "",
sggNm:
lastSearchedValues.gugun === "ALL"
? ""
: (lastSearchedValues.gugun ?? ""),
sewerBzmnCd: lastSearchedValues.bsnmCd ?? "",
...toInputSearchRegion(sidoListRef.current, lastSearchedValues),
...(noApplicable ? { noApplicable: true } : {}),
laePicNm: submitInfo.laePicNm,
laeKbrdrJbgdNm: submitInfo.laeKbrdrJbgdNm,
@@ -847,7 +854,7 @@ const SewageReservoirPumpInp = () => {
setGlobalProgressLabel("시계열 검증 진행 중...");
const imrParam = {
user_id: userInfo.userUnqId,
sewer_bzmn_cd: lastSearchedValues.bsnmCd ?? "",
sewer_bzmn_cd: lastSearchedValues?.bsnmCd ?? "",
stats_cd: statsCdForTab,
stats_yr: lastSearchedValues.year ?? "",
lae_sbmsn_stts_cd:
@@ -926,9 +933,12 @@ const SewageReservoirPumpInp = () => {
const [tabStatusInfoMap, setTabStatusInfoMap] = useState<
Map<string, SewerageStatusInfo | null>
>(new Map());
const [toolbarSnapshotByTab, setToolbarSnapshotByTab] = useState<
const [_toolbarSnapshotByTab, setToolbarSnapshotByTab] = useState<
Map<string, TabToolbarSnapshot>
>(new Map());
const [searchContextByTab, setSearchContextByTab] = useState<Map<string, SearchFormValues>>(
() => new Map(),
);
const [tabStatsCdMap, setTabStatsCdMap] = useState<Map<string, string>>(new Map());
const [isVerificationFailedByTab, setIsVerificationFailedByTab] = useState<
Map<string, boolean>
@@ -1024,6 +1034,13 @@ const SewageReservoirPumpInp = () => {
);
return next;
});
if (searchContext) {
setSearchContextByTab((prev) => {
const next = new Map(prev);
next.set(tabKey, searchContext);
return next;
});
}
};
const applyRowMap = (
@@ -1068,6 +1085,7 @@ const SewageReservoirPumpInp = () => {
const gridRows = mapSewageReservoirListToGridRows(
list,
commonInfo.ctpvNm,
values,
);
applyRowMap(mergeIntoExistingMap, (m) => {
@@ -1116,6 +1134,7 @@ const SewageReservoirPumpInp = () => {
const gridRows = mapRainfallPumpStationListToGridRows(
list,
commonInfo.ctpvNm,
values,
);
applyRowMap(mergeIntoExistingMap, (m) => {
@@ -1198,6 +1217,7 @@ const SewageReservoirPumpInp = () => {
setIsVerificationFailedByTab(new Map());
setFooterVerificationByTab(new Map());
setToolbarSnapshotByTab(new Map());
setSearchContextByTab(new Map());
setLastSearchedValues(null);
setSggOptions([]);
sggOptionsSidoRef.current = null;
@@ -1249,6 +1269,7 @@ const SewageReservoirPumpInp = () => {
setIsVerificationFailedByTab(new Map());
setFooterVerificationByTab(new Map());
setToolbarSnapshotByTab(new Map());
setSearchContextByTab(new Map());
loadedTabKeysRef.current.clear();
setActiveTab(firstTabKey);
}
@@ -1318,10 +1339,9 @@ const SewageReservoirPumpInp = () => {
}
};
const searchContextForToolbar = lastSearchedValues ?? searchValues;
const searchContextForToolbar = searchContextByTab.get(activeTab) ?? lastSearchedValues;
const activeTabStatus = tabStatusInfoMap.get(activeTab) ?? null;
const activeTabToolbar =
toolbarSnapshotByTab.get(activeTab) ??
computeTabToolbarSnapshot(
activeTabStatus,
tabRowDataExists(rowDataMap, activeTab),
@@ -1342,6 +1362,7 @@ const SewageReservoirPumpInp = () => {
baseShowEnterableToolbarButtons && toolbarGroupAllowed;
const showActionToolbarCard =
baseShowActionToolbarCard && toolbarGroupAllowed;
const submitOk = buildSubmitOkForToolbar(searchContextForToolbar);
const isReservoirOrRainfallTab =
activeTab === SEWAGE_RESERVOIR_STATS_CD || activeTab === rainfallPumpTabKey;
const showArticleToolbarCard =
@@ -1356,7 +1377,8 @@ const SewageReservoirPumpInp = () => {
activeTab,
tabRowDataExists(rowDataMap, activeTab),
tabStatusInfoMap.get(activeTab),
);
) &&
submitOk;
const setIsNotApplicableForActiveTab: Dispatch<SetStateAction<boolean>> = useCallback(
(next) => {
const tabKey = activeTabRef.current;
@@ -1514,9 +1536,8 @@ const SewageReservoirPumpInp = () => {
const statsCd = tabStatsCdMap.get(activeTab);
if (!ctx?.year || !ctx?.sido || !ctx?.bsnmCd || !statsCd) return null;
return {
sewerBzmnCd: ctx.bsnmCd,
...toInputSearchRegion(sidoListRef.current, ctx),
ctpvNm: ctx.sido,
sggNm: ctx.gugun === "ALL" ? "" : (ctx.gugun ?? ""),
statsYr: ctx.year,
statsCd,
};
@@ -1537,6 +1558,7 @@ const SewageReservoirPumpInp = () => {
<>
<div className="relative">
<SearchForm
isInput
key={searchFormRemountKey}
defaultValues={verificationSearchDefaults ?? undefined}
fctName={true}
@@ -1558,10 +1580,10 @@ const SewageReservoirPumpInp = () => {
<LastYearDataButton
getLastYearDataFunc={() => void getLastYearDataFunc()}
/>
<SubmitButton submitFunc={submitFunc} />
{submitOk && <SubmitButton submitFunc={submitFunc} />}
</>
)}
{activeTabStatus?.laeSbmsnSttsCd === "2" && (
{activeTabStatus?.laeSbmsnSttsCd === "2" && submitOk && (
<CancelSubmitButton cnacelSubmitFunc={cnacelSubmitFunc} />
)}
{showSaveInToolbar && <SaveButton saveFunc={saveFunc} />}
@@ -1607,7 +1629,7 @@ const SewageReservoirPumpInp = () => {
tabStatusInfoMap.get(tabKey) ?? null,
inputPeriodEnterable,
) || isAdminInfo) && inputPeriodEnterable;
const gugunOk = buildGugunOkForToolbar(lastSearchedValues);
const gugunOk = buildGugunOkForToolbar(searchContextForToolbar);
const tabStatusInfo = tabStatusInfoMap.get(tabKey) ?? null;
const isReservoirTab = tabKey === SEWAGE_RESERVOIR_STATS_CD;
return (
@@ -2,7 +2,7 @@ import { useEffect, useMemo, useRef, useState } from "react";
import { useConfirm } from "@frontend-opensource/use-react-hooks";
import { useAlertStore, useGlobalProgressStore } from "@/shared/lib";
import { useAlertStore, useGlobalProgressStore, useSearchConditionSidoList } from "@/shared/lib";
import { STATISTICS_INPUT_URL_PATH } from "@/shared/lib/stats-cd-input-navigation";
import { useStatisticsInputPendingNavigation } from "@/shared/lib/use-statistics-input-pending-navigation";
import { statisticsInputSewSupplyRateApi } from "@/entities/statistics/api/input/statistics-input-sew-supply-rate-service";
@@ -35,7 +35,15 @@ import type {
cancelSubmitRequest,
ImrStatusResponse,
SewerageStatusInfo,
Sido,
} from "@/entities/statistics/model/statistics-interface";
import {
filterBySelectedAdmdstCd,
isGugunOkForToolbar,
isSubmitOkForToolbar,
toInputSearchRegion,
} from "@/entities/statistics";
import { LoadingWithAnimation, Tabs, TabsContent, TabsList, TabsTrigger } from "@common/components";
import { getUserInfo } from "../../../../../../packages/common/components/src/api";
@@ -54,7 +62,6 @@ import { VerificationResultDialog } from "@/components/module/VerificationResult
import { VerificationResultHistoryDialog } from "@/components/module/VerificationResultHistoryDialog";
import type { ColumnConfig, ColumnInfo } from "@/components/type/DataGrid.type";
import type { SearchFormValues } from "@/components/type/SearchForm.type";
import { doList } from "@/components/util/column/input/DoList";
import { CauserBurdenInpColumn } from "@/components/util/column/input/sewerageFinance/CauserBurdenInpColumn";
import { SewerageChargeInpColumn } from "@/components/util/column/input/sewerageFinance/SewerageChargeInpColumn";
import { SewerageFinanceSettleInpColumn } from "@/components/util/column/input/sewerageFinance/SewerageFinanceSettleInpColumn";
@@ -101,9 +108,8 @@ function buildSewerageFinanceSearchParam(
): SewerageFinanceRequestParams {
return {
statsYr: values.year,
sewerBzmnCd: values.bsnmCd,
ctpvNm: values.sido,
sggNm: values.gugun === "ALL" ? "" : values.gugun,
...toInputSearchRegion(sidoListRef.current, values),
...(overrides?.mode ? { mode: overrides.mode } : {}),
};
}
@@ -121,10 +127,14 @@ const computeTabEnterable = (
return periodEnterable;
};
const sidoListRef: { current: Sido[] } = { current: [] };
function buildGugunOkForToolbar(values: SearchFormValues | null): boolean {
return doList.includes(values?.bsnmCd || "")
? Boolean(values?.gugun && values.gugun !== "ALL")
: true;
return isGugunOkForToolbar(sidoListRef.current, values);
}
function buildSubmitOkForToolbar(values: SearchFormValues | null): boolean {
return isSubmitOkForToolbar(sidoListRef.current, values);
}
function computeTabToolbarSnapshot(
@@ -160,8 +170,8 @@ function tabRowDataExists(
function mapRegionalListToGridRows<
T extends { verificationResult?: SewerageFinanceVerificationResult },
>(list: T[], ctpvNm: string): GridRowWithVerification[] {
return list.map((item) => {
>(list: T[], ctpvNm: string, values?: SearchFormValues | null): GridRowWithVerification[] {
return filterBySelectedAdmdstCd(list, sidoListRef.current, values).map((item) => {
const { verificationResult, ...rest } = item;
const row = toGridRows([{ ctpvNm, ...rest }])[0] as GridRowWithVerification;
if (verificationResult) row.verificationResult = verificationResult;
@@ -342,6 +352,8 @@ async function waitForImrJobCompleted(
// 하수도 통계 관리 > 09. 하수도재정
const SewerageFinanceInp = () => {
const { sidoList } = useSearchConditionSidoList({ isInput: true });
sidoListRef.current = sidoList;
const { setMessage: alert } = useAlertStore((state) => state);
const { confirm } = useConfirm();
const { isAdminInfo } = useAdminStore();
@@ -369,9 +381,12 @@ const SewerageFinanceInp = () => {
const [footerVerificationByTab, setFooterVerificationByTab] = useState<
Map<string, VerificationResultLikeMap | null>
>(new Map());
const [toolbarSnapshotByTab, setToolbarSnapshotByTab] = useState<
const [_toolbarSnapshotByTab, setToolbarSnapshotByTab] = useState<
Map<string, TabToolbarSnapshot>
>(new Map());
const [searchContextByTab, setSearchContextByTab] = useState<Map<string, SearchFormValues>>(
() => new Map(),
);
const [columnGuidesByTab, setColumnGuidesByTab] = useState<
Record<string, Record<string, string>>
>({});
@@ -431,6 +446,13 @@ const SewerageFinanceInp = () => {
);
return next;
});
if (searchContext) {
setSearchContextByTab((prev) => {
const next = new Map(prev);
next.set(tabKey, searchContext);
return next;
});
}
};
const applyRowMap = (
@@ -471,6 +493,7 @@ const SewerageFinanceInp = () => {
const gridRows = mapRegionalListToGridRows(
(sewerageFinanceSettleList ?? []) as SewerageFinanceSettleItem[],
commonInfo.ctpvNm,
searchContext,
);
applyRowMap(mergeIntoExistingMap, (m) => {
@@ -500,6 +523,7 @@ const SewerageFinanceInp = () => {
const gridRows = mapRegionalListToGridRows(
(sewerageChargeList ?? []) as SewerageChargeItem[],
commonInfo.ctpvNm,
searchContext,
);
applyRowMap(mergeIntoExistingMap, (m) => {
@@ -529,6 +553,7 @@ const SewerageFinanceInp = () => {
const gridRows = mapRegionalListToGridRows(
(sewerageUsageFeeList ?? []) as SewerageUsageFeeItem[],
commonInfo.ctpvNm,
searchContext,
);
applyRowMap(mergeIntoExistingMap, (m) => {
@@ -558,6 +583,7 @@ const SewerageFinanceInp = () => {
const gridRows = mapRegionalListToGridRows(
(causerBurdenList ?? []) as CauserBurdenItem[],
commonInfo.ctpvNm,
searchContext,
);
applyRowMap(mergeIntoExistingMap, (m) => {
@@ -590,6 +616,7 @@ const SewerageFinanceInp = () => {
setIsVerificationFailedByTab(new Map());
setFooterVerificationByTab(new Map());
setToolbarSnapshotByTab(new Map());
setSearchContextByTab(new Map());
setActiveTab(firstTabKey);
activeTabRef.current = firstTabKey;
setLastSearchedValues(null);
@@ -633,6 +660,7 @@ const SewerageFinanceInp = () => {
setIsVerificationFailedByTab(new Map());
setFooterVerificationByTab(new Map());
setToolbarSnapshotByTab(new Map());
setSearchContextByTab(new Map());
activeTabRef.current = firstTabKey;
setActiveTab(firstTabKey);
}
@@ -742,12 +770,8 @@ const SewerageFinanceInp = () => {
}
const requestData: cancelSubmitRequest = {
sewerBzmnCd: lastSearchedValues.bsnmCd ?? "",
...toInputSearchRegion(sidoListRef.current, lastSearchedValues),
ctpvNm: lastSearchedValues.sido ?? "",
sggNm:
lastSearchedValues.gugun === "ALL"
? ""
: (lastSearchedValues.gugun ?? ""),
statsYr: lastSearchedValues.year ?? "",
mdfrId: userInfo.userUnqId,
statsCd: statsCdForTab,
@@ -830,11 +854,7 @@ const SewerageFinanceInp = () => {
const submitInfoBase = {
statsYr: lastSearchedValues.year ?? "",
ctpvNm: lastSearchedValues.sido ?? "",
sggNm:
lastSearchedValues.gugun === "ALL"
? ""
: (lastSearchedValues.gugun ?? ""),
sewerBzmnCd: lastSearchedValues.bsnmCd ?? "",
...toInputSearchRegion(sidoListRef.current, lastSearchedValues),
laePicNm: submitInfo.laePicNm,
laePicTelNo: submitInfo.laePicTelNo,
laeKbrdrDeptNm: submitInfo.laeKbrdrDeptNm,
@@ -846,12 +866,8 @@ const SewerageFinanceInp = () => {
};
const verificationQuery = {
sewerBzmnCd: lastSearchedValues.bsnmCd ?? "",
...toInputSearchRegion(sidoListRef.current, lastSearchedValues),
ctpvNm: lastSearchedValues.sido ?? "",
sggNm:
lastSearchedValues.gugun === "ALL"
? ""
: (lastSearchedValues.gugun ?? ""),
statsYr: lastSearchedValues.year ?? "",
statsCd: statsCdForTab,
};
@@ -924,7 +940,7 @@ const SewerageFinanceInp = () => {
setGlobalProgressLabel("시계열 검증 진행 중...");
const imrParam = {
user_id: userInfo.userUnqId,
sewer_bzmn_cd: lastSearchedValues.bsnmCd ?? "",
sewer_bzmn_cd: lastSearchedValues?.bsnmCd ?? "",
stats_cd: statsCdForTab,
stats_yr: lastSearchedValues.year ?? "",
lae_sbmsn_stts_cd: activeTabStatus?.laeSbmsnSttsCd === "4" ? "4" : "2",
@@ -1012,11 +1028,7 @@ const SewerageFinanceInp = () => {
const baseRequest = {
statsYr: lastSearchedValues.year ?? "",
ctpvNm: lastSearchedValues.sido ?? "",
sggNm:
lastSearchedValues.gugun === "ALL"
? ""
: (lastSearchedValues.gugun ?? ""),
sewerBzmnCd: lastSearchedValues.bsnmCd ?? "",
...toInputSearchRegion(sidoListRef.current, lastSearchedValues),
};
try {
@@ -1137,9 +1149,8 @@ const SewerageFinanceInp = () => {
const statsCd = tabStatsCdMap.get(activeTab);
if (!ctx?.year || !ctx?.sido || !ctx?.bsnmCd || !statsCd) return null;
return {
sewerBzmnCd: ctx.bsnmCd,
...toInputSearchRegion(sidoListRef.current, ctx),
ctpvNm: ctx.sido,
sggNm: ctx.gugun === "ALL" ? "" : (ctx.gugun ?? ""),
statsYr: ctx.year,
statsCd,
};
@@ -1170,19 +1181,20 @@ const SewerageFinanceInp = () => {
return map;
}, [tabStatusInfoMap, inputPeriodEnterable, isAdminInfo, columnGuidesByTab]);
const searchContextForToolbar = searchContextByTab.get(activeTab) ?? lastSearchedValues;
const activeTabStatus = tabStatusInfoMap.get(activeTab) ?? null;
const activeTabToolbar =
toolbarSnapshotByTab.get(activeTab) ??
computeTabToolbarSnapshot(
activeTabStatus,
tabRowDataExists(rowDataMap, activeTab),
hasSearched,
lastSearchedValues,
searchContextForToolbar,
inputPeriodEnterable,
isAdminInfo,
);
const { showSaveInToolbar, showEnterableToolbarButtons, showActionToolbarCard } =
activeTabToolbar;
const submitOk = buildSubmitOkForToolbar(searchContextForToolbar);
const verificationCellStyle = ({
fieldName,
@@ -1241,6 +1253,7 @@ const SewerageFinanceInp = () => {
<>
<div className="relative">
<SearchForm
isInput
key={searchFormRemountKey}
defaultValues={verificationSearchDefaults ?? undefined}
onSubmit={handleSearch}
@@ -1261,10 +1274,10 @@ const SewerageFinanceInp = () => {
<LastYearDataButton
getLastYearDataFunc={() => void lastYearDataFunc()}
/>
<SubmitButton submitFunc={submitFunc} />
{submitOk && <SubmitButton submitFunc={submitFunc} />}
</>
)}
{activeTabStatus?.laeSbmsnSttsCd === "2" && (
{activeTabStatus?.laeSbmsnSttsCd === "2" && submitOk && (
<CancelSubmitButton cnacelSubmitFunc={cnacelSubmitFunc} />
)}
{showSaveInToolbar && <SaveButton saveFunc={saveFunc} />}
@@ -1300,7 +1313,7 @@ const SewerageFinanceInp = () => {
tabStatusInfoMap.get(tabKey) ?? null,
inputPeriodEnterable,
) || isAdminInfo) && inputPeriodEnterable;
const gugunOk = buildGugunOkForToolbar(lastSearchedValues);
const gugunOk = buildGugunOkForToolbar(searchContextForToolbar);
const tabStatusInfo = tabStatusInfoMap.get(tabKey) ?? null;
return (
@@ -2,7 +2,7 @@ import { useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
import { useConfirm } from "@frontend-opensource/use-react-hooks";
import { useAlertStore, useGlobalProgressStore, useStatisticsInputToolbarGroupGate } from "@/shared/lib";
import { useAlertStore, useGlobalProgressStore, useSearchConditionSidoList, useStatisticsInputToolbarGroupGate } from "@/shared/lib";
import {
STATISTICS_INPUT_URL_PATH,
verificationSearchToFormValues,
@@ -25,8 +25,15 @@ import type {
cancelSubmitRequest,
ImrStatusResponse,
SewerageStatusInfo,
Sido,
SubmitExceptionRequest,
} from "@/entities/statistics/model/statistics-interface";
import {
filterBySelectedAdmdstCd,
isGugunOkForToolbar,
isSubmitOkForToolbar,
toInputSearchRegion,
} from "@/entities/statistics";
import { LoadingWithAnimation } from "@common/components";
import { getUserInfo } from "../../../../../../packages/common/components/src/api";
@@ -45,7 +52,6 @@ import SearchForm from "@/components/module/SearchForm";
import { VerificationResultDialog } from "@/components/module/VerificationResultDialog";
import { VerificationResultHistoryDialog } from "@/components/module/VerificationResultHistoryDialog";
import type { SearchFormValues } from "@/components/type/SearchForm.type";
import { doList } from "@/components/util/column/input/DoList";
import { SeweragePenetrationRateInpColumn } from "@/components/util/column/input/SeweragePenetrationRateInpColumn";
import { getFooterSummary } from "@/components/util/grid/footerSummary";
import { toGridRows } from "@/components/util/grid/gridFunction";
@@ -118,14 +124,15 @@ async function waitForImrJobCompleted(
throw new Error("시계열 검증 완료 대기 시간이 초과되었습니다.");
}
const sidoListRef: { current: Sido[] } = { current: [] };
function getSewerageSupplyRateParams(
values: SearchFormValues,
overrides?: { yr?: string; demoYr?: string; mode?: string }
): SewerageSupplyRateRequestParams {
return {
ctpvNm: values.sido,
sggNm: values.gugun === 'ALL' ? '' : values.gugun,
sewerBzmnCd: values.bsnmCd,
...toInputSearchRegion(sidoListRef.current, values),
statsYr: overrides?.yr ?? values.year,
...(overrides?.mode && { mode: overrides.mode }),
};
@@ -133,6 +140,8 @@ function getSewerageSupplyRateParams(
// 하수도 통계 관리 > 01. 하수도 보급률
const SeweragePenetrationRateInp = () => {
const { sidoList, isReady } = useSearchConditionSidoList({ isInput: true });
sidoListRef.current = sidoList;
const { setMessage: alert } = useAlertStore((state) => state);
const [rowData, setRowData] = useState<Record<string, string | number>[]>([]);
const [isLoading, setIsLoading] = useState<boolean>(false);
@@ -174,15 +183,16 @@ const SeweragePenetrationRateInp = () => {
if (activeTabId !== STATISTICS_INPUT_URL_PATH.SEWERAGE_PENETRATION_RATE) {
return;
}
if (!isReady) return;
const pending = useStatisticsInputFocusStore
.getState()
.takePendingForUrl(STATISTICS_INPUT_URL_PATH.SEWERAGE_PENETRATION_RATE);
if (!pending?.search) return;
const values = verificationSearchToFormValues(pending.search);
const values = verificationSearchToFormValues(pending.search, sidoList);
setVerificationSearchDefaults(values);
postVerificationSearchRef.current = values;
setSearchFormRemountKey((k) => k + 1);
}, [activeTabId, inputFocusNonce]);
}, [activeTabId, inputFocusNonce, isReady, sidoList]);
useEffect(() => {
if (activeTabId !== STATISTICS_INPUT_URL_PATH.SEWERAGE_PENETRATION_RATE) {
@@ -269,14 +279,22 @@ const SeweragePenetrationRateInp = () => {
setSearchFormRemountKey((k) => k + 1);
};
const fetchSewerageSupplyRate = async (params: SewerageSupplyRateRequestParams, isEnterable: boolean) => {
const fetchSewerageSupplyRate = async (
params: SewerageSupplyRateRequestParams,
isEnterable: boolean,
values?: SearchFormValues | null,
) => {
try {
setIsLoading(true);
const response = await statisticsInputSewSupplyRateApi.getSewerageSupplyRateList(params);
if (response.status === 'success' && response.data) {
const commonInfo = response.data.commonInfo;
const statusInfo = response.data.statusInfo;
const convertedData: SewerageSupplyRateItem[] = response.data.sewerageSupplyRateList.map((d: SewerageSupplyRateItem) => ({
const convertedData: SewerageSupplyRateItem[] = filterBySelectedAdmdstCd(
response.data.sewerageSupplyRateList,
sidoListRef.current,
values,
).map((d: SewerageSupplyRateItem) => ({
...d,
ctpvNm: commonInfo.ctpvNm,
spcCtpnRgnCn: d.spcCtpnRgnCn === '' || d.spcCtpnRgnCn === null ? '해당없음' : d.spcCtpnRgnCn,
@@ -346,7 +364,7 @@ const SeweragePenetrationRateInp = () => {
setPeriodCheckList(periods);
const checkEnterable = isInputPeriodCurrent(periods);
setLastSearchedYear(values.year || null);
await fetchSewerageSupplyRate(getSewerageSupplyRateParams(values), checkEnterable);
await fetchSewerageSupplyRate(getSewerageSupplyRateParams(values), checkEnterable, values);
setLastSearchedValues(values);
} else {
alert(response.message);
@@ -374,9 +392,8 @@ const SeweragePenetrationRateInp = () => {
const params: SubmitExceptionRequest = {
...submitInfo,
sewerBzmnCd: searchValues?.bsnmCd ?? '',
...toInputSearchRegion(sidoListRef.current, searchValues),
ctpvNm: searchValues?.sido ?? '',
sggNm: searchValues?.gugun === "ALL" ? "" : (searchValues?.gugun ?? ''),
statsYr: searchValues?.year ?? '',
userId: userInfo.userUnqId,
statsCd: statsCd,
@@ -392,7 +409,7 @@ const SeweragePenetrationRateInp = () => {
const response = await statisticsApi.submitException(params);
if (response.status === 'success') {
await fetchSewerageSupplyRate(getSewerageSupplyRateParams(searchValues ?? {}), false);
await fetchSewerageSupplyRate(getSewerageSupplyRateParams(searchValues ?? {}), false, searchValues ?? {});
alert('제출되었습니다.');
} else {
alert(response.message || '데이터 제출 중 오류가 발생했습니다.');
@@ -416,7 +433,7 @@ const SeweragePenetrationRateInp = () => {
return;
}
await fetchSewerageSupplyRate(getSewerageSupplyRateParams(values, { mode: 'PRE' }), true);
await fetchSewerageSupplyRate(getSewerageSupplyRateParams(values, { mode: 'PRE' }), true, values);
};
const submitFunc = async (isException: boolean) => {
@@ -512,9 +529,8 @@ const SeweragePenetrationRateInp = () => {
}));
const requestData: SewerageSupplyRateSaveRequest = {
sewerBzmnCd: searchValues?.bsnmCd ?? '',
...toInputSearchRegion(sidoListRef.current, searchValues),
ctpvNm: searchValues?.sido ?? '',
sggNm: searchValues?.gugun === "ALL" ? "" : (searchValues?.gugun ?? ''),
statsYr: searchValues?.year ?? '',
userId: userInfo.userUnqId,
submitList: convertedData,
@@ -558,13 +574,12 @@ const SeweragePenetrationRateInp = () => {
);
}
setGlobalProgress(100);
await fetchSewerageSupplyRate(getSewerageSupplyRateParams(searchValues ?? {}), true);
await fetchSewerageSupplyRate(getSewerageSupplyRateParams(searchValues ?? {}), true, searchValues ?? {});
await openVerificationResultDialogIfNeeded(
searchValues?.year && searchValues?.sido && searchValues?.bsnmCd && statsCd
? {
sewerBzmnCd: searchValues.bsnmCd,
...toInputSearchRegion(sidoListRef.current, searchValues),
ctpvNm: searchValues.sido,
sggNm: searchValues.gugun === "ALL" ? "" : (searchValues.gugun ?? ""),
statsYr: searchValues.year,
statsCd,
}
@@ -573,14 +588,13 @@ const SeweragePenetrationRateInp = () => {
{ notify: alert },
);
} catch (e) {
await fetchSewerageSupplyRate(getSewerageSupplyRateParams(searchValues ?? {}), true);
await fetchSewerageSupplyRate(getSewerageSupplyRateParams(searchValues ?? {}), true, searchValues ?? {});
setIsLoading(false);
await openVerificationResultDialogIfNeeded(
searchValues?.year && searchValues?.sido && searchValues?.bsnmCd && statsCd
? {
sewerBzmnCd: searchValues.bsnmCd,
...toInputSearchRegion(sidoListRef.current, searchValues),
ctpvNm: searchValues.sido,
sggNm: searchValues.gugun === "ALL" ? "" : (searchValues.gugun ?? ""),
statsYr: searchValues.year,
statsCd,
}
@@ -597,13 +611,12 @@ const SeweragePenetrationRateInp = () => {
}
} else {
setGlobalProgress(100);
await fetchSewerageSupplyRate(getSewerageSupplyRateParams(searchValues ?? {}), false);
await fetchSewerageSupplyRate(getSewerageSupplyRateParams(searchValues ?? {}), false, searchValues ?? {});
await openVerificationResultDialogIfNeeded(
searchValues?.year && searchValues?.sido && searchValues?.bsnmCd && statsCd
? {
sewerBzmnCd: searchValues.bsnmCd,
...toInputSearchRegion(sidoListRef.current, searchValues),
ctpvNm: searchValues.sido,
sggNm: searchValues.gugun === "ALL" ? "" : (searchValues.gugun ?? ""),
statsYr: searchValues.year,
statsCd,
}
@@ -702,9 +715,8 @@ const SeweragePenetrationRateInp = () => {
}));
const requestData: SewerageSupplyRateSaveRequest = {
sewerBzmnCd: searchValues?.bsnmCd ?? '', // 하수도 사업자 코드
...toInputSearchRegion(sidoListRef.current, searchValues),
ctpvNm: searchValues?.sido ?? '', // 시도
sggNm: searchValues?.gugun === "ALL" ? "" : (searchValues?.gugun ?? ''),
statsYr: searchValues?.year ?? '', // 통계 연도
userId: userInfo.userUnqId, // 사용자
saveList: convertedData, // 저장 데이터
@@ -720,7 +732,7 @@ const SeweragePenetrationRateInp = () => {
if (response.status === 'success') {
setGlobalProgress(50);
setGlobalProgress(100);
await fetchSewerageSupplyRate(getSewerageSupplyRateParams(searchValues ?? {}), true);
await fetchSewerageSupplyRate(getSewerageSupplyRateParams(searchValues ?? {}), true, searchValues ?? {});
alert('저장되었습니다.');
} else {
alert(response.message || '데이터 저장 중 오류가 발생했습니다.');
@@ -747,9 +759,8 @@ const SeweragePenetrationRateInp = () => {
const userInfo = await getUserInfo();
const requestData: cancelSubmitRequest = {
sewerBzmnCd: searchValues?.bsnmCd ?? '',
...toInputSearchRegion(sidoListRef.current, searchValues),
ctpvNm: searchValues?.sido ?? '',
sggNm: searchValues?.gugun === "ALL" ? "" : (searchValues?.gugun ?? ""),
statsYr: searchValues?.year ?? '',
mdfrId: userInfo.userUnqId,
statsCd: statsCd,
@@ -758,7 +769,7 @@ const SeweragePenetrationRateInp = () => {
const response = await statisticsApi.cancelSubmit(requestData);
if (response.status === 'success') {
fetchSewerageSupplyRate(getSewerageSupplyRateParams(searchValues ?? {}), true);
fetchSewerageSupplyRate(getSewerageSupplyRateParams(searchValues ?? {}), true, searchValues ?? {});
alert('제출 취소되었습니다.');
} else {
alert(response.message ?? '제출 취소 중 오류가 발생했습니다.');
@@ -777,9 +788,9 @@ const SeweragePenetrationRateInp = () => {
setVerificationHistoryOpen(true);
};
const gugunOkOrNotDoList = doList.includes(lastSearchedValues?.bsnmCd || '')
? Boolean(lastSearchedValues?.gugun && lastSearchedValues.gugun !== 'ALL')
: true;
const toolbarSearchContext = lastSearchedValues;
const gugunOkOrNotDoList = isGugunOkForToolbar(sidoList, toolbarSearchContext);
const submitOk = isSubmitOkForToolbar(sidoList, toolbarSearchContext);
const inputPeriodCurrent = isInputPeriodCurrent(periodCheckList);
const isSubmitted = statusInfo?.laeSbmsnSttsCd === '2';
@@ -802,6 +813,7 @@ const SeweragePenetrationRateInp = () => {
<>
<div className="relative">
<SearchForm
isInput
key={searchFormRemountKey}
defaultValues={verificationSearchDefaults ?? undefined}
onSubmit={handleSearch}
@@ -818,10 +830,10 @@ const SeweragePenetrationRateInp = () => {
{showEnterableToolbarButtons && (
<>
<LastYearDataButton getLastYearDataFunc={() => getLastYearDataFunc(searchValues ?? {})} />
<SubmitButton submitFunc={() => submitFunc(false)} />
{submitOk && <SubmitButton submitFunc={() => submitFunc(false)} />}
</>
)}
{statusInfo?.laeSbmsnSttsCd === '2' && <CancelSubmitButton cnacelSubmitFunc={cnacelSubmitFunc} />}
{statusInfo?.laeSbmsnSttsCd === '2' && submitOk && <CancelSubmitButton cnacelSubmitFunc={cnacelSubmitFunc} />}
{showSaveInToolbar && <SaveButton saveFunc={saveFunc} />}
</div>
</div>
@@ -836,7 +848,7 @@ const SeweragePenetrationRateInp = () => {
<DataGrid
key={((isEnterable || isAdminInfo) && inputPeriodCurrent) ? 'enterable' : 'readonly'}
columnInfo={columnInfo}
isExcelImport={(rowData.length > 0) && isEnterable && (doList.includes(lastSearchedValues?.bsnmCd || '') ? Boolean(lastSearchedValues?.gugun && lastSearchedValues.gugun !== 'ALL') : true)}
isExcelImport={(rowData.length > 0) && isEnterable && gugunOkOrNotDoList}
excelImportSewerBzmnCd={(lastSearchedValues ?? searchValues)?.bsnmCd}
excelExportSearchContext={toExcelExportSearchContextFromSearchForm(lastSearchedValues ?? searchValues)}
rowStartNum={3}
@@ -892,9 +904,8 @@ const SeweragePenetrationRateInp = () => {
queryContext={
searchValues?.year && searchValues?.sido && searchValues?.bsnmCd && statsCd
? {
sewerBzmnCd: searchValues.bsnmCd,
...toInputSearchRegion(sidoListRef.current, searchValues),
ctpvNm: searchValues.sido,
sggNm: searchValues.gugun === "ALL" ? "" : (searchValues.gugun ?? ""),
statsYr: searchValues.year,
statsCd,
}
@@ -912,12 +923,8 @@ const SeweragePenetrationRateInp = () => {
queryContext={
searchValues?.year && searchValues?.sido && searchValues?.bsnmCd && statsCd
? {
sewerBzmnCd: searchValues.bsnmCd,
...toInputSearchRegion(sidoListRef.current, searchValues),
ctpvNm: searchValues.sido,
sggNm:
searchValues.gugun === "ALL"
? ""
: (searchValues.gugun ?? ""),
statsYr: searchValues.year,
statsCd,
}
@@ -2,7 +2,7 @@ import { useEffect, useMemo, useRef, useState } from "react";
import { useConfirm } from "@frontend-opensource/use-react-hooks";
import { useAlertStore, useGlobalProgressStore, useStatisticsInputToolbarGroupGate } from "@/shared/lib";
import { useAlertStore, useGlobalProgressStore, useStatisticsInputToolbarGroupGate, useSearchConditionSidoList } from "@/shared/lib";
import { STATISTICS_INPUT_URL_PATH } from "@/shared/lib/stats-cd-input-navigation";
import { useStatisticsInputPendingNavigation } from "@/shared/lib/use-statistics-input-pending-navigation";
import { ConfirmDialog } from "@/shared/ui/confirm-dialog";
@@ -25,7 +25,16 @@ import type {
cancelSubmitRequest,
ImrStatusResponse,
SewerageStatusInfo,
Sido,
} from "@/entities/statistics/model/statistics-interface";
import {
filterBySelectedAdmdstCd,
isGugunOkForToolbar,
isSubmitOkForToolbar,
resolveNoApplicableForRequest,
toInputSearchRegion,
} from "@/entities/statistics";
import { LoadingWithAnimation, Tabs, TabsContent, TabsList, TabsTrigger } from "@common/components";
import { getUserInfo } from "../../../../../../packages/common/components/src/api";
@@ -45,7 +54,6 @@ import { VerificationResultDialog } from "@/components/module/VerificationResult
import { VerificationResultHistoryDialog } from "@/components/module/VerificationResultHistoryDialog";
import type { ColumnConfig, ColumnInfo } from "@/components/type/DataGrid.type";
import type { SearchFormValues } from "@/components/type/SearchForm.type";
import { doList } from "@/components/util/column/input/DoList";
import { ComplaintInpColumn } from "@/components/util/column/input/sewerageServiceLevel/ComplaintInpColumn";
import { ResidentFriendlyFactInpColumn } from "@/components/util/column/input/sewerageServiceLevel/ResidentFriendlyFactInpColumn";
import { fetchColumnGuidesRecord } from "@/components/util/grid/columnGuides";
@@ -120,10 +128,22 @@ const computeTabEnterable = (
return periodEnterable;
};
const sidoListRef: { current: Sido[] } = { current: [] };
function buildGugunOkForToolbar(values: SearchFormValues | null): boolean {
return doList.includes(values?.bsnmCd || "")
? Boolean(values?.gugun && values.gugun !== "ALL")
: true;
return isGugunOkForToolbar(sidoListRef.current, values);
}
function buildSubmitOkForToolbar(values: SearchFormValues | null): boolean {
return isSubmitOkForToolbar(sidoListRef.current, values);
}
function buildNoApplicableForRequest(
values: SearchFormValues | null,
checked: boolean,
isSaveListEmpty: boolean,
): boolean {
return resolveNoApplicableForRequest(sidoListRef.current, values, checked, isSaveListEmpty);
}
function computeTabToolbarSnapshot(
@@ -155,17 +175,16 @@ function buildSewerageServiceLevelSearchParam(
): SewerageServiceLevelComplaintRequestParams {
return {
statsYr: values.year,
sewerBzmnCd: values.bsnmCd,
ctpvNm: values.sido,
sggNm: values.gugun === "ALL" ? "" : values.gugun,
...toInputSearchRegion(sidoListRef.current, values),
...(overrides?.mode ? { mode: overrides.mode } : {}),
};
}
function mapServiceLevelListToGridRows<
T extends { verificationResult?: SewerageServiceLevelVerificationResult },
>(list: T[], ctpvNm: string): GridRowWithVerification[] {
return list.map((item) => {
>(list: T[], ctpvNm: string, values?: SearchFormValues | null): GridRowWithVerification[] {
return filterBySelectedAdmdstCd(list, sidoListRef.current, values).map((item) => {
const { verificationResult, ...rest } = item;
const row = toGridRows([{ ctpvNm, ...rest }])[0] as GridRowWithVerification;
if (verificationResult) row.verificationResult = verificationResult;
@@ -271,6 +290,8 @@ async function waitForImrJobCompleted(
// 하수도 통계 관리 > 13. 하수도 서비스 수준
const SewerageServiceLevelInp = () => {
const { sidoList } = useSearchConditionSidoList({ isInput: true });
sidoListRef.current = sidoList;
const { setMessage: alert } = useAlertStore((state) => state);
const { confirm } = useConfirm();
const { isAdminInfo } = useAdminStore();
@@ -301,9 +322,12 @@ const SewerageServiceLevelInp = () => {
const [footerVerificationByTab, setFooterVerificationByTab] = useState<
Map<string, VerificationResultLikeMap | null>
>(new Map());
const [toolbarSnapshotByTab, setToolbarSnapshotByTab] = useState<
const [_toolbarSnapshotByTab, setToolbarSnapshotByTab] = useState<
Map<string, TabToolbarSnapshot>
>(new Map());
const [searchContextByTab, setSearchContextByTab] = useState<Map<string, SearchFormValues>>(
() => new Map(),
);
const [columnGuidesByTab, setColumnGuidesByTab] = useState<
Record<string, Record<string, string>>
>({});
@@ -366,6 +390,13 @@ const SewerageServiceLevelInp = () => {
);
return next;
});
if (searchContext) {
setSearchContextByTab((prev) => {
const next = new Map(prev);
next.set(tabKey, searchContext);
return next;
});
}
};
const applyRowMap = (
@@ -407,6 +438,7 @@ const SewerageServiceLevelInp = () => {
const gridRows = mapServiceLevelListToGridRows(
(complaintList ?? []) as SewerageServiceLevelComplaintItem[],
commonInfo.ctpvNm,
searchContext,
);
applyRowMap(mergeIntoExistingMap, (m) => {
@@ -439,6 +471,7 @@ const SewerageServiceLevelInp = () => {
const gridRows = mapServiceLevelListToGridRows(
(residentFriendlyFactList ?? []) as SewerageServiceLevelResidentFriendlyFactItem[],
commonInfo.ctpvNm,
searchContext,
);
if (!fromPreYear) {
publicSewageFacilitiesAvailableRef.current = gridRows.length > 0;
@@ -483,6 +516,7 @@ const SewerageServiceLevelInp = () => {
setIsVerificationFailedByTab(new Map());
setFooterVerificationByTab(new Map());
setToolbarSnapshotByTab(new Map());
setSearchContextByTab(new Map());
setActiveTab(firstTabKey);
activeTabRef.current = firstTabKey;
setLastSearchedValues(null);
@@ -529,6 +563,7 @@ const SewerageServiceLevelInp = () => {
setIsVerificationFailedByTab(new Map());
setFooterVerificationByTab(new Map());
setToolbarSnapshotByTab(new Map());
setSearchContextByTab(new Map());
setIsNotApplicable(false);
activeTabRef.current = firstTabKey;
setActiveTab(firstTabKey);
@@ -647,9 +682,19 @@ const SewerageServiceLevelInp = () => {
const tabKey = activeTabRef.current;
const isResidentTab = tabKey === ResidentFriendlyFactInpColumn.tabKey;
const latestRows = getTabGridRows(tabKey);
const noApplicable = isResidentTab && isNotApplicable;
const noApplicable =
isResidentTab &&
buildNoApplicableForRequest(
searchContextByTab.get(tabKey) ?? lastSearchedValues,
isNotApplicable,
latestRows.length === 0,
);
if (latestRows.length === 0) {
if (isResidentTab && !noApplicable) {
if (
isResidentTab &&
!noApplicable &&
buildSubmitOkForToolbar(searchContextByTab.get(tabKey) ?? lastSearchedValues)
) {
alert("해당사항 없음을 체크해주세요.");
return;
}
@@ -690,7 +735,13 @@ const SewerageServiceLevelInp = () => {
return next;
});
const noApplicable = isResidentTab && isNotApplicable;
const noApplicable =
isResidentTab &&
buildNoApplicableForRequest(
searchContextByTab.get(tabKey) ?? lastSearchedValues,
isNotApplicable,
latestRows.length === 0,
);
const complaintSubmitList = buildComplaintSaveList(latestRows);
const residentSubmitList = noApplicable
? []
@@ -700,7 +751,12 @@ const SewerageServiceLevelInp = () => {
alert("제출할 데이터가 없습니다.");
return;
}
if (isResidentTab && !noApplicable && residentSubmitList.length === 0) {
if (
isResidentTab &&
!noApplicable &&
residentSubmitList.length === 0 &&
buildSubmitOkForToolbar(searchContextByTab.get(tabKey) ?? lastSearchedValues)
) {
alert("해당사항 없음을 체크해주세요.");
return;
}
@@ -715,11 +771,7 @@ const SewerageServiceLevelInp = () => {
const submitInfoBase = {
statsYr: lastSearchedValues.year ?? "",
ctpvNm: lastSearchedValues.sido ?? "",
sggNm:
lastSearchedValues.gugun === "ALL"
? ""
: (lastSearchedValues.gugun ?? ""),
sewerBzmnCd: lastSearchedValues.bsnmCd ?? "",
...toInputSearchRegion(sidoListRef.current, lastSearchedValues),
laePicNm: submitInfo.laePicNm,
laePicTelNo: submitInfo.laePicTelNo,
laeKbrdrDeptNm: submitInfo.laeKbrdrDeptNm,
@@ -731,12 +783,8 @@ const SewerageServiceLevelInp = () => {
};
const verificationQuery = {
sewerBzmnCd: lastSearchedValues.bsnmCd ?? "",
...toInputSearchRegion(sidoListRef.current, lastSearchedValues),
ctpvNm: lastSearchedValues.sido ?? "",
sggNm:
lastSearchedValues.gugun === "ALL"
? ""
: (lastSearchedValues.gugun ?? ""),
statsYr: lastSearchedValues.year ?? "",
statsCd: statsCdForTab,
};
@@ -784,7 +832,7 @@ const SewerageServiceLevelInp = () => {
setGlobalProgressLabel("시계열 검증 진행 중...");
const imrParam = {
user_id: userInfo.userUnqId,
sewer_bzmn_cd: lastSearchedValues.bsnmCd ?? "",
sewer_bzmn_cd: lastSearchedValues?.bsnmCd ?? "",
stats_cd: statsCdForTab,
stats_yr: lastSearchedValues.year ?? "",
lae_sbmsn_stts_cd: activeTabStatus?.laeSbmsnSttsCd === "4" ? "4" : "2",
@@ -865,15 +913,17 @@ const SewerageServiceLevelInp = () => {
return next;
});
const noApplicable = isResidentTab && isNotApplicable;
const noApplicable =
isResidentTab &&
buildNoApplicableForRequest(
searchContextByTab.get(tabKey) ?? lastSearchedValues,
isNotApplicable,
latestRows.length === 0,
);
const baseRequest = {
statsYr: lastSearchedValues.year ?? "",
ctpvNm: lastSearchedValues.sido ?? "",
sggNm:
lastSearchedValues.gugun === "ALL"
? ""
: (lastSearchedValues.gugun ?? ""),
sewerBzmnCd: lastSearchedValues.bsnmCd ?? "",
...toInputSearchRegion(sidoListRef.current, lastSearchedValues),
};
try {
@@ -903,7 +953,11 @@ const SewerageServiceLevelInp = () => {
const saveList = noApplicable
? []
: buildResidentFriendlyFactSaveList(latestRows);
if (!noApplicable && saveList.length === 0) {
if (
!noApplicable &&
saveList.length === 0 &&
buildSubmitOkForToolbar(searchContextByTab.get(tabKey) ?? lastSearchedValues)
) {
alert("해당사항 없음을 체크해주세요.");
return;
}
@@ -963,12 +1017,8 @@ const SewerageServiceLevelInp = () => {
}
const requestData: cancelSubmitRequest = {
sewerBzmnCd: lastSearchedValues.bsnmCd ?? "",
...toInputSearchRegion(sidoListRef.current, lastSearchedValues),
ctpvNm: lastSearchedValues.sido ?? "",
sggNm:
lastSearchedValues.gugun === "ALL"
? ""
: (lastSearchedValues.gugun ?? ""),
statsYr: lastSearchedValues.year ?? "",
mdfrId: userInfo.userUnqId,
statsCd: statsCdForTab,
@@ -1026,15 +1076,15 @@ const SewerageServiceLevelInp = () => {
return map;
}, [tabStatusInfoMap, inputPeriodEnterable, isAdminInfo, columnGuidesByTab]);
const searchContextForToolbar = searchContextByTab.get(activeTab) ?? lastSearchedValues;
const activeTabStatus = tabStatusInfoMap.get(activeTab) ?? null;
const activeTabRowData = rowDataMap.get(activeTab) ?? [];
const activeTabToolbar =
toolbarSnapshotByTab.get(activeTab) ??
computeTabToolbarSnapshot(
activeTabStatus,
tabRowDataExists(rowDataMap, activeTab),
hasSearched,
lastSearchedValues,
searchContextForToolbar,
inputPeriodEnterable,
isAdminInfo,
);
@@ -1045,12 +1095,14 @@ const SewerageServiceLevelInp = () => {
activeTabToolbar.showEnterableToolbarButtons && toolbarGroupAllowed;
const showActionToolbarCard =
activeTabToolbar.showActionToolbarCard && toolbarGroupAllowed;
const submitOk = buildSubmitOkForToolbar(searchContextForToolbar);
const showNotApplicableForResidentTab =
activeTab === ResidentFriendlyFactInpColumn.tabKey &&
searchLoaded &&
hasSearched &&
activeTabRowData.length === 0 &&
computeTabEnterable(activeTabStatus, inputPeriodEnterable);
computeTabEnterable(activeTabStatus, inputPeriodEnterable) &&
submitOk;
const showSecondaryToolbarCard =
hasSearched &&
toolbarGroupAllowed &&
@@ -1061,9 +1113,8 @@ const SewerageServiceLevelInp = () => {
const statsCd = tabStatsCdMap.get(activeTab);
if (!ctx?.year || !ctx?.sido || !ctx?.bsnmCd || !statsCd) return null;
return {
sewerBzmnCd: ctx.bsnmCd,
...toInputSearchRegion(sidoListRef.current, ctx),
ctpvNm: ctx.sido,
sggNm: ctx.gugun === "ALL" ? "" : (ctx.gugun ?? ""),
statsYr: ctx.year,
statsCd,
};
@@ -1126,6 +1177,7 @@ const SewerageServiceLevelInp = () => {
<>
<div className="relative">
<SearchForm
isInput
key={searchFormRemountKey}
defaultValues={verificationSearchDefaults ?? undefined}
onSubmit={handleSearch}
@@ -1146,10 +1198,10 @@ const SewerageServiceLevelInp = () => {
<LastYearDataButton
getLastYearDataFunc={() => void getLastYearDataFunc()}
/>
<SubmitButton submitFunc={submitFunc} />
{submitOk && <SubmitButton submitFunc={submitFunc} />}
</>
)}
{activeTabStatus?.laeSbmsnSttsCd === "2" && (
{activeTabStatus?.laeSbmsnSttsCd === "2" && submitOk && (
<CancelSubmitButton cnacelSubmitFunc={cnacelSubmitFunc} />
)}
{showSaveInToolbar && <SaveButton saveFunc={saveFunc} />}
@@ -1197,7 +1249,7 @@ const SewerageServiceLevelInp = () => {
tabStatusInfoMap.get(tabKey) ?? null,
inputPeriodEnterable,
) || isAdminInfo) && inputPeriodEnterable;
const gugunOk = buildGugunOkForToolbar(lastSearchedValues);
const gugunOk = buildGugunOkForToolbar(searchContextForToolbar);
const tabStatusInfo = tabStatusInfoMap.get(tabKey) ?? null;
return (
@@ -70,7 +70,7 @@ const StatisticsReviewHistory = () => {
return (
<div className="relative">
<SearchForm onSubmit={handleSearch} onReset={handleReset} />
<SearchForm isInput onSubmit={handleSearch} onReset={handleReset} />
{isLoading && (
<div className="absolute inset-0 z-50 [data-theme='black']:bg-transparent rounded-lg p-10 flex justify-center items-center">
<div className="relative size-[5rem]">
@@ -4,7 +4,7 @@ import { useConfirm } from "@frontend-opensource/use-react-hooks";
import { RealGridReact } from "realgrid-react";
import useSWR, { useSWRConfig } from "swr";
import { useActiveTabRegAuthorityAllowed, useAlertStore } from "@/shared/lib";
import { useActiveTabRegAuthorityAllowed, useAlertStore, useSearchConditionSidoList } from "@/shared/lib";
import { statisticsInputSewSupplyRateApi } from "@/entities/statistics/api/input/statistics-input-sew-supply-rate-service";
import { StatisticsInputStatusApi } from "@/entities/statistics/api/input/statistics-input-status-service";
import { statisticsApi } from "@/entities/statistics/api/statistics-service";
@@ -17,6 +17,7 @@ import {
isInputPeriodCurrent,
} from "@/entities/statistics/model/input/statistics-sewage-supply-rate-input-interface";
import type { StatsInputStatusApproveItem } from "@/entities/statistics/model/statistics-interface";
import { isGugunOkForToolbar } from "@/entities/statistics";
import { LoadingWithAnimation } from "@common/components";
import { getUserInfo } from "../../../../../../packages/common/components/src/api";
@@ -30,7 +31,6 @@ import {
import SearchForm from "@/components/module/SearchForm";
import type { DataCellClickCallbackParams } from "@/components/type/DataGrid.type";
import type { SearchFormValues } from "@/components/type/SearchForm.type";
import { doList } from "@/components/util/column/input/DoList";
import { StatsInputStatusInpColumn } from "@/components/util/column/input/StatsInputStatusInpColumn";
import { toGridRows } from "@/components/util/grid/gridFunction";
import { useTabStore } from "@/store/tab-store";
@@ -44,6 +44,7 @@ const getStatsInputStatusFetcher = async (
// 하수도 통계 관리 > 00. 통계 입력 현황
const StatsInputStatusInp = () => {
const { sidoList } = useSearchConditionSidoList();
const { setMessage: alert } = useAlertStore((state) => state);
const { confirm } = useConfirm();
const activeTabId = useTabStore((state) => state.activeTabId);
@@ -254,9 +255,7 @@ const StatsInputStatusInp = () => {
await mutate(["stats-input-status", searchParams]);
}, [mutate, searchParams]);
const gugunOkOrNotDoList = doList.includes(lastSearchedValues?.bsnmCd || "")
? Boolean(lastSearchedValues?.gugun && lastSearchedValues.gugun !== "ALL")
: true;
const gugunOkOrNotDoList = isGugunOkForToolbar(sidoList, lastSearchedValues);
const allRowsLaeSbmsnApproved = useMemo(
() =>
@@ -13,7 +13,7 @@ import { useConfirm } from "@frontend-opensource/use-react-hooks";
import { ValueType } from "realgrid";
import type { RealGridReact } from "realgrid-react";
import { useAlertStore, useGlobalProgressStore, useStatisticsInputToolbarGroupGate } from "@/shared/lib";
import { useAlertStore, useGlobalProgressStore, useStatisticsInputToolbarGroupGate, useSearchConditionSidoList } from "@/shared/lib";
import { STATISTICS_INPUT_URL_PATH } from "@/shared/lib/stats-cd-input-navigation";
import { useStatisticsInputPendingNavigation } from "@/shared/lib/use-statistics-input-pending-navigation";
import { ConfirmDialog } from "@/shared/ui/confirm-dialog";
@@ -48,7 +48,16 @@ import type {
ImrStatusResponse,
SewerageStatusInfo,
Sgg,
Sido,
} from "@/entities/statistics/model/statistics-interface";
import {
filterBySelectedAdmdstCd,
isGugunOkForToolbar,
isSubmitOkForToolbar,
resolveNoApplicableForRequest,
toInputSearchRegion,
} from "@/entities/statistics";
import { LoadingWithAnimation, Tabs, TabsContent, TabsList, TabsTrigger } from "@common/components";
import { getUserInfo } from "../../../../../../packages/common/components/src/api";
@@ -71,7 +80,6 @@ import { VerificationResultDialog } from "@/components/module/VerificationResult
import { VerificationResultHistoryDialog } from "@/components/module/VerificationResultHistoryDialog";
import type { ColumnConfig, ColumnInfo } from "@/components/type/DataGrid.type";
import type { SearchFormValues } from "@/components/type/SearchForm.type";
import { doList } from "@/components/util/column/input/DoList";
import { PublicSewageTreatWaterReuseInpColumn } from "@/components/util/column/input/waterReuse/PublicSewageTreatWaterReuseInpColumn";
import { RainFallUtilFactStatusInpColumn } from "@/components/util/column/input/waterReuse/RainFallUtilFactStatusInpColumn";
import { RecycledWaterStatusInpColumn } from "@/components/util/column/input/waterReuse/RecycledWaterStatusInpColumn";
@@ -159,10 +167,22 @@ const computeTabEnterable = (
return periodEnterable;
};
const sidoListRef: { current: Sido[] } = { current: [] };
function buildGugunOkForToolbar(values: SearchFormValues | null): boolean {
return doList.includes(values?.bsnmCd || "")
? Boolean(values?.gugun && values.gugun !== "ALL")
: true;
return isGugunOkForToolbar(sidoListRef.current, values);
}
function buildSubmitOkForToolbar(values: SearchFormValues | null): boolean {
return isSubmitOkForToolbar(sidoListRef.current, values);
}
function buildNoApplicableForRequest(
values: SearchFormValues | null,
checked: boolean,
isSaveListEmpty: boolean,
): boolean {
return resolveNoApplicableForRequest(sidoListRef.current, values, checked, isSaveListEmpty);
}
function computeTabToolbarSnapshot(
@@ -194,9 +214,8 @@ function buildWaterReuseSearchParam(
): WaterReuseRequestParams {
return {
statsYr: values.year,
sewerBzmnCd: values.bsnmCd,
ctpvNm: values.sido,
sggNm: values.gugun === "ALL" ? "" : values.gugun,
...toInputSearchRegion(sidoListRef.current, values),
...(overrides?.mode ? { mode: overrides.mode } : {}),
};
}
@@ -510,6 +529,8 @@ async function waitForImrJobCompleted(
// 하수도 통계 관리 > 10. 물 재이용
const WaterReuseInp = () => {
const { sidoList } = useSearchConditionSidoList({ isInput: true });
sidoListRef.current = sidoList;
const { setMessage: alert } = useAlertStore((state) => state);
const { confirm } = useConfirm();
const { isAdminInfo } = useAdminStore();
@@ -541,9 +562,12 @@ const WaterReuseInp = () => {
const [footerVerificationByTab, setFooterVerificationByTab] = useState<
Map<string, VerificationResultLikeMap | null>
>(new Map());
const [toolbarSnapshotByTab, setToolbarSnapshotByTab] = useState<
const [_toolbarSnapshotByTab, setToolbarSnapshotByTab] = useState<
Map<string, TabToolbarSnapshot>
>(new Map());
const [searchContextByTab, setSearchContextByTab] = useState<Map<string, SearchFormValues>>(
() => new Map(),
);
const [columnGuidesByTab, setColumnGuidesByTab] = useState<
Record<string, Record<string, string>>
>({});
@@ -644,6 +668,13 @@ const WaterReuseInp = () => {
);
return next;
});
if (searchContext) {
setSearchContextByTab((prev) => {
const next = new Map(prev);
next.set(tabKey, searchContext);
return next;
});
}
};
const applyRowMap = (
@@ -673,6 +704,8 @@ const WaterReuseInp = () => {
): Promise<boolean> => {
const requestParam = overrides?.mode ? { ...param, mode: overrides.mode } : param;
const fromPreYear = overrides?.mode === "PRE";
const filterFetched = <T,>(list: T[] | undefined) =>
filterBySelectedAdmdstCd(list, sidoListRef.current, searchContext);
const applyNotApplicableForLoadedTab = (
gridRows: readonly Record<string, string | number>[],
@@ -704,7 +737,7 @@ const WaterReuseInp = () => {
}
const { commonInfo, statusInfo, publicSewageTreatWaterReuseList } = response.data;
const gridRows = mapPublicSewageTreatWaterReuseListToGridRows(
(publicSewageTreatWaterReuseList ?? []) as PublicSewageTreatWaterReuseItem[],
filterFetched(publicSewageTreatWaterReuseList) as PublicSewageTreatWaterReuseItem[],
commonInfo.ctpvNm,
);
applyRowMap(mergeIntoExistingMap, (m) => {
@@ -735,7 +768,7 @@ const WaterReuseInp = () => {
}
const { commonInfo, statusInfo, recycledWaterList } = response.data;
const gridRows = mapRecycledWaterStatusListToGridRows(
(recycledWaterList ?? []) as RecycledWaterStatusItem[],
filterFetched(recycledWaterList) as RecycledWaterStatusItem[],
commonInfo.ctpvNm,
);
applyRowMap(mergeIntoExistingMap, (m) => {
@@ -766,7 +799,7 @@ const WaterReuseInp = () => {
}
const { commonInfo, statusInfo, rainFallUtilFactStatusList } = response.data;
const gridRows = mapRainFallUtilFactStatusListToGridRows(
(rainFallUtilFactStatusList ?? []) as RainFallUtilFactStatusItem[],
filterFetched(rainFallUtilFactStatusList) as RainFallUtilFactStatusItem[],
commonInfo.ctpvNm,
);
applyRowMap(mergeIntoExistingMap, (m) => {
@@ -798,8 +831,7 @@ const WaterReuseInp = () => {
}
const { commonInfo, statusInfo, treatWaterReuseDesignConstStatusList } = response.data;
const gridRows = mapTreatWaterReuseStatusListToGridRows(
(treatWaterReuseDesignConstStatusList ??
[]) as TreatWaterReuseDesignConstStatusItem[],
filterFetched(treatWaterReuseDesignConstStatusList) as TreatWaterReuseDesignConstStatusItem[],
commonInfo.ctpvNm,
);
applyRowMap(mergeIntoExistingMap, (m) => {
@@ -832,8 +864,7 @@ const WaterReuseInp = () => {
const { commonInfo, statusInfo, treatWaterReuseBusinessApprStatusList } =
response.data;
const gridRows = mapTreatWaterReuseStatusListToGridRows(
(treatWaterReuseBusinessApprStatusList ??
[]) as TreatWaterReuseBusinessApprStatusItem[],
filterFetched(treatWaterReuseBusinessApprStatusList) as TreatWaterReuseBusinessApprStatusItem[],
commonInfo.ctpvNm,
);
applyRowMap(mergeIntoExistingMap, (m) => {
@@ -906,6 +937,7 @@ const WaterReuseInp = () => {
setIsVerificationFailedByTab(new Map());
setFooterVerificationByTab(new Map());
setToolbarSnapshotByTab(new Map());
setSearchContextByTab(new Map());
setActiveTab(firstTabKey);
activeTabRef.current = firstTabKey;
setLastSearchedValues(null);
@@ -954,6 +986,7 @@ const WaterReuseInp = () => {
setIsVerificationFailedByTab(new Map());
setFooterVerificationByTab(new Map());
setToolbarSnapshotByTab(new Map());
setSearchContextByTab(new Map());
setDeleteListByTab(new Map());
loadedTabKeysRef.current.clear();
activeTabRef.current = firstTabKey;
@@ -1076,9 +1109,9 @@ const WaterReuseInp = () => {
return;
}
const noApplicable = isNotApplicableByTab.get(tabKey) ?? false;
const noApplicable = buildNoApplicableForRequest(searchContextByTab.get(tabKey) ?? lastSearchedValues, isNotApplicableByTab.get(tabKey) ?? false, getTabGridRows(tabKey).length === 0);
const currentData = getTabGridRows(tabKey);
if (!noApplicable && currentData.length === 0) {
if (!noApplicable && currentData.length === 0 && buildSubmitOkForToolbar(searchContextByTab.get(tabKey) ?? lastSearchedValues)) {
alert("해당사항 없음을 체크해주세요.");
return;
}
@@ -1111,11 +1144,7 @@ const WaterReuseInp = () => {
const submitRequestBase = {
statsYr: lastSearchedValues.year ?? "",
ctpvNm: lastSearchedValues.sido ?? "",
sggNm:
lastSearchedValues.gugun === "ALL"
? ""
: (lastSearchedValues.gugun ?? ""),
sewerBzmnCd: lastSearchedValues.bsnmCd ?? "",
...toInputSearchRegion(sidoListRef.current, lastSearchedValues),
laePicNm: submitInfo.laePicNm,
laePicTelNo: submitInfo.laePicTelNo,
laeKbrdrDeptNm: submitInfo.laeKbrdrDeptNm,
@@ -1135,12 +1164,8 @@ const WaterReuseInp = () => {
WATER_REUSE_COLUMN_GUIDE_STATS_CD_BY_TAB_KEY[tabKey] ??
tabKey;
const verificationQuery = {
sewerBzmnCd: lastSearchedValues.bsnmCd ?? "",
...toInputSearchRegion(sidoListRef.current, lastSearchedValues),
ctpvNm: lastSearchedValues.sido ?? "",
sggNm:
lastSearchedValues.gugun === "ALL"
? ""
: (lastSearchedValues.gugun ?? ""),
statsYr: lastSearchedValues.year ?? "",
statsCd: statsCdForTab,
};
@@ -1174,12 +1199,12 @@ const WaterReuseInp = () => {
};
if (isPublicSewageTab) {
const noApplicable = isNotApplicableByTab.get(tabKey) ?? false;
const noApplicable = buildNoApplicableForRequest(searchContextByTab.get(tabKey) ?? lastSearchedValues, isNotApplicableByTab.get(tabKey) ?? false, getTabGridRows(tabKey).length === 0);
const currentData = getTabGridRows(tabKey);
const submitList = noApplicable
? []
: currentData.map(buildPublicSewageTreatWaterReuseSaveItem);
if (!noApplicable && submitList.length === 0) {
if (!noApplicable && submitList.length === 0 && buildSubmitOkForToolbar(searchContextByTab.get(tabKey) ?? lastSearchedValues)) {
alert("해당사항 없음을 체크해주세요.");
return;
}
@@ -1191,7 +1216,7 @@ const WaterReuseInp = () => {
submitList,
});
} else {
const noApplicable = isNotApplicableByTab.get(tabKey) ?? false;
const noApplicable = buildNoApplicableForRequest(searchContextByTab.get(tabKey) ?? lastSearchedValues, isNotApplicableByTab.get(tabKey) ?? false, getTabGridRows(tabKey).length === 0);
const currentData = getTabGridRows(tabKey);
const sido = lastSearchedValues.sido ?? "";
@@ -1222,7 +1247,7 @@ const WaterReuseInp = () => {
.filter((row) => isPersistedArticleRow(tabKey, row))
.map((row) => buildRecycledWaterStatusSaveItem(row, list));
if (!noApplicable && submitList.length === 0) {
if (!noApplicable && submitList.length === 0 && buildSubmitOkForToolbar(searchContextByTab.get(tabKey) ?? lastSearchedValues)) {
alert("해당사항 없음을 체크해주세요.");
return;
}
@@ -1242,7 +1267,7 @@ const WaterReuseInp = () => {
.filter((row) => isPersistedArticleRow(tabKey, row))
.map((row) => buildRainFallUtilFactStatusSaveItem(row, list));
if (!noApplicable && submitList.length === 0) {
if (!noApplicable && submitList.length === 0 && buildSubmitOkForToolbar(searchContextByTab.get(tabKey) ?? lastSearchedValues)) {
alert("해당사항 없음을 체크해주세요.");
return;
}
@@ -1264,7 +1289,7 @@ const WaterReuseInp = () => {
buildTreatWaterReuseDesignConstStatusSaveItem(row, list),
);
if (!noApplicable && submitList.length === 0) {
if (!noApplicable && submitList.length === 0 && buildSubmitOkForToolbar(searchContextByTab.get(tabKey) ?? lastSearchedValues)) {
alert("해당사항 없음을 체크해주세요.");
return;
}
@@ -1289,7 +1314,7 @@ const WaterReuseInp = () => {
buildTreatWaterReuseBusinessApprStatusSaveItem(row, list),
);
if (!noApplicable && submitList.length === 0) {
if (!noApplicable && submitList.length === 0 && buildSubmitOkForToolbar(searchContextByTab.get(tabKey) ?? lastSearchedValues)) {
alert("해당사항 없음을 체크해주세요.");
return;
}
@@ -1321,7 +1346,7 @@ const WaterReuseInp = () => {
setGlobalProgressLabel("시계열 검증 진행 중...");
const imrParam = {
user_id: userInfo.userUnqId,
sewer_bzmn_cd: lastSearchedValues.bsnmCd ?? "",
sewer_bzmn_cd: lastSearchedValues?.bsnmCd ?? "",
stats_cd: statsCdForTab,
stats_yr: lastSearchedValues.year ?? "",
lae_sbmsn_stts_cd:
@@ -1396,11 +1421,7 @@ const WaterReuseInp = () => {
const requestBase = {
statsYr: lastSearchedValues.year ?? "",
ctpvNm: lastSearchedValues.sido ?? "",
sggNm:
lastSearchedValues.gugun === "ALL"
? ""
: (lastSearchedValues.gugun ?? ""),
sewerBzmnCd: lastSearchedValues.bsnmCd ?? "",
...toInputSearchRegion(sidoListRef.current, lastSearchedValues),
...(isAdminInfo ? { superAdmin: "superAdmin" } : {}),
};
@@ -1418,12 +1439,12 @@ const WaterReuseInp = () => {
};
if (tabKey === PublicSewageTreatWaterReuseInpColumn.tabKey) {
const noApplicable = isNotApplicableByTab.get(tabKey) ?? false;
const noApplicable = buildNoApplicableForRequest(searchContextByTab.get(tabKey) ?? lastSearchedValues, isNotApplicableByTab.get(tabKey) ?? false, getTabGridRows(tabKey).length === 0);
const currentData = getTabGridRows(tabKey);
const saveList = noApplicable
? []
: currentData.map(buildPublicSewageTreatWaterReuseSaveItem);
if (!noApplicable && saveList.length === 0) {
if (!noApplicable && saveList.length === 0 && buildSubmitOkForToolbar(searchContextByTab.get(tabKey) ?? lastSearchedValues)) {
alert("해당사항 없음을 체크해주세요.");
return;
}
@@ -1454,7 +1475,7 @@ const WaterReuseInp = () => {
}
if (tabKey === RecycledWaterStatusInpColumn.tabKey) {
const noApplicable = isNotApplicableByTab.get(tabKey) ?? false;
const noApplicable = buildNoApplicableForRequest(searchContextByTab.get(tabKey) ?? lastSearchedValues, isNotApplicableByTab.get(tabKey) ?? false, getTabGridRows(tabKey).length === 0);
const currentData = getTabGridRows(tabKey);
const sido = lastSearchedValues.sido ?? "";
@@ -1477,7 +1498,7 @@ const WaterReuseInp = () => {
.filter((row) => isPersistedArticleRow(tabKey, row))
.map((row) => buildRecycledWaterStatusSaveItem(row, list));
if (!noApplicable && saveList.length === 0) {
if (!noApplicable && saveList.length === 0 && buildSubmitOkForToolbar(searchContextByTab.get(tabKey) ?? lastSearchedValues)) {
alert("해당사항 없음을 체크해주세요.");
return;
}
@@ -1514,7 +1535,7 @@ const WaterReuseInp = () => {
}
if (tabKey === RainFallUtilFactStatusInpColumn.tabKey) {
const noApplicable = isNotApplicableByTab.get(tabKey) ?? false;
const noApplicable = buildNoApplicableForRequest(searchContextByTab.get(tabKey) ?? lastSearchedValues, isNotApplicableByTab.get(tabKey) ?? false, getTabGridRows(tabKey).length === 0);
const currentData = getTabGridRows(tabKey);
const sido = lastSearchedValues.sido ?? "";
@@ -1537,7 +1558,7 @@ const WaterReuseInp = () => {
.filter((row) => isPersistedArticleRow(tabKey, row))
.map((row) => buildRainFallUtilFactStatusSaveItem(row, list));
if (!noApplicable && saveList.length === 0) {
if (!noApplicable && saveList.length === 0 && buildSubmitOkForToolbar(searchContextByTab.get(tabKey) ?? lastSearchedValues)) {
alert("해당사항 없음을 체크해주세요.");
return;
}
@@ -1575,7 +1596,7 @@ const WaterReuseInp = () => {
}
if (tabKey === TreatWaterReuseDesignConstStatusInpColumn.tabKey) {
const noApplicable = isNotApplicableByTab.get(tabKey) ?? false;
const noApplicable = buildNoApplicableForRequest(searchContextByTab.get(tabKey) ?? lastSearchedValues, isNotApplicableByTab.get(tabKey) ?? false, getTabGridRows(tabKey).length === 0);
const currentData = getTabGridRows(tabKey);
const sido = lastSearchedValues.sido ?? "";
@@ -1600,7 +1621,7 @@ const WaterReuseInp = () => {
buildTreatWaterReuseDesignConstStatusSaveItem(row, list),
);
if (!noApplicable && saveList.length === 0) {
if (!noApplicable && saveList.length === 0 && buildSubmitOkForToolbar(searchContextByTab.get(tabKey) ?? lastSearchedValues)) {
alert("해당사항 없음을 체크해주세요.");
return;
}
@@ -1640,7 +1661,7 @@ const WaterReuseInp = () => {
}
if (tabKey === TreatWaterReuseBusinessApprStatusInpColumn.tabKey) {
const noApplicable = isNotApplicableByTab.get(tabKey) ?? false;
const noApplicable = buildNoApplicableForRequest(searchContextByTab.get(tabKey) ?? lastSearchedValues, isNotApplicableByTab.get(tabKey) ?? false, getTabGridRows(tabKey).length === 0);
const currentData = getTabGridRows(tabKey);
const sido = lastSearchedValues.sido ?? "";
@@ -1665,7 +1686,7 @@ const WaterReuseInp = () => {
buildTreatWaterReuseBusinessApprStatusSaveItem(row, list),
);
if (!noApplicable && saveList.length === 0) {
if (!noApplicable && saveList.length === 0 && buildSubmitOkForToolbar(searchContextByTab.get(tabKey) ?? lastSearchedValues)) {
alert("해당사항 없음을 체크해주세요.");
return;
}
@@ -1719,11 +1740,7 @@ const WaterReuseInp = () => {
const request = {
statsYr: lastSearchedValues.year ?? "",
ctpvNm: lastSearchedValues.sido ?? "",
sggNm:
lastSearchedValues.gugun === "ALL"
? ""
: (lastSearchedValues.gugun ?? ""),
sewerBzmnCd: lastSearchedValues.bsnmCd ?? "",
...toInputSearchRegion(sidoListRef.current, lastSearchedValues),
userId: userInfo.userUnqId,
};
@@ -1881,12 +1898,8 @@ const WaterReuseInp = () => {
}
const requestData: cancelSubmitRequest = {
sewerBzmnCd: lastSearchedValues.bsnmCd ?? "",
...toInputSearchRegion(sidoListRef.current, lastSearchedValues),
ctpvNm: lastSearchedValues.sido ?? "",
sggNm:
lastSearchedValues.gugun === "ALL"
? ""
: (lastSearchedValues.gugun ?? ""),
statsYr: lastSearchedValues.year ?? "",
mdfrId: userInfo.userUnqId,
statsCd: statsCdForTab,
@@ -1963,14 +1976,14 @@ const WaterReuseInp = () => {
return map;
}, [tabStatusInfoMap, inputPeriodEnterable, isAdminInfo, columnGuidesByTab, sggOptions]);
const searchContextForToolbar = searchContextByTab.get(activeTab) ?? lastSearchedValues;
const activeTabStatus = tabStatusInfoMap.get(activeTab) ?? null;
const activeTabToolbar =
toolbarSnapshotByTab.get(activeTab) ??
computeTabToolbarSnapshot(
activeTabStatus,
tabRowDataExists(rowDataMap, activeTab),
hasSearched,
lastSearchedValues,
searchContextForToolbar,
inputPeriodEnterable,
isAdminInfo,
);
@@ -1981,6 +1994,7 @@ const WaterReuseInp = () => {
activeTabToolbar.showEnterableToolbarButtons && toolbarGroupAllowed;
const showActionToolbarCard =
activeTabToolbar.showActionToolbarCard && toolbarGroupAllowed;
const submitOk = buildSubmitOkForToolbar(searchContextForToolbar);
const showSecondaryToolbarCard =
hasSearched &&
toolbarGroupAllowed &&
@@ -1995,7 +2009,8 @@ const WaterReuseInp = () => {
activeTab,
tabRowDataExists(rowDataMap, activeTab),
activeTabStatus,
);
) &&
submitOk;
const setIsNotApplicableForActiveTab: Dispatch<SetStateAction<boolean>> = useCallback(
(next) => {
const tabKey = activeTabRef.current;
@@ -2014,9 +2029,8 @@ const WaterReuseInp = () => {
const statsCd = tabStatsCdMap.get(activeTab);
if (!ctx?.year || !ctx?.sido || !ctx?.bsnmCd || !statsCd) return null;
return {
sewerBzmnCd: ctx.bsnmCd,
...toInputSearchRegion(sidoListRef.current, ctx),
ctpvNm: ctx.sido,
sggNm: ctx.gugun === "ALL" ? "" : (ctx.gugun ?? ""),
statsYr: ctx.year,
statsCd,
};
@@ -2079,6 +2093,7 @@ const WaterReuseInp = () => {
<>
<div className="relative">
<SearchForm
isInput
key={searchFormRemountKey}
defaultValues={verificationSearchDefaults ?? undefined}
onSubmit={handleSearch}
@@ -2099,10 +2114,10 @@ const WaterReuseInp = () => {
<LastYearDataButton
getLastYearDataFunc={() => void getLastYearDataFunc()}
/>
<SubmitButton submitFunc={submitFunc} />
{submitOk && <SubmitButton submitFunc={submitFunc} />}
</>
)}
{activeTabStatus?.laeSbmsnSttsCd === "2" && (
{activeTabStatus?.laeSbmsnSttsCd === "2" && submitOk && (
<CancelSubmitButton cnacelSubmitFunc={cnacelSubmitFunc} />
)}
{showSaveInToolbar && <SaveButton saveFunc={saveFunc} />}
@@ -2161,7 +2176,7 @@ const WaterReuseInp = () => {
tabStatusInfoMap.get(tabKey) ?? null,
inputPeriodEnterable,
) || isAdminInfo) && inputPeriodEnterable;
const gugunOk = buildGugunOkForToolbar(lastSearchedValues);
const gugunOk = buildGugunOkForToolbar(searchContextForToolbar);
const tabStatusInfo = tabStatusInfoMap.get(tabKey) ?? null;
return (