This commit is contained in:
2026-11-27 16:27:10 +09:00
8 changed files with 203 additions and 45 deletions
@@ -695,6 +695,20 @@ const SidoSggFacilityNameSearchForm = ({
</div>
)}
<div className="flex w-full min-w-0 items-stretch gap-[1.2rem]">
<div className="flex min-w-0 flex-1 flex-col gap-2">
<h3 className="text-[1.4rem] font-medium text-foreground">
처리시설 정보
</h3>
<CompactDataGrid
columnInfo={treatmentFacilityColumnInfo}
rowData={treatmentFacilityRows}
setRowData={setTreatmentFacilityRows}
showHeaderCheckbox={false}
compactFullWidth
onRowClick={handleTreatmentFacilityRowClick}
// compactGridHeightClass="h-[min(40vh,28rem)] min-h-[16rem]"
/>
</div>
<div className="flex min-w-0 flex-1 flex-col gap-2">
<div className="flex items-center justify-between gap-2">
<h3 className="text-[1.4rem] font-medium text-foreground">
@@ -712,20 +726,6 @@ const SidoSggFacilityNameSearchForm = ({
// compactGridHeightClass="h-[min(40vh,28rem)] min-h-[16rem]"
/>
</div>
<div className="flex min-w-0 flex-1 flex-col gap-2">
<h3 className="text-[1.4rem] font-medium text-foreground">
처리시설 정보
</h3>
<CompactDataGrid
columnInfo={treatmentFacilityColumnInfo}
rowData={treatmentFacilityRows}
setRowData={setTreatmentFacilityRows}
showHeaderCheckbox={false}
compactFullWidth
onRowClick={handleTreatmentFacilityRowClick}
// compactGridHeightClass="h-[min(40vh,28rem)] min-h-[16rem]"
/>
</div>
</div>
</div>
);
@@ -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, useSearchConditionSidoList } from "@/shared/lib";
import { useAlertStore, useGlobalProgressStore, useStatisticsInputToolbarGroupGate, useSearchConditionSidoList, useUserStore } 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";
@@ -42,6 +42,7 @@ import type {
import {
filterBySelectedAdmdstCd,
isGugunOkForToolbar,
isJeonnamGwangjuSidoAllToolbarException,
isSubmitOkForToolbar,
resolveNoApplicableForRequest,
toInputSearchRegion,
@@ -174,12 +175,43 @@ const computeTabEnterable = (
};
const sidoListRef: { current: Sido[] } = { current: [] };
const relatedToolbarUserIdRef: { current: string } = { current: "" };
function buildGugunOkForToolbar(values: SearchFormValues | null): boolean {
function isJeonnamGwangjuSidoAllToolbarTab(tabKey: string | null | undefined): boolean {
return Boolean(tabKey && ARTICLE_EDIT_TAB_KEYS.has(tabKey));
}
function buildGugunOkForToolbar(
values: SearchFormValues | null,
tabKey?: string | null,
): boolean {
if (
isJeonnamGwangjuSidoAllToolbarTab(tabKey) &&
isJeonnamGwangjuSidoAllToolbarException(
sidoListRef.current,
values,
relatedToolbarUserIdRef.current,
)
) {
return true;
}
return isGugunOkForToolbar(sidoListRef.current, values);
}
function buildSubmitOkForToolbar(values: SearchFormValues | null): boolean {
function buildSubmitOkForToolbar(
values: SearchFormValues | null,
tabKey?: string | null,
): boolean {
if (
isJeonnamGwangjuSidoAllToolbarTab(tabKey) &&
isJeonnamGwangjuSidoAllToolbarException(
sidoListRef.current,
values,
relatedToolbarUserIdRef.current,
)
) {
return true;
}
return isSubmitOkForToolbar(sidoListRef.current, values);
}
@@ -198,8 +230,9 @@ function computeTabToolbarSnapshot(
searchContext: SearchFormValues | null,
periodEnterable: boolean,
isAdminInfo: boolean,
tabKey?: string | null,
): TabToolbarSnapshot {
const gugunOk = buildGugunOkForToolbar(searchContext);
const gugunOk = buildGugunOkForToolbar(searchContext, tabKey);
const enterable = computeTabEnterable(statusInfo, periodEnterable);
const isSubmitted = statusInfo?.lclgvSbmsnSttsCd === "2";
const showSaveInToolbar = (enterable || isAdminInfo) && periodEnterable && gugunOk;
@@ -616,6 +649,8 @@ async function waitForImrJobCompleted(
const SewageExcretaRelatedInp = () => {
const { sidoList } = useSearchConditionSidoList({ isInput: true });
sidoListRef.current = sidoList;
const userId = useUserStore((state) => state.userInfo?.userId ?? "");
relatedToolbarUserIdRef.current = userId;
const { setMessage: alert } = useAlertStore((state) => state);
const { confirm } = useConfirm();
const isAdminInfo = useAdminStore((state) => state.isAdminInfo);
@@ -679,6 +714,8 @@ const SewageExcretaRelatedInp = () => {
/** ST00120001·ST00120002 — 전년도(PRE) 조회로 로드된 ognzSn */
const preYearArticleOgnzSnByTabRef = useRef<Map<string, ArticleOgnzSnSet>>(new Map());
const sggOptionsSidoRef = useRef<string | null>(null);
const sggHeadOptionsRef = useRef<Sgg[]>([]);
const sggHeadOptionsSidoRef = useRef<string | null>(null);
activeTabRef.current = activeTab;
const activeTabId = useTabStore((s) => s.activeTabId);
@@ -747,6 +784,22 @@ const SewageExcretaRelatedInp = () => {
}
}, []);
const loadSggHeadOptions = useCallback(async (sido: string): Promise<Sgg[]> => {
if (!sido || sido === "ALL") {
sggHeadOptionsRef.current = [];
return [];
}
try {
const res = await statisticsApi.getSggAllHeadList(sido);
const list = parseSggListFromResponse(res);
sggHeadOptionsRef.current = list;
return list;
} catch {
sggHeadOptionsRef.current = [];
return [];
}
}, []);
const commitToolbarSnapshotForLoadedTab = (
tabKey: string,
statusInfo: SewerageStatusInfo | null,
@@ -764,6 +817,7 @@ const SewageExcretaRelatedInp = () => {
searchContext,
periodEnterableRef.current,
isAdminInfo,
tabKey,
),
);
return next;
@@ -1071,6 +1125,8 @@ const SewageExcretaRelatedInp = () => {
);
setSggOptions([]);
sggOptionsSidoRef.current = null;
sggHeadOptionsRef.current = [];
sggHeadOptionsSidoRef.current = null;
setVerificationHistoryOpen(false);
};
@@ -1266,7 +1322,7 @@ const SewageExcretaRelatedInp = () => {
alert("먼저 조회를 진행해주세요.");
return;
}
if (!buildGugunOkForToolbar(lastSearchedValues)) {
if (!buildGugunOkForToolbar(lastSearchedValues, tabKey)) {
alert("시군구를 선택해주세요.");
return;
}
@@ -1275,7 +1331,7 @@ const SewageExcretaRelatedInp = () => {
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 && buildSubmitOkForToolbar(searchContextByTab.get(tabKey) ?? lastSearchedValues)) {
if (!noApplicable && currentData.length === 0 && buildSubmitOkForToolbar(searchContextByTab.get(tabKey) ?? lastSearchedValues, tabKey)) {
alert("해당사항 없음을 체크해주세요.");
return;
}
@@ -1300,7 +1356,7 @@ const SewageExcretaRelatedInp = () => {
alert("먼저 조회를 진행해주세요.");
return;
}
if (!buildGugunOkForToolbar(lastSearchedValues)) {
if (!buildGugunOkForToolbar(lastSearchedValues, tabKey)) {
alert("시군구를 선택해주세요.");
return;
}
@@ -1380,7 +1436,7 @@ const SewageExcretaRelatedInp = () => {
)
.map((row) => buildPublicInstitutionIndustrySaveItem(row, list));
if (!noApplicable && submitList.length === 0 && buildSubmitOkForToolbar(searchContextByTab.get(tabKey) ?? lastSearchedValues)) {
if (!noApplicable && submitList.length === 0 && buildSubmitOkForToolbar(searchContextByTab.get(tabKey) ?? lastSearchedValues, tabKey)) {
alert("해당사항 없음을 체크해주세요.");
return;
}
@@ -1558,7 +1614,7 @@ const SewageExcretaRelatedInp = () => {
alert("먼저 조회를 진행해주세요.");
return;
}
if (!buildGugunOkForToolbar(lastSearchedValues)) {
if (!buildGugunOkForToolbar(lastSearchedValues, tabKey)) {
alert("시군구를 선택해주세요.");
return;
}
@@ -1662,7 +1718,7 @@ const SewageExcretaRelatedInp = () => {
)
.map((row) => buildPublicInstitutionIndustrySaveItem(row, list));
if (!noApplicable && saveList.length === 0 && buildSubmitOkForToolbar(searchContextByTab.get(tabKey) ?? lastSearchedValues)) {
if (!noApplicable && saveList.length === 0 && buildSubmitOkForToolbar(searchContextByTab.get(tabKey) ?? lastSearchedValues, tabKey)) {
alert("해당사항 없음을 체크해주세요.");
return;
}
@@ -1725,21 +1781,20 @@ const SewageExcretaRelatedInp = () => {
alert("먼저 조회를 진행해주세요.");
return;
}
if (!buildGugunOkForToolbar(ctx)) {
const tabKey = activeTabRef.current;
if (!buildGugunOkForToolbar(ctx, tabKey)) {
alert("시군구를 선택해주세요.");
return;
}
const tabKey = activeTabRef.current;
if (!ARTICLE_EDIT_TAB_KEYS.has(tabKey)) {
alert("항목을 추가할 수 없는 탭입니다.");
return;
}
let list = sggOptions;
if (sggOptionsSidoRef.current !== ctx.sido || list.length === 0) {
list = await loadSggOptions(ctx.sido);
sggOptionsSidoRef.current = ctx.sido;
let list = sggHeadOptionsRef.current;
if (sggHeadOptionsSidoRef.current !== ctx.sido || list.length === 0) {
list = await loadSggHeadOptions(ctx.sido);
sggHeadOptionsSidoRef.current = ctx.sido;
}
if (list.length === 0) {
alert("시군구 목록을 불러오지 못했습니다.");
@@ -1807,7 +1862,7 @@ const SewageExcretaRelatedInp = () => {
alert("먼저 조회를 진행해주세요.");
return;
}
if (!buildGugunOkForToolbar(ctx)) {
if (!buildGugunOkForToolbar(ctx, tabKey)) {
alert("시군구를 선택해주세요.");
return;
}
@@ -1941,6 +1996,7 @@ const SewageExcretaRelatedInp = () => {
searchContextForToolbar,
inputPeriodEnterable,
isAdminInfo,
activeTab,
);
const showSaveInToolbar = activeTabToolbar.showSaveInToolbar && toolbarGroupAllowed;
@@ -1951,8 +2007,8 @@ 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 gugunOk = buildGugunOkForToolbar(searchContextForToolbar, activeTab);
const submitOk = buildSubmitOkForToolbar(searchContextForToolbar, activeTab);
const showNotApplicableForActiveTab =
NOT_APPLICABLE_TAB_KEYS.has(activeTab) &&
loadedTabKeys.has(activeTab) &&
@@ -2,7 +2,7 @@ import { useEffect, useMemo, useRef, useState } from "react";
import { useConfirm } from "@frontend-opensource/use-react-hooks";
import { useAlertStore, useGlobalProgressStore, useSearchConditionSidoList } from "@/shared/lib";
import { useAlertStore, useGlobalProgressStore, useSearchConditionSidoList, useUserStore } 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";
@@ -41,6 +41,7 @@ import type {
import {
filterBySelectedAdmdstCd,
isGugunOkForToolbar,
isJeonnamGwangjuSidoAllToolbarException,
isSubmitOkForToolbar,
toInputSearchRegion,
} from "@/entities/statistics";
@@ -133,12 +134,31 @@ const computeTabEnterable = (
};
const sidoListRef: { current: Sido[] } = { current: [] };
const financeToolbarUserIdRef: { current: string } = { current: "" };
function buildGugunOkForToolbar(values: SearchFormValues | null): boolean {
if (
isJeonnamGwangjuSidoAllToolbarException(
sidoListRef.current,
values,
financeToolbarUserIdRef.current,
)
) {
return true;
}
return isGugunOkForToolbar(sidoListRef.current, values);
}
function buildSubmitOkForToolbar(values: SearchFormValues | null): boolean {
if (
isJeonnamGwangjuSidoAllToolbarException(
sidoListRef.current,
values,
financeToolbarUserIdRef.current,
)
) {
return true;
}
return isSubmitOkForToolbar(sidoListRef.current, values);
}
@@ -356,6 +376,8 @@ async function waitForImrJobCompleted(
const SewerageFinanceInp = () => {
const { sidoList } = useSearchConditionSidoList({ isInput: true });
sidoListRef.current = sidoList;
const userId = useUserStore((state) => state.userInfo?.userId ?? "");
financeToolbarUserIdRef.current = userId;
const { setMessage: alert } = useAlertStore((state) => state);
const { confirm } = useConfirm();
const { isAdminInfo } = useAdminStore();
@@ -19,7 +19,6 @@ import {
DialogHeader,
DialogTitle,
Input,
InputDatePicker,
Label,
Select,
SelectContent,
@@ -48,9 +47,32 @@ function normalizeStatsYrInput(raw: string): string {
function formatDateToYmd(d: Date | undefined): string | null {
if (!d || Number.isNaN(d.getTime())) return null;
const y = d.getFullYear();
if (y < 1000 || y > 9999) return null;
const m = String(d.getMonth() + 1).padStart(2, "0");
const day = String(d.getDate()).padStart(2, "0");
return `${y}${m}${day}`;
return `${String(y).padStart(4, "0")}${m}${day}`;
}
/** Chrome `type="date"`는 max가 없으면 연도를 6자리까지 받음 */
const PERIOD_DATE_INPUT_MIN = "1000-01-01";
const PERIOD_DATE_INPUT_MAX = "9999-12-31";
function formatDateToInputValue(d: Date | undefined): string {
if (!d || Number.isNaN(d.getTime())) return "";
const ymd = formatDateToYmd(d);
if (!ymd) return "";
return `${ymd.slice(0, 4)}-${ymd.slice(4, 6)}-${ymd.slice(6, 8)}`;
}
function parseFourDigitYearDate(raw: string): Date | undefined {
const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(raw);
if (!match) return undefined;
const year = Number(match[1]);
const month = Number(match[2]);
const day = Number(match[3]);
const parsed = new Date(year, month - 1, day);
if (Number.isNaN(parsed.getTime()) || parsed.getFullYear() !== year) return undefined;
return parsed;
}
export interface StatisticsInputPeriodDialogProps {
@@ -281,18 +303,26 @@ export function StatisticsInputPeriodDialog({
)}
<div className="flex flex-col gap-2">
<Label className="text-label">시작일</Label>
<InputDatePicker
value={bgngYmd}
onChange={setBgngYmd}
className="w-full"
<Input
type="date"
min={PERIOD_DATE_INPUT_MIN}
max={PERIOD_DATE_INPUT_MAX}
value={formatDateToInputValue(bgngYmd)}
onChange={(e) => setBgngYmd(parseFourDigitYearDate(e.target.value))}
disabled={isSubmitting}
className="!text-[1.3rem] w-full"
/>
</div>
<div className="flex flex-col gap-2">
<Label className="text-label">종료일</Label>
<InputDatePicker
value={endYmd}
onChange={setEndYmd}
className="w-full"
<Input
type="date"
min={PERIOD_DATE_INPUT_MIN}
max={PERIOD_DATE_INPUT_MAX}
value={formatDateToInputValue(endYmd)}
onChange={(e) => setEndYmd(parseFourDigitYearDate(e.target.value))}
disabled={isSubmitting}
className="!text-[1.3rem] w-full"
/>
</div>
</div>
@@ -102,6 +102,17 @@ export class StatisticsApiService implements StatisticsService {
return response.data;
}
public async getSggAllHeadList(
sidoName: string,
params?: { instSeCd?: string; gugunSkipYn?: "Y" | "N" },
): Promise<ApiResponse<Sgg[]>> {
const response = await stClient.get<ApiResponse<Sgg[]>>(
`${ENDPOINT.ST_SERVICE.COMMON}/sgg-all-head`,
{ params: { sidoName, ...params } },
);
return response.data;
}
/** 통계 입력 기간(연도·분류별) 목록 조회 — 경로는 백엔드 스펙에 맞게 수정 */
public async getStatsInputPeriodList(
params?: StatsInputPeriodListRequest,
+3
View File
@@ -10,6 +10,9 @@ export { dashboardApi } from "./api/dashboard/dashboard-service";
export { useScheduleInfo } from "./api/dashboard/schedule-info-queries";
export { scheduleInfoApi } from "./api/dashboard/schedule-info-service";
export { imrApi } from "./api/imr-api";
export {
isJeonnamGwangjuSidoAllToolbarException,
} from "./lib/jeonnam-gwangju-sido-all-toolbar";
export {
filterBySelectedAdmdstCd,
findSidoBySearch,
@@ -0,0 +1,35 @@
import { findSidoBySearch, type SidoGugunLookup } from "./sido-gugun";
import type { Sido } from "../model/statistics-interface";
/** 전남광주통합특별시 — 도 목록에 있어 시군구 전체 조회 시 버튼이 숨겨짐 */
export const JEONNAM_GWANGJU_UNIFIED_SIDO_CD = "1200000000";
export const SIDO_ALL_TOOLBAR_USER_IDS = new Set(["CLEANWATER", "S3291"]);
function isEmptyOrAllGugun(values: SidoGugunLookup | null | undefined): boolean {
const gugun = values?.gugun?.trim() ?? "";
return !gugun || gugun === "ALL";
}
function isJeonnamGwangjuUnifiedSido(
sidoList: readonly Sido[] | undefined,
values: SidoGugunLookup | null | undefined,
): boolean {
if (!values) return false;
const sido = findSidoBySearch(sidoList, values);
const cd = (sido?.bsnmCd ?? values.bsnmCd ?? "").trim();
if (cd === JEONNAM_GWANGJU_UNIFIED_SIDO_CD) return true;
return (values.sido ?? "").trim() === "전남광주통합특별시";
}
export function isJeonnamGwangjuSidoAllToolbarException(
sidoList: readonly Sido[] | undefined,
values: SidoGugunLookup | null | undefined,
userId: string | null | undefined,
): boolean {
if (!SIDO_ALL_TOOLBAR_USER_IDS.has((userId ?? "").trim().toUpperCase())) {
return false;
}
return isJeonnamGwangjuUnifiedSido(sidoList, values) && isEmptyOrAllGugun(values);
}
@@ -562,6 +562,7 @@ export interface StatisticsService {
getSidoListInput(params?: { instSeCd?: string }): Promise<ApiResponse<SearchCondition>>;
getSggList(sidoName: string, params?: { instSeCd?: string; gugunSkipYn?: "Y" | "N" }): Promise<ApiResponse<Sgg[]>>;
getSggAllList(sidoName: string, params?: { instSeCd?: string; gugunSkipYn?: "Y" | "N" }): Promise<ApiResponse<Sgg[]>>;
getSggAllHeadList(sidoName: string, params?: { instSeCd?: string; gugunSkipYn?: "Y" | "N" }): Promise<ApiResponse<Sgg[]>>;
getStatsInputPeriodList(params?: StatsInputPeriodListRequest): Promise<StatsInputPeriodListApiResponse>;
getStatsInputPeriodDetail(param: StatsInputPeriodDetailRequest): Promise<StatsInputPeriodDetailResponse>;
saveStatsInputPeriod(param: StatsInputPeriodSaveRequest): Promise<StatsInputPeriodSaveApiResponse>;