diff --git a/apps/wr/app/ruseFcltMng/fcltSttn/htdflSttn/page.tsx b/apps/wr/app/ruseFcltMng/fcltSttn/htdflSttn/page.tsx index e8362edbe..8948d81b2 100644 --- a/apps/wr/app/ruseFcltMng/fcltSttn/htdflSttn/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltSttn/htdflSttn/page.tsx @@ -21,12 +21,11 @@ import { type ReturnType, } from "@common/business_components/ui"; import ListDiv from "@common/business_components/ui/list_div"; -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"; import { useCallback, useEffect, useRef, useState } from "react"; import { excelHtdflSttnParsing } from "@/app/store/ruseFcltMng/fcltSttn/htdflSttn/excel"; +import { HeadMakeColSpan } from "@common/business_components/ui/table/HeadMakeColSpan"; export default function HtdflSttn() { const { code, htdflSttn, htdflSttnSearch, initHtdfl } = useWrStore( @@ -120,16 +119,14 @@ export default function HtdflSttn() { selectUnitWaterShedData={code.lgbsnCd} selectMiddleRegionData={code.mdmbsnCd} selectEnvPartData={code.lclgvrnmntCd} - rightChildren={ - - } + rightChildren={} leftChildren={undefined} queryClick={function (returnType: ReturnType): void { // '{partValue: 'A', sidoValue: '0', sigunValue: '0', regionValue: '0', unitWaterShedValue: '0', …}' @@ -140,12 +137,11 @@ export default function HtdflSttn() { con = returnType.sidoValue; } // rainSttnSearch(1, "20", con); - }} + } } excelClick={excelClick} - initClick={function (): void {}} + initClick={function (): void { } } btnClass={btnClass} - ref={ref} - /> + ref={ref} isAdmin={false} />
@@ -155,7 +151,7 @@ export default function HtdflSttn() { headName={[]} tableData={bdstTable || []} children={ - + } headlist={htdflSttn.htdflSttHeadList} pageSize={20} diff --git a/apps/wr/app/ruseFcltMng/fcltSttn/rainSttn/page.tsx b/apps/wr/app/ruseFcltMng/fcltSttn/rainSttn/page.tsx index ebdd64a4e..b9a73aa0f 100644 --- a/apps/wr/app/ruseFcltMng/fcltSttn/rainSttn/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltSttn/rainSttn/page.tsx @@ -19,7 +19,10 @@ import { import ListDiv from "@common/business_components/ui/list_div"; import { Button } from "@common/components/ui"; import { useCallback, useEffect, useRef, useState } from "react"; -import type { chgBuilding, customRainBdst } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; +import type { + chgBuilding, + customRainBdst, +} from "@/app/store/ruseFcltMng/fcltReg/rainReg"; 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"; @@ -34,7 +37,10 @@ export default function RainSttn() { 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[]; @@ -42,22 +48,29 @@ export default function RainSttn() { const codeData = getCityOrSgg(ref); - 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){ + 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 - + bdstTable[index]?.chgBuilding[0]?.bdstChgNm !== null ) { - setBdstChgProps({ isOpen:true , chBuilding: bdstTable[index].chgBuilding}); + setBdstChgProps({ + isOpen: true, + chBuilding: bdstTable[index].chgBuilding, + }); } } - - } - + }; useEffect(() => { if (!rainSttn.isInit) { @@ -73,8 +86,7 @@ export default function RainSttn() { ...item, ...item.reuseBuilding[0], ...item.reuseBuilding[0].rainyObj, - chBuildingYn:item.chgBuilding[0]?.bdstChgNm!==null?'Y':'N' - + chBuildingYn: item.chgBuilding[0]?.bdstChgNm !== null ? "Y" : "N", })) .filter((item: any) => item.rainyObj !== undefined); @@ -99,7 +111,7 @@ export default function RainSttn() { const excelClick = useCallback(() => { if (codeData) rainSttnSearch(1, "10000", codeData); - }, [rainSttnSearch,codeData]); + }, [rainSttnSearch, codeData]); return ( <> @@ -139,6 +151,7 @@ export default function RainSttn() { initClick={function (): void {}} btnClass={btnClass} ref={ref} + isAdmin={false} />
@@ -154,7 +167,9 @@ export default function RainSttn() { headlist={rainSttn.rainSttHeadList} 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} > @@ -177,12 +192,13 @@ export default function RainSttn() { } /> { - setDetailModal({...detailModal, isOpen:!detailModal.isOpen}) - }} - bodyClass={"w-[40vw] max-w-none max-h-[calc(100%-70px)]"} - body={}/> + open={detailModal.isOpen} + onOpenChange={() => { + setDetailModal({ ...detailModal, isOpen: !detailModal.isOpen }); + }} + bodyClass={"w-[40vw] max-w-none max-h-[calc(100%-70px)]"} + body={} + /> comFcltActions = (set: any) => { try { const url = `/prcsFclt/CstRt/${year}`; const rateFeeRes = await getFetch(fetchType.COMMON, url); + set((state: comFcltState) => { - state.rateFeeRes = rateFeeRes; - return state; + return state.rateFeeRes = rateFeeRes;; }); } catch (e) { console.log(" error ", e); @@ -112,8 +112,7 @@ export const searchActions: (set: any) => comFcltActions = (set: any) => { const url = `/prcsFclt/CstRuse/${year}`; const constCost = await getFetch(fetchType.COMMON, url); set((state: comFcltState) => { - state.constCostRes = constCost; - return state; + return state.constCostRes = constCost;; }); }catch (e) { } diff --git a/apps/wr/app/store/common/searchCode/type.tsx b/apps/wr/app/store/common/searchCode/type.tsx index 064d7e821..0026bd785 100644 --- a/apps/wr/app/store/common/searchCode/type.tsx +++ b/apps/wr/app/store/common/searchCode/type.tsx @@ -4,9 +4,29 @@ export type conCostFeeType= { fctCd: string, stdCost: string } + + + export type rateFeeType = { yr: string, incExpCd: string, stdCost: number, rt: number - } \ No newline at end of file + } + + + + export type ContCostMap = { + gubun: string; + "500": number; + "1000": number; + "2000": number; + "3000": number; + "5000": number; + "10000": number; + "20000": number; + "30000": number; + "50000": number; + "100000": number; + [key: string]: any; + }; \ No newline at end of file diff --git a/apps/wr/app/store/matDmd/coMatRvw/headList.tsx b/apps/wr/app/store/matDmd/coMatRvw/headList.tsx index 747c5cbb1..b13796950 100644 --- a/apps/wr/app/store/matDmd/coMatRvw/headList.tsx +++ b/apps/wr/app/store/matDmd/coMatRvw/headList.tsx @@ -1,15 +1,8 @@ -import { z } from "zod"; -import type { CommonTableProps } from "../../common/type/header"; +import type { CommonTableProps, TableUpperProps } from "../../common/type/header"; -export const sttnHeadListType = z.array( - z.object({ - id: z.string(), - title: z.string(), - visible: z.boolean(), - }) -); -export const coRvwHeadListExport: z.infer = [ + +export const coRvwHeadListExport: CommonTableProps[]= [ { id: "cityText", title: "시도", @@ -47,7 +40,6 @@ export const coRvwHeadListExport: z.infer = [ }, ]; - // id는 다확인해야함 export const coRvwNodeListExport: CommonTableProps[] = [ { @@ -81,7 +73,8 @@ export const coRvwNodeListExport: CommonTableProps[] = [ row: 1, rowSpan: 1, colSpan: 1, - },{ + }, + { id: "telNo", title: "전화번호", visible: true, @@ -105,107 +98,67 @@ export const coRvwNodeListExport: CommonTableProps[] = [ rowSpan: 1, colSpan: 1, }, - ]; -export const cmpttnHeadListExport: CommonTableProps[] = [ +export const constCostHeadListExport: CommonTableProps[] = [ { - id: "", + id: "gubun", title: "구분", visible: true, }, - { - id: "BD", - title: "처리시설 용량(m³)", - visible: true, - row: 1, - rowSpan: 1, - colSpan: 1, - }, { id: "500", title: "500", visible: true, - row: 1, - rowSpan: 1, - colSpan: 1, }, { id: "1000", title: "1,000", visible: true, - row: 1, - rowSpan: 1, - colSpan: 1, - },{ + }, + { id: "2000", title: "2,000", visible: true, - row: 1, - rowSpan: 1, - colSpan: 1, }, { id: "3000", //바꾸기 title: "3,000", visible: true, - row: 1, - rowSpan: 1, - colSpan: 1, }, { id: "5000", //바꾸기 title: "5,000", visible: true, - row: 1, - rowSpan: 1, - colSpan: 1, }, { - id: "10000", //바꾸기 + id: "10000", // title: "10,000", visible: true, - row: 1, - rowSpan: 1, - colSpan: 1, }, { - id: "20000", //바꾸기 + id: "20000", // title: "20,000", visible: true, - row: 1, - rowSpan: 1, - colSpan: 1, }, { - id: "30000", //바꾸기 + id: "30000", // title: "30,000", visible: true, - row: 1, - rowSpan: 1, - colSpan: 1, }, { - id: "50000", //바꾸기 + id: "50000", // title: "50,000", visible: true, - row: 1, - rowSpan: 1, - colSpan: 1, }, { id: "100000", //바꾸기 title: "100,000", visible: true, - row: 1, - rowSpan: 1, - colSpan: 1, }, - ]; - -export const coModalHeadListExport: CommonTableProps[] = [ +export const rateFeeHeadListExport: CommonTableProps[] = [ { id: "gubun", title: "공사비/구분", @@ -231,9 +184,9 @@ export const coModalHeadListExport: CommonTableProps[] = [ title: "시설부대비", visible: true, }, -] +]; -export const usageProcData =[ +export const usageProcData = [ { usage: "청소", process: "총인처리시설 + 염소소독" }, { usage: "화장실용수", process: "총인처리시설 + 염소소독" }, { usage: "세척", process: "총인처리시설 + UV소독" }, @@ -243,4 +196,4 @@ export const usageProcData =[ { usage: "하천", process: "총인처리시설 + UV소독" }, { usage: "지하수", process: "전처리시설 + RO" }, { usage: "공업", process: "전처리시설 + RO" }, -] \ No newline at end of file +]; diff --git a/apps/wr/app/store/matDmd/coMatRvw/index.tsx b/apps/wr/app/store/matDmd/coMatRvw/index.tsx index af4d25985..89836957b 100644 --- a/apps/wr/app/store/matDmd/coMatRvw/index.tsx +++ b/apps/wr/app/store/matDmd/coMatRvw/index.tsx @@ -1,6 +1,4 @@ -import type { z } from "zod"; -import type { sttnHeadListType } from "../coSttn/headList"; -import { coRvwHeadListExport, coRvwNodeListExport } from "./headList"; +import { constCostHeadListExport, coRvwHeadListExport, coRvwNodeListExport, rateFeeHeadListExport } from "./headList"; import type { CommonTableProps } from "../../common/type/header"; import type { DedMatUpdateType, DmdCoReqType } from "./type"; import { fetchType, getFetch, putFectch } from "@/components/lib/api"; @@ -8,13 +6,16 @@ import toast from "react-hot-toast/headless"; const coRvwHeadList = coRvwHeadListExport; const coRvwNodeList = coRvwNodeListExport; - +const rateFeeHeadList =rateFeeHeadListExport; +const constCostHeadList=constCostHeadListExport export type coRvwState = { coRvw: { isInit: boolean; coMatRvwRes: DmdCoReqType[]; coRvwHeadList: CommonTableProps[]; coRvwNodeList: CommonTableProps[]; + rateFeeHeadList: CommonTableProps[]; + constCostHeadList: CommonTableProps[]; }; }; @@ -24,6 +25,8 @@ export const coRvwStateExport: coRvwState = { coMatRvwRes: [], coRvwHeadList: coRvwHeadList, coRvwNodeList: coRvwNodeList, + rateFeeHeadList:rateFeeHeadList, + constCostHeadList:constCostHeadList }, }; diff --git a/apps/wr/components/ui/form/coMat/conCostForm/conCostForm.tsx b/apps/wr/components/ui/form/coMat/conCostForm/conCostForm.tsx index e9a36e172..21746c099 100644 --- a/apps/wr/components/ui/form/coMat/conCostForm/conCostForm.tsx +++ b/apps/wr/components/ui/form/coMat/conCostForm/conCostForm.tsx @@ -17,7 +17,7 @@ import { } from "@common/business_components/ui"; import PopoverUi from "@common/business_components/ui/popover_ui"; import { Button, Input, Label } from "@common/components/ui"; -import { useEffect, useState } from "react"; +import { useEffect, useRef, useState } from "react"; import { type UseFormReturn } from "react-hook-form"; export default function ConCostForm({ @@ -27,8 +27,20 @@ export default function ConCostForm({ form: UseFormReturn; type: string; }) { - const { coMatRvwUpdate, ruseRvwCalUpdate } = useWrStore((state) => state); + const { coMatRvwUpdate, ruseRvwCalUpdate,getRateFee ,getConstCostFee} = useWrStore((state) => state); + const ref = useRef(false); + + useEffect(() => { + if (!ref.current) { + const currentYear = new Date().getFullYear(); + getConstCostFee(String(currentYear)); + getRateFee(String(currentYear)); + ref.current = true; + } + }, [ref, getConstCostFee ,getRateFee ]); + + const [isTrfMo, setIsTrfMo] = useState<{ isModal: boolean; }>({ isModal: false }); @@ -58,10 +70,8 @@ export default function ConCostForm({ prcsFcltCpctCstrnCst: form.getValues("demandCst.prcsFcltCpctCstrnCst"), rgtr: TEST_UUID, }; - console.log("mat data ", data); coMatRvwUpdate("11000SW001R1", form.getValues("dmdInfoFk"), data); } else if (type === "hist") { - console.log("hist data ", value); ruseRvwCalUpdate(value); } }; @@ -101,7 +111,7 @@ export default function ConCostForm({ placeholder="" type="text" onChange={(e) => { - field.onChange(Number(e.target.value)); + field.onChange((e.target.value)); }} value={field.value ?? ""} /> @@ -367,17 +377,17 @@ export default function ConCostForm({ {}}>} - bodyClass="w-[40vw] max-w-none h-[30vh]" + body={{}}>} + bodyClass="w-[40vw] h-[40vh] " open={isTrfMo.isModal} onOpenChange={(open) => { setIsTrfMo({ isModal: open }); }} /> {}}>} - bodyClass="w-[70vw] max-w-none h-[30vh]" - open={isCmpttnMo.isModal} + body={{}}>} + bodyClass="w-[40vw] max-w-none h-[40vh]" + open={isCmpttnMo.isModal} onOpenChange={(open) => { setIsCmpttnMo({ isModal: open }); }} diff --git a/apps/wr/components/ui/modal/coMat/constCostFeeTable.tsx b/apps/wr/components/ui/modal/coMat/constCostFeeTable.tsx index bfb416a44..6748ef487 100644 --- a/apps/wr/components/ui/modal/coMat/constCostFeeTable.tsx +++ b/apps/wr/components/ui/modal/coMat/constCostFeeTable.tsx @@ -1,60 +1,106 @@ "use client"; import { useWrStore } from "@/app/store"; -import { cmpttnHeadListExport } from "@/app/store/matDmd/coMatRvw/headList"; +import type { + conCostFeeType, + ContCostMap, +} from "@/app/store/common/searchCode/type"; import { yearOptions } from "@/components/lib/func/commom"; -import { SelectBox, UiTable } from "@common/business_components/ui"; -import { Label } from "@common/components/ui"; -import { useEffect, useState } from "react"; -export function ConstCostFeeTable({ +import { SelectBox, UiTable } from "@common/business_components/ui"; +import ListDiv from "@common/business_components/ui/list_div"; +import { Label, ScrollArea } from "@common/components/ui"; +import { useEffect, useRef, useState } from "react"; + +export function ConstCostFeeTable({ setReturnData, }: { setReturnData: (data: any) => void; }) { - const { constCostRes,getConstCostFee } = useWrStore((state) => state); - + const { coRvw, constCostRes, getConstCostFee } = useWrStore((state) => state); const [year, setYear] = useState(String(new Date().getFullYear())); + const [constCostData, setConstCostData] = useState([]); + + + function getFctDescription(fctCd: string) { + const fctMap: { [key: string]: string } = { + "001": "총인", + "002": "염소.소독", + "003": "uv소독", + "004": "생물학적탈질", + "005": "RO", + }; + + return fctMap[fctCd]; + } useEffect(() => { + const tableData = constCostRes?.reduce( + (acc: ContCostMap[], cur: conCostFeeType) => { + const key = cur.fctCd; + let target = acc?.find((item: any) => item.gubun === key); + if (!target) { + target = { + gubun: cur.fctCd, + "500": 0, + "1000": 0, + "2000": 0, + "3000": 0, + "5000": 0, + "10000": 0, + "20000": 0, + "30000": 0, + "50000": 0, + "100000": 0, + }; + acc?.push(target); + } + target[cur.fctCpc] = cur.stdCost; - getConstCostFee(year) - - }, [year,getConstCostFee]); - - - useEffect(() => { - - const tableData = constCostRes.map((item) => {}) - console.log(' constCostRes : ', constCostRes); - },[constCostRes]) + return acc; + }, + [] + ); + console.log("tableData", tableData); + const formattedTableData = tableData?.map((item: ContCostMap) => { + return { + ...item, + gubun: getFctDescription(item.gubun) || item.gubun, + }; + }); + setConstCostData(formattedTableData); + }, [constCostRes]); return ( <> -

- 공사비 산정표 보기 -

-
-
- - setYear(String(val))} - /> -
- {}} - onPageChange={() => {}} - /> + +

+ 공사비 산정표 보기 +

+
+
+ + setYear(String(val))} + /> +
+ + {}} + onPageChange={() => {}} + /> + +
); } diff --git a/apps/wr/components/ui/modal/coMat/rateFeeModal.tsx b/apps/wr/components/ui/modal/coMat/rateFeeModal.tsx index f52c6394b..c5131097c 100644 --- a/apps/wr/components/ui/modal/coMat/rateFeeModal.tsx +++ b/apps/wr/components/ui/modal/coMat/rateFeeModal.tsx @@ -2,82 +2,120 @@ import { useWrStore } from "@/app/store"; import type { rateFeeType } from "@/app/store/common/searchCode/type"; -import { coModalHeadListExport } from "@/app/store/matDmd/coMatRvw/headList"; import { yearOptions } from "@/components/lib/func/commom"; import { SelectBox, UiTable } from "@common/business_components/ui"; -import { Label } from "@common/components/ui"; +import ListDiv from "@common/business_components/ui/list_div"; +import { Label, ScrollArea } from "@common/components/ui"; +import { Scroll } from "lucide-react"; import { useEffect, useState } from "react"; -export function RateFeeTableModal({ setReturnData}: { setReturnData: (data: any) => void }) { +export function RateFeeTableModal({ + setReturnData, +}: { + setReturnData: (data: any) => void; +}) { + const { code, coRvw,rateFeeRes } = useWrStore((state) => state); const [year, setYear] = useState(String(new Date().getFullYear())); - - const { rateFeeRes,getRateFee } = useWrStore((state) => state); + const [reateFeeTable, setRateFeeTable] = useState([]); - useEffect(() => { + const gubunLabelMap: Record = { + 50: "5천만원까지", + 100: "1억원까지", + 200: "2억원까지", + 300: "3억원까지", + 500: "5억원까지", + 1000: "10억원까지", + 2000: "20억원까지", + 3000: "30억원까지", + 5000: "50억원까지", + 10000: "100억원까지", + 20000: "200억원까지", + 30000: "300억원까지", + 40000: "400억원까지", + 50000: "500억원까지", + 70000: "700억원까지", + 100000: "1000억원까지", + 150000: "1500억원까지", + 200000: "2000억원까지", + 300000: "3000억원까지", + 500000: "5000억원까지", + }; - getRateFee(year) - },[year,getRateFee]) - - - - useEffect(() => { - - let tableData = [] - const data = rateFeeRes.reduce((acc: any,cur:rateFeeType) =>{ + const fetchData = async (rateFeeRes: rateFeeType[]) => { + const data = await rateFeeRes?.reduce((acc: any, cur: rateFeeType) => { const key = cur.stdCost; - - let target = acc.find((item: any) => item.stdCost === key); - - if(!target){ - target={ - gubun: cur.stdCost, + if (!target) { + target = { + stdCost: cur.stdCost, BD: 0, WD: 0, SE: 0, CE: 0, - } + }; acc.push(target); } - target[cur.incExpCd] = cur.rt; + return acc; + }, []); - return acc - },[]) + const dataGubun = data?.map((item: any) => { + return { + ...item, + gubun: gubunLabelMap[item.stdCost] || item.stdCost, + }; + }); - console.log('data : ', data); + return dataGubun?.sort((a: any, b: any) => a.stdCost - b.stdCost); + }; - },[rateFeeRes]) - - + useEffect(() => { + console.log("rateFeeRes ", rateFeeRes); + if (rateFeeRes?.length >= 0) { + fetchData(rateFeeRes).then((data) => { + setRateFeeTable(data); + }); + } + }, [rateFeeRes]); return ( <> -
-

요율표 보기

-
-
- - setYear(String(val))} - /> + +
+

+ 요율표 보기 +

+
+ +
+ + setYear(String(val))} + /> +
+
+ + {}} + pageSize={0} + total={0} + cellClick={undefined} + /> + +
- {}} - pageSize={0} - total={0} - cellClick={undefined} - /> -
+ ); }