feat: 02.하수관로 tab1지역별 시설현황 조회 기능 추가
This commit is contained in:
@@ -1,25 +1,25 @@
|
||||
import { useState, useMemo } from "react";
|
||||
// import { TabDataGrid } from "@rsone/components";
|
||||
import TabDataGrid from "@/components/module/TabDataGrid";
|
||||
import SearchForm from "@/components/module/SearchForm";
|
||||
import SaveButton from "@/components/button/SaveButton";
|
||||
import ApproveButton from "@/components/button/ApproveButton";
|
||||
import ReviewOpinionButton from "@/components/button/ReviewOpinionButton";
|
||||
import ReturnButton from "@/components/button/ReturnButton";
|
||||
import { useAlertStore } from "@/shared/lib";
|
||||
import { LoadingWithAnimation } from "@common/components";
|
||||
|
||||
import { sewagePipeReviewApi } from "@/entities/statistics/api/statistics-sewage-pipe-review-service";
|
||||
import { useAlertStore } from "@/shared/lib";
|
||||
import { statisticsManagementApi } from "@/entities/statistics/api/statistics-management-service";
|
||||
import { SewagePipeColumnInfoListRvw } from "@/components/util/column/review/SewagePipeRvwColumn";
|
||||
import type { SearchFormValues } from "@/components/type/SearchForm.type";
|
||||
import { toGridRows } from "@/components/util/grid/gridFunction";
|
||||
|
||||
// 하수도 통계 검토 02.하수관로
|
||||
const SewagePipeRvw = () => {
|
||||
const { setMessage: alert } = useAlertStore((state) => state);
|
||||
const [rowDataMap, setRowDataMap] = useState<Map<string, any[]>>(new Map());
|
||||
const [isLoading, setIsLoading] = useState<boolean>(false);
|
||||
|
||||
const columnInfo = useMemo(() => {
|
||||
|
||||
return SewagePipeColumnInfoListRvw.map((tab: any) => ({
|
||||
...tab,
|
||||
columns: tab.columns.map((col: any) => ({
|
||||
@@ -32,40 +32,45 @@ const SewagePipeRvw = () => {
|
||||
|
||||
const handleReset = () => setRowDataMap(new Map());
|
||||
|
||||
const handleSearch = async (values: SearchFormValues) => {
|
||||
try {
|
||||
setIsLoading(true);
|
||||
const response = await sewagePipeReviewApi.getSewagePipeReviewList({
|
||||
sido: values.sido,
|
||||
gugun: values.gugun === 'ALL' ? '' : values.gugun,
|
||||
bsnmCd: values.bsnmCd,
|
||||
yr: values.year,
|
||||
});
|
||||
|
||||
if (response.status === 'success' && response.data) {
|
||||
|
||||
const rawList = response.data;
|
||||
|
||||
console.log("추출된 리스트 (rawList):", rawList);
|
||||
|
||||
const newRowDataMap = new Map<string, any[]>();
|
||||
|
||||
newRowDataMap.set('a', toGridRows(rawList));
|
||||
|
||||
setRowDataMap(newRowDataMap);
|
||||
} else {
|
||||
handleReset();
|
||||
alert(response.message || "데이터가 없습니다.");
|
||||
const handleSearch = async (values: SearchFormValues) => {
|
||||
if (!values.sido || values.sido === 'ALL') {
|
||||
alert('시도를 선택해주세요.');
|
||||
return;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("조회 에러:", error);
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
setIsLoading(true);
|
||||
const response = await statisticsManagementApi.getSewagePipeReviewList({
|
||||
sido: values.sido,
|
||||
gugun: values.gugun === 'ALL' ? '' : values.gugun,
|
||||
bsnmCd: values.bsnmCd,
|
||||
yr: values.year,
|
||||
});
|
||||
|
||||
if (response.status === 'success' && response.data) {
|
||||
const rawList = response.data;
|
||||
const newRowDataMap = new Map<string, any[]>();
|
||||
|
||||
newRowDataMap.set('a', toGridRows(rawList));
|
||||
|
||||
setRowDataMap(newRowDataMap);
|
||||
} else {
|
||||
handleReset();
|
||||
alert(response.message || "데이터가 없습니다.");
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("조회 에러:", error);
|
||||
alert('데이터 조회 중 오류가 발생했습니다.');
|
||||
handleReset();
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<SearchForm onSubmit={handleSearch} onReset={handleReset} fctName={true} />
|
||||
<div className="relative">
|
||||
<SearchForm onSubmit={handleSearch} onReset={handleReset} />
|
||||
|
||||
<div className="card !py-0">
|
||||
<div className="flex justify-end items-center gap-[0.6rem] m-[0.6rem]">
|
||||
<ReviewOpinionButton reviewOpinionFunc={() => {}} />
|
||||
@@ -74,13 +79,21 @@ const handleSearch = async (values: SearchFormValues) => {
|
||||
<SaveButton saveFunc={() => {}} />
|
||||
</div>
|
||||
</div>
|
||||
{isLoading && (
|
||||
<div className="absolute inset-0 z-50 [data-theme='black']:bg-transparent bg-white/50 rounded-lg p-10 flex justify-center items-center">
|
||||
<div className="relative size-[5rem]">
|
||||
<LoadingWithAnimation color="primary" />
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<TabDataGrid
|
||||
columnInfo={columnInfo}
|
||||
isExcelImport={true}
|
||||
isExcelImport={false}
|
||||
rowDataMap={rowDataMap}
|
||||
setRowDataMap={setRowDataMap}
|
||||
/>
|
||||
</>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user