From e0c235e26bb2a8b8d237f56dce5848b746ccfcaf Mon Sep 17 00:00:00 2001 From: leedj312 Date: Sat, 7 Jun 2025 08:05:04 +0900 Subject: [PATCH 1/4] =?UTF-8?q?=EC=A4=91=EB=B3=B5=20=ED=83=80=EC=9E=85=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0=20=EB=B0=8F=20=EC=8B=A4=EC=A0=81=EB=93=B1?= =?UTF-8?q?=EB=A1=9D=20=EC=99=84=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ruseFcltMng/fcltReg/htdflReg/page.tsx | 1 - .../app/ruseFcltMng/fcltReg/pbnstReg/page.tsx | 3 - .../ruseFcltMng/fcltReg/rainReg/TableHead.tsx | 4 +- .../app/ruseFcltMng/fcltReg/rswtReg/page.tsx | 2 +- .../ruseFcltMng/fcltSttn/htdflSttn/page.tsx | 4 +- .../prfmncReg/chkgdnReg/TableHead.tsx | 2 +- .../prfmncReg/pbnstPrfmncReg/page.tsx | 151 +++++-- .../common/type/{headder.tsx => header.tsx} | 6 +- .../wr/app/store/matDmd/coMatRvw/headList.tsx | 2 +- apps/wr/app/store/matDmd/coMatRvw/index.tsx | 2 +- apps/wr/app/store/matDmd/coSttn/headList.tsx | 2 +- apps/wr/app/store/matDmd/coSttn/index.tsx | 2 +- .../app/store/matDmd/ldrmntCoSttn/index.tsx | 2 +- .../store/matDmd/ruseRvwHstry/headList.tsx | 2 +- .../app/store/matDmd/ruseRvwHstry/index.tsx | 2 +- .../chkgdnReg/rainChkgdn/headList.tsx | 22 +- .../prfmncReg/chkgdnReg/rainChkgdn/index.tsx | 4 +- .../chkgdnReg/rswrtChkgdn/headList.tsx | 22 +- .../store/prfmncReg/pbnstPrfmncReg/excel.tsx | 5 +- .../prfmncReg/pbnstPrfmncReg/headList.tsx | 31 +- .../store/prfmncReg/pbnstPrfmncReg/index.tsx | 21 +- .../store/prfmncReg/pbnstPrfmncReg/type.tsx | 381 ++++++++++++++++-- .../chkgdnSttn/rainChkgdnSttn/headList.tsx | 20 +- .../chkgdnSttn/rswtChkgdnSttn/headList.tsx | 2 +- .../chkgdnSttn/rswtChkgdnSttn/index.tsx | 2 +- .../prfmncSttn/pbnstPrfmncSttn/index.tsx | 2 +- .../ruseFcltMng/fcltReg/bdstReg/index.tsx | 11 +- .../ruseFcltMng/fcltReg/htdflReg/index.tsx | 3 +- .../ruseFcltMng/fcltReg/pbnstReg/headList.tsx | 2 +- .../ruseFcltMng/fcltReg/rainReg/index.tsx | 16 +- .../ruseFcltMng/fcltReg/rswtReg/index.tsx | 3 +- .../fcltSttn/htdflSttn/headList.tsx | 2 +- .../ruseFcltMng/fcltSttn/htdflSttn/index.tsx | 4 +- .../fcltSttn/pbnstSttn/headList.tsx | 2 +- .../ruseFcltMng/fcltSttn/pbnstSttn/index.tsx | 2 +- .../fcltSttn/rainSttn/headList.tsx | 2 +- .../ruseFcltMng/fcltSttn/rainSttn/index.tsx | 2 +- .../fcltSttn/rswtSttn/headList.tsx | 2 +- .../ruseFcltMng/fcltSttn/rswtSttn/index.tsx | 2 +- apps/wr/components/lib/func/TableData.tsx | 65 ++- .../ui/modal/chkgd/chkgdModal/chkgdModal.tsx | 2 +- .../pbnPrfExcelModal/pbnPrfExcelModal.tsx | 7 +- .../fcOrgwtsRegModal/fcOrgwtsRegModal.tsx | 2 +- .../sttn/sttnDetailModal/coDatailModal.tsx | 2 +- .../sttn/sttnDetailModal/sttnDetailModal.tsx | 2 +- .../guideDetailTable/guideDetailTable.tsx | 71 +--- .../chkgdTable/rainChkgd/rainChkgdTable.tsx | 2 +- .../chkgdTable/rswtChkgd/rswtChkgdTable.tsx | 2 +- 48 files changed, 657 insertions(+), 250 deletions(-) rename apps/wr/app/store/common/type/{headder.tsx => header.tsx} (69%) diff --git a/apps/wr/app/ruseFcltMng/fcltReg/htdflReg/page.tsx b/apps/wr/app/ruseFcltMng/fcltReg/htdflReg/page.tsx index c0d6d4377..8cb85e9fb 100644 --- a/apps/wr/app/ruseFcltMng/fcltReg/htdflReg/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltReg/htdflReg/page.tsx @@ -20,7 +20,6 @@ import HtdflRegForm from "@/components/ui/form/fcltReg/htdflReg/htdflRegForm"; import type { chgBuilding } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; import BdstChgModal from "@/components/ui/modal/fcltReg/bdstChgModal/bdstChgModal"; import type { customHtdflBdst } from "@/app/store/ruseFcltMng/fcltReg/htdflReg"; -import { headMakeColSpan } from "../rainReg/TableHead"; import { BdstReg } from "@/components/ui/modal/fcltReg/bdstRegModal/bdstRegModal"; export default function Home() { diff --git a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx index cefc971a4..dce624479 100644 --- a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx @@ -17,14 +17,11 @@ import ListDiv from "@common/business_components/ui/list_div"; import { tableData } from "@/components/lib/func/commom"; import type { customPbnst, - fcBizSchema, fcBizType, pubHasuType, - ruseFcltType, } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; import { PbnstMngForm } from "@/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm"; import { PbnstBuseForm } from "@/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm"; -import { z } from "zod"; import { PbnstRegModal } from "@/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal"; import { Toaster } from "react-hot-toast"; import { ToastFormUi } from "@/components/ui/toast/toastFromUi"; diff --git a/apps/wr/app/ruseFcltMng/fcltReg/rainReg/TableHead.tsx b/apps/wr/app/ruseFcltMng/fcltReg/rainReg/TableHead.tsx index 39137d364..9dd67dc44 100644 --- a/apps/wr/app/ruseFcltMng/fcltReg/rainReg/TableHead.tsx +++ b/apps/wr/app/ruseFcltMng/fcltReg/rainReg/TableHead.tsx @@ -1,7 +1,7 @@ -import type { TableUpperProps } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; +import type { TableUpperProps } from "@/app/store/common/type/header"; import { TableRow, TableHead } from "@common/components/ui"; -export const headMakeColSpan = (upHeadList: TableUpperProps[]) => { +export const makeFcltRegHead = (upHeadList: TableUpperProps[]) => { return ( <> diff --git a/apps/wr/app/ruseFcltMng/fcltReg/rswtReg/page.tsx b/apps/wr/app/ruseFcltMng/fcltReg/rswtReg/page.tsx index ea51326ef..534d3e340 100644 --- a/apps/wr/app/ruseFcltMng/fcltReg/rswtReg/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltReg/rswtReg/page.tsx @@ -19,7 +19,7 @@ import { tableData } from "@/components/lib/func/commom"; import RswtrRegForm from "@/components/ui/form/fcltReg/rswtrReg/rswtrRegForm"; import BdstChgModal from "@/components/ui/modal/fcltReg/bdstChgModal/bdstChgModal"; import type { chgBuilding } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; -import { headMakeColSpan } from "../rainReg/TableHead"; +import { makeFcltRegHead } from "../rainReg/TableHead"; import { BdstReg } from "@/components/ui/modal/fcltReg/bdstRegModal/bdstRegModal"; 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 f2ab7c06d..e8362edbe 100644 --- a/apps/wr/app/ruseFcltMng/fcltSttn/htdflSttn/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltSttn/htdflSttn/page.tsx @@ -21,7 +21,7 @@ import { 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 { makeFcltRegHead } from "@common/business_components/ui/table/makeFcltRegHead"; import SttnDetailModal from "@/components/ui/modal/sttn/sttnDetailModal/sttnDetailModal"; import BdstChgModal from "@/components/ui/modal/fcltReg/bdstChgModal/bdstChgModal"; import { Button } from "@common/components/ui"; @@ -155,7 +155,7 @@ export default function HtdflSttn() { headName={[]} tableData={bdstTable || []} children={ - + } headlist={htdflSttn.htdflSttHeadList} pageSize={20} diff --git a/apps/wr/app/ruseFcltMng/prfmncReg/chkgdnReg/TableHead.tsx b/apps/wr/app/ruseFcltMng/prfmncReg/chkgdnReg/TableHead.tsx index 130578654..10a0bf85f 100644 --- a/apps/wr/app/ruseFcltMng/prfmncReg/chkgdnReg/TableHead.tsx +++ b/apps/wr/app/ruseFcltMng/prfmncReg/chkgdnReg/TableHead.tsx @@ -1,5 +1,5 @@ +import type { TableUpperProps } from "@/app/store/common/type/header"; import type { chHeadType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList"; -import type { TableUpperProps } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; import { TableHead, TableRow } from "@common/components/ui"; export const headMakeprfmnc = ( diff --git a/apps/wr/app/ruseFcltMng/prfmncReg/pbnstPrfmncReg/page.tsx b/apps/wr/app/ruseFcltMng/prfmncReg/pbnstPrfmncReg/page.tsx index f640c8d2d..4efa94fa1 100644 --- a/apps/wr/app/ruseFcltMng/prfmncReg/pbnstPrfmncReg/page.tsx +++ b/apps/wr/app/ruseFcltMng/prfmncReg/pbnstPrfmncReg/page.tsx @@ -1,6 +1,5 @@ "use client"; import { useWrStore } from "@/app/store"; -import type { FcPrfType } from "@/app/store/prfmncReg/pbnstPrfmncReg/type"; import type { pubHasuType } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; import { excelDownload, yearOptions } from "@/components/lib/func/commom"; import PbnPrfExcelModal from "@/components/ui/modal/chkgd/pbnPrfExcelModal/pbnPrfExcelModal"; @@ -17,17 +16,41 @@ import { UiModal, } from "@common/business_components/ui"; import ListDiv from "@common/business_components/ui/list_div"; -import { Button, Label } from "@common/components/ui"; +import { + Button, + Label, + Table, + TableBody, + TableHeader, +} from "@common/components/ui"; import { useState, useEffect, useCallback } from "react"; import { set } from "react-hook-form"; import { Toaster } from "react-hot-toast"; +import { headMakeprfmnc } from "../chkgdnReg/TableHead"; +import { InputTableBody } from "@/components/lib/func/TableData"; +import { + initValInUsage, + initValOutUsage, + subTotalObj, + totalObj, + type FcPrfType, + type PrfType, +} from "@/app/store/prfmncReg/pbnstPrfmncReg/type"; +import { excelToPbnPrfData } from "@/app/store/prfmncReg/pbnstPrfmncReg/excel"; export default function prfmncPrfmncReg() { - const { code, prfmnc, prfmncHasuInit } = useWrStore((state) => state); + const { code, prfmnc, prfmncHasuInit, prfmnRegData } = useWrStore( + (state) => state + ); const { pbnstPrfmncHeadList, monthHeadList, prfmncRes } = prfmnc; const [bdstTable, setbdstTable] = useState(); const [searchTxt, setSearchTxt] = useState(); - const [isExcelOpen, setIsExcelOPen] = useState<{isModal:boolean, data:FcPrfType}>({isModal:false, data:{} as FcPrfType }); + const [isExcelOpen, setIsExcelOPen] = useState<{ + isModal: boolean; + data: FcPrfType; + }>({ isModal: false, data: {} as FcPrfType }); + const [inputData, setInputData] = useState(); + const [pbnstRuseFcltPk, setPbnstRuseFcltPk] = useState(); const [searchYear, setSearchYear] = useState( String(new Date().getFullYear()) @@ -41,15 +64,86 @@ export default function prfmncPrfmncReg() { ); }, [prfmnc.excelList]); + const onSave = useCallback(() => { + if (pbnstRuseFcltPk) { + prfmnRegData( + excelToPbnPrfData( + inputData as unknown as JSON[], + searchYear, + pbnstRuseFcltPk + ) as unknown as PrfType + ); + prfmncHasuInit("1", "11"); + } + }, [inputData, searchYear, pbnstRuseFcltPk,prfmncHasuInit]); + const cellClick = useCallback( + (index: number | undefined, headId: string) => { + if (index !== undefined) { + setIsExcelOPen({ + isModal: false, + data: prfmncRes[index] || ({} as FcPrfType), + }); + const inUsageData = initValInUsage; + const outUsageData = initValOutUsage; + const inSubtotal = subTotalObj; + const outSubtotal = subTotalObj; - const cellClick = useCallback((index:number|undefined, headId:string) => { + if (prfmncRes[index]?.prfList) { + prfmncRes[index].prfList?.forEach((prfItem) => { + const month = Number(prfItem?.ym?.slice(4)); // "MM" + const monthKey = `${month}월`; - if(index !== undefined) - setIsExcelOPen({isModal:false, data:prfmncRes[index] || {} as FcPrfType}) + inUsageData.forEach((inData: any) => { + const usageKey = inData.usage; + const value = (prfItem as any)[usageKey] ?? 0; - }, [prfmncRes]); + inData[monthKey] = value; + inData.total += value; + + if (inSubtotal && usageKey !== "subtotal") { + (inSubtotal as any)[monthKey] = + ((inSubtotal as any)[monthKey] ?? 0) + value; + inSubtotal.total += value; + } + }); + + outUsageData.forEach((outData: any) => { + const usageKey = outData.usage; + const value = (prfItem as any)[usageKey] ?? 0; + + outData[monthKey] = value; + outData.total += value; + + if (usageKey !== "subtotal") { + (outSubtotal as any)[monthKey] = + ((outSubtotal as any)[monthKey] ?? 0) + value; + outSubtotal.total += value; + } + }); + }); + inUsageData.push(inSubtotal); + outUsageData.push(outSubtotal); + const usageTotalObj: { [key: string]: any } = totalObj; + for (const key in usageTotalObj) { + if (["usage", "gubun", "edit"].includes(key)) continue; + const val = + (Number((inSubtotal as any)[key]) || 0) + + (Number((outSubtotal as any)[key]) || 0); + + (usageTotalObj as any)[key] = val; + } + const tableData = [...inUsageData, ...outUsageData, usageTotalObj]; + setPbnstRuseFcltPk(prfmncRes[index].pbnstRuseFcltPk); + setInputData(tableData); + } else { + setInputData([]); + } + } + }, + [prfmncRes] + ); useEffect(() => { if (!prfmnc.isInit) { @@ -103,13 +197,18 @@ export default function prfmncPrfmncReg() { - } - leftChildren={undefined} + leftChildren={ + <> +
+ + setSearchYear(String(val)) + } + /> +
+ { + setPbnRuseNm(searchNm || ""); + }} + setRtnData={function (rtnData: any[]): void { + setBdstTable(rtnData); + }} + searchList={pbnstSttn.pbnstSearchData||[]} + > + + + } queryClick={function (returnType: ReturnType): void { // '{partValue: 'A', sidoValue: '0', sigunValue: '0', regionValue: '0', unitWaterShedValue: '0', …}' let con; @@ -94,7 +159,7 @@ export default function PbnstSttn() { // pbnstSttnSearch(1, "20", con); }} excelClick={excelClick} - initClick={function (): void { }} + initClick={function (): void {}} btnClass={btnClass} ref={ref} /> @@ -112,7 +177,9 @@ export default function PbnstSttn() { headlist={pbnstSttn.pbnstSttHeadList} pageSize={20} total={100000} - cellClick={(index: number | undefined, headId: string) => { }} + cellClick={(index: number | undefined, headId: string) => { + cellCLick(index); + }} onPageChange={setPageNation} > @@ -134,6 +201,18 @@ export default function PbnstSttn() { /> } /> + + } + bodyClass="w-[68vw] max-w-none h-[90vh]" + open={isRuseReg.isModal} + onOpenChange={(open) => { + setIsRuseReg({ data: {} as pubHasuType, isModal: open }); + }} + /> ); diff --git a/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/type.tsx b/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/type.tsx index 89fced5a7..3bd741663 100644 --- a/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/type.tsx +++ b/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/type.tsx @@ -1,5 +1,6 @@ import { z } from "zod"; import type { TableUpperProps } from "../../common/type/header"; +import { fcOperSchema } from "../../ruseFcltMng/fcltReg/pbnstReg/type"; export const PrfSchema = z.object({ pbnstRuseFcltFk: z.string(), @@ -36,6 +37,7 @@ export const FcPrfSchema = z.object({ mdfcnDt: z.date().default(new Date()), mdfr: z.string(), prfList: z.array(PrfSchema), + operList:z.array(fcOperSchema), bscFctNm: z.string().nullish(), }); diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx index de7a71d4f..e22037892 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx @@ -273,7 +273,6 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { }; }); - console.log(" pbnstBizCycle ", pbnstBizCycle); return set((state: pubFacState) => ({ ...state, pbnst: { diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx index 6f33baf72..cbc081c01 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx @@ -89,7 +89,7 @@ const fcFileSchema = z.object({ mdfr: z.string().nullish(), }); -const fcOperSchema = z.object({ +export const fcOperSchema = z.object({ pbnstRuseFcltOperInfoPk: z.number().nullish(), pbnstRuseFcltFk: z.string().nullish(), operMthd: z.string(), diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/headList.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/headList.tsx index cb3cf1731..a1043be1d 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/headList.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/headList.tsx @@ -65,7 +65,7 @@ export const pbnSttHeadListExport: z.infer = [ }, { - id: "mngMeth", + id: "operMthd", title: "운영방식", visible: true, }, @@ -75,12 +75,12 @@ export const pbnSttHeadListExport: z.infer = [ visible: true, }, { - id: "firstDay", + id: "bgngDt", title: "시작일", visible: true, }, { - id: "LastDay", + id: "endDt", title: "종료일", visible: true, }, diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/index.tsx index deb2176a6..7ebfda0d8 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/index.tsx @@ -7,15 +7,19 @@ import type { sttnHeadListType } from "../rainSttn/headList"; import type { customPbnst, pubHasuType } from "../../fcltReg/pbnstReg/type"; import { excelPbnstSttnParsing } from "./excel"; import type { FcPrfType } from "@/app/store/prfmncReg/pbnstPrfmncReg/type"; +import type { ReturnType } from "@common/business_components/ui"; +import type { WaterReuseFacility } from "./type"; const pbnstSttHeadList = pbnSttHeadListExport; const pbnstSttNodeList = pbnstSttNodeListExport; export type pbnstSttnState = { pbnstSttn: { - pbnstSttnRes: customPbnst[]; + pbnstSttnRes: WaterReuseFacility[]; + pbnstSearchData: WaterReuseFacility[]; pbnstSttHeadList: CommonTableProps[]; pbnstSttNodeList: CommonTableProps[]; + pbnstDetail: customPbnst; excelList: []; isInit: boolean; }; @@ -23,8 +27,27 @@ export type pbnstSttnState = { type pbnstSttnActions = { pbnstChSttnHead: (headList: z.infer) => void; - pbnstSttnSearch: (page: string, total: string, con: string) => void; - pbnSttnInit: (page: string, sggOrCity: string) => void; + pbnstSttnSearch: ( + page: string, + total: string, + reurnValue: ReturnType, + searchNm: string | undefined, + year: string + ) => void; + pbnSttnInit: ( + page: string, + total: string, + reurnValue: ReturnType, + year: string + ) => void; + getPbnStnDetail: (bscFctCd: string) => void; + pbnNmSearch: ( + page: string, + total: string, + reurnValue: ReturnType, + searchNm: string | undefined, + year: string + ) => void; }; export type pbnstSttnType = pbnstSttnState & pbnstSttnActions; @@ -34,74 +57,110 @@ export const pbnstSttnStateExport: pbnstSttnState = { pbnstSttHeadList: pbnstSttHeadList, pbnstSttNodeList: pbnstSttNodeList, pbnstSttnRes: [], + pbnstDetail: {} as customPbnst, + pbnstSearchData: [], excelList: [], isInit: false, }, }; -const checkWrRegList = async () => { - const wrRegList = await getFetch("wr", `/reuseFc/pubDetailList`); - return wrRegList; -}; -const hasuListFetch = async (page: string, sggOrCity: string) => { - const checkWrRegListRes = await checkWrRegList(); - const rainRes = await postFectch( - `/prcsFclt/ruseInfo/${page ? page : 1}/10/A/${sggOrCity ? sggOrCity : "11"}/0/1/SW`, - checkWrRegListRes?.fcltCds, - fetchType.COMMON +const hasuListFetch = async ( + page: string, + total: string, + reurnValue: ReturnType, + searchNm: string | undefined, + year: string +) => { + let url = ""; + if (reurnValue.partValue === "A") { + url = `/prcsFclt/info/${page}/${total}/${reurnValue.partValue}/${ + reurnValue.sidoValue ? reurnValue.sidoValue : reurnValue.sigunValue + }/0/1/SW` + } else if (reurnValue.partValue === "R") { + url = `/prcsFclt/info/${page}/${total}/${reurnValue.partValue}/${ + reurnValue.regionValue + ? reurnValue.regionValue + : reurnValue.unitWaterShedValue + ? reurnValue.unitWaterShedValue + : reurnValue.middleRegionValue + }/0/1/SW` + } else { + url = `/prcsFclt/info/${page}/${total}/${reurnValue.envPartValue}/${reurnValue.sidoValue ? reurnValue.sidoValue : reurnValue.sigunValue}/0/1/SW` + + } + if( searchNm&& searchNm?.length>0){ + url+="/"+searchNm + } + const pbnList = await getFetch(fetchType.COMMON, url); + const arrayList = pbnList.map((item: pubHasuType) => item.bscFctCd); + const getRuseList = await postFectch( + `/reuseFc/pubDetailList/${year}`, + arrayList, + fetchType.WR ); - const data = checkWrRegListRes.fcPrfList.map((item: FcPrfType) => { - const findData = rainRes.data.find( - (fclt: pubHasuType) => - fclt.bscFctCd === item.pbnstRuseFcltPk.substring(0, 11) - ); - const usage = item.prfList.reduce( - (acc, cur) => { - acc.inUsage += - cur.wshwtr + - cur.coolUswtr + - cur.cleanUswtr + - cur.drwtUswtr + - cur.dltnUswtr + - cur.ithlRswtr + - cur.ithlEtcUswtr + - cur.cleanToilUswtr + - cur.resn; - acc.outUsage += - cur.lndwtr + - cur.hydUswtr + - cur.ugwtChr + - cur.farmUswtr + - cur.rvrKeepUswtr + - cur.indstUswtr; - acc.total = acc.inUsage + acc.outUsage; + const checkWrRegListRes = getRuseList.data; - return acc; - }, - { total: 0, inUsage: 0, outUsage: 0 } - ); - return { - rvbsn: findData?.rvbsn, - lgbsn: findData?.lgbsn, - mdmbsn: findData?.mdmbsn, - rgnNm: findData?.rgnNm, - sido: findData?.sido, - gugun: findData?.gugun, - bscFctNm: findData?.bscFctNm, - efflWqltStndrdNm: findData?.efflWqltStndrdNm, - fctCpc: findData.fctCpc, - tel: findData?.lclgvrnmnt ?? "-", - ruseUtztnFcltNm: item.ruseUtztnFcltNm, - fcltCpct: item.fcltCpct, - splyExtraCpct: item.splyExtraCpct, - ruseCpct: item.ruseCpct, - pbnstRuseFcltPk: item.pbnstRuseFcltPk, - usageTotal: usage.total, - inUsage: usage.inUsage, - outUsage: usage.outUsage, - fcOpers: item?.fcOpers ?? [], - }; - }); + const data: WaterReuseFacility[] = checkWrRegListRes.map( + (item: FcPrfType) => { + const findData = pbnList.find( + (fclt: pubHasuType) => + fclt.bscFctCd === item.pbnstRuseFcltPk.substring(0, 11) + ); + + const usage = item.prfList.reduce( + (acc, cur) => { + acc.inUsage += + cur.wshwtr + + cur.coolUswtr + + cur.cleanUswtr + + cur.drwtUswtr + + cur.dltnUswtr + + cur.ithlRswtr + + cur.ithlEtcUswtr + + cur.cleanToilUswtr + + cur.resn; + acc.outUsage += + cur.lndwtr + + cur.hydUswtr + + cur.ugwtChr + + cur.farmUswtr + + cur.rvrKeepUswtr + + cur.indstUswtr; + acc.total = acc.inUsage + acc.outUsage; + + return acc; + }, + { total: 0, inUsage: 0, outUsage: 0 } + ); + + return { + rvbsn: findData?.rvbsn, + lgbsn: findData?.lgbsn, + mdmbsn: findData?.mdmbsn, + rgnNm: findData?.rgnNm, + sido: findData?.sido, + gugun: findData?.gugun, + bscFctNm: findData?.bscFctNm, + efflWqltStndrdNm: findData?.efflWqltStndrdNm, + fctCpc: findData.fctCpc, + tel: findData?.tel ?? "-", + ruseUtztnFcltNm: item.ruseUtztnFcltNm, + fcltCpct: item.fcltCpct, + splyExtraCpct: item.splyExtraCpct, + ruseCpct: item.ruseCpct, + pbnstRuseFcltPk: item.pbnstRuseFcltPk, + usageTotal: usage.total, + inUsage: usage.inUsage, + outUsage: usage.outUsage, + operMthd: item.operList[0]?.operMthd, + rprtvBzenty: item.operList[0]?.rprtvBzenty, + bgngDt: item.operList[0]?.bgngDt.toLocaleDateString ?? "", + endDt: item.operList[0]?.endDt.toLocaleDateString?? "", + searchNm: findData.bscFctNm, + searchPk: findData.bscFctCd, + }; + } + ); return data; }; @@ -122,10 +181,21 @@ export const pbnstSttnActionsExport: (set: any) => pbnstSttnActions = ( }, })); }, - pbnstSttnSearch: async (page: string, total: string, con: string) => { + pbnstSttnSearch: async ( + page: string, + total: string, + reurnValue: ReturnType, + searchNm: string | undefined, + year: string + ) => { try { - - const pbnstSttnRes = await hasuListFetch(page, con); + const pbnstSttnRes = await hasuListFetch( + page, + total, + reurnValue, + searchNm, + year + ); console.log("pbnstSttnRes", pbnstSttnRes); if (Number(total) > 9000) { const pbnstExcel = excelPbnstSttnParsing(pbnstSttnRes); @@ -153,10 +223,23 @@ export const pbnstSttnActionsExport: (set: any) => pbnstSttnActions = ( console.log("error", erTxt); } }, - pbnSttnInit: async (page: string, sggOrCity: string) => { + pbnSttnInit: async ( + page: string, + total: string, + reurnValue: ReturnType, + year: string + ) => { try { - const pbnstSttnRes = await hasuListFetch(page, sggOrCity); - console.log("pbnstSttnRes", pbnstSttnRes); + + const pbnstSttnRes = await hasuListFetch( + page, + total, + reurnValue, + undefined, + year + ); + + console.log('pbnstSttnRes ', pbnstSttnRes) set((state: pbnstSttnState) => { return { ...state, @@ -171,5 +254,52 @@ export const pbnstSttnActionsExport: (set: any) => pbnstSttnActions = ( console.log("error", erTxt); } }, + getPbnStnDetail: async (bscFctCd: string) => { + try { + const pbnstDetail = await getFetch("wr", `/reuseFc/pubFc/${bscFctCd}`); + console.log("pbnstDetail ", pbnstDetail); + set((state: pbnstSttnState) => { + return { + ...state, + pbnstSttn: { + ...state.pbnstSttn, + pbnstDetail: pbnstDetail, + }, + }; + }); + } catch (errorHasu) { + console.log(errorHasu); + } + }, + pbnNmSearch: async ( + page: string, + total: string, + reurnValue: ReturnType, + searchNm: string | undefined, + year: string + ) => { + try { + + const pbnstSttnRes = await hasuListFetch( + page, + total, + reurnValue, + searchNm, + year + ); + + set((state: pbnstSttnState) => { + return { + ...state, + pbnstSttn: { + ...state.pbnstSttn, + pbnstSearchData: pbnstSttnRes, + }, + }; + }); + } catch (e) { + console.log(e); + } + }, }; }; diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/type.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/type.tsx new file mode 100644 index 000000000..0709d991b --- /dev/null +++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/type.tsx @@ -0,0 +1,24 @@ +export type WaterReuseFacility = { + bscFctNm: string; // 기본시설명 (예: "난지") + efflWqltStndrdNm: string; // 방류수 수질 기준명 (예: "500톤 이상(Ⅲ지역)") + fcltCpct: number; // 시설 용량 (숫자형, 예: 1) + fctCpc: string; // 시설 처리 능력 (예: "2360000") + gugun: string; // 구군 정보 (예: " ") + inUsage: number; // 유입량 (예: 1387) + lgbsn: string; // 대수계 (예: "한강본류") + mdmbsn: string; // 중권역 (예: "한강서울") + outUsage: number; // 유출량 (예: 900) + pbnstRuseFcltPk: string; // 공공하수 재이용 시설 PK (예: "11000SW001R1") + rgnNm: string; // 관할 기관명 (예: "한강유역환경청") + ruseCpct: number; // 재이용 가능 용량 (예: 123) + ruseUtztnFcltNm: string; // 재사용 활용 시설명 (예: "난지 재사용") + rvbsn: string; // 소수계 (예: "한강") + sido: string; // 시도 정보 (예: "서울특별시") + splyExtraCpct: number; // 추가 공급 용량 (예: 123) + tel: string; // 전화번호 (예: "-") + usageTotal: number; // 총 사용량 (예: 2287) + operMthd: string; + rprtvBzenty: string; + bgngDt: string; + endDt: string; +}; diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx index 32878b736..f1d1ee464 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx @@ -160,7 +160,6 @@ export function PbnstBuseForm({ formData.pplInstls = ref.current ? [...ref.current] : []; // ← form 내부 상태 기준으로 복사 formData.fcDemands = fcDemands; formData.fcOrgwts = fcOrgwtFiled; -ß if (formType === "reg") { if ( firstBizData && @@ -460,13 +459,13 @@ export function PbnstBuseForm({ render={({ field: f }) => ( { f.onChange(val); if (val) getDemandCompList(val, 3); }} - setRtnData={(valList: PbnstDemandComType[]) => { + setRtnData={(valList: any[]) => { if ( valList.length > 0 && valList['0'] @@ -507,6 +506,15 @@ export function PbnstBuseForm({ } }} + searchList={demandCompList?.map((item=>{ + return({ + ...item, + searchNm:item.dmdCoNm, + searchPk:item.dmdInfoPk + }) + })) + } + > )} diff --git a/apps/wr/components/ui/searchInput/searchInput.tsx b/apps/wr/components/ui/searchInput/searchInput.tsx index 413c3593a..e7097363f 100644 --- a/apps/wr/components/ui/searchInput/searchInput.tsx +++ b/apps/wr/components/ui/searchInput/searchInput.tsx @@ -1,56 +1,69 @@ +import React, { useCallback, useEffect, useRef, useState } from "react"; -import { useWrStore } from '@/app/store'; -import type { PbnstDemandComType } from '@/app/store/ruseFcltMng/fcltReg/pbnstReg/type'; -import type { DemandCompType } from '@common/business_components/ui'; -import React, { useCallback, useEffect, useRef, useState } from 'react'; - +type SearchType = { + searchNm: string; + searchPk: string; +}; type thisProps = { label: string | undefined; initValue: string | undefined; - setValue : (dmdCoNm?: string) => void; - setRtnData : (rtnData: PbnstDemandComType[]) => void; -} - - -export default function SearchInputText({label=undefined, initValue=undefined, setValue=()=>{}, setRtnData=()=>{}} :thisProps) { - - const { demandCompList } = useWrStore((state) => state); - - + setValue: (searchNm?: string) => void; + setRtnData: (rtnData: any[]) => void; + searchList?: any[]; +}; +export default function SearchInputText({ + label = undefined, + initValue = undefined, + setValue = () => {}, + setRtnData = () => {}, + searchList = undefined, +}: thisProps) { + const [isOpen, setIsOpen] = useState(false); - const [textValue, setTextValue] = useState(initValue || ''); - const wrapperRef = useRef(null); - const handleInputChange = useCallback((e: React.ChangeEvent) => { - const value = e.target.value; - setTextValue(value); - setValue(value); - if (value) { - setIsOpen(true); - } else { - setIsOpen(false); - } - }, [ setValue]); + const [textValue, setTextValue] = useState(initValue || ""); - const handleSuggestionClick = useCallback((dmdCoNm: string) => { - setTextValue(dmdCoNm); - setValue(dmdCoNm); - setIsOpen(false); - setRtnData(demandCompList); - }, [demandCompList, setRtnData, setValue]); + const wrapperRef = useRef(null); + const handleInputChange = useCallback( + (e: React.ChangeEvent) => { + const value = e.target.value; + setTextValue(value); + setValue(value); + if (value) { + setIsOpen(true); + } else { + setIsOpen(false); + } + }, + [setValue] + ); + + const handleSuggestionClick = useCallback( + (dmdCoNm: string) => { + setTextValue(dmdCoNm); + setValue(dmdCoNm); + setIsOpen(false); + setRtnData(searchList || []); + }, + [searchList, setRtnData, setValue] + ); useEffect(() => { const handleClickOutside = (event: MouseEvent) => { - if (wrapperRef.current && !wrapperRef.current.contains(event.target as Node)) { + if ( + wrapperRef.current && + !wrapperRef.current.contains(event.target as Node) + ) { setIsOpen(false); } }; - document.addEventListener('mousedown', handleClickOutside); + document.addEventListener("mousedown", handleClickOutside); return () => { - document.removeEventListener('mousedown', handleClickOutside); + document.removeEventListener("mousedown", handleClickOutside); }; }, []); + return (
- {demandCompList && demandCompList.length > 0 ? demandCompList.map((item : DemandCompType, index : number) => ( -
handleSuggestionClick(item.dmdCoNm)} - role="button" - tabIndex={0} - onKeyDown={(e) => { - if (e.key === 'Enter' || e.key === ' ') { - handleSuggestionClick(item.dmdCoNm); - } - }} - > - {item.dmdInfoPk.substring(0,10)} {item.dmdCoNm} -
- )) : ( + {searchList && searchList.length > 0 ? ( + searchList.map((item: SearchType, index: number) => ( +
handleSuggestionClick(item.searchNm)} + role="button" + tabIndex={0} + onKeyDown={(e) => { + if (e.key === "Enter" || e.key === " ") { + handleSuggestionClick(item.searchNm); + } + }} + > + {item.searchPk?.substring(0, 10)}  + {item.searchNm} +
+ )) + ) : (
검색 결과가 없습니다.
@@ -88,5 +104,5 @@ export default function SearchInputText({label=undefined, initValue=undefined, s
)}
- ) -} \ No newline at end of file + ); +}