From 256e71c67e4e8a946bb759e391c692249849d2af Mon Sep 17 00:00:00 2001 From: leedj312 Date: Fri, 25 Apr 2025 15:17:27 +0900 Subject: [PATCH] =?UTF-8?q?=EB=B9=97=EB=AC=BC=EC=8B=9C=EC=84=A4=20?= =?UTF-8?q?=ED=98=84=ED=99=A9=20=EC=A1=B0=ED=9A=8C=20api=20=EC=A0=81?= =?UTF-8?q?=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruseFcltMng/fcltSttn/rainSttn/page.tsx | 56 ++++++++------ .../prfmncReg/chkgdnReg/rainChkgdn/excel.tsx | 6 +- .../store/ruseFcltMng/fcltSttn/sttn/index.tsx | 74 +++++++++++++------ 3 files changed, 89 insertions(+), 47 deletions(-) diff --git a/apps/wr/app/ruseFcltMng/fcltSttn/rainSttn/page.tsx b/apps/wr/app/ruseFcltMng/fcltSttn/rainSttn/page.tsx index 77bce97e8..5fd3e4b9e 100644 --- a/apps/wr/app/ruseFcltMng/fcltSttn/rainSttn/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltSttn/rainSttn/page.tsx @@ -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({} as ReturnType); const [bdstTable, setBdstTable] = useState(); 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 ( <> @@ -82,17 +86,25 @@ export default function RainSttn() { }} > 조회항목설정 - } + + } 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} + />
diff --git a/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/excel.tsx b/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/excel.tsx index 26f9a7e42..ead156cb2 100644 --- a/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/excel.tsx +++ b/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/excel.tsx @@ -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, diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/sttn/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/sttn/index.tsx index 21ef1831e..ac55700b7 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltSttn/sttn/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/sttn/index.tsx @@ -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, + }, + })); }, }; };