빗물시설 현황 조회 api 적용

This commit is contained in:
leedj312
2025-04-25 15:17:27 +09:00
parent a8ca2b4da6
commit 256e71c67e
3 changed files with 89 additions and 47 deletions
@@ -11,7 +11,7 @@ import {
Title,
UiModal,
UiTable,
type ReturnType
type ReturnType,
} from "@common/business_components/ui";
import ListDiv from "@common/business_components/ui/list_div";
import { Button } from "@common/components/ui";
@@ -19,31 +19,36 @@ import { useCallback, useEffect, useRef, useState } from "react";
import { headMakeTriple } from "./TableHead";
export default function RainSttn() {
const { code, rain, init, sttnCommon, excelExportAction } = useWrStore((state) => state);
const { rainRes } = rain;
const { code, init, sttnCommon, excelExportAction, rainSttnInit } =
useWrStore((state) => state);
const { rainRes } = sttnCommon;
const [isChHead, setIsChHead] = useState(false);
const ref = useRef<ReturnType>({} as ReturnType);
const [bdstTable, setBdstTable] = useState<any[]>();
const nodeList = headMakeTriple(
sttnCommon.rainSttHeadList,
sttnCommon.rainSttHeadNm
);
useEffect(() => {
if (!rain.isInit) {
init(undefined);
if (!sttnCommon.isInit) {
let con
if (ref.current.sigunValue != '0') {
con = ref.current.sigunValue
}else{
con = ref.current.sidoValue
}
rainSttnInit('1', '20' ,con);
}
}, [rain.isInit, init]);
}, [sttnCommon.isInit, rainSttnInit]);
useEffect(() => {
if (code.sggCd.length > 0) {
if (rainRes.length > 0) {
const data = tableData(rainRes, { code });
// data 는 위 JSON 객체라고 가정
// TODO: 이게 뭐하는 작업이지?
const unVisibleHead = sttnCommon.rainSttHeadList.filter(
(item: TableTripleProps) => item.visible === false
);
const chData = data
.map((item: any) => ({
...item,
@@ -52,15 +57,14 @@ export default function RainSttn() {
}))
.filter((item: any) => item.rainyObj !== undefined);
console.log("chData ", chData);
setBdstTable(chData);
}
}, [code, rainRes, sttnCommon.rainSttHeadList]);
}, [code, sttnCommon.rainRes]);
const excelClick = useCallback(() => {
excelExportAction(code.cityCd, code.sggCd);
},[code.cityCd, code.sggCd, excelExportAction]);
}, [ code.sggCd, excelExportAction]);
return (
<>
<ContentsDiv>
@@ -82,17 +86,25 @@ export default function RainSttn() {
}}
>
조회항목설정
</Button>}
</Button>
}
leftChildren={undefined}
queryClick={function (returnType: ReturnType): void {
// page: string, total: string, con: string
// '{partValue: 'A', sidoValue: '0', sigunValue: '0', regionValue: '0', unitWaterShedValue: '0', …}'
let con
if (returnType.sigunValue != '0') {
con = returnType.sigunValue
}else{
con = returnType.sidoValue
}
rainSttnInit('1', '20' ,con);
}}
excelClick={excelClick}
initClick={function (): void {
}}
initClick={function (): void {}}
btnClass={btnClass}
ref={ref} />
ref={ref}
/>
</div>
</div>
<div className="grid grid-cols-6 gap-4 ">
@@ -8,7 +8,7 @@ const useTypes = [
"친수용수",
"기타"
]
export type ExcelExportType = {
export type ExcelExportType = {
"NO": string,
"시도": string,
"시군구": string,
@@ -49,7 +49,9 @@ export type ExcelExportType = {
"과태료 부과일(위반일)": string,
"위반사항": string,
"과태료부과금액(천원)": string
}
}
export type Buildingtype = {
bdstInfoPk: number,
ctpvCd: 1,
@@ -1,9 +1,11 @@
import type { chHeadType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn";
import { type ExcelExportType } from "../../../prfmncReg/chkgdnReg/rainChkgdn/excel";
import {
type customRainBdst,
type TableTripleProps,
type TableUpperProps
type TableUpperProps,
} from "../../fcltReg/rainReg";
import { fetchType, getFetch } from "@/components/lib/api";
const pbnSttHeadNm: chHeadType[] = [
{ headNm: "catchment", text: "유역", length: 3 },
@@ -268,7 +270,7 @@ const rainSttHeadList: TableTripleProps[] = [
upName: ["insenInfo", "instlCstSprt"],
upSequnce: [2, 2],
},
{
id: "grntchBdstCertYn",
title: "녹색건축물인증여부",
@@ -298,19 +300,22 @@ const rainSttHeadList: TableTripleProps[] = [
upSequnce: [6, 4],
},
];
const rainRes: customRainBdst[] = [];
export type sttnState = {
sttnCommon: {
rainRes: customRainBdst[];
pbnSttHeadList: TableUpperProps[];
pbnSttHeadNm: chHeadType[];
rainSttHeadList: TableTripleProps[];
rainSttHeadNm: chHeadType[];
excelList:ExcelExportType[]
excelList: ExcelExportType[];
isInit:boolean
};
};
type sttnActions = {
rainSttnInit: (page: string, total: string, con: string) => void;
chSttnHead: (checkList: string[], type: string) => void;
pbnSttnInit: (sggCd: string, searchTxt: string, flg: string) => void;
};
export type sttnType = sttnState & sttnActions;
@@ -321,13 +326,34 @@ export const sttnStateExport: sttnState = {
pbnSttHeadNm: pbnSttHeadNm,
rainSttHeadList: rainSttHeadList,
rainSttHeadNm: rainSttHeadNm,
rainRes: rainRes,
excelList: [],
isInit:false
},
};
export const sttnActionsExport: (set: any) => sttnActions = (set: any) => {
return {
pbnSttnInit: async (sggCd: string, searchTxt: string, flg: string) => {},
rainSttnInit: async (page: string, total: string, con: string) => {
try {
const rainRes = await getFetch(
fetchType.WR,
`/reuseFc/rainyInfoList/${page}/${total}/${con}`
);
set((state: sttnState) => {
return {
...state,
sttnCommon: {
...state.sttnCommon,
rainRes: rainRes,
isInit: false,
},
};
});
} catch (erTxt) {
console.log("error", erTxt);
}
},
chSttnHead: async (checkList: string[], type: string) => {
const headList =
type === "pbn"
@@ -336,34 +362,36 @@ export const sttnActionsExport: (set: any) => sttnActions = (set: any) => {
? rainSttHeadList
: null;
let chNm = type === "pbn" ? pbnSttHeadNm : rainSttHeadNm;
let chNm = type === "pbn" ? pbnSttHeadNm : rainSttHeadNm;
headList?.forEach((item) => {
if (checkList.find((ch) => ch === item.id)) {
item.visible = false;
if (item.upName) {
const upNames = Array.isArray(item.upName) ? item.upName : [item.upName];
upNames?.forEach((up) => {
const upNames = Array.isArray(item.upName)
? item.upName
: [item.upName];
upNames?.forEach((up) => {
chNm.find((ch) => {
if (ch.headNm === up) {
ch.length = ch.length - 1;
}
}
);
})
}
});
});
}
}
});
set((state: sttnState) => ({
sttnCommon: {
...state.sttnCommon,
pbnSttHeadList: type === "pbn" ? headList : state.sttnCommon.pbnSttHeadList,
rainSttHeadList: type === "rain" ? headList : state.sttnCommon.rainSttHeadList,
rainSttHeadNm: type === "rain" ? chNm : state.sttnCommon.rainSttHeadNm,
pbnSttHeadNm: type === "rain" ? chNm : state.sttnCommon.pbnSttHeadNm,
},
}));
set((state: sttnState) => ({
sttnCommon: {
...state.sttnCommon,
pbnSttHeadList:
type === "pbn" ? headList : state.sttnCommon.pbnSttHeadList,
rainSttHeadList:
type === "rain" ? headList : state.sttnCommon.rainSttHeadList,
rainSttHeadNm:
type === "rain" ? chNm : state.sttnCommon.rainSttHeadNm,
pbnSttHeadNm: type === "rain" ? chNm : state.sttnCommon.pbnSttHeadNm,
},
}));
},
};
};