From 2ce2d2eca395572de9c53942f5c46af42893b515 Mon Sep 17 00:00:00 2001 From: jyha00 Date: Wed, 14 May 2025 14:35:11 +0900 Subject: [PATCH] =?UTF-8?q?=EC=98=A8=EB=B0=B0=EC=88=98=20=EC=99=84?= =?UTF-8?q?=EB=A3=8C,=20=EC=97=91=EC=85=80=20=ED=95=B4=EC=95=BC=EB=90=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/wr/app/page.tsx | 5 + .../ruseFcltMng/fcltSttn/htdflSttn/page.tsx | 58 ++++- .../prfmncSttn/chkgdnSttn/page.tsx | 206 ++++++++++++++++++ .../ruseFcltMng/fcltSttn/htdflSttn/index.tsx | 62 +++++- .../ui/modal/sttn/headChModal/headChModal.tsx | 4 +- .../sttn/sttnDetailModal/sttnDetailModal.tsx | 55 +++-- 6 files changed, 358 insertions(+), 32 deletions(-) create mode 100644 apps/wr/app/ruseFcltMng/prfmncSttn/chkgdnSttn/page.tsx diff --git a/apps/wr/app/page.tsx b/apps/wr/app/page.tsx index c173173ff..0d981b194 100644 --- a/apps/wr/app/page.tsx +++ b/apps/wr/app/page.tsx @@ -48,6 +48,11 @@ export default function Home() { +
+ +
diff --git a/apps/wr/app/ruseFcltMng/fcltSttn/htdflSttn/page.tsx b/apps/wr/app/ruseFcltMng/fcltSttn/htdflSttn/page.tsx index 8cbca00cb..2e06b05b3 100644 --- a/apps/wr/app/ruseFcltMng/fcltSttn/htdflSttn/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltSttn/htdflSttn/page.tsx @@ -7,20 +7,24 @@ import type { customRainBdst, } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; import { getCityOrSgg, tableData } from "@/components/lib/func/commom"; +import HeadChModal from "@/components/ui/modal/sttn/headChModal/headChModal"; import { ContentsDiv, SearchBaseForm, Title, + UiModal, 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 SttnDetailModal from "@/components/ui/modal/sttn/sttnDetailModal/sttnDetailModal"; +import BdstChgModal from "@/components/ui/modal/fcltReg/bdstChgModal/bdstChgModal"; import { Button } from "@common/components/ui"; import { useCallback, useEffect, useRef, useState } from "react"; export default function HtdflSttn() { - const { code, htdflSttn ,initHtdfl} = useWrStore((state) => state); + const { code, htdflSttn, htdflSttnSearch, initHtdfl} = useWrStore((state) => state); const { htdflSttnRes } = htdflSttn; const ref = useRef({} as ReturnType); @@ -40,11 +44,26 @@ export default function HtdflSttn() { const codeData = getCityOrSgg(ref); const excelClick = useCallback(() => { - // if (codeData) rainSttnSearch(1, "10000", codeData); + if (codeData) htdflSttnSearch(1, "10000", codeData); }, []); - const cellClick = (index: number | undefined, headId: string) => {}; + useEffect(() => { + if (codeData != null) htdflSttnSearch(pageNation, "20", codeData); + }, [pageNation]); + const cellClick = (index: number | undefined, headId: string) => { + if(headId!=='chBuildingYn' && index!==undefined && bdstTable!==undefined){ + setDetailModal({isOpen:true ,data:bdstTable[index] }) + }else if( headId==='chBuildingYn' && index!==undefined && bdstTable!==undefined){ + if ( + bdstTable[index] && + bdstTable[index]?.chgBuilding[0]?.bdstChgNm!==null + + ) { + setBdstChgProps({ isOpen:true , chBuilding: bdstTable[index].chgBuilding}); + } + } + }; useEffect(() => { if (!htdflSttn.isInit) { @@ -129,6 +148,39 @@ export default function HtdflSttn() { + { + setIsChHead(!isChHead); + }} + bodyClass={""} + body={ + ({ + ...item, + visible: item.visible ?? false, + }))} + /> + } + /> + { + setDetailModal({...detailModal, isOpen:!detailModal.isOpen}) + }} + bodyClass={"w-[40vw] max-w-none max-h-[calc(100%-70px)]"} + body={}/> + + } + onOpenChange={(open) => { + setBdstChgProps({ ...bdstChgProps, isOpen: open }); + }} + /> ); diff --git a/apps/wr/app/ruseFcltMng/prfmncSttn/chkgdnSttn/page.tsx b/apps/wr/app/ruseFcltMng/prfmncSttn/chkgdnSttn/page.tsx new file mode 100644 index 000000000..4ddc4246a --- /dev/null +++ b/apps/wr/app/ruseFcltMng/prfmncSttn/chkgdnSttn/page.tsx @@ -0,0 +1,206 @@ +"use client"; + +import { useWrStore } from "@/app/store"; +import { type rainChkZodType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn"; +import type { rswtChkZodType } from "@/app/store/prfmncReg/chkgdnReg/rswrtChkgdn"; +import { + excelArrayDownload, + excelDownload, +} from "@/components/lib/func/commom"; +import ChkgdExcel from "@/components/ui/modal/chkgd/chkgdExcel/chkgdExcel"; +import ChkgdModal from "@/components/ui/modal/chkgd/chkgdModal/chkgdModal"; +import RainChkgdTable from "@/components/ui/table/chkgdTable/rainChkgd/rainChkgdTable"; +import RswtChkgdTable from "@/components/ui/table/chkgdTable/rswtChkgd/rswtChkgdTable"; +import { + ContentsDiv, + SearchDiv, + SearchFormLeft, + SearchFormRight, + SearchInput, + SelectBox, + Title, + UiModal, +} from "@common/business_components/ui"; +import ListDiv from "@common/business_components/ui/list_div"; +import { Button } from "@common/components/ui"; +import { useCallback, useEffect, useState } from "react"; +import { Toaster } from "react-hot-toast"; + +//----------------------- +export default function Page() { + const { + code, + rainChkgdn, + rswtChkgdn, + rainChkInit, + rainChkDetilUpdate, + rainChkDelete, + rainChkExcelDownload, + rswtrChkExcelDownload, + + rswtChkgdnInit + } = useWrStore((state) => { + return state; + }); + const [isRegExcel, setIsRegExcel] = useState(false); + const [searchTxt, setSearchTxt] = useState(); + const [updateRainDetail, setUpdateRainDetail] = useState( + [] + ); + const [deleteIdx, setDeleteIdx] = useState([]); + const [selFcltDiv, setSelFcltDiv] = useState("RNB"); + const [isModal, setIsModal] = useState({ + open: false, + data: {}, + }); + const cellClick = () => { + if (searchTxt) rainChkInit(searchTxt, "0"); + }; + + useEffect(() => { + if (!rainChkgdn.isInit) { + rainChkInit("2024", "0"); + setIsModal({ data: {}, open: rainChkgdn.isModalClose }); + setIsRegExcel(false); + } + + if (!rswtChkgdn.isInit) { + rswtChkgdnInit("2024", "0"); + setIsModal({ data: {}, open: rainChkgdn.isModalClose }); + setIsRegExcel(false); + } + }, [rainChkgdn.isInit, rainChkInit]); + + useEffect(() => { + console.log("rswtChkgdn.excelList ", rswtChkgdn.excelList); + + if (rswtChkgdn.excelList[0]?.data.length > 1) + excelArrayDownload( + "중수도_점검결과_이용량현황", + "sample_rs_chk.xlsx", + rswtChkgdn.excelList + ); + }, [rswtChkgdn.excelList]); + + useEffect(() => { + excelDownload( + rainChkgdn.excelList, + "빗물이용시설 지도점검", + "sample_rainy.xlsx", + "A1:AN1" + ); + }, [rainChkgdn.excelList]); + + const excelClick = useCallback(() => { + console.log("selFcltDiv ", selFcltDiv); + if (selFcltDiv === "RNB") { + rainChkExcelDownload(code.cityCd, code.sggCd); + } else { + rswtrChkExcelDownload(code.cityCd, code.sggCd); + } + }, [ + rainChkExcelDownload, + rswtrChkExcelDownload, + code.cityCd, + code.sggCd, + selFcltDiv, + ]); + + const handleClick = useCallback( + (data: any) => { + if (data) setIsModal({ open: true, data: data }); + }, + [isModal] + ); + + const clickDelete = (data: number[]) => { + if (data.length > 0) { + rainChkDelete(data); + } + }; + + return ( + +
+
+ + <SearchDiv> + <SearchFormLeft> + <SearchInput + className="col-span-3 my-7 !text-xl" + label=" 지도점검년도" + textValue={searchTxt ?? ""} + setText={(e) => { + setSearchTxt(e); + }} + /> + <SelectBox + className={"col-span-3 w-full h-full text-2xl"} + label={"시설구분"} + selectClass={""} + selectArray={rainChkgdn.fcltDiv} + onSelectValue={(val: string | number) => + setSelFcltDiv(String(val)) + } + value={selFcltDiv ?? rainChkgdn.fcltDiv[0]?.val} + /> + </SearchFormLeft> + <SearchFormRight> + <div className="space-y"> + <div className="flex flex-row space-x-2"> + <Button + size={"sm"} + onClick={(e) => { + cellClick(); + }} + > + 조회 + </Button> + </div> + <div className="flex flex-row space-x-2 pt-3"> + <Button color="green" size={"sm"} onClick={excelClick}> + 양식받기 + </Button> + </div> + </div> + </SearchFormRight> + </SearchDiv> + </div> + </div> + <div className="grid grid-cols-6 gap-4 "> + <div className="col-span-6"> + <ListDiv> + {selFcltDiv === "RNB" ? ( + <RainChkgdTable + deleteData={setDeleteIdx} + detailUp={setUpdateRainDetail} + handleClick={handleClick} + /> + ) : ( + <RswtChkgdTable detaiRswtlUpdate={function (data: rswtChkZodType[]): void { + throw new Error("Function not implemented."); + } } deleteRswtData={function (selectedIds: number[]): void { + throw new Error("Function not implemented."); + } } /> + )} + </ListDiv> + </div> + </div> + <UiModal + open={isModal.open} + onOpenChange={() => { + setIsModal({ open: !open, data: {} }); + }} + bodyClass={"w-[80vw] max-w-none"} + body={<ChkgdModal type={"RNB"} obj={isModal.data} />} + ></UiModal> + <UiModal + open={isRegExcel} + onOpenChange={setIsRegExcel} + bodyClass={"w-[40vw] max-w-none"} + body={<ChkgdExcel type={selFcltDiv}></ChkgdExcel>} + /> + <Toaster position="top-center" /> + </ContentsDiv> + ); +} diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/htdflSttn/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/htdflSttn/index.tsx index c6da1b2f8..0dedb1570 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltSttn/htdflSttn/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/htdflSttn/index.tsx @@ -2,8 +2,9 @@ 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 { controlHeadView } from "../rainSttn"; import type { customHtdflBdst } from "../../fcltReg/htdflReg"; -import { getFetch } from "@/components/lib/api"; +import { fetchType, getFetch } from "@/components/lib/api"; const htdflSttHeadList = htdflSttHeadListExport; const htdflSttNodeList = htdflSttNodeListExport; @@ -16,7 +17,13 @@ export type htdflSttnState = { htdflSttnRes:customHtdflBdst[] }; }; -type htdflSttnActions = {}; +type htdflSttnActions = { + initHtdfl:(con:string) => void; + htdflSttnSearch: (page: number, total: string, con: string) => void; + htdflChSttnHead: ( + headList: z.infer<typeof sttnHeadListType>, + ) => void; +}; export type htdflSttnType = htdflSttnState & htdflSttnActions; @@ -29,11 +36,11 @@ export const htdflSttnStateExport: htdflSttnState = { }, }; const initFetch = async (code:string|number) => { - const rswtRes = await getFetch( + const htdflRes = await getFetch( "wr", `/drain/facilityList/1/20/${code}`) - return rswtRes; + return htdflRes; }; export const htdflSttnActionsExport: (set: any) => htdflSttnActions = ( @@ -57,5 +64,52 @@ export const htdflSttnActionsExport: (set: any) => htdflSttnActions = ( console.log(error); } }, + htdflSttnSearch: async (page: number, total: string, con: string) => { + try { + const htdflSttnRes = await getFetch( + fetchType.WR, + `/drain/facilityList/${page}/${total}/${con}` + ); + if (Number(total) > 9000) { + // const htdflExcel = excelHtdflSttnParsing(htdflSttnRes); + set((state: htdflSttnState) => { + return { + ...state, + htdflSttn: { + ...state.htdflSttn, + // excelList: htdflExcel, + }, + }; + }); + } else + set((state: htdflSttnState) => { + return { + ...state, + htdflSttn: { + ...state.htdflSttn, + htdflSttnRes: htdflSttnRes, + isInit: false, + }, + }; + }); + } catch (erTxt) { + console.log("error", erTxt); + } + }, + htdflChSttnHead: async ( + headList: z.infer<typeof sttnHeadListType> + ): Promise<void> => { + + console.log('head ', headList) + const changeNodeList= controlHeadView(headList,htdflSttNodeList) + + return set((state: htdflSttnState) => ({ + htdflSttn: { + ...state.htdflSttn, + htdflSttHeadList: headList, + htdflSttNodeList: changeNodeList, + }, + })); + }, } } \ No newline at end of file diff --git a/apps/wr/components/ui/modal/sttn/headChModal/headChModal.tsx b/apps/wr/components/ui/modal/sttn/headChModal/headChModal.tsx index 1f97373ca..bd08489f2 100644 --- a/apps/wr/components/ui/modal/sttn/headChModal/headChModal.tsx +++ b/apps/wr/components/ui/modal/sttn/headChModal/headChModal.tsx @@ -8,7 +8,7 @@ import { useForm } from "react-hook-form"; import { z } from "zod"; export default function HeadChModal({headList, type }:{headList : z.infer<typeof sttnHeadListType> ,type:string }) { - const { rainChSttnHead , rswtChSttnHead} = useWrStore((state) => state); + const { rainChSttnHead , rswtChSttnHead, htdflChSttnHead} = useWrStore((state) => state); let items = headList.map(item => ({id:item.id, title:item.title, val:item.visible })); @@ -32,6 +32,8 @@ export default function HeadChModal({headList, type }:{headList : z.infer<typeo rainChSttnHead(valueList) }else if(type=== 'RST'){ rswtChSttnHead(valueList) + }else if(type === 'HTB'){ + htdflChSttnHead(valueList) } } diff --git a/apps/wr/components/ui/modal/sttn/sttnDetailModal/sttnDetailModal.tsx b/apps/wr/components/ui/modal/sttn/sttnDetailModal/sttnDetailModal.tsx index 443757f98..9a2929ffd 100644 --- a/apps/wr/components/ui/modal/sttn/sttnDetailModal/sttnDetailModal.tsx +++ b/apps/wr/components/ui/modal/sttn/sttnDetailModal/sttnDetailModal.tsx @@ -2,8 +2,10 @@ import { ScrollArea, Title, UiTable } from "@common/business_components/ui"; import RainRegForm from "../../../form/fcltReg/rainReg/rainRegForm"; import RswtrRegForm from "../../../form/fcltReg/rswtrReg/rswtrRegForm"; +import HtdflRegForm from "../../../form/fcltReg/htdflReg/htdflRegForm"; import type { customRainBdst } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; import type { customRswtBdst } from "@/app/store/ruseFcltMng/fcltReg/rswtReg"; +import type { customHtdflBdst } from "@/app/store/ruseFcltMng/fcltReg/htdflReg"; import { useWrStore } from "@/app/store"; import { useEffect, useState } from "react"; import type { CommonTableProps } from "@/app/store/common/type/headder"; @@ -72,31 +74,36 @@ export default function SttnDetailModal({ return ( <div> - <Title title={type === "RNB" ?"빗물이용시설 상세정보":"중수도시설 상세정보"}> - 0?"h-[80vh]":"h-[70vh]"} > - {type === "RNB" ? ( - - ) : ( - - )} + + 0?"h-[80vh]":"h-[70vh]"} > + {type === "RNB" ? ( + + ) : type === "RST" ? ( + + ) : ()} - {detailData.data.length>0? - } - - pageSize={0} - total={0} - cellClick={undefined} - onPageChange={function (page: number): void { - throw new Error("Function not implemented."); - }} - >:<>} - + {detailData.data.length>0? + } + + pageSize={0} + total={0} + cellClick={undefined} + onPageChange={function (page: number): void { + throw new Error("Function not implemented."); + }} + >:<>} + +
); }