st: feat: 로그 조회, 입력-하수관로 조회, 입력-하수도보급률 예외 제출
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { useState, useMemo } from "react";
|
||||
import { useState, useMemo, useRef } from "react";
|
||||
|
||||
import SearchForm from "@/components/module/SearchForm";
|
||||
import TabDataGrid from "@/components/module/TabDataGrid";
|
||||
@@ -12,16 +12,98 @@ import type { ColumnInfoList, ColumnConfig } from "@/components/type/DataGrid.ty
|
||||
import type { SearchFormValues } from "@/components/type/SearchForm.type";
|
||||
import { useAlertStore } from "@/shared/lib";
|
||||
import { useAdminStore } from "@/store/admin-store";
|
||||
import { statisticsInputSewSupplyRateApi } from "@/entities/statistics/api/input/statistics-input-sew-supply-rate-service";
|
||||
import { useConfirm } from "@frontend-opensource/use-react-hooks";
|
||||
import { doList } from "@/components/util/column/input/DoList";
|
||||
import { statisticsInputSewPipeApiService } from "@/entities/statistics/api/input/statistics-sewage-pipe-input-service";
|
||||
import type {
|
||||
SeweragePipeInputAdminAreaConnectionItem,
|
||||
SeweragePipeInputFacilityConnectionItem,
|
||||
SeweragePipeInputFactInstallStatusItem,
|
||||
SeweragePipeInputManholeStatusItem,
|
||||
SeweragePipeInputPipeDiameterStatusItem,
|
||||
SeweragePipeInputPipeTypeStatusItem,
|
||||
SeweragePipeInputRegionalFactStatusItem,
|
||||
SeweragePipeInputRegionalFactStatusSaveRequest,
|
||||
SeweragePipeInputStatusInfo,
|
||||
SeweragePipeRequestParams,
|
||||
} from "@/entities/statistics/model/input/statistics-sewage-pipe-input-interface";
|
||||
import { RegionalFactStatusInpColumn } from "@/components/util/column/input/sewagePipe/RegionalFactStatusInpColumn";
|
||||
import { toGridRows } from "@/components/util/grid/gridFunction";
|
||||
import { LoadingWithAnimation } from "@common/components";
|
||||
import { getUserInfo } from "../../../../../../packages/common/components/src/api";
|
||||
|
||||
const applyEnterableFromStatus = (
|
||||
statusInfo: SeweragePipeInputStatusInfo | null | undefined,
|
||||
periodEnterable: boolean,
|
||||
setIsEnterable: (v: boolean) => void
|
||||
) => {
|
||||
if (statusInfo?.laeSbmsnSttsCd) {
|
||||
if (["2", "3"].includes(statusInfo.laeSbmsnSttsCd)) {
|
||||
setIsEnterable(false);
|
||||
} else {
|
||||
setIsEnterable(periodEnterable);
|
||||
}
|
||||
} else {
|
||||
setIsEnterable(periodEnterable);
|
||||
}
|
||||
};
|
||||
|
||||
function buildSewagePipeSearchParam(
|
||||
values: SearchFormValues,
|
||||
overrides?: { mode?: string },
|
||||
): SeweragePipeRequestParams {
|
||||
return {
|
||||
statsYr: values.year,
|
||||
sewerBzmnCd: values.bsnmCd,
|
||||
ctpvNm: values.sido,
|
||||
sggNm: values.gugun === "ALL" ? "" : values.gugun,
|
||||
...(overrides?.mode ? { mode: overrides.mode } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
// 하수도 통계 관리 > 02. 하수관로
|
||||
const SewagePipeInp = () => {
|
||||
const [rowDataMap, setRowDataMap] = useState<Map<string, Record<string, string | number>[]>>(new Map());
|
||||
const { setMessage: alert } = useAlertStore((state) => state);
|
||||
const [_isLoading, setIsLoading] = useState<boolean>(false);
|
||||
const [activeTab, setActiveTab] = useState<string>(SewagePipeInpColumnInfoList[0]?.tabKey ?? "ST00020001");
|
||||
const [isEnterable, _setIsEnterable] = useState<boolean>(true);
|
||||
const [isLoading, setIsLoading] = useState<boolean>(false);
|
||||
const [searchValues, setSearchValues] = useState<SearchFormValues | null>(null);
|
||||
const [isEnterable, setIsEnterable] = useState<boolean>(true);
|
||||
const [lastSearchedYear, setLastSearchedYear] = useState<string | null>(null);
|
||||
const [lastSearchedValues, setLastSearchedValues] = useState<SearchFormValues | null>(null);
|
||||
const [statusInfo, setStatusInfo] = useState<SeweragePipeInputStatusInfo | null>(null);
|
||||
// const [showDailog, setShowDailog] = useState<boolean>(false);
|
||||
// const [isExceptionSubmitFlow, setIsExceptionSubmitFlow] = useState(false);
|
||||
const [_statsCd, setStatsCd] = useState<string>('');
|
||||
/** API 연결 전에도 검색 후 툴바 등 UI를 쓸 수 있게 함 */
|
||||
const [hasSearched, setHasSearched] = useState(false);
|
||||
// const { confirm } = useConfirm();
|
||||
const { isAdminInfo } = useAdminStore();
|
||||
|
||||
const getGridDataRef = useRef<(() => Record<string, string | number>[]) | null>(null);
|
||||
const searchParamRef = useRef<SeweragePipeRequestParams | null>(null);
|
||||
/** 검색 시 checkInputPeriod 결과 — 탭 전환 지연 조회 시 편집 가능 여부와 동일하게 맞춤 */
|
||||
const periodEnterableRef = useRef(true);
|
||||
/** 검색 완료 후(API 연결 전) 탭별 지연 로그용 — 첫 탭에 행이 없어도 동작하도록 보조 */
|
||||
const searchDoneRef = useRef(false);
|
||||
const lazyTabLoggedRef = useRef<Set<string>>(new Set());
|
||||
|
||||
const firstTabKey = SewagePipeInpColumnInfoList[0]?.tabKey ?? "ST00020001";
|
||||
|
||||
const handleReset = () => {
|
||||
setRowDataMap(new Map());
|
||||
setStatusInfo(null);
|
||||
setLastSearchedYear(null);
|
||||
setLastSearchedValues(null);
|
||||
setHasSearched(false);
|
||||
searchParamRef.current = null;
|
||||
searchDoneRef.current = false;
|
||||
lazyTabLoggedRef.current.clear();
|
||||
periodEnterableRef.current = true;
|
||||
setActiveTab(firstTabKey);
|
||||
};
|
||||
|
||||
const columnInfo = useMemo(() => {
|
||||
const canEdit = isEnterable || isAdminInfo;
|
||||
return SewagePipeInpColumnInfoList.map((tab: ColumnInfoList) => {
|
||||
@@ -46,51 +128,313 @@ const SewagePipeInp = () => {
|
||||
});
|
||||
}, [isEnterable, isAdminInfo]);
|
||||
|
||||
// const handleSearch = async (values: SearchFormValues) => {
|
||||
// if (!values.sido || values.sido === 'ALL') {
|
||||
// alert('시도를 선택해주세요.');
|
||||
// return;
|
||||
// }
|
||||
/** mergeIntoExistingMap: true면 지난연도(PRE) 등 — 현재 탭만 갱신, 나머지 탭 캐시 유지 */
|
||||
const loadSewagePipeActiveTabData = async (
|
||||
tabKey: string,
|
||||
searchParam: SeweragePipeRequestParams,
|
||||
values: SearchFormValues,
|
||||
checkEnterable: boolean,
|
||||
mergeIntoExistingMap: boolean,
|
||||
updateLastSearchedValues: boolean,
|
||||
): Promise<boolean> => {
|
||||
const applyRowMap = (apply: (m: Map<string, Record<string, string | number>[]>) => void) => {
|
||||
if (mergeIntoExistingMap) {
|
||||
setRowDataMap((prev) => {
|
||||
const next = new Map(prev);
|
||||
apply(next);
|
||||
return next;
|
||||
});
|
||||
} else {
|
||||
const next = new Map<string, Record<string, string | number>[]>();
|
||||
apply(next);
|
||||
setRowDataMap(next);
|
||||
}
|
||||
};
|
||||
|
||||
// setActiveTab('ST00020001');
|
||||
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) => ({
|
||||
ctpvNm: commonInfo.ctpvNm,
|
||||
...d,
|
||||
}));
|
||||
applyRowMap((m) => m.set('ST00020001', toGridRows(convertedData)));
|
||||
setStatusInfo(response.data.statusInfo);
|
||||
setStatsCd(commonInfo.statsCd);
|
||||
applyEnterableFromStatus(response.data.statusInfo, checkEnterable, setIsEnterable);
|
||||
if (updateLastSearchedValues) setLastSearchedValues(values);
|
||||
return true;
|
||||
}
|
||||
alert(response.message || '데이터 조회 중 오류가 발생했습니다.');
|
||||
return false;
|
||||
}
|
||||
if (tabKey === 'ST00020002') {
|
||||
const response = await statisticsInputSewPipeApiService.getFactInstallStatus(searchParam);
|
||||
if (response.status === 'success') {
|
||||
const commonInfo = response.data.commonInfo;
|
||||
const convertedData = (response.data.factInstallStatusList ?? []).map((d) => ({
|
||||
ctpvNm: commonInfo.ctpvNm,
|
||||
...d,
|
||||
}));
|
||||
applyRowMap((m) => m.set('ST00020002', toGridRows(convertedData)));
|
||||
setStatusInfo(response.data.statusInfo);
|
||||
setStatsCd(commonInfo.statsCd);
|
||||
applyEnterableFromStatus(response.data.statusInfo, checkEnterable, setIsEnterable);
|
||||
if (updateLastSearchedValues) setLastSearchedValues(values);
|
||||
return true;
|
||||
}
|
||||
alert(response.message || '데이터 조회 중 오류가 발생했습니다.');
|
||||
return false;
|
||||
}
|
||||
if (tabKey === 'ST00020003') {
|
||||
const response = await statisticsInputSewPipeApiService.getPipeTypeStatus(searchParam);
|
||||
if (response.status === 'success') {
|
||||
const commonInfo = response.data.commonInfo;
|
||||
const convertedData = (response.data.pipeTypeStatusList ?? []).map((d) => ({
|
||||
ctpvNm: commonInfo.ctpvNm,
|
||||
...d,
|
||||
}));
|
||||
applyRowMap((m) => m.set('ST00020003', toGridRows(convertedData)));
|
||||
setStatusInfo(response.data.statusInfo);
|
||||
setStatsCd(commonInfo.statsCd);
|
||||
applyEnterableFromStatus(response.data.statusInfo, checkEnterable, setIsEnterable);
|
||||
if (updateLastSearchedValues) setLastSearchedValues(values);
|
||||
return true;
|
||||
}
|
||||
alert(response.message || '데이터 조회 중 오류가 발생했습니다.');
|
||||
return false;
|
||||
}
|
||||
if (tabKey === 'ST00020004') {
|
||||
const response = await statisticsInputSewPipeApiService.getPipeDiameterStatus(searchParam);
|
||||
if (response.status === 'success') {
|
||||
const commonInfo = response.data.commonInfo;
|
||||
const convertedData = (response.data.pipeDiameterStatusList ?? []).map((d) => ({
|
||||
ctpvNm: commonInfo.ctpvNm,
|
||||
...d,
|
||||
}));
|
||||
applyRowMap((m) => m.set('ST00020004', toGridRows(convertedData)));
|
||||
setStatusInfo(response.data.statusInfo);
|
||||
setStatsCd(commonInfo.statsCd);
|
||||
applyEnterableFromStatus(response.data.statusInfo, checkEnterable, setIsEnterable);
|
||||
if (updateLastSearchedValues) setLastSearchedValues(values);
|
||||
return true;
|
||||
}
|
||||
alert(response.message || '데이터 조회 중 오류가 발생했습니다.');
|
||||
return false;
|
||||
}
|
||||
if (tabKey === 'ST00020005') {
|
||||
const response = await statisticsInputSewPipeApiService.getManholeStatus(searchParam);
|
||||
if (response.status === 'success') {
|
||||
const commonInfo = response.data.commonInfo;
|
||||
const convertedData = (response.data.manholeStatusList ?? []).map((d) => ({
|
||||
ctpvNm: commonInfo.ctpvNm,
|
||||
...d,
|
||||
}));
|
||||
applyRowMap((m) => m.set('ST00020005', toGridRows(convertedData)));
|
||||
setStatusInfo(response.data.statusInfo);
|
||||
setStatsCd(commonInfo.statsCd);
|
||||
applyEnterableFromStatus(response.data.statusInfo, checkEnterable, setIsEnterable);
|
||||
if (updateLastSearchedValues) setLastSearchedValues(values);
|
||||
return true;
|
||||
}
|
||||
alert(response.message || '데이터 조회 중 오류가 발생했습니다.');
|
||||
return false;
|
||||
}
|
||||
if (tabKey === 'ST00020006') {
|
||||
const response = await statisticsInputSewPipeApiService.getConnectionStatus(searchParam);
|
||||
if (response.status === 'success') {
|
||||
const commonInfo = response.data.commonInfo;
|
||||
const facilityConvertedData = (response.data.facilityConnectionList ?? []).map((d) => ({
|
||||
...d,
|
||||
}));
|
||||
const adminConvertedData = (response.data.adminAreaConnectionList ?? []).map((d) => ({
|
||||
...d,
|
||||
ctpvNm: d.ctpvNm || commonInfo.ctpvNm,
|
||||
}));
|
||||
applyRowMap((m) => {
|
||||
m.set('treatmentPlantConnectionInp', toGridRows(facilityConvertedData));
|
||||
m.set('adminAreaConnectionInp', toGridRows(adminConvertedData));
|
||||
});
|
||||
setStatusInfo(response.data.statusInfo);
|
||||
setStatsCd(commonInfo.statsCd);
|
||||
applyEnterableFromStatus(response.data.statusInfo, checkEnterable, setIsEnterable);
|
||||
if (updateLastSearchedValues) setLastSearchedValues(values);
|
||||
return true;
|
||||
}
|
||||
alert(response.message || '데이터 조회 중 오류가 발생했습니다.');
|
||||
return false;
|
||||
}
|
||||
if (!mergeIntoExistingMap) {
|
||||
setRowDataMap(new Map());
|
||||
}
|
||||
if (updateLastSearchedValues) setLastSearchedValues(values);
|
||||
applyEnterableFromStatus(null, checkEnterable, setIsEnterable);
|
||||
return true;
|
||||
};
|
||||
|
||||
// setRowDataMap(new Map());
|
||||
const handleSearch = async (values: SearchFormValues) => {
|
||||
if (!values.sido || values.sido === 'ALL') {
|
||||
alert('시도를 선택해주세요.');
|
||||
return;
|
||||
}
|
||||
|
||||
// try {
|
||||
// setIsLoading(true);
|
||||
try {
|
||||
const periodResponse = await statisticsInputSewSupplyRateApi.checkInputPeriod(values.year || '');
|
||||
|
||||
// // const searchParam: SewagePipeReviewRequestParams = {
|
||||
// // statsYr: values.year,
|
||||
// // sewerBzmnCd: values.bsnmCd,
|
||||
// // ctpvNm: values.sido,
|
||||
// // sggNm: values.gugun === 'ALL' ? '' : values.gugun
|
||||
// // };
|
||||
if (periodResponse.status !== 'success') {
|
||||
alert(periodResponse.message);
|
||||
return;
|
||||
}
|
||||
|
||||
// // searchParamRef.current = searchParam;
|
||||
// // const response = await statisticsManagementApi.getSewagePipeReviewRegionalList(searchParam);
|
||||
const checkEnterable = periodResponse.data;
|
||||
periodEnterableRef.current = checkEnterable;
|
||||
|
||||
// // if (response?.status === 'success' && response.data) {
|
||||
// // const newRowDataMap = new Map<string, Record<string, string | number>[]>();
|
||||
// // newRowDataMap.set('ST00020001', toGridRows(response.data as object[]));
|
||||
// // setRowDataMap(newRowDataMap);
|
||||
// // } else {
|
||||
// // alert(response?.message || "데이터가 없습니다.");
|
||||
// // }
|
||||
// } catch {
|
||||
// alert('데이터 조회 중 오류가 발생했습니다.');
|
||||
// } finally {
|
||||
// setIsLoading(false);
|
||||
// }
|
||||
// };
|
||||
setRowDataMap(new Map());
|
||||
lazyTabLoggedRef.current.clear();
|
||||
|
||||
setIsLoading(true);
|
||||
|
||||
const searchParam = buildSewagePipeSearchParam(values);
|
||||
searchParamRef.current = searchParam;
|
||||
searchDoneRef.current = true;
|
||||
setHasSearched(true);
|
||||
setLastSearchedYear(values.year ?? null);
|
||||
|
||||
await loadSewagePipeActiveTabData(activeTab, searchParam, values, checkEnterable, false, true);
|
||||
} catch {
|
||||
alert('데이터 조회 중 오류가 발생했습니다.');
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleActiveTabChange = async (tabKey: string) => {
|
||||
setActiveTab(tabKey);
|
||||
|
||||
const activeTabData = rowDataMap.get(tabKey);
|
||||
const hasActiveTabData = Array.isArray(activeTabData) && activeTabData.length > 0;
|
||||
|
||||
const canLazyLoad =
|
||||
searchParamRef.current &&
|
||||
!hasActiveTabData &&
|
||||
!lazyTabLoggedRef.current.has(tabKey) &&
|
||||
searchDoneRef.current;
|
||||
|
||||
if (!canLazyLoad) return;
|
||||
|
||||
const searchParam = searchParamRef.current;
|
||||
if (!searchParam) return;
|
||||
|
||||
try {
|
||||
setIsLoading(true);
|
||||
|
||||
let response;
|
||||
|
||||
if (tabKey === 'ST00020001') {
|
||||
response = await statisticsInputSewPipeApiService.getRegionalFactStatus(searchParam);
|
||||
} else if (tabKey === 'ST00020002') {
|
||||
response = await statisticsInputSewPipeApiService.getFactInstallStatus(searchParam);
|
||||
} else if (tabKey === 'ST00020003') {
|
||||
response = await statisticsInputSewPipeApiService.getPipeTypeStatus(searchParam);
|
||||
} else if (tabKey === 'ST00020004') {
|
||||
response = await statisticsInputSewPipeApiService.getPipeDiameterStatus(searchParam);
|
||||
} else if (tabKey === 'ST00020005') {
|
||||
response = await statisticsInputSewPipeApiService.getManholeStatus(searchParam);
|
||||
} else if (tabKey === 'ST00020006') {
|
||||
response = await statisticsInputSewPipeApiService.getConnectionStatus(searchParam);
|
||||
}
|
||||
lazyTabLoggedRef.current.add(tabKey);
|
||||
|
||||
if (response?.status === 'success') {
|
||||
setStatusInfo(response.data.statusInfo);
|
||||
setStatsCd(response.data.commonInfo.statsCd);
|
||||
applyEnterableFromStatus(response.data.statusInfo, periodEnterableRef.current, setIsEnterable);
|
||||
setRowDataMap(prev => {
|
||||
const next = new Map(prev);
|
||||
if (tabKey === 'ST00020001') {
|
||||
const commonInfo = response.data.commonInfo;
|
||||
const convertedData = (response.data.regionalFactStatusList ?? []).map((d: SeweragePipeInputRegionalFactStatusItem) => ({
|
||||
ctpvNm: commonInfo.ctpvNm,
|
||||
...d
|
||||
}));
|
||||
next.set(tabKey, toGridRows(convertedData));
|
||||
} else if (tabKey === 'ST00020002') {
|
||||
const commonInfo = response.data.commonInfo;
|
||||
const convertedData = (response.data.factInstallStatusList ?? []).map((d: SeweragePipeInputFactInstallStatusItem) => ({
|
||||
ctpvNm: commonInfo.ctpvNm,
|
||||
...d
|
||||
}));
|
||||
next.set(tabKey, toGridRows(convertedData));
|
||||
} else if (tabKey === 'ST00020003') {
|
||||
const commonInfo = response.data.commonInfo;
|
||||
const convertedData = (response.data.pipeTypeStatusList ?? []).map((d: SeweragePipeInputPipeTypeStatusItem) => ({
|
||||
ctpvNm: commonInfo.ctpvNm,
|
||||
...d
|
||||
}));
|
||||
next.set(tabKey, toGridRows(convertedData));
|
||||
} else if (tabKey === 'ST00020004') {
|
||||
const commonInfo = response.data.commonInfo;
|
||||
const convertedData = (response.data.pipeDiameterStatusList ?? []).map((d: SeweragePipeInputPipeDiameterStatusItem) => ({
|
||||
ctpvNm: commonInfo.ctpvNm,
|
||||
...d
|
||||
}));
|
||||
next.set(tabKey, toGridRows(convertedData));
|
||||
} else if (tabKey === 'ST00020005') {
|
||||
const commonInfo = response.data.commonInfo;
|
||||
const convertedData = (response.data.manholeStatusList ?? []).map((d: SeweragePipeInputManholeStatusItem) => ({
|
||||
ctpvNm: commonInfo.ctpvNm,
|
||||
...d
|
||||
}));
|
||||
next.set(tabKey, toGridRows(convertedData));
|
||||
} else if (tabKey === 'ST00020006') {
|
||||
const commonInfo = response.data.commonInfo;
|
||||
const facilityConvertedData = (response.data.facilityConnectionList ?? []).map((d: SeweragePipeInputFacilityConnectionItem) => ({
|
||||
...d
|
||||
}));
|
||||
const adminConvertedData = (response.data.adminAreaConnectionList ?? []).map((d: SeweragePipeInputAdminAreaConnectionItem) => ({
|
||||
...d,
|
||||
ctpvNm: d.ctpvNm || commonInfo.ctpvNm,
|
||||
}));
|
||||
next.set('treatmentPlantConnectionInp', toGridRows(facilityConvertedData));
|
||||
next.set('adminAreaConnectionInp', toGridRows(adminConvertedData));
|
||||
}
|
||||
return next;
|
||||
});
|
||||
} else {
|
||||
alert(response?.message || '데이터 조회 중 오류가 발생했습니다.');
|
||||
}
|
||||
} catch {
|
||||
alert('데이터 조회 중 오류가 발생했습니다.');
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const SubmitExceptionFunc = () => {
|
||||
console.log('submit exception');
|
||||
// 예외 제출 로직
|
||||
};
|
||||
|
||||
const getLastYearDataFunc = () => {
|
||||
console.log('get last year data');
|
||||
// 지난연도 데이터 가져오기 로직
|
||||
const getLastYearDataFunc = async () => {
|
||||
const values = lastSearchedValues ?? searchValues;
|
||||
if (!values?.sido || values.sido === 'ALL') {
|
||||
alert('시도를 선택해주세요.');
|
||||
return;
|
||||
}
|
||||
if (!lastSearchedYear) {
|
||||
alert('먼저 데이터를 조회해주세요.');
|
||||
return;
|
||||
}
|
||||
try {
|
||||
setIsLoading(true);
|
||||
const param = buildSewagePipeSearchParam(values, { mode: 'PRE' });
|
||||
await loadSewagePipeActiveTabData(activeTab, param, values, periodEnterableRef.current, true, false);
|
||||
} catch {
|
||||
alert('데이터 조회 중 오류가 발생했습니다.');
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const submitFunc = () => {
|
||||
@@ -98,29 +442,146 @@ const SewagePipeInp = () => {
|
||||
// 제출 로직
|
||||
};
|
||||
|
||||
const saveFunc = () => {
|
||||
console.log('save');
|
||||
// 저장 로직
|
||||
const saveFunc = async () => {
|
||||
if (activeTab !== "ST00020001") {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const currentData = getGridDataRef.current?.();
|
||||
if (!currentData || currentData.length === 0) {
|
||||
alert("저장할 데이터가 없습니다.");
|
||||
return;
|
||||
}
|
||||
const values = lastSearchedValues ?? searchValues;
|
||||
if (!values?.year) {
|
||||
alert("검색 후 저장해 주세요.");
|
||||
return;
|
||||
}
|
||||
|
||||
const columnFormatMap = new Map<string, string>();
|
||||
RegionalFactStatusInpColumn.columns.forEach((col) => {
|
||||
if (col.fieldName && col.dataFormat) {
|
||||
columnFormatMap.set(col.fieldName, col.dataFormat);
|
||||
}
|
||||
});
|
||||
|
||||
const formatNumber = (value: string | number | null | undefined, fieldName: string): number => {
|
||||
if (value === null || value === undefined || value === "") return 0;
|
||||
const num = typeof value === "string" ? parseFloat(value.replace(/,/g, "")) : value;
|
||||
if (isNaN(num)) return 0;
|
||||
const format = columnFormatMap.get(fieldName);
|
||||
if (!format) return num;
|
||||
const decimalPlaces = format.match(/\.(\d+)/)?.[1]?.length ?? 0;
|
||||
return decimalPlaces > 0 ? parseFloat(num.toFixed(decimalPlaces)) : Math.round(num);
|
||||
};
|
||||
|
||||
const userInfo = await getUserInfo();
|
||||
|
||||
const saveList = currentData.map((d) => ({
|
||||
admdstCd: String(d.admdstCd ?? ""),
|
||||
sggNm: String(d.sggNm ?? ""),
|
||||
admdstNm: String(d.admdstNm ?? ""),
|
||||
goalYr: String(d.goalYr ?? ""),
|
||||
wholPplMtncPlanPrlg: formatNumber(d.wholPplMtncPlanPrlg, "wholPplMtncPlanPrlg"),
|
||||
wholPlanPrlg: formatNumber(d.wholPlanPrlg, "wholPlanPrlg"),
|
||||
wholFcltPrlg: formatNumber(d.wholFcltPrlg, "wholFcltPrlg"),
|
||||
swagePplPsplyRt: formatNumber(d.swagePplPsplyRt, "swagePplPsplyRt"),
|
||||
cbsysPplMtncPlanArea: formatNumber(d.cbsysPplMtncPlanArea, "cbsysPplMtncPlanArea"),
|
||||
cbsysPplMtncPlanPrlg: formatNumber(d.cbsysPplMtncPlanPrlg, "cbsysPplMtncPlanPrlg"),
|
||||
cbsysPlanPrlg: formatNumber(d.cbsysPlanPrlg, "cbsysPlanPrlg"),
|
||||
cbsysFcltPrlg: formatNumber(d.cbsysFcltPrlg, "cbsysFcltPrlg"),
|
||||
cbsysSqrePrlg: formatNumber(d.cbsysSqrePrlg, "cbsysSqrePrlg"),
|
||||
cbsysCiclPrlg: formatNumber(d.cbsysCiclPrlg, "cbsysCiclPrlg"),
|
||||
cbsysOpnPrlg: formatNumber(d.cbsysOpnPrlg, "cbsysOpnPrlg"),
|
||||
cbsysGttrPrlg: formatNumber(d.cbsysGttrPrlg, "cbsysGttrPrlg"),
|
||||
drtwPplMtncPlanArea: formatNumber(d.drtwPplMtncPlanArea, "drtwPplMtncPlanArea"),
|
||||
drtwPplMtncPlanPrlg: formatNumber(d.drtwPplMtncPlanPrlg, "drtwPplMtncPlanPrlg"),
|
||||
drtwPplPlanPrlg: formatNumber(d.drtwPplPlanPrlg, "drtwPplPlanPrlg"),
|
||||
drtwPplFcltPrlg: formatNumber(d.drtwPplFcltPrlg, "drtwPplFcltPrlg"),
|
||||
drtwPplSqrePrlg: formatNumber(d.drtwPplSqrePrlg, "drtwPplSqrePrlg"),
|
||||
drtwPplCiclPrlg: formatNumber(d.drtwPplCiclPrlg, "drtwPplCiclPrlg"),
|
||||
exlnPplMtncPlanArea: formatNumber(d.exlnPplMtncPlanArea, "exlnPplMtncPlanArea"),
|
||||
exlnPplMtncPlanPrlg: formatNumber(d.exlnPplMtncPlanPrlg, "exlnPplMtncPlanPrlg"),
|
||||
exlnPplPlanPrlg: formatNumber(d.exlnPplPlanPrlg, "exlnPplPlanPrlg"),
|
||||
exlnPplFcltPrlg: formatNumber(d.exlnPplFcltPrlg, "exlnPplFcltPrlg"),
|
||||
exlnPplSqrePrlg: formatNumber(d.exlnPplSqrePrlg, "exlnPplSqrePrlg"),
|
||||
exlnPplCiclPrlg: formatNumber(d.exlnPplCiclPrlg, "exlnPplCiclPrlg"),
|
||||
exlnPplOpnPrlg: formatNumber(d.exlnPplOpnPrlg, "exlnPplOpnPrlg"),
|
||||
exlnPplGttrPrlg: formatNumber(d.exlnPplGttrPrlg, "exlnPplGttrPrlg"),
|
||||
cbsysMnhlCnt: formatNumber(d.cbsysMnhlCnt, "cbsysMnhlCnt"),
|
||||
sprsysDrtwMnhlCnt: formatNumber(d.sprsysDrtwMnhlCnt, "sprsysDrtwMnhlCnt"),
|
||||
sprsysExlnMnhlCnt: formatNumber(d.sprsysExlnMnhlCnt, "sprsysExlnMnhlCnt"),
|
||||
drtwRcvprpCnt: formatNumber(d.drtwRcvprpCnt, "drtwRcvprpCnt"),
|
||||
exlnRcvprpCnt: formatNumber(d.exlnRcvprpCnt, "exlnRcvprpCnt"),
|
||||
stofcbrCnt: formatNumber(d.stofcbrCnt, "stofcbrCnt"),
|
||||
exlnOtflCnt: formatNumber(d.exlnOtflCnt, "exlnOtflCnt"),
|
||||
sewerLdgrEdpPrlg: formatNumber(d.sewerLdgrEdpPrlg, "sewerLdgrEdpPrlg"),
|
||||
sewerLdgrEdpRt: formatNumber(d.sewerLdgrEdpRt, "sewerLdgrEdpRt"),
|
||||
rmrk: (d.rmrk as string | null) ?? null,
|
||||
}));
|
||||
|
||||
const param: SeweragePipeInputRegionalFactStatusSaveRequest = {
|
||||
statsYr: values.year ?? "",
|
||||
ctpvNm: values.sido ?? "",
|
||||
sggNm: values.gugun === "ALL" ? "" : (values.gugun ?? ""),
|
||||
sewerBzmnCd: values.bsnmCd ?? "",
|
||||
userId: userInfo.userUnqId,
|
||||
superAdmin: isAdminInfo ? "superAdmin" : "",
|
||||
saveList,
|
||||
};
|
||||
|
||||
console.log(param);
|
||||
} catch {
|
||||
alert("저장 준비 중 오류가 발생했습니다.");
|
||||
}
|
||||
};
|
||||
|
||||
const gugunOkOrNotDoList = doList.includes(lastSearchedValues?.bsnmCd || '')
|
||||
? Boolean(lastSearchedValues?.gugun && lastSearchedValues.gugun !== 'ALL')
|
||||
: true;
|
||||
|
||||
const showSaveInToolbar = (isEnterable || isAdminInfo) && gugunOkOrNotDoList;
|
||||
const showEnterableToolbarButtons = isEnterable && gugunOkOrNotDoList;
|
||||
|
||||
/** TabDataGrid는 rowDataMap 사용 — 행이 하나라도 있을 때만 툴바 카드 의미 있음 */
|
||||
const hasRowData = Array.from(rowDataMap.values()).some((rows) => rows.length > 0);
|
||||
|
||||
const showActionToolbarCard =
|
||||
(hasRowData || hasSearched) &&
|
||||
(showSaveInToolbar ||
|
||||
(statusInfo?.laeSbmsnSttsCd === '2' && (isAdminInfo || (isEnterable && gugunOkOrNotDoList))));
|
||||
|
||||
return (
|
||||
<>
|
||||
<SearchForm />
|
||||
<div className="card !py-0">
|
||||
<div className="flex justify-end items-center gap-[0.6rem] mx-[0.6rem]">
|
||||
<SubmitExceptionButton SubmitExceptionFunc={SubmitExceptionFunc} />
|
||||
<LastYearDataButton getLastYearDataFunc={getLastYearDataFunc} />
|
||||
<SubmitButton submitFunc={submitFunc} />
|
||||
<SaveButton saveFunc={saveFunc} />
|
||||
<SearchForm onSubmit={handleSearch} onReset={handleReset} onValuesChange={setSearchValues} />
|
||||
{showActionToolbarCard && (
|
||||
<div className="card !py-0">
|
||||
<div className="flex justify-end items-center gap-[0.6rem] mx-[0.6rem]">
|
||||
{showEnterableToolbarButtons && (
|
||||
<>
|
||||
<SubmitExceptionButton SubmitExceptionFunc={SubmitExceptionFunc} />
|
||||
<LastYearDataButton getLastYearDataFunc={() => void getLastYearDataFunc()} />
|
||||
<SubmitButton submitFunc={submitFunc} />
|
||||
</>
|
||||
)}
|
||||
{showSaveInToolbar && <SaveButton saveFunc={saveFunc} />}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{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]">
|
||||
<LoadingWithAnimation color="primary" />
|
||||
</div>
|
||||
</div>}
|
||||
<TabDataGrid
|
||||
columnInfo={columnInfo}
|
||||
rowDataMap={rowDataMap}
|
||||
setRowDataMap={setRowDataMap}
|
||||
activeTab={activeTab}
|
||||
onActiveTabChange={setActiveTab}
|
||||
onActiveTabChange={handleActiveTabChange}
|
||||
isExcelImport={hasRowData && isEnterable && gugunOkOrNotDoList}
|
||||
facilitySearchStatsYr={lastSearchedYear}
|
||||
getGridDataRef={getGridDataRef}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -30,7 +30,7 @@ import type {
|
||||
SewerageSupplyRateSaveRequest,
|
||||
SewerageSupplyRateStatusInfo,
|
||||
} from "@/entities/statistics/model/input/statistics-sewage-supply-rate-input-interface";
|
||||
import type { cancelSubmitRequest } from "@/entities/statistics/model/statistics-interface";
|
||||
import type { cancelSubmitRequest, SubmitExceptionRequest } from "@/entities/statistics/model/statistics-interface";
|
||||
import type { StatisticsInputSubmitInfoFormData } from "@/entities/statistics/model/statistics-input-submit-info-schema";
|
||||
import { SeweragePenetrationRateInpColumn } from "@/components/util/column/input/SeweragePenetrationRateInpColumn";
|
||||
import { doList } from "@/components/util/column/input/DoList";
|
||||
@@ -69,6 +69,8 @@ const SeweragePenetrationRateInp = () => {
|
||||
const [lastSearchedValues, setLastSearchedValues] = useState<SearchFormValues | null>(null);
|
||||
const [statusInfo, setStatusInfo] = useState<SewerageSupplyRateStatusInfo | null>(null);
|
||||
const [showDailog, setShowDailog] = useState<boolean>(false);
|
||||
/** 예외제출 버튼으로 연 다이얼로그인지 (확인 시 executeSubmit 대신 SubmitExceptionFunc 경로) */
|
||||
const [isExceptionSubmitFlow, setIsExceptionSubmitFlow] = useState(false);
|
||||
const [statsCd, setStatsCd] = useState<string>('');
|
||||
const [footerFromApi, setFooterFromApi] = useState<{ sewerBzmnWholPpltnCnt?: number; sewerBzmnDomplWholPpltnCnt?: number; sewerBzmnFrgnrWholPpltnCnt?: number; sewerBzmnArea?: number } | null>(null);
|
||||
const { confirm } = useConfirm();
|
||||
@@ -190,8 +192,39 @@ const SeweragePenetrationRateInp = () => {
|
||||
}
|
||||
};
|
||||
|
||||
const SubmitExceptionFunc = () => {
|
||||
|
||||
const SubmitExceptionFunc = async (submitInfo: StatisticsInputSubmitInfoFormData) => {
|
||||
const userInfo = await getUserInfo();
|
||||
|
||||
const params: SubmitExceptionRequest = {
|
||||
...submitInfo,
|
||||
sewerBzmnCd: searchValues?.bsnmCd ?? '',
|
||||
ctpvNm: searchValues?.sido ?? '',
|
||||
sggNm: searchValues?.gugun ?? '',
|
||||
statsYr: searchValues?.year ?? '',
|
||||
userId: userInfo.userUnqId,
|
||||
statsCd: statsCd,
|
||||
};
|
||||
|
||||
// if (isAdminInfo) {
|
||||
// params.superAdmin = 'superAdmin';
|
||||
// }
|
||||
|
||||
try {
|
||||
setIsLoading(true);
|
||||
|
||||
const response = await statisticsAPi.submitException(params);
|
||||
|
||||
if (response.status === 'success') {
|
||||
await fetchSewerageSupplyRate(getSewerageSupplyRateParams(searchValues ?? {}), false);
|
||||
alert('제출되었습니다.');
|
||||
} else {
|
||||
alert(response.message || '데이터 제출 중 오류가 발생했습니다.');
|
||||
}
|
||||
} catch {
|
||||
alert('데이터 제출 중 오류가 발생했습니다.');
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const getLastYearDataFunc = async (values: SearchFormValues) => {
|
||||
@@ -209,21 +242,33 @@ const SeweragePenetrationRateInp = () => {
|
||||
await fetchSewerageSupplyRate(getSewerageSupplyRateParams(values, { mode: 'PRE' }), true);
|
||||
};
|
||||
|
||||
const submitFunc = async () => {
|
||||
const isError = rowData.filter((d) =>
|
||||
hasVerificationErrors((d as GridRowWithVerification).verificationResult)
|
||||
);
|
||||
const submitFunc = async (isException: boolean) => {
|
||||
if (!isException) {
|
||||
const isError = rowData.filter((d) =>
|
||||
hasVerificationErrors((d as GridRowWithVerification).verificationResult)
|
||||
);
|
||||
|
||||
if (isError.length > 0) {
|
||||
alert(`데이터에 오류가 있습니다.
|
||||
수정 후 제출해주세요.`);
|
||||
return;
|
||||
}
|
||||
if (await confirm('제출 하시겠습니까?')) {
|
||||
setShowDailog(true);
|
||||
if (isError.length > 0) {
|
||||
alert(`데이터에 오류가 있습니다.
|
||||
수정 후 제출해주세요.`);
|
||||
return;
|
||||
}
|
||||
if (await confirm('제출 하시겠습니까?')) {
|
||||
setIsExceptionSubmitFlow(false);
|
||||
setShowDailog(true);
|
||||
}
|
||||
} else {
|
||||
if (await confirm('예외 제출 시 검증 결과에 오류가 있어도 제출 처리됩니다.')) {
|
||||
setIsExceptionSubmitFlow(true);
|
||||
setShowDailog(true);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const executeExceptionSubmit = async (submitInfo: StatisticsInputSubmitInfoFormData) => {
|
||||
await SubmitExceptionFunc(submitInfo);
|
||||
};
|
||||
|
||||
const executeSubmit = async (submitInfo: StatisticsInputSubmitInfoFormData) => {
|
||||
try {
|
||||
setIsLoading(true);
|
||||
@@ -457,7 +502,7 @@ const SeweragePenetrationRateInp = () => {
|
||||
if (await confirm('제출된 내용을 취소하시겠습니까?')) {
|
||||
|
||||
const userInfo = await getUserInfo();
|
||||
|
||||
|
||||
const requestData: cancelSubmitRequest = {
|
||||
sewerBzmnCd: searchValues?.bsnmCd ?? '',
|
||||
ctpvNm: searchValues?.sido ?? '',
|
||||
@@ -503,11 +548,11 @@ const SeweragePenetrationRateInp = () => {
|
||||
{showEnterableToolbarButtons && (
|
||||
<>
|
||||
{isAdminInfo && statusInfo && statusInfo.laeSbmsnSttsCd !== '0' && (
|
||||
<SubmitExceptionButton SubmitExceptionFunc={SubmitExceptionFunc} />
|
||||
<SubmitExceptionButton SubmitExceptionFunc={() => submitFunc(true)} />
|
||||
)}
|
||||
<LastYearDataButton getLastYearDataFunc={() => getLastYearDataFunc(searchValues ?? {})} />
|
||||
<SubmitButton submitFunc={submitFunc} />
|
||||
|
||||
<SubmitButton submitFunc={() => submitFunc(false)} />
|
||||
|
||||
</>
|
||||
)}
|
||||
{statusInfo?.laeSbmsnSttsCd === '2' && <CancelSubmitButton cnacelSubmitFunc={cnacelSubmitFunc} />}
|
||||
@@ -557,7 +602,18 @@ const SeweragePenetrationRateInp = () => {
|
||||
/>
|
||||
</div>
|
||||
<ConfirmDialog isOpen={false} />
|
||||
<SubmitDailog open={showDailog} onOpenChange={setShowDailog} statusInfo={statusInfo} onConfirm={executeSubmit} isLoading={isLoading} />
|
||||
<SubmitDailog
|
||||
open={showDailog}
|
||||
onOpenChange={(open) => {
|
||||
setShowDailog(open);
|
||||
if (!open) setIsExceptionSubmitFlow(false);
|
||||
}}
|
||||
statusInfo={statusInfo}
|
||||
onConfirm={executeSubmit}
|
||||
onExceptionConfirm={executeExceptionSubmit}
|
||||
submitMode={isExceptionSubmitFlow ? 'exception' : 'normal'}
|
||||
isLoading={isLoading}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -47,7 +47,10 @@ interface SubmitDialogProps {
|
||||
statusInfo: SewerageSupplyRateStatusInfo | null;
|
||||
/** 다이얼로그에서 저장 클릭 시 호출. 제출 정보를 넘기면 부모에서 requestData에 포함해 제출 API 호출 */
|
||||
onConfirm?: (data: StatisticsInputSubmitInfoFormData) => void | Promise<void>;
|
||||
onExceptionConfirm?: (data: any) => void | Promise<void>;
|
||||
/** 예외 제출로 다이얼로그를 연 경우: 일반 제출(onConfirm) 대신 호출 */
|
||||
onExceptionConfirm?: (data: StatisticsInputSubmitInfoFormData) => void | Promise<void>;
|
||||
/** 'normal': onConfirm / 'exception': onExceptionConfirm */
|
||||
submitMode?: "normal" | "exception";
|
||||
isLoading?: boolean;
|
||||
}
|
||||
|
||||
@@ -75,7 +78,15 @@ function statusInfoToFormData(info: SewerageSupplyRateStatusInfo): StatisticsInp
|
||||
};
|
||||
};
|
||||
|
||||
const SubmitDailog = ({ open, onOpenChange, statusInfo, onConfirm, onExceptionConfirm, isLoading }: SubmitDialogProps) => {
|
||||
const SubmitDailog = ({
|
||||
open,
|
||||
onOpenChange,
|
||||
statusInfo,
|
||||
onConfirm,
|
||||
onExceptionConfirm,
|
||||
submitMode = "normal",
|
||||
isLoading,
|
||||
}: SubmitDialogProps) => {
|
||||
const { control, handleSubmit, reset, formState: { errors } } = useForm<StatisticsInputSubmitInfoFormData>({
|
||||
resolver: zodResolver(statisticsInputSubmitInfoSchema),
|
||||
defaultValues,
|
||||
@@ -88,7 +99,11 @@ const SubmitDailog = ({ open, onOpenChange, statusInfo, onConfirm, onExceptionCo
|
||||
}, [open, statusInfo, reset]);
|
||||
|
||||
async function onSubmit(data: StatisticsInputSubmitInfoFormData) {
|
||||
await onConfirm?.(data);
|
||||
if (submitMode === "exception") {
|
||||
await onExceptionConfirm?.(data);
|
||||
} else {
|
||||
await onConfirm?.(data);
|
||||
}
|
||||
onOpenChange(false);
|
||||
reset(defaultValues);
|
||||
}
|
||||
@@ -164,7 +179,7 @@ const SubmitDailog = ({ open, onOpenChange, statusInfo, onConfirm, onExceptionCo
|
||||
취소
|
||||
</Button>
|
||||
<Button type="submit" color="primary">
|
||||
제출
|
||||
{submitMode === 'normal' ? '제출' : '예외 제출'}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</form>
|
||||
|
||||
@@ -1,87 +1,78 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from 'react';
|
||||
// import useSWR from 'swr';
|
||||
import { useCallback, useState } from 'react';
|
||||
|
||||
import {
|
||||
Button,
|
||||
// Input,
|
||||
Label,
|
||||
// Select,
|
||||
// SelectTrigger,
|
||||
// SelectContent,
|
||||
// SelectItem,
|
||||
// SelectValue
|
||||
LoadingWithAnimation,
|
||||
}
|
||||
from "@common/components";
|
||||
import DataGrid from '@/components/module/DataGrid';
|
||||
import { CodeSelect } from '@/entities/code';
|
||||
import { CodeSelectWithAll } from '@/entities/code';
|
||||
|
||||
import { statisticsAPi } from '@/entities/statistics/api/statistics-service';
|
||||
import type { StatisticsLogRequest } from '@/entities/statistics/model/statistics-interface';
|
||||
import { toGridRows } from '@/components/util/grid/gridFunction';
|
||||
|
||||
import { LogHistoryColumn } from '@/components/util/column/management/LogHistoryColumn';
|
||||
// import { LwpoCodeApi } from "@/entities/code";
|
||||
import { LogHistoryTablePagination } from '@/components/statistics/management/LogHistoryTablePagination';
|
||||
|
||||
// const getStateCdListFetcher = async () => {
|
||||
// return LwpoCodeApi.getLwpoCodeList({
|
||||
// sort: 'regDt,desc',
|
||||
// upCd: 'STITEM',
|
||||
// page: 0,
|
||||
// size: 100,
|
||||
// });
|
||||
// }
|
||||
const PAGE_SIZE = 100;
|
||||
|
||||
const LogHistory = () => {
|
||||
// const { setMessage: alert } = useAlertStore((state) => state);
|
||||
const [statsCd, setStatsCd] = useState('');
|
||||
const [statsCd, setStatsCd] = useState<string>('');
|
||||
const [isLoading, setIsLoading] = useState<boolean>(false);
|
||||
const [rowData, setRowData] = useState<Record<string, string | number>[]>([]);
|
||||
const [pageIndex, setPageIndex] = useState(0);
|
||||
const [totalPages, setTotalPages] = useState(0);
|
||||
|
||||
// const { data: lwpoCdList } = useSWR(
|
||||
// "lwpo-code-list",
|
||||
// getStateCdListFetcher,
|
||||
// {
|
||||
// revalidateOnFocus: false,
|
||||
// revalidateOnReconnect: false,
|
||||
// revalidateIfStale: false,
|
||||
// dedupingInterval: 2000,
|
||||
// shouldRetryOnError: false,
|
||||
// onSuccess: (data) => {
|
||||
// if (!data.content || data.content.length == 0) {
|
||||
// alert(`시도 목록을 불러오는데 실패했습니다.
|
||||
// 새로고침 후 다시 시도해주세요.`);
|
||||
// }
|
||||
// },
|
||||
// onError: () => {
|
||||
// alert(`시도 목록을 불러오는데 실패했습니다.
|
||||
// 새로고침 후 다시 시도해주세요.`);
|
||||
// },
|
||||
// }
|
||||
// );
|
||||
const loadLogs = useCallback(async (page1Based: number) => {
|
||||
const param: StatisticsLogRequest = {
|
||||
statsCd: (statsCd === '' || statsCd === 'ALL') ? '' : statsCd,
|
||||
page: page1Based,
|
||||
size: PAGE_SIZE,
|
||||
};
|
||||
|
||||
try {
|
||||
setIsLoading(true);
|
||||
|
||||
const response = await statisticsAPi.getLogList(param);
|
||||
|
||||
if (response.status === 'success') {
|
||||
setRowData(toGridRows(response.data?.statsLogList ?? []));
|
||||
setTotalPages(response.data?.pageInfo?.totalPages ?? 0);
|
||||
setPageIndex(Math.max(0, page1Based - 1));
|
||||
} else {
|
||||
alert(response.message || '데이터 조회 중 오류가 발생했습니다.');
|
||||
}
|
||||
} catch {
|
||||
alert('데이터 조회 중 오류가 발생했습니다.');
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
}, [statsCd]);
|
||||
|
||||
const handleSearch = async (e: React.FormEvent<HTMLFormElement>) => {
|
||||
e.preventDefault();
|
||||
await loadLogs(1);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="relative">
|
||||
<div className="card card-border">
|
||||
<form>
|
||||
<form onSubmit={handleSearch}>
|
||||
<div className="flex items-center gap-8 p-2">
|
||||
<div className="flex items-center gap-2">
|
||||
<Label className="text-label">
|
||||
통계항목
|
||||
</Label>
|
||||
{/* <Select value={lwpoCd} onValueChange={setLwpoCd}>
|
||||
<SelectTrigger className="w-[22rem]">
|
||||
<SelectValue placeholder="전체"></SelectValue>
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="ALL">전체</SelectItem>
|
||||
{lwpoCdList?.content?.map((l) => (
|
||||
<SelectItem key={l.lwpoCd} value={l.lwpoCd}>
|
||||
{l.lwpoCdNm}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select> */}
|
||||
<CodeSelect
|
||||
<CodeSelectWithAll
|
||||
upCd="STITEM"
|
||||
value={statsCd}
|
||||
onValueChange={setStatsCd}
|
||||
placeholder="선택"
|
||||
placeholder="전체"
|
||||
className="w-[16rem]"
|
||||
/>
|
||||
</div>
|
||||
@@ -96,14 +87,23 @@ const LogHistory = () => {
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<DataGrid
|
||||
{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]">
|
||||
<LoadingWithAnimation color="primary" />
|
||||
</div>
|
||||
</div>}
|
||||
<DataGrid
|
||||
columnInfo={LogHistoryColumn}
|
||||
// rowStartNum={1}
|
||||
// fixedColumns={1}
|
||||
isExcelImport={false}
|
||||
// showHeaderCheckbox={true}
|
||||
rowData={[]}
|
||||
setRowData={() => {}}
|
||||
rowData={rowData}
|
||||
setRowData={() => { }}
|
||||
/>
|
||||
<LogHistoryTablePagination
|
||||
pageCount={totalPages}
|
||||
pageIndex={pageIndex}
|
||||
onPageIndexChange={(idx) => {
|
||||
void loadLogs(idx + 1);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
"use client";
|
||||
|
||||
/**
|
||||
* @common/components DataTable 내부 Pagination과 동일 마크업/클래스 (복제).
|
||||
* 공용 패키지 수정 없이 LogHistory 전용으로 둠.
|
||||
*/
|
||||
import {
|
||||
ChevronLeftIcon,
|
||||
ChevronRightIcon,
|
||||
DoubleArrowLeftIcon,
|
||||
DoubleArrowRightIcon,
|
||||
} from "@radix-ui/react-icons";
|
||||
|
||||
import { Button, cn } from "@common/components";
|
||||
|
||||
export type LogHistoryTablePaginationProps = {
|
||||
/** 총 페이지 수 (TanStack table.getPageCount()와 동일) */
|
||||
pageCount: number;
|
||||
/** 0부터 시작하는 현재 페이지 인덱스 */
|
||||
pageIndex: number;
|
||||
onPageIndexChange: (pageIndex: number) => void;
|
||||
};
|
||||
|
||||
export function LogHistoryTablePagination({
|
||||
pageCount,
|
||||
pageIndex: currentPage,
|
||||
onPageIndexChange,
|
||||
}: LogHistoryTablePaginationProps) {
|
||||
const maxVisiblePages = 10;
|
||||
|
||||
let startPage = Math.max(0, currentPage - maxVisiblePages / 2);
|
||||
const endPage = Math.min(pageCount, startPage + maxVisiblePages);
|
||||
|
||||
if (endPage - startPage < maxVisiblePages) {
|
||||
startPage = Math.max(0, endPage - maxVisiblePages);
|
||||
}
|
||||
|
||||
const pageNumbers = Array(endPage - startPage)
|
||||
.fill(0)
|
||||
.map((_, i) => startPage + i);
|
||||
|
||||
const canPrevious = currentPage > 0;
|
||||
const canNext = pageCount > 0 && currentPage < pageCount - 1;
|
||||
|
||||
return (
|
||||
<div className="mt-[24px] flex items-center justify-center space-x-2">
|
||||
<Button
|
||||
variant="ghost"
|
||||
color="white"
|
||||
className="hidden size-10 p-0 lg:flex"
|
||||
onClick={() => onPageIndexChange(0)}
|
||||
disabled={!canPrevious}
|
||||
>
|
||||
<span className="sr-only">첫 페이지로</span>
|
||||
<DoubleArrowLeftIcon className="size-4" />
|
||||
</Button>
|
||||
<Button
|
||||
variant="ghost"
|
||||
color="white"
|
||||
className="size-10 p-0"
|
||||
onClick={() => onPageIndexChange(currentPage - 1)}
|
||||
disabled={!canPrevious}
|
||||
>
|
||||
<span className="sr-only">이전 페이지로</span>
|
||||
<ChevronLeftIcon className="size-4" />
|
||||
</Button>
|
||||
<div className="flex items-center justify-center text-sm font-medium">
|
||||
{pageNumbers.map((pageNumber) => (
|
||||
<Button
|
||||
key={pageNumber}
|
||||
variant="ghost"
|
||||
className={cn(
|
||||
"inline-block h-10 min-w-10 !bg-transparent p-1 text-foreground hover:!bg-accent",
|
||||
currentPage === pageNumber &&
|
||||
"!bg-primary !font-bold !text-primary-foreground hover:!bg-primary",
|
||||
)}
|
||||
onClick={() => onPageIndexChange(pageNumber)}
|
||||
>
|
||||
{pageNumber + 1}
|
||||
</Button>
|
||||
))}
|
||||
</div>
|
||||
<Button
|
||||
variant="ghost"
|
||||
color="white"
|
||||
className="size-10 p-0"
|
||||
onClick={() => onPageIndexChange(currentPage + 1)}
|
||||
disabled={!canNext}
|
||||
>
|
||||
<span className="sr-only">다음 페이지로</span>
|
||||
<ChevronRightIcon className="size-4" />
|
||||
</Button>
|
||||
<Button
|
||||
variant="ghost"
|
||||
color="white"
|
||||
className="hidden size-10 p-0 lg:flex"
|
||||
onClick={() => onPageIndexChange(Math.max(0, pageCount - 1))}
|
||||
disabled={!canNext}
|
||||
>
|
||||
<span className="sr-only">마지막 페이지로</span>
|
||||
<DoubleArrowRightIcon className="size-4" />
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -54,11 +54,11 @@ const SewagePipeRvw = () => {
|
||||
try {
|
||||
setIsLoading(true);
|
||||
|
||||
const searchParam: SewagePipeReviewRequestParams = {
|
||||
statsYr: values.year,
|
||||
sewerBzmnCd: values.bsnmCd,
|
||||
ctpvNm: values.sido,
|
||||
sggNm: values.gugun === 'ALL' ? '' : values.gugun
|
||||
const searchParam: SewagePipeReviewRequestParams = {
|
||||
statsYr: values.year,
|
||||
sewerBzmnCd: values.bsnmCd,
|
||||
ctpvNm: values.sido,
|
||||
sggNm: values.gugun === 'ALL' ? '' : values.gugun
|
||||
};
|
||||
|
||||
searchParamRef.current = searchParam;
|
||||
@@ -69,7 +69,7 @@ const SewagePipeRvw = () => {
|
||||
newRowDataMap.set('ST00020001', toGridRows(response.data as object[]));
|
||||
setRowDataMap(newRowDataMap);
|
||||
} else {
|
||||
alert(response?.message || "데이터가 없습니다.");
|
||||
alert(response?.message || '데이터 조회 중 오류가 발생했습니다.');
|
||||
}
|
||||
} catch {
|
||||
alert('데이터 조회 중 오류가 발생했습니다.');
|
||||
@@ -96,14 +96,14 @@ const SewagePipeRvw = () => {
|
||||
|
||||
if (tabKey === 'ST00020002') {
|
||||
response = await statisticsManagementApi.getSewagePipeFacilityList(searchParamRef.current);
|
||||
}else if(tabKey === 'ST00020003'){
|
||||
response = await statisticsManagementApi.getSewagePipeTypeList(searchParamRef.current);
|
||||
}else if(tabKey === 'ST00020004'){
|
||||
response = await statisticsManagementApi.getSewagePipeDiamList(searchParamRef.current);
|
||||
} else if (tabKey === 'ST00020003') {
|
||||
response = await statisticsManagementApi.getSewagePipeTypeList(searchParamRef.current);
|
||||
} else if (tabKey === 'ST00020004') {
|
||||
response = await statisticsManagementApi.getSewagePipeDiamList(searchParamRef.current);
|
||||
}
|
||||
|
||||
if (response?.status === 'success' && response.data) {
|
||||
|
||||
|
||||
setRowDataMap(prev => {
|
||||
const next = new Map(prev);
|
||||
next.set(tabKey, toGridRows(response.data as object[]));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useState, useMemo } from "react";
|
||||
import { DataGrid } from "@rsone/components";
|
||||
import DataGrid from "@/components/module/DataGrid";
|
||||
import SearchForm from "@/components/module/SearchForm";
|
||||
import SaveButton from "@/components/button/SaveButton";
|
||||
import ApproveButton from "@/components/button/ApproveButton";
|
||||
@@ -45,17 +45,17 @@ const StatsInputStatusRvw = () => {
|
||||
setIsLoading(true);
|
||||
|
||||
const response = await statisticsManagementApi.getStatsInputStatusList({
|
||||
sido: values.sido,
|
||||
gugun: values.gugun === 'ALL' ? '' : values.gugun,
|
||||
yr: values.year,
|
||||
bsnmCd: values.bsnmCd
|
||||
ctpvNm: values.sido,
|
||||
sggNm: values.gugun === 'ALL' ? '' : values.gugun,
|
||||
statsYr: values.year,
|
||||
sewerBzmnCd: values.bsnmCd
|
||||
});
|
||||
|
||||
if (response.status === 'success' && response.data) {
|
||||
const rawList = response.data.sewerageSupplyRateList ?? [];
|
||||
const convertedData: StatsInputStatusReviewItem[] = rawList.map((item: StatsInputStatusReviewItem) => ({
|
||||
...item,
|
||||
status: item.status || '미확인',
|
||||
// status: item.status || '미확인',
|
||||
}));
|
||||
|
||||
setRowData(toGridRows(convertedData));
|
||||
@@ -100,9 +100,10 @@ const StatsInputStatusRvw = () => {
|
||||
|
||||
<DataGrid
|
||||
columnInfo={columnInfo}
|
||||
isExcelImport={false}
|
||||
isExcelImport={false}
|
||||
showHeaderCheckbox={true}
|
||||
rowStartNum={2}
|
||||
fixedColumns={2}
|
||||
fixedColumns={4}
|
||||
rowData={rowData}
|
||||
setRowData={setRowData}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user