diff --git a/apps/wr/app/matMng/coMat/coMatRvw/page.tsx b/apps/wr/app/matMng/coMat/coMatRvw/page.tsx index 49f23127f..446323b83 100644 --- a/apps/wr/app/matMng/coMat/coMatRvw/page.tsx +++ b/apps/wr/app/matMng/coMat/coMatRvw/page.tsx @@ -14,8 +14,8 @@ import { tableData, yearOptions, } from "@/components/lib/func/commom"; -import { CmpttnModal } from "@/components/ui/modal/coMat/cmpttnModal"; -import { CoMatModal } from "@/components/ui/modal/coMat/coMatModal"; +import { CmpttnModal } from "@/components/ui/modal/coMat/constCostFeeTable"; +import { CoMatModal } from "@/components/ui/modal/coMat/rateFeeModal"; import type { objSearchType } from "@/components/ui/modal/fcltReg/bdstRegModal/bdstRegModal"; import { ContentsDiv, @@ -45,9 +45,8 @@ import { zodResolver } from "@hookform/resolvers/zod"; import ConCostForm from "@/components/ui/form/coMat/conCostForm/conCostForm"; export default function CoMatRvw() { - const { code, coRvw, coMatRvwInit ,coMatRvwSearch ,coMatRvwInqua} = useWrStore( - (state) => state - ); + const { code, coRvw, coMatRvwInit, coMatRvwSearch, coMatRvwInqua } = + useWrStore((state) => state); const { coMatRvwRes } = coRvw; //init, sub, match const initRef = useRef(false); @@ -78,9 +77,7 @@ export default function CoMatRvw() { sggCd: string, dmdCoNm: string ) => { - - if (dmdCoNm.length>0 ) { - + if (dmdCoNm.length > 0) { coMatRvwSearch( pageNation, 13, @@ -101,7 +98,6 @@ export default function CoMatRvw() { const TableCellClick = (index: number) => { console.log(coMatRvwRes); if (coMatRvwRes && coMatRvwRes[index]) { - console.log(dmdMatData[index]); setSelectData(coMatRvwRes[index]); } @@ -118,21 +114,19 @@ export default function CoMatRvw() { }, [form.watch("useUsgCd")]); useEffect(() => { - - console.log(' coMatRvwRes ', coMatRvwRes) if (coMatRvwRes) { const data = coMatRvwRes?.map((item, index) => { - console.log(" item ", item); + let flag = ""; + flag = getdmdMatFlag(item?.demandMatching?.splyFcltFlg ??""); return { ...item, - ctpvCd: item.demandCo.ctpvCd, - sggCd: item.demandCo.sggCd, - dmdCoNm: item.demandCo.dmdCoNm, - daddr: item.demandCo.daddr, - telno: item.demandCo.telno, - splyFcltFlg: getdmdMatFlag(item.demandMatching?.splyFcltFlg), + ctpvCd: item.demandCo?.ctpvCd, + sggCd: item.demandCo?.sggCd, + dmdCoNm: item.demandCo?.dmdCoNm, + daddr: item.demandCo?.daddr, + telno: item.demandCo?.telno, regDt: moment(item?.demandCo?.regDt).format("YYYY-MM-DD"), - state: "", + splyFcltFlg: flag, }; }); setDmdMtaData(tableData(data, { code })); @@ -242,16 +236,10 @@ export default function CoMatRvw() { if (String(objSearch.city).length > 0) { con = String(objSearch.city); } - if (String(objSearch.sgg).length > 0) { + if (String(objSearch.sgg).length > 0 && String(objSearch.sgg) !== "0") { con = String(objSearch.sgg); } - getSearch( - fromNum, - toNum, - con, - dmdCoNm - ); - + getSearch(fromNum, toNum, con, dmdCoNm); } } }} @@ -674,7 +662,7 @@ export default function CoMatRvw() { - + diff --git a/apps/wr/app/matMng/coMat/ruseRvwHstry/page.tsx b/apps/wr/app/matMng/coMat/ruseRvwHstry/page.tsx index 934831be8..7a5a59a93 100644 --- a/apps/wr/app/matMng/coMat/ruseRvwHstry/page.tsx +++ b/apps/wr/app/matMng/coMat/ruseRvwHstry/page.tsx @@ -4,6 +4,7 @@ import { useWrStore } from "@/app/store"; import { DmdCoReqSchema, type DmdCoReqType, + type RvwHistTableType, } from "@/app/store/matDmd/coMatRvw/type"; import { getCity, @@ -32,11 +33,17 @@ import { set, useFieldArray, useForm } from "react-hook-form"; import { z } from "zod"; import { tableData } from "@/components/lib/func/commom"; import toast, { Toaster } from "react-hot-toast"; +import { ToastFormUi } from "@/components/ui/toast/toastFromUi"; export default function RuseRvwHstry() { - const { code, ruseHist, ruseRvwHistInit, ruseRvwSearch, ruseRvwInqua } = - useWrStore((state) => state); + const { + code, + ruseHist, + ruseRvwHistInit, + ruseRvwSearch, + ruseRvwInqua, + ruseRvwComplete, + } = useWrStore((state) => state); const { rvwHistRes, ruseHistHeadList } = ruseHist; - const schema = z.object({}); const [pageNation, setPageNatiion] = useState(1); const [dmdCoNm, setDmdCoNm] = useState(""); @@ -53,7 +60,7 @@ export default function RuseRvwHstry() { const [toDate, setToDate] = useState( String(new Date().getFullYear()) ); - const [rvwHistData, setRvwHistData] = useState(); + const [rvwHistData, setRvwHistData] = useState(); const getSelCity = (val: string | number) => { const cityValue = String(val); // Ensure val is treated as a string @@ -85,12 +92,16 @@ export default function RuseRvwHstry() { ruseUtztnFcltNm ); } else { + + + console.log("시도코드", sggCd); ruseRvwInqua(pageNation, 13, String(startYear), String(endYear), sggCd); } }; const form = useForm({ resolver: zodResolver(DmdCoReqSchema), + mode: "onChange", }); const TableCellClick = useCallback( @@ -106,7 +117,37 @@ export default function RuseRvwHstry() { }, [rvwHistRes, form] ); - + const confrirmToast = () => { + const completeData = rvwHistData + ?.map((item) => { + form.clearErrors; + if (item?.completeYn) { + return item.dmdInfoSn; + } + }) + .filter((item) => item !== undefined); + if (form.formState.isDirty) { + toast((t) => ( + + 표준공사비 정보가 변경되었습니다. 검토 완료 진행시 입력한 정보는 + 초기화 됩니다. +
+ 진행하시겠습니까? + + +
+ )); + } else { + ruseRvwComplete(completeData as string[]); + } + }; useEffect(() => { if (!ruseHist.isInit) { ruseRvwHistInit( @@ -121,13 +162,17 @@ export default function RuseRvwHstry() { useEffect(() => { if (rvwHistRes) { const data = rvwHistRes?.map((item, index) => { + let flag = ""; + flag = getdmdMatFlag(item.demandMatching?.splyFcltFlg ?? ""); + + console.log("flag", flag); return { ...item, - ctpvCd: item.demandCo.ctpvCd, - sggCd: item.demandCo.sggCd, - dmdCoNm: item.demandCo.dmdCoNm, - daddr: item.demandCo.daddr, - telno: item.demandCo.telno, + ctpvCd: item.demandCo?.ctpvCd, + sggCd: item.demandCo?.sggCd, + dmdCoNm: item.demandCo?.dmdCoNm, + daddr: item.demandCo?.daddr, + telno: item.demandCo?.telno, regDt: item?.demandCo?.regDt ? moment(item?.demandCo?.regDt).format("YYYY-MM-DD") : "없음", @@ -137,17 +182,21 @@ export default function RuseRvwHstry() { mtchnCmptnYmd: item?.mtchnCmptnYmd ? moment(item?.mtchnCmptnYmd).format("YYYY-MM-DD") : "없음", - splyFcltFk: item.demandMatching?.splyFcltFk, + ruseUtztnFcltNm: item.ruseUtztnFcltNm, dmndQty: item.dmndQty, - splyFcltFlg: getdmdMatFlag(item.demandMatching?.splyFcltFlg), - matYn: false, - }; + splyFcltFlg: flag, + completeYn: false, + } as unknown as RvwHistTableType; }); + setRvwHistData(tableData(data, { code })); } }, [rvwHistRes]); + useEffect(() => {}, [form.formState]); + useEffect(() => { + console.log("변경여부 ", form.formState.isDirty); }, [form.formState]); return ( @@ -238,7 +287,7 @@ export default function RuseRvwHstry() { if (String(objSearch.city).length > 0) { con = String(objSearch.city); } - if (String(objSearch.sgg).length > 0) { + if (String(objSearch.sgg).length > 0 && objSearch.sgg !== "0") { con = String(objSearch.sgg); } getSearch( @@ -254,7 +303,7 @@ export default function RuseRvwHstry() { > 조회 - diff --git a/apps/wr/app/ruseFcltMng/fcltSttn/htdflSttn/page.tsx b/apps/wr/app/ruseFcltMng/fcltSttn/htdflSttn/page.tsx index 00af0e72d..a738b73cc 100644 --- a/apps/wr/app/ruseFcltMng/fcltSttn/htdflSttn/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltSttn/htdflSttn/page.tsx @@ -6,7 +6,6 @@ import type { chgBuilding, customRainBdst, } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; -import { excelHtdflSttnParsing } from "@/app/store/ruseFcltMng/fcltSttn/htdflSttn/excel"; import { excelDownload, getCityOrSgg, @@ -23,9 +22,10 @@ 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 { 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( @@ -119,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', …}' @@ -138,13 +136,12 @@ export default function HtdflSttn() { } else { con = returnType.sidoValue; } - htdflSttnSearch(pageNation, "20", con); - }} + htdflSttnSearch(pageNation, "20", con); + } } excelClick={excelClick} - initClick={function (): void {}} + initClick={function (): void { } } btnClass={btnClass} - ref={ref} - /> + ref={ref} isAdmin={false} />
diff --git a/apps/wr/app/ruseFcltMng/fcltSttn/pbnstSttn/page.tsx b/apps/wr/app/ruseFcltMng/fcltSttn/pbnstSttn/page.tsx index 3f6ad7566..862e260fd 100644 --- a/apps/wr/app/ruseFcltMng/fcltSttn/pbnstSttn/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltSttn/pbnstSttn/page.tsx @@ -40,11 +40,9 @@ export default function PbnstSttn() { } = useWrStore((state) => state); const ref = useRef({} as ReturnType); - const codeData = getCityOrSgg(ref); const [searchYear, setSearchYear] = useState( String(new Date().getFullYear()) ); - const [pageNation, setPageNation] = useState(1); const [isChHead, setIsChHead] = useState(false); const [bdstTable, setBdstTable] = useState(); @@ -53,10 +51,8 @@ export default function PbnstSttn() { data: customPbnst; }>({ isModal: false, data: {} as customPbnst }); - const [clickPk , setClickPk] = useState("") const [pbnRuseNm, setPbnRuseNm] = useState(""); - const excelClick = useCallback(() => { pbnstSttnSearch("1", "10000", ref.current, "", searchYear); }, [pbnstSttnSearch, searchYear, ref.current]); @@ -69,7 +65,6 @@ export default function PbnstSttn() { pbnstSttn.pbnstSttnRes[index] ) { const pbnstRuseFcltPk = pbnstSttn.pbnstSttnRes[index].pbnstRuseFcltPk; - // setClickPk(pbnstRuseFcltPk) getPbnStnDetail(pbnstRuseFcltPk); } }, diff --git a/apps/wr/app/ruseFcltMng/fcltSttn/rainSttn/page.tsx b/apps/wr/app/ruseFcltMng/fcltSttn/rainSttn/page.tsx index 52edb193e..88b3c8649 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[]; @@ -43,20 +49,28 @@ 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) { + 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 }); + setBdstChgProps({ + isOpen: true, + chBuilding: bdstTable[index].chgBuilding, + }); } } - - } + }; useEffect(() => { if (!rainSttn.isInit) { @@ -72,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); @@ -139,6 +152,7 @@ export default function RainSttn() { initClick={function (): void { }} btnClass={btnClass} ref={ref} + isAdmin={false} />
@@ -154,7 +168,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} > @@ -179,10 +195,11 @@ export default function RainSttn() { { - setDetailModal({ ...detailModal, isOpen: !detailModal.isOpen }) + setDetailModal({ ...detailModal, isOpen: !detailModal.isOpen }); }} bodyClass={"w-[40vw] max-w-none max-h-[calc(100%-70px)]"} - body={} /> + body={} + /> void; getDemandCompList: (searchNm: string, cnt: number) => void; regDemandCompany: (data: DemandCompType) => void; updateDemandCompany: (data: DemandCompType) => void; + getConstCostFee: (year: string) => void; + getRateFee: (year: string) => void; }; export const searchActions: (set: any) => comFcltActions = (set: any) => { @@ -47,7 +53,7 @@ export const searchActions: (set: any) => comFcltActions = (set: any) => { console.log(coList); set((state: comFcltState) => { - return state.demandCompList = [...coList]; + return (state.demandCompList = [...coList]); }); }, regDemandCompany: async (data: DemandCompType) => { @@ -64,9 +70,8 @@ export const searchActions: (set: any) => comFcltActions = (set: any) => { message = "fail"; } set((state: comFcltState) => { - state.dmdIsSucees = message; + state.dmdIsSucees = message; return state; - }); } catch (err) { console.log(err); @@ -84,15 +89,34 @@ export const searchActions: (set: any) => comFcltActions = (set: any) => { } set((state: comFcltState) => { - state.dmdIsSucees = message; + state.dmdIsSucees = message; return state; - }); - - } catch (err) { console.log(err); } + }, + getRateFee: async (year: string) => { + try { + const url = `/prcsFclt/CstRt/${year}`; + const rateFeeRes = await getFetch(fetchType.COMMON, url); + + set((state: comFcltState) => { + return state.rateFeeRes = rateFeeRes;; + }); + } catch (e) { + console.log(" error ", e); + } + },getConstCostFee: async (year: string) => { + try { + const url = `/prcsFclt/CstRuse/${year}`; + const constCost = await getFetch(fetchType.COMMON, url); + set((state: comFcltState) => { + 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 e69de29bb..0026bd785 100644 --- a/apps/wr/app/store/common/searchCode/type.tsx +++ b/apps/wr/app/store/common/searchCode/type.tsx @@ -0,0 +1,32 @@ +export type conCostFeeType= { + yr: string, + fctCpc: string, + fctCd: string, + stdCost: string + } + + + + export type rateFeeType = { + yr: string, + incExpCd: string, + stdCost: number, + rt: number + } + + + + 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 1848a36c5..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,153 +98,95 @@ export const coRvwNodeListExport: CommonTableProps[] = [ rowSpan: 1, colSpan: 1, }, - ]; -export const cmpttnHeadListExport: CommonTableProps[] = [ +export const constCostHeadListExport: CommonTableProps[] = [ { - id: "ctpv", + id: "gubun", title: "구분", visible: true, - row: 1, - rowSpan: 1, - colSpan: 1, - }, - { - id: "sgg", - 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: "공사비/구분", visible: true, - row: 1, - rowSpan: 1, - colSpan: 1, }, { - id: "a", + id: "BD", title: "기본조사설계비", visible: true, - row: 1, - rowSpan: 1, - colSpan: 1, }, { - id: "aa", + id: "WD", title: "실시설계비", visible: true, - row: 1, - rowSpan: 1, - colSpan: 1, }, { - id: "aaa", + id: "SE", title: "공사감리비", visible: true, - row: 1, - rowSpan: 1, - colSpan: 1, }, { - id: "aaaa", + id: "CE", title: "시설부대비", visible: true, - row: 1, - rowSpan: 1, - colSpan: 1, }, -] +]; -export const usageProcData =[ +export const usageProcData = [ { usage: "청소", process: "총인처리시설 + 염소소독" }, { usage: "화장실용수", process: "총인처리시설 + 염소소독" }, { usage: "세척", process: "총인처리시설 + UV소독" }, @@ -261,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 6ad500d99..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 }, }; @@ -64,7 +67,7 @@ const coMatInit = async ( startYear: string, endYear: string, ) => { - const url = `/reuseFc/request/infoList/${pageNo}/${pageCnt}/${startYear}/${endYear}`; + const url = `/reuseFc/request/infoList/sub/${pageNo}/${pageCnt}/${startYear}/${endYear}`; const coMatRvwRes = await getFetch(fetchType.WR, url); return coMatRvwRes; @@ -78,8 +81,7 @@ export const coRvwActionsExport: (set: any) => coRvwActions = (set: any) => { startYear: string, endYear: string, ) => { - const url = `/reuseFc/request/infoList/${pageNo}/${pageCnt}/${startYear}/${endYear}`; - const coMatRvwRes = await getFetch(fetchType.WR, url); + const coMatRvwRes = await coMatInit(pageNo, pageCnt, startYear, endYear); return set((state: coRvwState) => ({ ...state, @@ -127,7 +129,7 @@ export const coRvwActionsExport: (set: any) => coRvwActions = (set: any) => { sggCd: string, dmdCoNm: string, ) => { - let url = `/reuseFc/request/infoList/${pageNo}/${pageCnt}/${startYear}/${endYear}`; + let url = `/reuseFc/request/infoList/sub/${pageNo}/${pageCnt}/${startYear}/${endYear}`; if (sggCd.length > 0) { url += `/${sggCd}`; @@ -159,9 +161,9 @@ export const coRvwActionsExport: (set: any) => coRvwActions = (set: any) => { sggCd: string ) => { try { - let url = `/reuseFc/request/infoList/${pageNo}/${pageCnt}/${startYear}/${endYear}`; + let url = `/reuseFc/request/infoList/sub/${pageNo}/${pageCnt}/${startYear}/${endYear}`; if (sggCd.length > 0) { - url += `/${sggCd}`; + url += `/${sggCd}/0`; }else if(sggCd ==='0'){ url += `/0/0`; } @@ -176,6 +178,6 @@ export const coRvwActionsExport: (set: any) => coRvwActions = (set: any) => { } catch (e) { console.log(" error ", e); } - }, + } }; }; diff --git a/apps/wr/app/store/matDmd/coMatRvw/type.tsx b/apps/wr/app/store/matDmd/coMatRvw/type.tsx index de1b123c7..b4990c7eb 100644 --- a/apps/wr/app/store/matDmd/coMatRvw/type.tsx +++ b/apps/wr/app/store/matDmd/coMatRvw/type.tsx @@ -91,7 +91,8 @@ import { z } from "zod"; rvwCmptnYmd: z.string().nullish(), demandCo: DemandCoSchema.nullish(), demandMatching: DemandMatchingSchema.nullish(), - demandCst: DemandCstSchema + demandCst: DemandCstSchema, + ruseUtztnFcltNm:z.string().nullish(), }); @@ -103,7 +104,7 @@ export type DmdMatTableType = { daddr:string, telno:string, regDt:string, - state:string + splyFcltFlg:string } @@ -115,4 +116,56 @@ export type DedMatUpdateType = fcltSbsdEpsTrf: number; prcsFcltCpctCstrnCst: number; rgtr: string; +} + + +export type RvwHistTableType = { + cityText:string, + sggText:string, + dmdCoNm:string, + daddr:string, + telno:string, + regDt:string, + rvwCmptnYmd:string, + mtchnCmptnYmd:string, + ruseUtztnFcltNm:string, + dmndQty:string, + useUsgCd:string, + splyFcltFlg:string + completeYn:boolean + dmdInfoSn :string + +} + +export type RvwHistTableType = { + cityText:string, + sggText:string, + dmdCoNm:string, + daddr:string, + telno:string, + regDt:string, + rvwCmptnYmd:string, + mtchnCmptnYmd:string, + ruseUtztnFcltNm:string, + dmndQty:string, + useUsgCd:string, + splyFcltFlg:string + completeYn:boolean + dmdInfoSn :string + +} + + + +export type conCostFeeType= { + yr: string, + fctCpc: string, + fctCd: string, + stdCost: string +} +export type rateFeeType = { + yr: string, + incExpCd: string, + stdCost: number, + rt: number } \ No newline at end of file diff --git a/apps/wr/app/store/matDmd/ruseRvwHstry/headList.tsx b/apps/wr/app/store/matDmd/ruseRvwHstry/headList.tsx index 5702406e1..90c793c2f 100644 --- a/apps/wr/app/store/matDmd/ruseRvwHstry/headList.tsx +++ b/apps/wr/app/store/matDmd/ruseRvwHstry/headList.tsx @@ -43,7 +43,7 @@ export const ruseHstryHeadListExport:TableUpperProps[]= [ visible: true, }, { - id: "splyFcltFk", //바꾸기 + id: "ruseUtztnFcltNm", //바꾸기 title: "공급처", visible: true, }, @@ -63,10 +63,9 @@ export const ruseHstryHeadListExport:TableUpperProps[]= [ visible: true, }, { - id: "matYn", //바꾸기 + id: "completeYn", //바꾸기 title: "매칭완료 여부", visible: true, - type:'check' }, ]; diff --git a/apps/wr/app/store/matDmd/ruseRvwHstry/index.tsx b/apps/wr/app/store/matDmd/ruseRvwHstry/index.tsx index b14e7b3a0..698a49abb 100644 --- a/apps/wr/app/store/matDmd/ruseRvwHstry/index.tsx +++ b/apps/wr/app/store/matDmd/ruseRvwHstry/index.tsx @@ -5,7 +5,7 @@ import type { TableUpperProps, } from "../../common/type/header"; import { ruseHstryHeadListExport } from "./headList"; -import { fetchType, getFetch, putFectch } from "@/components/lib/api"; +import { fetchType, getFetch, postFectch, putFectch } from "@/components/lib/api"; import type { DmdCoReqType } from "../coMatRvw/type"; import toast from "react-hot-toast"; @@ -46,7 +46,6 @@ type ruseHstryActions = { sggCd: string, dmdCoNm: string, ruseUtztnFcltNm: string - ) => void; ruseRvwInqua: ( pageNo: number, @@ -55,6 +54,7 @@ type ruseHstryActions = { endYear: string, sggCd: string ) => void; + ruseRvwComplete:( data: string[]) => void; }; const irvwHistInit = async ( @@ -64,7 +64,7 @@ const irvwHistInit = async ( endYear: string, sggCd?: string ) => { - let url = `/reuseFc/request/infoList/${pageNo}/${pageCnt}/${startYear}/${endYear}`; + let url = `/reuseFc/request/infoList/matched/${pageNo}/${pageCnt}/${startYear}/${endYear}`; console.log("sggCd ", sggCd); if (sggCd) { @@ -87,11 +87,6 @@ export const ruseHstryActionsExport: (set: any) => ruseHstryActions = ( endYear: string, sggCd?: string ) => { - let url = `/reuseFc/request/infoList/${pageNo}/${pageCnt}/${startYear}/${endYear}`; - - if (sggCd) { - url += `/${sggCd}`; - } const rvwHistRes = await irvwHistInit( pageNo, pageCnt, @@ -122,7 +117,7 @@ export const ruseHstryActionsExport: (set: any) => ruseHstryActions = ( 10, new Date().getFullYear().toString(), new Date().getFullYear().toString(), - "11" + "0" ); return set((state: ruseHstryState) => ({ ...state, @@ -146,9 +141,8 @@ export const ruseHstryActionsExport: (set: any) => ruseHstryActions = ( sggCd: string, dmdCoNm: string, ruseUtztnFcltNm: string - ) => { - let url = `/reuseFc/request/infoList/${pageNo}/${pageCnt}/${startYear}/${endYear}`; + let url = `/reuseFc/request/infoList/matched/${pageNo}/${pageCnt}/${startYear}/${endYear}`; if (sggCd.length > 0) { url += `/${sggCd}`; @@ -183,11 +177,10 @@ export const ruseHstryActionsExport: (set: any) => ruseHstryActions = ( sggCd: string ) => { try { - let url = `/reuseFc/request/infoList/${pageNo}/${pageCnt}/${startYear}/${endYear}`; + let url = `/reuseFc/request/infoList/matched/${pageNo}/${pageCnt}/${startYear}/${endYear}`; if (sggCd.length > 0) { - url += `/${sggCd}`; + url += `/${sggCd}/0`; } - const rvwHistRes = await getFetch(fetchType.WR, url); return set((state: ruseHstryState) => ({ ...state, @@ -200,5 +193,30 @@ export const ruseHstryActionsExport: (set: any) => ruseHstryActions = ( console.log(" error ", e); } }, + ruseRvwComplete: async (data: string[]) => { + try { + const complet = await postFectch( + `/reuseFc/request/completeCheck`, + JSON.stringify(data), + fetchType.WR + ); + if (complet.status === 200) { + toast.success("완료 처리가 완료되었습니다."); + const rvwHistRes = await irvwHistInit( + 1, + 10, + new Date().getFullYear().toString(), + new Date().getFullYear().toString(), + "0" + ); + } + } catch (e) { + console.log(" error ", e); + toast.error("완료 처리 중 오류가 발생했습니다."); + } + }, }; }; + + + diff --git a/apps/wr/components/lib/func/commom.tsx b/apps/wr/components/lib/func/commom.tsx index 72f2943ce..ba0f5c588 100644 --- a/apps/wr/components/lib/func/commom.tsx +++ b/apps/wr/components/lib/func/commom.tsx @@ -138,21 +138,18 @@ export const yearOptions: { val: string; text: string }[] = Array.from( }) ); -export const getdmdMatFlag = (flag: string) => { +export const getdmdMatFlag = (flag: string|undefined) => { let flagMat = ""; - switch (flag) { - case "Init": - flagMat = "신청"; - break; - case "Sub": - flagMat = "검토"; - break; - case "Matched": - flagMat = "완료"; - break; - default : - flagMat = ""; - break; + + if(flag === undefined || flag === null) { + flagMat = "신청"; + }else if(flag.trim() === "Sub") { + flagMat = "검토"; + + }else if(flag.trim() === "matched") { + flagMat = "매칭완료"; + }else { + flagMat = "신청"; } return flagMat; }; diff --git a/apps/wr/components/ui/form/coMat/conCostForm/conCostForm.tsx b/apps/wr/components/ui/form/coMat/conCostForm/conCostForm.tsx index 1d5fa789c..21746c099 100644 --- a/apps/wr/components/ui/form/coMat/conCostForm/conCostForm.tsx +++ b/apps/wr/components/ui/form/coMat/conCostForm/conCostForm.tsx @@ -6,8 +6,8 @@ import type { } from "@/app/store/matDmd/coMatRvw/type"; import { TEST_UUID } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; import { formH1Class } from "@/components/lib/class/comClass"; -import { CmpttnModal } from "@/components/ui/modal/coMat/cmpttnModal"; -import { CoMatModal } from "@/components/ui/modal/coMat/coMatModal"; +import { ConstCostFeeTable } from "@/components/ui/modal/coMat/constCostFeeTable"; +import { RateFeeTableModal } from "@/components/ui/modal/coMat/rateFeeModal"; import { Form, FormField, @@ -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 }); @@ -36,10 +48,19 @@ export default function ConCostForm({ isModal: boolean; }>({ isModal: false }); - + const zipDowonLoad = () => { + fetch(`/2024_constarctFeeProgram.zip`, {}).then(async (response) => { + const blobRet = await response.blob(); + // const blob = new Blob([blobRet], { type: "application/octet-stream" }); + const link = document.createElement("a"); + link.href = URL.createObjectURL(blobRet); + link.download = + "24년_수도시설 운영비 및 개략공사비 산정프로그램.zip"; + link.click(); + }); + }; const onSubmit = (value: DmdCoReqType) => { - if (type === "mat") { const data: DedMatUpdateType = { dmdInfoSn: form.getValues("dmdInfoSn"), @@ -49,11 +70,9 @@ 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) + ruseRvwCalUpdate(value); } }; @@ -92,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 ?? ""} /> @@ -177,7 +196,7 @@ export default function ConCostForm({ onChange={(e) => { field.onChange(Number(e.target.value)); }} - value={(Number(field.value) * 365)|| 0} + value={Number(field.value) * 365 || 0} /> )} @@ -295,7 +314,7 @@ export default function ConCostForm({ placeholder="" type="text" onChange={(e) => { - field.onChange(Number(e.target.value)); + field.onChange(e.target.value); }} value={field.value ?? ""} /> @@ -303,9 +322,7 @@ export default function ConCostForm({ )} /> -
-
-
- - -
-
+
+ + +
} - bodyClass="w-[40vw] max-w-none h-[70vh]" + body={{}}>} + bodyClass="w-[40vw] h-[40vh] " open={isTrfMo.isModal} onOpenChange={(open) => { setIsTrfMo({ isModal: open }); }} /> } - bodyClass="w-[70vw] max-w-none h-[50vh]" - 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/cmpttnModal.tsx b/apps/wr/components/ui/modal/coMat/cmpttnModal.tsx deleted file mode 100644 index ab18e3542..000000000 --- a/apps/wr/components/ui/modal/coMat/cmpttnModal.tsx +++ /dev/null @@ -1,36 +0,0 @@ -"use client" - -import { cmpttnHeadListExport } 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 { useState } from "react"; - -export function CmpttnModal({ data }: { data: [] }) { - const [year, setYear] = useState(String(new Date().getFullYear())); - return ( - <> -

공사비 산정표 보기

-
-
- - setYear(String(val))} /> -
- { }} - onPageChange={() => { }} - /> - - ) -} \ No newline at end of file diff --git a/apps/wr/components/ui/modal/coMat/coMatModal.tsx b/apps/wr/components/ui/modal/coMat/coMatModal.tsx deleted file mode 100644 index 4717a89a3..000000000 --- a/apps/wr/components/ui/modal/coMat/coMatModal.tsx +++ /dev/null @@ -1,32 +0,0 @@ -"use client" - -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 { useState } from "react"; - -export function CoMatModal({ data }: { data: [] }) { - const [year, setYear] = useState(String(new Date().getFullYear())); - return ( - <> -

요율표 보기

-
-
- - setYear(String(val))} /> -
- { }} pageSize={0} total={0} cellClick={undefined} /> - - ) -} \ No newline at end of file diff --git a/apps/wr/components/ui/modal/coMat/constCostFeeTable.tsx b/apps/wr/components/ui/modal/coMat/constCostFeeTable.tsx new file mode 100644 index 000000000..6748ef487 --- /dev/null +++ b/apps/wr/components/ui/modal/coMat/constCostFeeTable.tsx @@ -0,0 +1,106 @@ +"use client"; + +import { useWrStore } from "@/app/store"; +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 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 { 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; + + 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={() => {}} + /> + +
+ + ); +} diff --git a/apps/wr/components/ui/modal/coMat/rateFeeModal.tsx b/apps/wr/components/ui/modal/coMat/rateFeeModal.tsx new file mode 100644 index 000000000..c5131097c --- /dev/null +++ b/apps/wr/components/ui/modal/coMat/rateFeeModal.tsx @@ -0,0 +1,121 @@ +"use client"; + +import { useWrStore } from "@/app/store"; +import type { rateFeeType } from "@/app/store/common/searchCode/type"; +import { yearOptions } from "@/components/lib/func/commom"; +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 { Scroll } from "lucide-react"; +import { useEffect, useState } from "react"; + +export function RateFeeTableModal({ + setReturnData, +}: { + setReturnData: (data: any) => void; +}) { + const { code, coRvw,rateFeeRes } = useWrStore((state) => state); + const [year, setYear] = useState(String(new Date().getFullYear())); + const [reateFeeTable, setRateFeeTable] = useState([]); + + 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억원까지", + }; + + + 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 = { + stdCost: cur.stdCost, + BD: 0, + WD: 0, + SE: 0, + CE: 0, + }; + acc.push(target); + } + target[cur.incExpCd] = cur.rt; + return acc; + }, []); + + const dataGubun = data?.map((item: any) => { + return { + ...item, + gubun: gubunLabelMap[item.stdCost] || item.stdCost, + }; + }); + + return dataGubun?.sort((a: any, b: any) => a.stdCost - b.stdCost); + }; + + useEffect(() => { + console.log("rateFeeRes ", rateFeeRes); + if (rateFeeRes?.length >= 0) { + fetchData(rateFeeRes).then((data) => { + setRateFeeTable(data); + }); + } + }, [rateFeeRes]); + + return ( + <> + +
+

+ 요율표 보기 +

+
+ +
+ + setYear(String(val))} + /> +
+
+ + {}} + pageSize={0} + total={0} + cellClick={undefined} + /> + +
+
+
+ + ); +} diff --git a/apps/wr/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal.tsx b/apps/wr/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal.tsx index a899f8128..d7ecee90a 100644 --- a/apps/wr/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal.tsx +++ b/apps/wr/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal.tsx @@ -129,9 +129,7 @@ export function PbnstRegModal({ formType={"reg"} firstFcltData={pbnstBdstForm} indexMng={indexMng} - setIndexMng={function (index: number): void { - throw new Error("Function not implemented."); - }} + setIndexMng={setIndexMng} /> diff --git a/apps/wr/components/ui/modal/sttn/pbnstSttnModal/pbnstSttnModal.tsx b/apps/wr/components/ui/modal/sttn/pbnstSttnModal/pbnstSttnModal.tsx index 1704a481d..438ab439c 100644 --- a/apps/wr/components/ui/modal/sttn/pbnstSttnModal/pbnstSttnModal.tsx +++ b/apps/wr/components/ui/modal/sttn/pbnstSttnModal/pbnstSttnModal.tsx @@ -1,9 +1,17 @@ import { useWrStore } from "@/app/store"; import type { TableUpperProps } from "@/app/store/common/type/header"; -import { initValInUsage, initValOutUsage, subTotalObj, totalObj, type PrfType } from "@/app/store/prfmncReg/pbnstPrfmncReg/type"; -import type { - customPbnst, - fcBizType, +import { + initValInUsage, + initValOutUsage, + subTotalObj, + totalObj, + type PrfType, +} from "@/app/store/prfmncReg/pbnstPrfmncReg/type"; +import { + pbnstRegArrayZod, + pbnstRegZod, + type customPbnst, + type fcBizType, } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; import { PbnstMngForm } from "@/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm"; import { ScrollArea, Title, UiTable } from "@common/business_components/ui"; @@ -15,11 +23,13 @@ import { Button, TabsContent, } from "@common/components/ui"; +import { zodResolver } from "@hookform/resolvers/zod"; import { useEffect, useState } from "react"; -import { set } from "react-hook-form"; +import { set, useForm } from "react-hook-form"; +import { z } from "zod"; export function PbnstSttnModal({ data }: { data: customPbnst }) { - const { code, pbnstSttn,prfmnc } = useWrStore((state) => state); + const { code, pbnstSttn, prfmnc } = useWrStore((state) => state); const [fcltTab, setFcltTab] = useState("fclt"); const [ruseTab, setRuseTab] = useState("inoutTotal"); const [ruseBizData, setRuseBizData] = useState<{ @@ -28,9 +38,22 @@ export function PbnstSttnModal({ data }: { data: customPbnst }) { }>(); const [ruseHeadList, setRuseHeadList] = useState([]); const [ruseTableData, setRuseTableData] = useState([]); - const [prfData , setPrfData] = useState<{inPrf: any[],outPrf: any[], totalPrf:any[] }> () + const [prfData, setPrfData] = useState<{ + inPrf: any[]; + outPrf: any[]; + totalPrf: any[]; + }>(); + const [indexMng, setIndexMng] = useState(0); + const [indexBiz, setIndexBiz] = useState(0); + const form = useForm<{ + items: z.infer[]; + }>({ + resolver: zodResolver(z.object({ items: pbnstRegArrayZod })), + defaultValues: { items: pbnstRegArrayZod.parse([]) }, + mode: "onChange", + }); - const {monthHeadList } = prfmnc; + const { monthHeadList } = prfmnc; useEffect(() => { let tableData; if (fcltTab === "fclt") { @@ -38,46 +61,46 @@ export function PbnstSttnModal({ data }: { data: customPbnst }) { return { cycl: item.cycl + "차", seCd: item.seCd, - gvsbs: item.gvsbs??'-', - lcep: item.lcep??'-', - cusrAlotm: item.cusrAlotm??'-', - etc: item.etc??'-', + gvsbs: item.gvsbs ?? "-", + lcep: item.lcep ?? "-", + cusrAlotm: item.cusrAlotm ?? "-", + etc: item.etc ?? "-", totalMoney: Number(item.addr) + Number(item.gvsbs) + Number(item.lcep) + Number(item.cusrAlotm), - instlAprvSncnDt: item.instlAprvSncnDt?.toISOString??'-', - bizCmcnDay: item.bizCmcnDay?.toISOString??'-', - rprcsFcltCpct: item.rprcsFcltCpct??'-', - rprcsMthdCd: item.rprcsMthdCd??'-', - majorPrcsMsrcCd: item.majorPrcsMsrcCd??'-', - inoutYn: item.inoutYn??'-', - addr: item.addr??'-', + instlAprvSncnDt: item.instlAprvSncnDt?.toISOString ?? "-", + bizCmcnDay: item.bizCmcnDay?.toISOString ?? "-", + rprcsFcltCpct: item.rprcsFcltCpct ?? "-", + rprcsMthdCd: item.rprcsMthdCd ?? "-", + majorPrcsMsrcCd: item.majorPrcsMsrcCd ?? "-", + inoutYn: item.inoutYn ?? "-", + addr: item.addr ?? "-", }; }); } else if (fcltTab === "sply") { tableData = data.fcBizs.flatMap((item: fcBizType) => { - return item?.fcOrgwts?.map((fcOrgwt) => { - return { - cycl: item.cycl + "차", - orgwtWtritQnt: fcOrgwt.orgwtWtritQnt, - tmsYn: fcOrgwt.tmsYn, - dschgFmYn: fcOrgwt.dschgFmYn, - dtlPstnExpln: fcOrgwt.dtlPstnExpln, - }; - }) + return item?.fcOrgwts?.map((fcOrgwt) => { + return { + cycl: item.cycl + "차", + orgwtWtritQnt: fcOrgwt.orgwtWtritQnt, + tmsYn: fcOrgwt.tmsYn, + dschgFmYn: fcOrgwt.dschgFmYn, + dtlPstnExpln: fcOrgwt.dtlPstnExpln, + }; + }); }); } else if (fcltTab === "ppi") { tableData = data.fcBizs?.flatMap((item: fcBizType) => { - return item?.pplInstls?.map((ppl) => { - return { - cycl: item.cycl + "차", - ppMqlt: ppl.ppMqlt, - pdmt: ppl.pdmt, - cpct: ppl.cpct, - }; - }) + return item?.pplInstls?.map((ppl) => { + return { + cycl: item.cycl + "차", + ppMqlt: ppl.ppMqlt, + pdmt: ppl.pdmt, + cpct: ppl.cpct, + }; + }); }); } else if (fcltTab === "guarantee") { tableData = data.fcBizs?.map((item: fcBizType) => { @@ -97,18 +120,20 @@ export function PbnstSttnModal({ data }: { data: customPbnst }) { }); } else if (fcltTab === "dmdCo") { tableData = data.fcBizs?.flatMap((item: fcBizType) => { + + console.log("item.fcDemands", item.fcDemands); return item?.fcDemands?.map((dmd) => { - return { - cycl: item.cycl + "차", - dmdCoNm: dmd.dmdCoNm, - daddr: dmd.daddr, - useUsgCd: dmd.useUsgCd, - splyBgngDay: dmd.splyBgngDay?.toISOString, - splyEndDay: dmd.splyEndDay?.toISOString, - splyCpct: dmd.splyCpct, - splyFmYn: dmd.splyFmYn, - }; - }) + return { + cycl: item.cycl + "차", + dmdCoNm: dmd.dmdCoNm, + daddr: dmd.daddr, + useUsgCd: dmd.useUsgCd, + splyBgngDay: dmd.splyBgngDay?.toISOString, + splyEndDay: dmd.splyEndDay?.toISOString, + splyCpct: dmd.splyCpct, + splyFmYn: dmd.splyFmYn, + }; + }); }); } console.log(tableData); @@ -137,85 +162,98 @@ export function PbnstSttnModal({ data }: { data: customPbnst }) { pbnstSttn.ruseDmdHeadList, ]); - const getTablePrfData = (prfList:PrfType[]) => { + const getTablePrfData = (prfList: PrfType[]) => { const inUsageData = [...initValInUsage]; const outUsageData = [...initValOutUsage]; const inSubtotal = subTotalObj; const outSubtotal = subTotalObj; - + if (prfList) { prfList?.forEach((prfItem) => { - const month = Number(prfItem?.ym?.slice(4)); // "MM" - const monthKey = `${month}월`; + const month = Number(prfItem?.ym?.slice(4)); // "MM" + const monthKey = `${month}월`; - inUsageData.forEach((inData: any) => { - const usageKey = inData.usage; - const value = (prfItem as any)[usageKey] ?? 0; + inUsageData.forEach((inData: any) => { + const usageKey = inData.usage; + const value = (prfItem as any)[usageKey] ?? 0; - inData[monthKey] = value; - inData.total += value; + inData[monthKey] = value; + inData.total += value; - if (inSubtotal && usageKey !== "subtotal") { - (inSubtotal as any)[monthKey] = - ((inSubtotal as any)[monthKey] ?? 0) + value; - inSubtotal.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; + outUsageData.forEach((outData: any) => { + const usageKey = outData.usage; + const value = (prfItem as any)[usageKey] ?? 0; - outData[monthKey] = value; - outData.total += value; + 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); + 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]; + (usageTotalObj as any)[key] = val; + } + const tableData = [...inUsageData, ...outUsageData, usageTotalObj]; - setPrfData({ - inPrf: inUsageData, - outPrf: outUsageData, - totalPrf: tableData, - }); + setPrfData({ + inPrf: inUsageData, + outPrf: outUsageData, + totalPrf: tableData, + }); } + }; + useEffect(() => { + if (pbnstSttn.pbnstSttnRes && data) { + const prfList = pbnstSttn.pbnstSttnRes.find( + (item) => item.pbnstRuseFcltPk === data.pbnstRuseFcltPk + )?.prfList; - } - useEffect(() => { - - if(pbnstSttn.pbnstSttnRes&&data){ - const prfList = pbnstSttn.pbnstSttnRes.find((item) => item.pbnstRuseFcltPk=== data.pbnstRuseFcltPk )?.prfList - - if(prfList){ - getTablePrfData(prfList) + if (prfList) { + getTablePrfData(prfList); + } } - - } }, [pbnstSttn.pbnstSttnRes, data]); useEffect(() => {}, [ruseBizData?.head]); + + + useEffect(()=>{ + + if(data){ + form.reset({items:[data]}) + } + + },[data, form]) return ( <>
<ScrollArea className={"h-[70vh]"}> - <PbnstMngForm firstFcltData={data} formType={"sttn"} /> + <PbnstMngForm + form={form} + formType={"sttn"} + indexMng={indexMng} + setIndexMng={setIndexMng} + /> <Tabs defaultValue="mng" onValueChange={setFcltTab}> <TabsList className=""> <TabsTrigger className="!text-xl" value="fclt"> @@ -245,7 +283,11 @@ export function PbnstSttnModal({ data }: { data: customPbnst }) { onPageChange={function (page: number): void { throw new Error("Function not implemented."); }} - children={fcltTab==='fclt'?<HeadMakeColSpan upHeadList={pbnstSttn.ruseFcltNodeList} />:undefined} + children={ + fcltTab === "fclt" ? ( + <HeadMakeColSpan upHeadList={pbnstSttn.ruseFcltNodeList} /> + ) : undefined + } ></UiTable> </TabsContent> </Tabs> @@ -263,22 +305,21 @@ export function PbnstSttnModal({ data }: { data: customPbnst }) { </TabsTrigger> </TabsList> <TabsContent className="max-h-full" value={ruseTab}> - {prfData && ( - <UiTable - headName={undefined} - tableData={prfData[ruseTab as keyof typeof prfData] || []} - headlist={monthHeadList || []} - pageSize={0} - total={0} - cellClick={undefined} - onPageChange={function (page: number): void { - throw new Error("Function not implemented."); - }} - ></UiTable> - )} + {prfData && ( + <UiTable + headName={undefined} + tableData={prfData[ruseTab as keyof typeof prfData] || []} + headlist={monthHeadList || []} + pageSize={0} + total={0} + cellClick={undefined} + onPageChange={function (page: number): void { + throw new Error("Function not implemented."); + }} + ></UiTable> + )} </TabsContent> </Tabs> - </ScrollArea> </div> </> diff --git a/apps/wr/public/2024_constarctFeeProgram.zip b/apps/wr/public/2024_constarctFeeProgram.zip new file mode 100644 index 000000000..f399fa091 Binary files /dev/null and b/apps/wr/public/2024_constarctFeeProgram.zip differ