From dc6491862753d842b418389a6360dacdfb644e60 Mon Sep 17 00:00:00 2001 From: leedj312 Date: Mon, 23 Jun 2025 11:13:11 +0900 Subject: [PATCH] =?UTF-8?q?=EC=88=98=EC=9A=94=EB=A7=A4=EC=B9=AD=20?= =?UTF-8?q?=EB=B0=8F=20=EC=9E=AC=EC=9D=B4=EC=9A=A9=20=EA=B2=80=ED=86=A0=20?= =?UTF-8?q?=EC=9D=B4=EB=A0=A5=20=EA=B3=84=EC=82=B0=20=EC=99=84=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruseFcltMng/fcltSttn/pbnstSttn/page.tsx | 1 + .../prfmncReg/pbnstPrfmncReg/page.tsx | 11 +- .../prfmncSttn/pbnstPrfmncSttn/page.tsx | 10 +- apps/wr/app/store/common/type/header.tsx | 1 + apps/wr/app/store/matDmd/coMatRvw/type.tsx | 22 +- .../fcltSttn/pbnstSttn/headList.tsx | 31 +- .../lib/func/calculateConstCost .tsx | 57 +++- .../ui/form/coMat/conCostForm/conCostForm.tsx | 158 ++++----- .../fcltReg/pbnstReg/mngReg/mngRegForm.tsx | 316 ++++++++---------- .../pbnPrfExcelModal/pbnPrfExcelModal.tsx | 7 +- .../ui/modal/coMat/constCostFeeTable.tsx | 4 +- .../ui/modal/coMat/rateFeeModal.tsx | 44 ++- .../sttn/pbnstSttnModal/pbnstSttnModal.tsx | 28 +- .../ruseMngTableForm/ruseMngTableForm.tsx | 36 +- 14 files changed, 346 insertions(+), 380 deletions(-) diff --git a/apps/wr/app/ruseFcltMng/fcltSttn/pbnstSttn/page.tsx b/apps/wr/app/ruseFcltMng/fcltSttn/pbnstSttn/page.tsx index 862e260fd..8823abf6d 100644 --- a/apps/wr/app/ruseFcltMng/fcltSttn/pbnstSttn/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltSttn/pbnstSttn/page.tsx @@ -87,6 +87,7 @@ export default function PbnstSttn() { } }, [pbnstSttn.isInit, pbnSttnInit, ref.current]); useEffect(() => { + setBdstTable(pbnstSttn.pbnstSttnRes); }, [pbnstSttn.pbnstSttnRes]); diff --git a/apps/wr/app/ruseFcltMng/prfmncReg/pbnstPrfmncReg/page.tsx b/apps/wr/app/ruseFcltMng/prfmncReg/pbnstPrfmncReg/page.tsx index 46ec39658..0714c9306 100644 --- a/apps/wr/app/ruseFcltMng/prfmncReg/pbnstPrfmncReg/page.tsx +++ b/apps/wr/app/ruseFcltMng/prfmncReg/pbnstPrfmncReg/page.tsx @@ -84,10 +84,10 @@ export default function prfmncPrfmncReg() { isModal: false, data: prfmncRes[index] || ({} as FcPrfType), }); - const inUsageData = [...initValInUsage]; - const outUsageData = [...initValOutUsage]; - const inSubtotal = subTotalObj; - const outSubtotal = subTotalObj; + const inUsageData = structuredClone(initValInUsage); + const outUsageData = structuredClone(initValOutUsage); + const inSubtotal = structuredClone(subTotalObj); + const outSubtotal = structuredClone(subTotalObj); if (prfmncRes[index]?.prfList) { prfmncRes[index].prfList?.forEach((prfItem) => { const month = Number(prfItem?.ym?.slice(4)); // "MM" @@ -123,7 +123,7 @@ export default function prfmncPrfmncReg() { }); inUsageData.push(inSubtotal); outUsageData.push(outSubtotal); - const usageTotalObj: { [key: string]: any } = totalObj; + const usageTotalObj: { [key: string]: any } = structuredClone(totalObj); for (const key in usageTotalObj) { if (["usage", "gubun", "edit"].includes(key)) continue; const val = @@ -135,7 +135,6 @@ export default function prfmncPrfmncReg() { const tableData = [...inUsageData, ...outUsageData, usageTotalObj]; setPbnstRuseFcltPk(prfmncRes[index].pbnstRuseFcltPk); - console.log(' tableData ' ,tableData) setInputData(tableData); } else { setInputData([]); diff --git a/apps/wr/app/ruseFcltMng/prfmncSttn/pbnstPrfmncSttn/page.tsx b/apps/wr/app/ruseFcltMng/prfmncSttn/pbnstPrfmncSttn/page.tsx index 74c566c03..95ce7d7d9 100644 --- a/apps/wr/app/ruseFcltMng/prfmncSttn/pbnstPrfmncSttn/page.tsx +++ b/apps/wr/app/ruseFcltMng/prfmncSttn/pbnstPrfmncSttn/page.tsx @@ -65,11 +65,11 @@ export default function PbnstPrfmncSttn() { type lineChartDataProps = { label: string, val: number, color: string }; const prfTableData = (prfList: PrfType[], year:string) => { - const inUsageData = initValInUsage; - const outUsageData = initValOutUsage; + const inUsageData = structuredClone(initValInUsage); + const outUsageData = structuredClone(initValOutUsage); - const inSubtotal = subTotalObj; - const outSubtotal = subTotalObj; + const inSubtotal = structuredClone(subTotalObj); + const outSubtotal = structuredClone(subTotalObj); console.log(' prfList ', prfList) const prfFilter = prfList?.filter((e) => e.ym.slice(0, 4) === year) @@ -108,7 +108,7 @@ export default function PbnstPrfmncSttn() { }); inUsageData.push(inSubtotal); outUsageData.push(outSubtotal); - const usageTotalObj: { [key: string]: any } = totalObj; + const usageTotalObj: { [key: string]: any } = structuredClone(totalObj); for (const key in usageTotalObj) { if (["usage", "gubun", "edit"].includes(key)) continue; const val = diff --git a/apps/wr/app/store/common/type/header.tsx b/apps/wr/app/store/common/type/header.tsx index 45ef9e291..f064b7580 100644 --- a/apps/wr/app/store/common/type/header.tsx +++ b/apps/wr/app/store/common/type/header.tsx @@ -22,5 +22,6 @@ export type TableUpperProps = { selectData ?:string; // type 이 seelct 일경우 selectarray 정하기 위해 row?:number; mergeCell?:boolean // 셀을 합칠경우 + readonly?:boolean }; diff --git a/apps/wr/app/store/matDmd/coMatRvw/type.tsx b/apps/wr/app/store/matDmd/coMatRvw/type.tsx index 90c2790d5..739ba7a44 100644 --- a/apps/wr/app/store/matDmd/coMatRvw/type.tsx +++ b/apps/wr/app/store/matDmd/coMatRvw/type.tsx @@ -73,19 +73,19 @@ import { z } from "zod"; dmdInfoFk: z.string(), dmndTmng: z.coerce.date(), dmndQty: z.number(), - wntUntprc: z.number(), - grssClfg: z.number(), - combResdch: z.number(), - trbt: z.number(), + wntUntprc: z.number().nullish(), + grssClfg: z.number().nullish(), + combResdch: z.number().nullish(), + trbt: z.number().nullish(), blgcOxygDmndQnt: z.number(), - smll: z.number(), - crmty: z.number(), - tn: z.number(), - tph: z.number(), - ph: z.number(), - clIonQnt: z.number(), + smll: z.number().nullish(), + crmty: z.number().nullish(), + tn: z.number().nullish(), + tph: z.number().nullish(), + ph: z.number().nullish(), + clIonQnt: z.number().nullish(), cdtnv: z.number(), - rmrk: z.string(), + rmrk: z.string().nullish(), useUsgCd: z.string().nullish(), mtchnCmptnYmd: z.string().nullish(), rvwCmptnYmd: z.string().nullish(), diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/headList.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/headList.tsx index 9fe7fddc9..7c2953932 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/headList.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/headList.tsx @@ -31,8 +31,8 @@ export const pbnSttHeadListExport: z.infer = [ { id: "bscFctNm", title: "시설명", visible: true }, { id: "efflWqltStndrdNm", title: "지역구분", visible: true }, - { id: "fctCpc", title: "시설용량(톤/일)", visible: true }, { id: "tel", title: "전화번호", visible: true }, + { id: "fctCpc", title: "시설용량(톤/일)", visible: true }, { id: "ruseUtztnFcltNm", title: "재이용시설명", visible: true }, { @@ -132,7 +132,7 @@ export const pbnstSttNodeListExport: CommonTableProps[] = [ colSpan: 1, }, { - id: "phone", + id: "tel", title: "전화번호", visible: true, row: 1, @@ -140,7 +140,7 @@ export const pbnstSttNodeListExport: CommonTableProps[] = [ colSpan: 1, }, { - id: "fcltQuantity", + id: "fctCpc", title: "시설용량(톤/일)", visible: true, row: 1, @@ -325,7 +325,7 @@ export const ruseFcltNodeListExport: TableUpperProps[] = [ visible: true, row: 1, rowSpan: 1, - colSpan: 10, + colSpan: 9, }, { id: "ruseFclt", @@ -333,10 +333,10 @@ export const ruseFcltNodeListExport: TableUpperProps[] = [ visible: true, row: 1, rowSpan: 1, - colSpan: 5, + colSpan: 3, }, { - id: "mainSply", + id: "mainSplyPumpCpct", title: "메인공급펌프용량", visible: true, row: 1, @@ -349,7 +349,7 @@ export const ruseFcltNodeListExport: TableUpperProps[] = [ visible: true, row: 2, rowSpan: 1, - colSpan: 6, + colSpan: 5, }, { id: "instlAprvSncnDt", @@ -424,14 +424,7 @@ export const ruseFcltNodeListExport: TableUpperProps[] = [ rowSpan: 1, colSpan: 1, }, - { - id: "cusrAlotm2", - title: "원인자부담금", - visible: true, - row: 3, - rowSpan: 1, - colSpan: 1, - }, + { id: "etc", title: "기타", visible: true, row: 3, rowSpan: 1, colSpan: 1 }, { id: "totalMoney", @@ -498,11 +491,7 @@ export const ruseFcltHeadListExport: CommonTableProps[] = [ title: "민간투자비", visible: true, }, - { - id: "cusrAlotm2", - title: "원인자부담금", - visible: true, - }, + { id: "etc", title: "기타", visible: true }, { id: "totalMoney", @@ -545,7 +534,7 @@ export const ruseFcltHeadListExport: CommonTableProps[] = [ visible: true, }, { - id: "mainSply", + id: "mainSplyPumpCpct", title: "메인공급펌프용량", visible: true, }, diff --git a/apps/wr/components/lib/func/calculateConstCost .tsx b/apps/wr/components/lib/func/calculateConstCost .tsx index 73cd506b4..5e9387385 100644 --- a/apps/wr/components/lib/func/calculateConstCost .tsx +++ b/apps/wr/components/lib/func/calculateConstCost .tsx @@ -1,44 +1,66 @@ export const findBounds = ( data: any[], fctCd: string, + dataCode: string, + qtyCode:string, qty: number -): { lower?: any; upper?: any } => { - const filtered = data.filter((item) => item.fctCd === fctCd); +): { lower: any; upper: any } => { - const lowers = filtered.filter((item) => Number(item.fctCpc) <= qty); - const uppers = filtered.filter((item) => Number(item.fctCpc) > qty); + + const filtered = data.filter((item) => item[dataCode] === fctCd); + + const lowers = filtered.filter((item) => Number(item[qtyCode]) <= qty); + const uppers = filtered.filter((item) => Number(item[qtyCode]) > qty); const lower = lowers.length > 0 ? lowers.reduce((acc, curr) => - Number(curr.fctCpc) > Number(acc.fctCpc) ? curr : acc - ) - : undefined; - const upper = - uppers.length > 0 - ? uppers.reduce((acc, curr) => - Number(curr.fctCpc) < Number(acc.fctCpc) ? curr : acc + Number(curr[qtyCode]) > Number(acc[qtyCode]) ? curr : acc ) : undefined; - return { lower, upper }; + const upper = + uppers.length > 0 + ? uppers.reduce((acc, curr) => + Number(curr[qtyCode]) < Number(acc[qtyCode]) ? curr : acc + ) + : undefined; + + // ✅ 바운더리 하나만 있을 경우 대체 처리 + if (!lower && upper) return { lower: upper, upper }; + if (!upper && lower) return { lower, upper: lower }; + + // ✅ 정상 보간 구간 + if (lower && upper) return { lower, upper }; + + // ❌ 둘 다 없을 경우 (fctCd 필터 결과가 없음) + throw new Error(`No matching bounds found for fctCd: ${fctCd}, qty: ${qty}`); }; + // (기울기) a = (y2 - y1) / (x2 - x1) // (절편) b = y1 - a * x1 // ↓ // 결과값 y = a * x + b + export const getInterpolation = ( Upper: { stdCost: number; fctCpc: number }, Lower: { stdCost: number; fctCpc: number }, qtyYear: number ): number => { - const slope = - (Number(Upper?.stdCost) - Number(Lower?.stdCost)) / - (Number(Upper?.fctCpc) - Number(Lower?.fctCpc)); - const intercept = Number(Lower?.stdCost) - slope * Number(Lower?.fctCpc); - return slope * qtyYear + intercept; + const x1 = Number(Lower.fctCpc); // 최소 처리 용량 + const y1 = Number(Lower.stdCost); // 최소 공사비/요율 + const x2 = Number(Upper.fctCpc); // 최대 처리 용량 + const y2 = Number(Upper.stdCost); // 최대 공사비/요율 + + if (qtyYear <= x1) return y1; // 최소 이하면 y1 반환 + if (qtyYear >= x2) return y2; // 최대 이상이면 y2 반환 + + const slope = (y2 - y1) / (x2 - x1); // 기울기 a + const intercept = y1 - slope * x1; // 절편 b + + return slope * qtyYear + intercept; // 보간 계산 }; export const transformAndInterpolate = ( @@ -60,7 +82,6 @@ export const transformAndInterpolate = ( stdCost: item.upper?.rt, }, }; - console.log("range ", range); result[key] = getInterpolation(range.Upper, range.Lower, dmndQtyYear); } diff --git a/apps/wr/components/ui/form/coMat/conCostForm/conCostForm.tsx b/apps/wr/components/ui/form/coMat/conCostForm/conCostForm.tsx index f62e8b2a2..5809ce120 100644 --- a/apps/wr/components/ui/form/coMat/conCostForm/conCostForm.tsx +++ b/apps/wr/components/ui/form/coMat/conCostForm/conCostForm.tsx @@ -26,6 +26,7 @@ import { Button, Input, Label } from "@common/components/ui"; import type { read } from "fs"; import { useCallback, useEffect, useRef, useState } from "react"; import { type UseFormReturn } from "react-hook-form"; +import toast from "react-hot-toast"; export default function ConCostForm({ form, @@ -89,11 +90,15 @@ export default function ConCostForm({ const { lower: firstLower, upper: firstUpper } = findBounds( constCostRes, firstProc || "", + 'fctCd', + 'fctCpc', Number(dmndQtyYear) ); const { lower: secondLower, upper: secondUpper } = findBounds( constCostRes, secondProc || "", + 'fctCd', + 'fctCpc', Number(dmndQtyYear) ); @@ -112,44 +117,32 @@ export default function ConCostForm({ const groupCodes = ["BD", "CE", "SE", "WD"]; const groupedBounds: { [key: string]: { lower?: any; upper?: any } } = {}; for (const code of groupCodes) { - const groupItems = rateFeeRes.filter((item) => item.incExpCd === code); - const lowers = groupItems.filter( - (item) => Number(item.stdCost) <= result - ); - const uppers = groupItems.filter( - (item) => Number(item.stdCost) > result - ); - - const lower = - lowers.length > 0 - ? lowers.reduce((acc, curr) => - Number(curr.stdCost) > Number(acc.stdCost) ? curr : acc - ) - : undefined; - - const upper = - uppers.length > 0 - ? uppers.reduce((acc, curr) => - Number(curr.stdCost) < Number(acc.stdCost) ? curr : acc - ) - : undefined; - - groupedBounds[code] = { lower, upper }; + + groupedBounds[code] = findBounds(rateFeeRes, code, 'incExpCd', 'stdCost',result); } const resultRate = transformAndInterpolate(groupedBounds, result); - const fcltSbsdEpsTrf =result * (resultRate.BD + resultRate.CE + resultRate.SE + resultRate.WD); + const fcltSbsdEpsTrf = + result * + (resultRate.BD + resultRate.CE + resultRate.SE + resultRate.WD); - const realResult = - result +fcltSbsdEpsTrf; + const realResult = result + fcltSbsdEpsTrf; - form.setValue("demandCst.prcsFcltCpctCstrnCst", result); - form.setValue( "demandCst.fcltSbsdEpsTrf",fcltSbsdEpsTrf); - form.setValue("totalConstCost", realResult); + form.setValue("demandCst.prcsFcltCpctCstrnCst", Math.round(result) ); + form.setValue("demandCst.fcltSbsdEpsTrf", Math.round(fcltSbsdEpsTrf)) ; + form.setValue("totalConstCost", Math.round(realResult)); } }, [constCostRes, rateFeeRes, usgPrcsProcsWatch, dmndQtyWatch]); - const onSubmit = (value: DmdCoReqType) => { + + if( !form.getValues('demandCst.prcsFcltCpctCstrnCst') ){ + + console.log(" form ", form.getValues()); + toast.error('공사비 계산 진행 후 저장을 눌러주새요') + return + } + + if (type === "mat") { const data: DedMatUpdateType = { dmdInfoSn: form.getValues("dmdInfoSn"), @@ -159,14 +152,14 @@ export default function ConCostForm({ prcsFcltCpctCstrnCst: form.getValues("demandCst.prcsFcltCpctCstrnCst"), rgtr: TEST_UUID, }; - coMatRvwUpdate("11000SW001R1", form.getValues("dmdInfoFk"), data); + coMatRvwUpdate("11000SW001R1", form.getValues("dmdInfoFk"), data); } else if (type === "hist") { ruseRvwCalUpdate(value); } }; useEffect(() => { - // console.log(" form ", form.formState.errors); + console.log(" form ", form.formState.errors); }, [form.formState]); return ( @@ -297,14 +290,23 @@ export default function ConCostForm({
- - + + + + } + childrenBody={ + <> + {}} + > + + } + bodyClassName={"w-[40vw] h-full"} + >
)} @@ -326,13 +329,23 @@ export default function ConCostForm({
- - + + + + } + childrenBody={ + <> + {}} + > + + } + bodyClassName={"w-[22vw]"} + >
)} @@ -438,26 +452,15 @@ export default function ConCostForm({ />
- ( - - )} + +
@@ -472,27 +475,6 @@ export default function ConCostForm({
- - {}}> - } - bodyClass="w-[40vw] max-w-none h-[40vh]" - open={isCmpttnMo.isModal} - onOpenChange={(open) => { - setIsCmpttnMo({ isModal: open }); - }} - /> - {}}> - } - bodyClass="w-[40vw] h-[40vh] " - open={isTrfMo.isModal} - onOpenChange={(open) => { - setIsTrfMo({ isModal: open }); - }} - /> ); diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx index 66acb0bf8..21dc3cf83 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx @@ -9,8 +9,8 @@ import { } from "@common/business_components/ui"; import { Form, FormField } from "@common/business_components/ui/form"; import { Button, Input } from "@common/components"; -import { useEffect, useRef, useState } from "react"; -import { useFieldArray, useForm, type UseFormReturn } from "react-hook-form"; +import { useEffect, useState } from "react"; +import { useFieldArray, useWatch, type UseFormReturn } from "react-hook-form"; import { z } from "zod"; import { commonButonSize, @@ -38,10 +38,10 @@ export function PbnstMngForm({ form, formType, firstFcltData, - indexMng , + indexMng, setIndexMng, }: { -form: UseFormReturn<{items:PbnstRegArrrayType}>; + form: UseFormReturn<{ items: PbnstRegArrrayType }>; formType: string; firstFcltData?: customPbnst; indexMng: number; @@ -64,37 +64,11 @@ form: UseFormReturn<{items:PbnstRegArrrayType}>; const [planFiles, setPlanFiles] = useState(null); const [relationfiles, setRelationFiles] = useState(null); const [fcltNm, setFcltNm] = useState(null); - //const [fcOpresData, setFcOpresData] = useState(null); const [mngMtdCode, setMngMtdCode] = useState<{ name: string; val: SelectDataType[] }[]>(); const [progress, setProgress] = useState(0); - //const new File([] as BlobPart[], "") 파일 다운로드 활용 - //const ref = useRef(null); - - // const form = useForm>({ - // resolver: zodResolver(pbnstRegZod), - // defaultValues: - // formType === "reg" && pbnst.pbnstMngRegData - // ? pbnst.pbnstMngRegData[0] - // : formType === "update" && - // typeof pbnst.pbnsUpdateIndex.mng === "number" && - // pbnst.pbnsUpdateIndex.mng >= 0 && - // pbnst.pbnstRes - // ? pbnst.pbnstRes[pbnst.pbnsUpdateIndex.mng] - // : formType === "sttn" && firstFcltData - // ? { - // ruseUtztnFcltNm: firstFcltData?.ruseUtztnFcltNm, - // fcltCpct: firstFcltData?.fcltCpct, - // ruseCpct: firstFcltData?.ruseCpct, - // splyExtraCpct: firstFcltData?.splyExtraCpct, - // fcOpers: firstFcltData?.fcOpers, - // fcFiles: firstFcltData?.fcFiles, - // } - // : pbnstRegZod.parse({}), - // mode: "onChange", - // }); const { fields: fcOpersField, append, @@ -104,39 +78,33 @@ form: UseFormReturn<{items:PbnstRegArrrayType}>; name: `items.${indexMng}.fcOpers`, }); - - - const selectFclt = (val: number) => { - // if (pbnst.pbnstRes && pbnst.pbnstRes[val]) { - // getBizCycle(pbnst.pbnstRes[val]); - // // form.reset(pbnst.pbnstRes[val]); - - // getpbnstInsertIndex({ ...pbnst.pbnsUpdateIndex, mng: val }); - // } - }; + const watchedItem = useWatch({ + control: form.control, + name: `items.${indexMng}`, + }); const plusHist = () => { - append( { + append({ choose: false, - pbnstRuseFcltFk: form.getValues(`items.${indexMng}.pbnstRuseFcltPk`) ?? "", + pbnstRuseFcltFk: + form.getValues(`items.${indexMng}.pbnstRuseFcltPk`) ?? "", rgtr: "", mdfr: "", operMthd: "", rprtvBzenty: "", bgngDt: new Date(), endDt: new Date(), - }) - + }); }; const removeSelected = () => { + const nowOpers = form.getValues(`items.${indexMng}.fcOpers`); + if (!nowOpers) return; - const nowOpers = form.getValues(`items.${indexMng}.fcOpers`); - if(!nowOpers) return; - - const selectedIdxs = nowOpers.map((item, idx) => (item.choose ? idx : -1)) - .filter((idx) => idx !== -1); - selectedIdxs.reverse().forEach((idx) => remove(idx)); + const selectedIdxs = nowOpers + .map((item, idx) => (item.choose ? idx : -1)) + .filter((idx) => idx !== -1); + selectedIdxs.reverse().forEach((idx) => remove(idx)); }; const fileHandler = (files: File[], type: string) => { @@ -209,32 +177,14 @@ form: UseFormReturn<{items:PbnstRegArrrayType}>; return [...exFileDatas, ...currentdata]; }; - // 등록할때 신규 값을 계속 가지고 있으려고 useEffect(() => { - // if ( - // formType === "reg" && - // firstFcltData && - // (form.getValues(`items.${indexMng}.swtrmtFcltFk`) === "" || - // form.getValues(`items.${indexMng}.swtrmtFcltFk`) === undefined) - // ) { - // form.setValue(`items.${indexMng}.swtrmtFcltFk`, firstFcltData.swtrmtFcltFk); - // form.setValue( - // `items.${indexMng}.pbnstRuseFcltPk`, - // String(firstFcltData.pbnstRuseFcltPk) - // ); - // form.setValue(`items.${indexMng}.fcBizs`, firstFcltData.fcBizs); - // } - console.log('indexMng ', indexMng) - }, [indexMng]); - - useEffect(() => { - if(indexMng>=0){ - const defaultFiles = form.getValues(`items.${indexMng}.fcFiles`); + if (indexMng >= 0) { + const defaultFiles = watchedItem?.fcFiles; if (defaultFiles && defaultFiles.length > 0) { const relationFileList = defaultFiles.filter( (item) => item.fileKnd === "계통도" ); - + const planFileList = defaultFiles.filter( (item) => item.fileKnd === "평면도" ); @@ -244,8 +194,11 @@ form: UseFormReturn<{items:PbnstRegArrrayType}>; atflCd: item.fileTkn, file: new File([] as BlobPart[], item.filePath), })) - ); // 또는 파일 형식 변환 로직이 있다면 여기에 추가 - + ); + else { + setRelationFiles(null); + } + if (planFileList.length > 0) setPlanFiles( planFileList.map((item) => ({ @@ -253,46 +206,15 @@ form: UseFormReturn<{items:PbnstRegArrrayType}>; file: new File([] as BlobPart[], item.filePath), })) ); - }else{ + else { + setPlanFiles(null); + } + } else { setRelationFiles(null); setPlanFiles(null); } } - }, [form.watch(`items.${indexMng}`),indexMng]); // 초기화 이후 1회 실행 - - // 등록할때 신규 값을 계속 가지고 있으려고 - useEffect(() => { - // if ( - // formType === "update" && - // pbnst.pbnsUpdateIndex.biz >= 0 && - // pbnst.pbnstRes - // ) { - // const bizData = pbnst.pbnstRes[pbnst.pbnsUpdateIndex.biz]; - - // if (bizData) { - // getBizCycle(bizData); - // } - // } - }, [pbnst.pbnsUpdateIndex, pbnst.pbnstRes, formType, getBizCycle]); - - //신규 등록시 입력할때 데이터 넣기 - useEffect(() => { - // const formData = form.watch(); - // formData.fcOpers = ref.current ? [...ref.current] : []; - // formData.fcFiles = regFileList ? [...regFileList] : []; - // if (formType === "reg") { - // console.log("formData ", formData); - // pbnstMngData([formData] as customPbnst[]); - // } else if (formType === "update") { - // const updateRes = pbnst.pbnstRes?.map((item) => { - // if (item.pbnstRuseFcltPk === item.pbnstRuseFcltPk) { - // item = formData as customPbnst; - // } - // return item; - // }); - // pbnstMngData(updateRes as customPbnst[]); - // } - }, [form.formState, regFileList, formType, pbnst.pbnstRes]); + }, [watchedItem, indexMng]); useEffect(() => { // pbnstMngData(pbnst.pbnstMngRegData); @@ -309,7 +231,7 @@ form: UseFormReturn<{items:PbnstRegArrrayType}>; // 2. Define a submit handler. function onSubmit(values: z.infer) { - values.fcOpers = []; + values.fcOpers = []; values.fcFiles = regFileList || []; pbnstInsert(values); } @@ -325,15 +247,12 @@ form: UseFormReturn<{items:PbnstRegArrrayType}>; } }, [planFiles]); - useEffect(() => { if (code.ruseMngMtd) { setMngMtdCode([{ name: "ruseMngMtd", val: code.ruseMngMtd }]); } }, [code]); - - return (
@@ -348,7 +267,7 @@ form: UseFormReturn<{items:PbnstRegArrrayType}>; {formType === "update" ? ( ( @@ -381,6 +300,7 @@ form: UseFormReturn<{items:PbnstRegArrrayType}>; field.onChange(String(e.target.value)); }} value={field.value ?? ""} + readOnly={formType === "sttn" ? true : false} /> )} @@ -393,28 +313,41 @@ form: UseFormReturn<{items:PbnstRegArrrayType}>;
재이용시설 운영정보 -
- - -
+ {formType === "sttn" ? ( + <> + ) : ( +
+ + +
+ )}
{ + return { + ...item, + readonly: true, + }; + }) + : pbnst.pbnstMngUpHeadList + } upHeadList={pbnst.pbnstMngNm} code={mngMtdCode || []} onTableSet={(val) => { @@ -423,7 +356,7 @@ form: UseFormReturn<{items:PbnstRegArrrayType}>; indexMng={indexMng} form={form} formNm={"fcOpers"} - // ref={ref} + // ref={ref} >
@@ -445,6 +378,7 @@ form: UseFormReturn<{items:PbnstRegArrrayType}>; field.onChange(Number(e.target.value)); }} value={field.value ?? 0} + readOnly={formType === "sttn" ? true : false} /> )} @@ -453,19 +387,20 @@ form: UseFormReturn<{items:PbnstRegArrrayType}>;
( { field.onChange(Number(e.target.value)); }} value={field.value ?? 0} + readOnly={formType === "sttn" ? true : false} /> )} @@ -473,19 +408,20 @@ form: UseFormReturn<{items:PbnstRegArrrayType}>;
( { field.onChange(Number(e.target.value)); }} value={field.value ?? 0} + readOnly={formType === "sttn" ? true : false} /> )} @@ -497,40 +433,78 @@ form: UseFormReturn<{items:PbnstRegArrrayType}>;
- - item.file) || []} - setFiles={(files: File[] | null) => { - if (files) fileHandler(files, "relation"); - }} - fileTypes="PDF" - onFileClick={(index) => { - fileDownLoad( - relationfiles?.find( - (item, fileIndex) => fileIndex === index - )?.atflCd as string - ); - }} - > - + {formType === "sttn" ? ( + relationfiles && relationfiles?.length > 0 ? ( + <> + + {relationfiles?.map((item, index) => ( + fileDownLoad(item.atflCd)} + > + {item.file.name} + + ))} + + ) : ( + <> + ) + ) : ( + + item.file) || []} + setFiles={(files: File[] | null) => { + if (files) fileHandler(files, "relation"); + }} + fileTypes="PDF" + onFileClick={(index) => { + fileDownLoad( + relationfiles?.find( + (item, fileIndex) => fileIndex === index + )?.atflCd as string + ); + }} + > + + )}
- - item.file) || []} - setFiles={(files: File[] | null) => { - if (files) fileHandler(files, "plan"); - }} - fileTypes="PDF" - onFileClick={(index) => { - fileDownLoad( - planFiles?.find( - (item, fileIndex) => fileIndex === index - )?.atflCd as string - ); - }} - > - + {formType === "sttn" ? ( + planFiles && planFiles?.length > 0 ? ( + <> + + {planFiles?.map((item, index) => ( + fileDownLoad(item.atflCd)} + > + {item.file.name} + + ))} + + ) : ( + <> + ) + ) : ( + + item.file) || []} + setFiles={(files: File[] | null) => { + if (files) fileHandler(files, "plan"); + }} + fileTypes="PDF" + onFileClick={(index) => { + fileDownLoad( + planFiles?.find( + (item, fileIndex) => fileIndex === index + )?.atflCd as string + ); + }} + > + + )}
diff --git a/apps/wr/components/ui/modal/chkgd/pbnPrfExcelModal/pbnPrfExcelModal.tsx b/apps/wr/components/ui/modal/chkgd/pbnPrfExcelModal/pbnPrfExcelModal.tsx index 9fe45fc33..28dc882c3 100644 --- a/apps/wr/components/ui/modal/chkgd/pbnPrfExcelModal/pbnPrfExcelModal.tsx +++ b/apps/wr/components/ui/modal/chkgd/pbnPrfExcelModal/pbnPrfExcelModal.tsx @@ -99,7 +99,7 @@ export default function PbnPrfExcelModal({ data }: { data: FcPrfType }) { selectClass={""} label="" selectArray={yearOptions} - value={field.value} + value={field.value||new Date().getFullYear()} onSelectValue={(val) => field.onChange(val)} /> @@ -113,7 +113,7 @@ export default function PbnPrfExcelModal({ data }: { data: FcPrfType }) { @@ -127,7 +127,7 @@ export default function PbnPrfExcelModal({ data }: { data: FcPrfType }) { @@ -146,6 +146,7 @@ export default function PbnPrfExcelModal({ data }: { data: FcPrfType }) { if (files) setFiles(files); }} fileTypes="xlsx" + maxFiles={1} > )} diff --git a/apps/wr/components/ui/modal/coMat/constCostFeeTable.tsx b/apps/wr/components/ui/modal/coMat/constCostFeeTable.tsx index b47047d9a..428e1ec3b 100644 --- a/apps/wr/components/ui/modal/coMat/constCostFeeTable.tsx +++ b/apps/wr/components/ui/modal/coMat/constCostFeeTable.tsx @@ -73,7 +73,7 @@ export function ConstCostFeeTable({ return ( <> - +

공사비 산정표 보기

@@ -89,7 +89,6 @@ export function ConstCostFeeTable({ onSelectValue={(val: string | number) => 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 c5131097c..1041785eb 100644 --- a/apps/wr/components/ui/modal/coMat/rateFeeModal.tsx +++ b/apps/wr/components/ui/modal/coMat/rateFeeModal.tsx @@ -5,7 +5,7 @@ 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 { Input, Label, ScrollArea } from "@common/components/ui"; import { Scroll } from "lucide-react"; import { useEffect, useState } from "react"; @@ -14,7 +14,7 @@ export function RateFeeTableModal({ }: { setReturnData: (data: any) => void; }) { - const { code, coRvw,rateFeeRes } = useWrStore((state) => state); + const { code, coRvw, rateFeeRes } = useWrStore((state) => state); const [year, setYear] = useState(String(new Date().getFullYear())); const [reateFeeTable, setRateFeeTable] = useState([]); @@ -31,26 +31,24 @@ export function RateFeeTableModal({ 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 data = await rateFeeRes?.filter((item: rateFeeType) => { + return item.incExpCd !== "SS"; + }) + .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, }; @@ -60,18 +58,19 @@ export function RateFeeTableModal({ return acc; }, []); + + console.log(' data ', data) 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); @@ -81,28 +80,26 @@ export function RateFeeTableModal({ return ( <> - +

요율표 보기


-
- - setYear(String(val))} +
+ + {}} + value={new Date().getFullYear() || ""} />
-
- +
-
diff --git a/apps/wr/components/ui/modal/sttn/pbnstSttnModal/pbnstSttnModal.tsx b/apps/wr/components/ui/modal/sttn/pbnstSttnModal/pbnstSttnModal.tsx index 438ab439c..d20d10591 100644 --- a/apps/wr/components/ui/modal/sttn/pbnstSttnModal/pbnstSttnModal.tsx +++ b/apps/wr/components/ui/modal/sttn/pbnstSttnModal/pbnstSttnModal.tsx @@ -53,6 +53,7 @@ export function PbnstSttnModal({ data }: { data: customPbnst }) { mode: "onChange", }); + const { monthHeadList } = prfmnc; useEffect(() => { let tableData; @@ -77,6 +78,7 @@ export function PbnstSttnModal({ data }: { data: customPbnst }) { majorPrcsMsrcCd: item.majorPrcsMsrcCd ?? "-", inoutYn: item.inoutYn ?? "-", addr: item.addr ?? "-", + mainSplyPumpCpct: item.mainSplyPumpCpct ?? "-", }; }); } else if (fcltTab === "sply") { @@ -113,6 +115,7 @@ export function PbnstSttnModal({ data }: { data: customPbnst }) { smll: item.smll, crmty: item.crmty, tph: item.tph, + tn: item.tn, ph: item.ph, cdtnv: item.cdtnv, @@ -121,7 +124,6 @@ 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 + "차", @@ -163,10 +165,10 @@ export function PbnstSttnModal({ data }: { data: customPbnst }) { ]); const getTablePrfData = (prfList: PrfType[]) => { - const inUsageData = [...initValInUsage]; - const outUsageData = [...initValOutUsage]; - const inSubtotal = subTotalObj; - const outSubtotal = subTotalObj; + const inUsageData = structuredClone(initValInUsage); + const outUsageData = structuredClone(initValOutUsage); + const inSubtotal = structuredClone(subTotalObj); + const outSubtotal = structuredClone(subTotalObj); if (prfList) { prfList?.forEach((prfItem) => { @@ -203,7 +205,7 @@ export function PbnstSttnModal({ data }: { data: customPbnst }) { }); inUsageData.push(inSubtotal); outUsageData.push(outSubtotal); - const usageTotalObj: { [key: string]: any } = totalObj; + const usageTotalObj: { [key: string]: any } = structuredClone(totalObj); for (const key in usageTotalObj) { if (["usage", "gubun", "edit"].includes(key)) continue; const val = @@ -227,14 +229,13 @@ export function PbnstSttnModal({ data }: { data: customPbnst }) { (item) => item.pbnstRuseFcltPk === data.pbnstRuseFcltPk )?.prfList; - if (prfList) { + if (prfList) {console.log("prfList", prfList); + getTablePrfData(prfList); } } }, [pbnstSttn.pbnstSttnRes, data]); - useEffect(() => {}, [ruseBizData?.head]); - useEffect(()=>{ @@ -243,6 +244,11 @@ export function PbnstSttnModal({ data }: { data: customPbnst }) { } },[data, form]) + + + useEffect(()=>{ + console.log("prfData", prfData); + },[prfData]) return ( <>
@@ -254,7 +260,7 @@ export function PbnstSttnModal({ data }: { data: customPbnst }) { indexMng={indexMng} setIndexMng={setIndexMng} /> - + 하수처리수 재이용시설 현황 @@ -292,7 +298,7 @@ export function PbnstSttnModal({ data }: { data: customPbnst }) { - + 장내외합계 diff --git a/apps/wr/components/ui/table/pbnstReg/ruseMngTableForm/ruseMngTableForm.tsx b/apps/wr/components/ui/table/pbnstReg/ruseMngTableForm/ruseMngTableForm.tsx index 2eeba6c69..11c183f1b 100644 --- a/apps/wr/components/ui/table/pbnstReg/ruseMngTableForm/ruseMngTableForm.tsx +++ b/apps/wr/components/ui/table/pbnstReg/ruseMngTableForm/ruseMngTableForm.tsx @@ -21,6 +21,7 @@ import { TableHeader, TableRow, } from "@common/components/ui"; +import { read } from "fs"; import React, { useEffect, useState } from "react"; type RuseMngTableProps = { @@ -37,22 +38,9 @@ type RuseMngTableProps = { const RuseMngTableForm = React.forwardRef( ({ tableData, headList, upHeadList, code, onTableSet, indexMng, form,formNm,indexBiz }, ref) => { - // const [tableState, setTableState] = useState([...tableData]); - // // useEffect(() => { - // // if (ref && typeof ref === "object" && "current" in ref) { - // // ref.current = tableState; - // // } - // // if (onTableSet) onTableSet(tableState); - // // }, [tableState, onTableSet]); - - // useEffect(() => { - - // if (tableData) - // setTableState(tableData); - // }, [tableData]); - + console.log('tableData ', tableData) return ( <> @@ -107,6 +95,7 @@ const RuseMngTableForm = React.forwardRef( ? (Number(field.value) ?? 0) : field.value || "" } + readOnly ={head.readonly ? true : false} /> ) : head.type === "select" ? ( ( className={""} selectClass={selectClass} onSelectValue={(val) => { - field.onChange(val); + + if(head.readonly === true){ + return + }else{ + + field.onChange(val); + } }} + // Disabled prop removed as SelectBox does not support it > ) : head.type === "date" ? ( - field.onChange(date), + value:typeof field.value === "string" ? new Date(field.value) : field.value, + onChange: (date: Date | undefined) => { + + console.log("date", date); + field.onChange(date); // readonly 상태가 아닐 때만 값 변경 + }, }} selectClass={"w-full"} /> @@ -141,7 +140,6 @@ const RuseMngTableForm = React.forwardRef( checked={ field.value || false} onCheckedChange={(checked) => { field.onChange(checked); - }} > ) : (