From e0c235e26bb2a8b8d237f56dce5848b746ccfcaf Mon Sep 17 00:00:00 2001 From: leedj312 Date: Sat, 7 Jun 2025 08:05:04 +0900 Subject: [PATCH] =?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() { -