From bca13cad659343bfd578a115af2f282039bcf411 Mon Sep 17 00:00:00 2001 From: leedj312 Date: Tue, 13 May 2025 11:02:27 +0900 Subject: [PATCH] =?UTF-8?q?=EC=98=A8=EB=B0=B0=EC=88=98=20=EC=B2=AB?= =?UTF-8?q?=ED=99=94=EB=A9=B4=20=EB=8D=B0=EC=9D=B4=ED=84=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruseFcltMng/fcltSttn/htdflSttn/page.tsx | 90 +++++++++++++------ .../ruseFcltMng/fcltSttn/htdflSttn/index.tsx | 28 ++++++ 2 files changed, 90 insertions(+), 28 deletions(-) diff --git a/apps/wr/app/ruseFcltMng/fcltSttn/htdflSttn/page.tsx b/apps/wr/app/ruseFcltMng/fcltSttn/htdflSttn/page.tsx index 64163b5fd..8cbca00cb 100644 --- a/apps/wr/app/ruseFcltMng/fcltSttn/htdflSttn/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltSttn/htdflSttn/page.tsx @@ -1,25 +1,37 @@ -'use client' +"use client"; import { useWrStore } from "@/app/store"; import { btnClass } from "@/app/store/common/code"; -import type { chgBuilding, customRainBdst } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; -import { getCityOrSgg } from "@/components/lib/func/commom"; -import { ContentsDiv, SearchBaseForm, Title ,UiTable,type ReturnType, } from "@common/business_components/ui" +import type { + chgBuilding, + customRainBdst, +} from "@/app/store/ruseFcltMng/fcltReg/rainReg"; +import { getCityOrSgg, tableData } from "@/components/lib/func/commom"; +import { + ContentsDiv, + SearchBaseForm, + Title, + UiTable, + type ReturnType, +} from "@common/business_components/ui"; import ListDiv from "@common/business_components/ui/list_div"; import { HeadMakeColSpan } from "@common/business_components/ui/table/HeadMakeColSpan"; import { Button } from "@common/components/ui"; -import { useCallback, useRef, useState } from "react"; +import { useCallback, useEffect, useRef, useState } from "react"; -export default function HtdflSttn(){ -const { code,htdflSttn } = useWrStore( - (state) => state - ); -const ref = useRef({} as ReturnType); +export default function HtdflSttn() { + const { code, htdflSttn ,initHtdfl} = useWrStore((state) => state); + const { htdflSttnRes } = htdflSttn; + + const ref = useRef({} as ReturnType); const [pageNation, setPageNation] = useState(1); const [isChHead, setIsChHead] = useState(false); const [bdstTable, setBdstTable] = useState(); - const [detailModal, setDetailModal] = useState<{isOpen:boolean,data:customRainBdst|undefined}>({data:undefined,isOpen:false }) + const [detailModal, setDetailModal] = useState<{ + isOpen: boolean; + data: customRainBdst | undefined; + }>({ data: undefined, isOpen: false }); const [bdstChgProps, setBdstChgProps] = useState<{ isOpen: boolean; chBuilding: chgBuilding[]; @@ -27,18 +39,38 @@ const ref = useRef({} as ReturnType); const codeData = getCityOrSgg(ref); - const excelClick = useCallback(() => { + const excelClick = useCallback(() => { // if (codeData) rainSttnSearch(1, "10000", codeData); - }, []); - - const cellClick=(index:number|undefined, headId: string)=>{ - - - - } - return( - <> - + }, []); + + const cellClick = (index: number | undefined, headId: string) => {}; + + + useEffect(() => { + if (!htdflSttn.isInit) { + initHtdfl(codeData ?? "0"); + } + }, [htdflSttn.isInit, initHtdfl]); + + useEffect(() => { + if (htdflSttnRes.length > 0 && code.cityCd.length > 0) { + const data = tableData(htdflSttnRes, { code }); + const chData = data + .map((item: any) => ({ + ...item, + ...item.reuseBuilding[0], + ...item.reuseBuilding[0].htdflObj, + chBuildingYn: item.chgBuilding[0]?.bdstChgNm !== null ? "Y" : "N", + })) + .filter((item: any) => item.htdflObj !== undefined); + + setBdstTable(chData); + } + }, [code, htdflSttnRes, htdflSttn.htdflSttHeadList]); + + return ( + <> +
@@ -68,7 +100,7 @@ const ref = useRef<ReturnType>({} as ReturnType); } else { con = returnType.sidoValue; } - // rainSttnSearch(1, "20", con); + // rainSttnSearch(1, "20", con); }} excelClick={excelClick} initClick={function (): void {}} @@ -89,13 +121,15 @@ const ref = useRef<ReturnType>({} as ReturnType); headlist={htdflSttn.htdflSttHeadList} pageSize={20} total={100000} - cellClick={(index: number | undefined,headId:string)=>{cellClick(index ?? undefined,headId)} } + cellClick={(index: number | undefined, headId: string) => { + cellClick(index ?? undefined, headId); + }} onPageChange={setPageNation} ></UiTable> </ListDiv> </div> </div> - </ContentsDiv> - </> - ) -} \ No newline at end of file + </ContentsDiv> + </> + ); +} diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/htdflSttn/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/htdflSttn/index.tsx index a5275f137..c6da1b2f8 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltSttn/htdflSttn/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/htdflSttn/index.tsx @@ -2,6 +2,8 @@ import type { CommonTableProps } from "@/app/store/common/type/headder"; import { htdflSttHeadListExport, htdflSttNodeListExport } from "./headList"; import type { sttnHeadListType } from "../rainSttn/headList"; import type { z } from "zod"; +import type { customHtdflBdst } from "../../fcltReg/htdflReg"; +import { getFetch } from "@/components/lib/api"; const htdflSttHeadList = htdflSttHeadListExport; const htdflSttNodeList = htdflSttNodeListExport; @@ -11,6 +13,7 @@ export type htdflSttnState = { isInit: boolean; htdflSttHeadList: z.infer<typeof sttnHeadListType>; htdflSttNodeList: CommonTableProps[]; + htdflSttnRes:customHtdflBdst[] }; }; type htdflSttnActions = {}; @@ -21,13 +24,38 @@ export const htdflSttnStateExport: htdflSttnState = { htdflSttn: { htdflSttHeadList: htdflSttHeadList, htdflSttNodeList: htdflSttNodeList, + htdflSttnRes:[], isInit: false, }, }; +const initFetch = async (code:string|number) => { + const rswtRes = await getFetch( + "wr", + `/drain/facilityList/1/20/${code}`) + + return rswtRes; +}; export const htdflSttnActionsExport: (set: any) => htdflSttnActions = ( set: any ) => { return { + initHtdfl: async (code: string | number) => { + try { + const htdflSttnRes = await initFetch(code); + set((state: htdflSttnState) => { + return { + ...state, + htdflSttn: { + ...state.htdflSttn, + htdflSttnRes: htdflSttnRes, + isInit: false, + }, + }; + }); + } catch (error) { + console.log(error); + } + }, } } \ No newline at end of file