diff --git a/apps/wr/app/matMng/coMat/coMatRvw/page.tsx b/apps/wr/app/matMng/coMat/coMatRvw/page.tsx index 446323b83..c1e601320 100644 --- a/apps/wr/app/matMng/coMat/coMatRvw/page.tsx +++ b/apps/wr/app/matMng/coMat/coMatRvw/page.tsx @@ -14,9 +14,6 @@ import { tableData, yearOptions, } from "@/components/lib/func/commom"; -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, Form, @@ -43,6 +40,7 @@ import moment from "moment"; import { usageProcData } from "@/app/store/matDmd/coMatRvw/headList"; import { zodResolver } from "@hookform/resolvers/zod"; import ConCostForm from "@/components/ui/form/coMat/conCostForm/conCostForm"; +import type { objSearchType } from "@/components/ui/modal/fcltReg/bdstRegModal/bdstRegModal"; export default function CoMatRvw() { const { code, coRvw, coMatRvwInit, coMatRvwSearch, coMatRvwInqua } = @@ -114,7 +112,7 @@ export default function CoMatRvw() { }, [form.watch("useUsgCd")]); useEffect(() => { - if (coMatRvwRes) { + if (coMatRvwRes.length > 0) { const data = coMatRvwRes?.map((item, index) => { let flag = ""; flag = getdmdMatFlag(item?.demandMatching?.splyFcltFlg ??""); diff --git a/apps/wr/app/matMng/coMat/ruseRvwHstry/page.tsx b/apps/wr/app/matMng/coMat/ruseRvwHstry/page.tsx index 7a5a59a93..2d339b869 100644 --- a/apps/wr/app/matMng/coMat/ruseRvwHstry/page.tsx +++ b/apps/wr/app/matMng/coMat/ruseRvwHstry/page.tsx @@ -94,7 +94,6 @@ export default function RuseRvwHstry() { } else { - console.log("시도코드", sggCd); ruseRvwInqua(pageNation, 13, String(startYear), String(endYear), sggCd); } }; @@ -122,7 +121,7 @@ export default function RuseRvwHstry() { ?.map((item) => { form.clearErrors; if (item?.completeYn) { - return item.dmdInfoSn; + return Number(item.dmdInfoSn); } }) .filter((item) => item !== undefined); @@ -136,7 +135,7 @@ export default function RuseRvwHstry() { - } + rightChildren={} leftChildren={undefined} queryClick={function (returnType: ReturnType): void { // '{partValue: 'A', sidoValue: '0', sigunValue: '0', regionValue: '0', unitWaterShedValue: '0', …}' if (codeCityOrSgg) - rswtSttnSearch(1, "20", codeCityOrSgg); - }} + rswtSttnSearch(1, "20", codeCityOrSgg, code.cityCd, code.sggCd); + } } excelClick={excelClick} - initClick={function (): void { }} + initClick={function (): void { } } btnClass={btnClass} - ref={ref} - /> + ref={ref} isAdmin={false} />
diff --git a/apps/wr/app/ruseFcltMng/prfmncReg/chkgdnReg/page.tsx b/apps/wr/app/ruseFcltMng/prfmncReg/chkgdnReg/page.tsx index f75737925..5e807d2e1 100644 --- a/apps/wr/app/ruseFcltMng/prfmncReg/chkgdnReg/page.tsx +++ b/apps/wr/app/ruseFcltMng/prfmncReg/chkgdnReg/page.tsx @@ -70,15 +70,14 @@ export default function Page() { useEffect(() => { if (!rainChkgdn.isInit) { - rainChkInit("2024", "0"); + rainChkInit(new Date().getFullYear().toString(), "0"); isRainSttn(false) - setIsModal({ data: {}, open: false }); setIsRegExcel(false); } if (!rswtChkgdn.isInit) { - rswtChkgdnInit("2024", "0"); + rswtChkgdnInit(new Date().getFullYear().toString(), "0"); setIsModal({ data: {}, open: false }); setIsRegExcel(false); } 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..8064aa2bb 100644 --- a/apps/wr/app/ruseFcltMng/prfmncSttn/pbnstPrfmncSttn/page.tsx +++ b/apps/wr/app/ruseFcltMng/prfmncSttn/pbnstPrfmncSttn/page.tsx @@ -3,22 +3,28 @@ import { useWrStore } from "@/app/store"; import { btnClass } from "@/app/store/common/code"; import { initValInUsage, initValOutUsage, subTotalObj, totalObj, type FcPrfType, type PrfType } from "@/app/store/prfmncReg/pbnstPrfmncReg/type"; -import { yearOptions } from "@/components/lib/func/commom"; -import { InputTableBody } from "@/components/lib/func/TableData"; -import { ContentsDiv, Title, SearchBaseForm, SelectBox, SearchInput, UiTable, type ReturnType, MainChart, type ChartConfig, CHART_FORM, ScrollArea } from "@common/business_components"; -import DoughnutChart from "@common/business_components/ui/chart/DoughnutChart"; +import { excelPrfmncSttnParsing } from "@/app/store/prfmncSttn/pbnstPrfmncSttn/excel"; +import { excelDownload, yearOptions } from "@/components/lib/func/commom"; +import SearchInputText from "@/components/ui/searchInput/searchInput"; +import { CHART_FORM, ContentsDiv, MainChart, ScrollArea, SearchBaseForm, SearchInput, SelectBox, Title, UiTable, type ChartConfig, type ReturnType } from "@common/business_components"; import ListDiv from "@common/business_components/ui/list_div"; -import { Button, Label, Table, TableBody, TableHeader } from "@common/components/ui"; -import { useEffect, useRef, useState } from "react"; -import { headMakeprfmnc } from "../../prfmncReg/chkgdnReg/TableHead"; +import { Button, Label } from "@common/components/ui"; +import { useCallback, useEffect, useRef, useState } from "react"; import toast, { Toaster } from "react-hot-toast"; - - export default function PbnstPrfmncSttn() { - const { code, tableHeadMaker, pbnstPrfmncSttn, pbnstPrfmncInit, pbnstPrfmncSearch, prfmnc } = useWrStore((state) => state); + const { + code, + tableHeadMaker, + pbnstPrfmncSttn, + pbnstPrfmncInit, + pbnstPrfmncSearch, + prfmnc, + pbnstSttn, + pbnNmSearch + } = useWrStore((state) => state); const { monthHeadList } = prfmnc - const { pbnstPrfHeadList, pbnstPrfmncRes, prfmncRes, rawData, selectYearList } = pbnstPrfmncSttn; + const { pbnstPrfHeadList, prfmncRes, rawData, selectYearList } = pbnstPrfmncSttn; const [isChHead, setIsChHead] = useState(false); const [fromDate, setFromDate] = useState(String(new Date().getFullYear())); const [toDate, setToDate] = useState(String(new Date().getFullYear())); @@ -26,6 +32,18 @@ export default function PbnstPrfmncSttn() { const [bdstTable, setbdstTable] = useState(); const ref = useRef({} as ReturnType); const [swtrmtFcltNm, setSwtrmtFcltNm] = useState(); + const [pbnRuseNm, setPbnRuseNm] = useState(""); + const [excelData, setExcelData] = useState([]); + const excelClick = useCallback(() => { + excelDownload( + excelData, + "하수재이용실적 현황", + "sample_pbnstPrfmncSttn.xlsx", + "A1:N1", + 2 + ); + }, [excelData]); + const [chartConfig, setChartConfig] = useState({}); const [chartData, setChartData] = useState([]); const [dnInUsage, setDnInUsage] = useState([]); @@ -48,7 +66,6 @@ export default function PbnstPrfmncSttn() { chartData8: lineChartDataProps[]; chartData9: lineChartDataProps[]; }>(); - // const [lnInChartConfig, setLnInChartConfig] = useState({}); const [outLineData, setOutLineData] = useState<{ chartData1: lineChartDataProps[]; chartData2: lineChartDataProps[]; @@ -58,21 +75,18 @@ export default function PbnstPrfmncSttn() { chartData6: lineChartDataProps[]; }>(); - - type dnChartForm = { label: string, val: number, fill?: string }; type barChartForm = { label: string, "장내용수": number, "장외용수": number }; type lineChartDataProps = { label: string, val: number, color: string }; - const prfTableData = (prfList: PrfType[], year:string) => { - const inUsageData = initValInUsage; - const outUsageData = initValOutUsage; + const prfTableData = (prfList: PrfType[], year: string) => { + 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) + const prfFilter = prfList?.filter((e) => e.ym.slice(0, 4) === year) if (prfList && prfFilter.length > 0) { prfList?.forEach((prfItem) => { const month = Number(prfItem?.ym?.slice(4)); // "MM" @@ -108,7 +122,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 = @@ -119,71 +133,190 @@ export default function PbnstPrfmncSttn() { } const tableData = [...inUsageData, ...outUsageData, usageTotalObj]; setPrfData(tableData); - + setExcelData(excelPrfmncSttnParsing(prfData ?? [])) } else { setPrfData([]); } } + useEffect(() => { - let wshwtr = 0; - let coolUswtr = 0; - let cleanUswtr = 0; - let drwtUswtr = 0; - let dltnUswtr = 0; - let ithlRswtr = 0; - let ithlEtcUswtr = 0; - let cleanToilUswtr = 0; - let resn = 0; - let lndwtr = 0; - let hydUswtr = 0; - let ugwtChr = 0; - let farmUswtr = 0; - let rvrKeepUswtr = 0; - let indstUswtr = 0; + // 누적 변수 초기화 + let wshwtr = 0, + coolUswtr = 0, + cleanUswtr = 0, + drwtUswtr = 0, + dltnUswtr = 0, + ithlRswtr = 0, + ithlEtcUswtr = 0, + cleanToilUswtr = 0, + resn = 0; + + let lndwtr = 0, + hydUswtr = 0, + ugwtChr = 0, + farmUswtr = 0, + rvrKeepUswtr = 0, + indstUswtr = 0; + + let inUsageSum = 0, + outUsageSum = 0; + + let inUsageArr: number[] = [], + outUsageArr: number[] = []; + + // 라인차트용 데이터 + const wshwtrData: lineChartDataProps[] = [], + coolUswtrData: lineChartDataProps[] = [], + cleanUswtrData: lineChartDataProps[] = [], + drwtUswtrData: lineChartDataProps[] = [], + dltnUswtrData: lineChartDataProps[] = [], + ithlRswtrData: lineChartDataProps[] = [], + ithlEtcUswtrData: lineChartDataProps[] = [], + cleanToilUswtrData: lineChartDataProps[] = [], + resnData: lineChartDataProps[] = []; + const lndwtrData: lineChartDataProps[] = [], + hydUswtrData: lineChartDataProps[] = [], + ugwtChrData: lineChartDataProps[] = [], + farmUswtrData: lineChartDataProps[] = [], + rvrKeepUswtrData: lineChartDataProps[] = [], + indstUswtrData: lineChartDataProps[] = []; + + // 막대차트 데이터 + const barData: barChartForm[] = []; + + // 도넛차트 데이터 + const dnData: dnChartForm[] = []; + const dnInData: dnChartForm[] = []; + const dnOutData: dnChartForm[] = []; + if (rawData) { rawData.forEach((item) => { + // 실적 테이블 데이터 prfTableData(item.prfList, year); - item.prfList.filter((e) => e.ym.slice(0, 4) === year) .forEach((element) => { - - wshwtr += element.wshwtr; //세척수 - coolUswtr += element.coolUswtr; //냉각수 - cleanUswtr += element.cleanUswtr; //청소수 - drwtUswtr += element.drwtUswtr; //식수대 - dltnUswtr += element.dltnUswtr //희석용수 - ithlRswtr += element.ithlRswtr //중수도 - ithlEtcUswtr += element.ithlEtcUswtr //기타 - cleanToilUswtr += element.cleanToilUswtr //청소화장실용수 - resn += element.resn //세척살수용수 - lndwtr += element.lndwtr; //조경용수 - hydUswtr += element.hydUswtr; //친수용수 - ugwtChr += element.ugwtChr; //지하수충전 - farmUswtr += element.farmUswtr //농업용수 - rvrKeepUswtr += element.rvrKeepUswtr //하천등유지용수 - indstUswtr += element.indstUswtr //공업용수 + item.prfList.filter((e) => e.ym.slice(0, 4) === year).forEach((element) => { + // 누적 + wshwtr += element.wshwtr; + coolUswtr += element.coolUswtr; + cleanUswtr += element.cleanUswtr; + drwtUswtr += element.drwtUswtr; + dltnUswtr += element.dltnUswtr; + ithlRswtr += element.ithlRswtr; + ithlEtcUswtr += element.ithlEtcUswtr; + cleanToilUswtr += element.cleanToilUswtr; + resn += element.resn; + lndwtr += element.lndwtr; + hydUswtr += element.hydUswtr; + ugwtChr += element.ugwtChr; + farmUswtr += element.farmUswtr; + rvrKeepUswtr += element.rvrKeepUswtr; + indstUswtr += element.indstUswtr; + // 월별 합계 + inUsageSum = element.wshwtr + + element.coolUswtr + + element.cleanUswtr + + element.drwtUswtr + + element.dltnUswtr + + element.ithlRswtr + + element.ithlEtcUswtr + + element.cleanToilUswtr + + element.resn; + outUsageSum = element.lndwtr + + element.hydUswtr + + element.ugwtChr + + element.farmUswtr + + element.rvrKeepUswtr + + element.indstUswtr; + inUsageArr.push(inUsageSum); + outUsageArr.push(outUsageSum); + + // 막대차트 + const month = Number(element.ym.slice(4, 6)); + barData.push({ label: `${month}월`, "장내용수": inUsageSum, "장외용수": outUsageSum }); + + // 라인차트 + wshwtrData.push({ label: `${month}월`, val: element.wshwtr, color: "red" }); + coolUswtrData.push({ label: `${month}월`, val: element.coolUswtr, color: "orange" }); + cleanUswtrData.push({ label: `${month}월`, val: element.cleanUswtr, color: "yellow" }); + drwtUswtrData.push({ label: `${month}월`, val: element.drwtUswtr, color: "pink" }); + dltnUswtrData.push({ label: `${month}월`, val: element.dltnUswtr, color: "purple" }); + ithlRswtrData.push({ label: `${month}월`, val: element.ithlRswtr, color: "green" }); + ithlEtcUswtrData.push({ label: `${month}월`, val: element.ithlEtcUswtr, color: "blue" }); + cleanToilUswtrData.push({ label: `${month}월`, val: element.cleanToilUswtr, color: "magenta" }); + resnData.push({ label: `${month}월`, val: element.resn, color: "skyblue" }); + + lndwtrData.push({ label: `${month}월`, val: element.lndwtr, color: "red" }); + hydUswtrData.push({ label: `${month}월`, val: element.hydUswtr, color: "orange" }); + ugwtChrData.push({ label: `${month}월`, val: element.ugwtChr, color: "yellow" }); + farmUswtrData.push({ label: `${month}월`, val: element.farmUswtr, color: "green" }); + rvrKeepUswtrData.push({ label: `${month}월`, val: element.rvrKeepUswtr, color: "blue" }); + indstUswtrData.push({ label: `${month}월`, val: element.indstUswtr, color: "purple" }); }); - }) - const data: dnChartForm[] = [] - data?.push({ label: "세척수", val: wshwtr, fill: "red" }) - data?.push({ label: "냉각수", val: coolUswtr, fill: "orange" }) - data?.push({ label: "청소수", val: cleanUswtr, fill: "yellow" }) - data?.push({ label: "식수대", val: drwtUswtr, fill: "green" }) - data?.push({ label: "희석용수", val: dltnUswtr, fill: "skyblue" }) - data?.push({ label: "중수도", val: ithlRswtr, fill: "blue" }) - data?.push({ label: "기타", val: ithlEtcUswtr, fill: "purple" }) - data?.push({ label: "청소화장실용수", val: cleanToilUswtr, fill: "red" }) - data?.push({ label: "세척살수용수", val: resn, fill: "orange" }) - data?.push({ label: "조경용수", val: lndwtr, fill: "yellow" }) - data?.push({ label: "친수용수", val: hydUswtr, fill: "green" }) - data?.push({ label: "지하수충전", val: ugwtChr, fill: "skyblue" }) - data?.push({ label: "농업용수", val: farmUswtr, fill: "blue" }) - data?.push({ label: "하천등유지용수", val: rvrKeepUswtr, fill: "purple" }) - data?.push({ label: "공업용수", val: indstUswtr, fill: "black" }) - setChartData(data); - } - }, [rawData, year]) + }); + // 도넛차트 데이터 + dnData.push({ label: "세척수", val: wshwtr, fill: "red" }); + dnData.push({ label: "냉각수", val: coolUswtr, fill: "orange" }); + dnData.push({ label: "청소수", val: cleanUswtr, fill: "yellow" }); + dnData.push({ label: "식수대", val: drwtUswtr, fill: "green" }); + dnData.push({ label: "희석용수", val: dltnUswtr, fill: "skyblue" }); + dnData.push({ label: "중수도", val: ithlRswtr, fill: "blue" }); + dnData.push({ label: "기타", val: ithlEtcUswtr, fill: "purple" }); + dnData.push({ label: "청소화장실용수", val: cleanToilUswtr, fill: "red" }); + dnData.push({ label: "세척살수용수", val: resn, fill: "orange" }); + dnData.push({ label: "조경용수", val: lndwtr, fill: "yellow" }); + dnData.push({ label: "친수용수", val: hydUswtr, fill: "green" }); + dnData.push({ label: "지하수충전", val: ugwtChr, fill: "skyblue" }); + dnData.push({ label: "농업용수", val: farmUswtr, fill: "blue" }); + dnData.push({ label: "하천등유지용수", val: rvrKeepUswtr, fill: "purple" }); + dnData.push({ label: "공업용수", val: indstUswtr, fill: "black" }); + + // 장내용수 도넛 + dnInData.push({ label: "세척수", val: wshwtr, fill: "yellow" }); + dnInData.push({ label: "냉각수", val: coolUswtr, fill: "green" }); + dnInData.push({ label: "청소수", val: cleanUswtr, fill: "yellow" }); + dnInData.push({ label: "식수대", val: drwtUswtr, fill: "green" }); + dnInData.push({ label: "희석용수", val: dltnUswtr, fill: "yellow" }); + dnInData.push({ label: "중수도", val: ithlRswtr, fill: "green" }); + dnInData.push({ label: "기타", val: ithlEtcUswtr, fill: "yellow" }); + dnInData.push({ label: "청소화장실용수", val: cleanToilUswtr, fill: "green" }); + dnInData.push({ label: "세척살수용수", val: resn, fill: "yellow" }); + + // 장외용수 도넛 + dnOutData.push({ label: "조경용수", val: lndwtr, fill: "yellow" }); + dnOutData.push({ label: "친수용수", val: hydUswtr, fill: "black" }); + dnOutData.push({ label: "지하수충전", val: ugwtChr, fill: "yellow" }); + dnOutData.push({ label: "농업용수", val: farmUswtr, fill: "black" }); + dnOutData.push({ label: "하천등유지용수", val: rvrKeepUswtr, fill: "yellow" }); + dnOutData.push({ label: "공업용수", val: indstUswtr, fill: "black" }); + + // 라인차트 데이터 + setInLineData({ + chartData1: wshwtrData, + chartData2: coolUswtrData, + chartData3: cleanUswtrData, + chartData4: drwtUswtrData, + chartData5: dltnUswtrData, + chartData6: ithlRswtrData, + chartData7: ithlEtcUswtrData, + chartData8: cleanToilUswtrData, + chartData9: resnData + }); + setOutLineData({ + chartData1: lndwtrData, + chartData2: hydUswtrData, + chartData3: ugwtChrData, + chartData4: farmUswtrData, + chartData5: rvrKeepUswtrData, + chartData6: indstUswtrData, + }); + setBarData(barData); + setChartData(dnData); + setDnInUsage(dnInData); + setDnOutUsage(dnOutData); + } + }, [rawData, year]); useEffect(() => { const newChartConfig = chartData.reduce((config, element) => { @@ -196,46 +329,6 @@ export default function PbnstPrfmncSttn() { setChartConfig(newChartConfig); }, [chartData]); - // 장내용수 도넛차트 - useEffect(() => { - let wshwtr = 0; - let coolUswtr = 0; - let cleanUswtr = 0; - let drwtUswtr = 0; - let dltnUswtr = 0; - let ithlRswtr = 0; - let ithlEtcUswtr = 0; - let cleanToilUswtr = 0; - let resn = 0; - if (rawData) { - rawData.forEach((item) => { - item.prfList.filter((e) => e.ym.slice(0, 4) === year) .forEach((element) => { - - wshwtr += element.wshwtr; //세척수 - coolUswtr += element.coolUswtr; //냉각수 - cleanUswtr += element.cleanUswtr; //청소수 - drwtUswtr += element.drwtUswtr; //식수대 - dltnUswtr += element.dltnUswtr //희석용수 - ithlRswtr += element.ithlRswtr //중수도 - ithlEtcUswtr += element.ithlEtcUswtr //기타 - cleanToilUswtr += element.cleanToilUswtr //청소화장실용수 - resn += element.resn //세척살수용수 - }); - }) - const data: dnChartForm[] = [] - data?.push({ label: "세척수", val: wshwtr, fill: "yellow" }) - data?.push({ label: "냉각수", val: coolUswtr, fill: "green" }) - data?.push({ label: "청소수", val: cleanUswtr, fill: "yellow" }) - data?.push({ label: "식수대", val: drwtUswtr, fill: "green" }) - data?.push({ label: "희석용수", val: dltnUswtr, fill: "yellow" }) - data?.push({ label: "중수도", val: ithlRswtr, fill: "green" }) - data?.push({ label: "기타", val: ithlEtcUswtr, fill: "yellow" }) - data?.push({ label: "청소화장실용수", val: cleanToilUswtr, fill: "green" }) - data?.push({ label: "세척살수용수", val: resn, fill: "yellow" }) - setDnInUsage(data); - } - }, [rawData, year]) - useEffect(() => { const newChartConfig = dnInUsage.reduce((config, element) => { config[element.label] = { @@ -247,37 +340,6 @@ export default function PbnstPrfmncSttn() { setDnInChartConfig(newChartConfig); }, [dnInUsage]); - // 장외용수 도넛차트 - useEffect(() => { - let lndwtr = 0; - let hydUswtr = 0; - let ugwtChr = 0; - let farmUswtr = 0; - let rvrKeepUswtr = 0; - let indstUswtr = 0; - if (rawData) { - rawData.forEach((item) => { - item.prfList.filter((e) => e.ym.slice(0, 4) === year) .forEach((element) => { - lndwtr += element.lndwtr; //조경용수 - hydUswtr += element.hydUswtr; //친수용수 - ugwtChr += element.ugwtChr; //지하수충전 - farmUswtr += element.farmUswtr //농업용수 - rvrKeepUswtr += element.rvrKeepUswtr //하천등유지용수 - indstUswtr += element.indstUswtr //공업용수 - - }); - }) - const data: dnChartForm[] = [] - data?.push({ label: "조경용수", val: lndwtr, fill: "yellow" }) - data?.push({ label: "친수용수", val: hydUswtr, fill: "black" }) - data?.push({ label: "지하수충전", val: ugwtChr, fill: "yellow" }) - data?.push({ label: "농업용수", val: farmUswtr, fill: "black" }) - data?.push({ label: "하천등유지용수", val: rvrKeepUswtr, fill: "yellow" }) - data?.push({ label: "공업용수", val: indstUswtr, fill: "black" }) - setDnOutUsage(data); - } - }, [rawData, year]) - useEffect(() => { const newChartConfig = dnOutUsage.reduce((config, element) => { config[element.label] = { @@ -289,69 +351,6 @@ export default function PbnstPrfmncSttn() { setDnOutChartConfig(newChartConfig); }, [dnOutUsage]); - //월별 장내외 용수 총 실적 막대차트 - useEffect(() => { - let wshwtr = 0; - let coolUswtr = 0; - let cleanUswtr = 0; - let drwtUswtr = 0; - let dltnUswtr = 0; - let ithlRswtr = 0; - let ithlEtcUswtr = 0; - let cleanToilUswtr = 0; - let resn = 0; - let lndwtr = 0; - let hydUswtr = 0; - let ugwtChr = 0; - let farmUswtr = 0; - let rvrKeepUswtr = 0; - let indstUswtr = 0; - let inUsageSum = 0; - let outUsageSum = 0; - let inUsageArr = []; - let outUsageArr = []; - - - if (rawData) { - const data: barChartForm[] = [] - rawData.forEach((item) => { - item.prfList - .filter((e) => e.ym.slice(0, 4) === year) .forEach((element) => { - - wshwtr = element.wshwtr; //세척수 - coolUswtr = element.coolUswtr; //냉각수 - cleanUswtr = element.cleanUswtr; //청소수 - drwtUswtr = element.drwtUswtr; //식수대 - dltnUswtr = element.dltnUswtr //희석용수 - ithlRswtr = element.ithlRswtr //중수도 - ithlEtcUswtr = element.ithlEtcUswtr //기타 - cleanToilUswtr = element.cleanToilUswtr //청소화장실용수 - resn = element.resn //세척살수용수 - - lndwtr = element.lndwtr; //조경용수 - hydUswtr = element.hydUswtr; //친수용수 - ugwtChr = element.ugwtChr; //지하수충전 - farmUswtr = element.farmUswtr //농업용수 - rvrKeepUswtr = element.rvrKeepUswtr //하천등유지용수 - indstUswtr = element.indstUswtr //공업용수 - - inUsageSum = wshwtr + coolUswtr + cleanUswtr + drwtUswtr + dltnUswtr + ithlRswtr + ithlEtcUswtr + cleanToilUswtr + resn; - inUsageArr.push(inUsageSum) - outUsageSum = lndwtr + hydUswtr + ugwtChr + farmUswtr + rvrKeepUswtr + indstUswtr; - outUsageArr.push(outUsageSum) - - const month = Number(element.ym.slice(4, 6)) - data.push({ label: `${month}월`, "장내용수": inUsageSum, "장외용수": outUsageSum }) - - }, - ); - - }) - - setBarData(data); - } - }, [rawData, year]) - useEffect(() => { const newChartConfig = barData.reduce((config, element) => { config[element.label] = { @@ -363,51 +362,6 @@ export default function PbnstPrfmncSttn() { setBarChartConfig(newChartConfig); }, [barData]); - //월별 장내 용수 실적 라인차트 - useEffect(() => { - - if (rawData) { - const wshwtrData: lineChartDataProps[] = [] - const coolUswtrData: lineChartDataProps[] = [] - const cleanUswtrData: lineChartDataProps[] = [] - const drwtUswtrData: lineChartDataProps[] = [] - const dltnUswtrData: lineChartDataProps[] = [] - const ithlRswtrData: lineChartDataProps[] = [] - const ithlEtcUswtrData: lineChartDataProps[] = [] - const cleanToilUswtrData: lineChartDataProps[] = [] - const resnData: lineChartDataProps[] = [] - rawData.forEach((item) => { - item.prfList.filter((e) => e.ym.slice(0, 4) === year) .forEach((element) => { - const month = Number(element.ym.slice(4, 6)) - wshwtrData.push({ label: `${month}월`, val: element.wshwtr, color: "red" }) - coolUswtrData.push({ label: `${month}월`, val: element.coolUswtr, color: "red" }) - cleanUswtrData.push({ label: `${month}월`, val: element.cleanUswtr, color: "red" }) - drwtUswtrData.push({ label: `${month}월`, val: element.drwtUswtr, color: "red" }) - dltnUswtrData.push({ label: `${month}월`, val: element.dltnUswtr, color: "red" }) - ithlRswtrData.push({ label: `${month}월`, val: element.ithlRswtr, color: "red" }) - ithlEtcUswtrData.push({ label: `${month}월`, val: element.ithlEtcUswtr, color: "red" }) - cleanToilUswtrData.push({ label: `${month}월`, val: element.cleanToilUswtr, color: "red" }) - resnData.push({ label: `${month}월`, val: element.resn, color: "red" }) - - }, - ); - }) - const rtndata = { - chartData1: wshwtrData, - chartData2: coolUswtrData, - chartData3: cleanUswtrData, - chartData4: drwtUswtrData, - chartData5: dltnUswtrData, - chartData6: ithlRswtrData, - chartData7: ithlEtcUswtrData, - chartData8: cleanToilUswtrData, - chartData9: resnData - } - - setInLineData(rtndata) - } - }, [rawData, year]) - useEffect(() => { if (inLineData?.chartData1) { const newChartConfig = { @@ -452,37 +406,6 @@ export default function PbnstPrfmncSttn() { } }, [inLineData]); - //월별 장외 용수 실적 라인차트 - useEffect(() => { - if (rawData) { - const lndwtrData: lineChartDataProps[] = [] - const hydUswtrData: lineChartDataProps[] = [] - const ugwtChrData: lineChartDataProps[] = [] - const farmUswtrData: lineChartDataProps[] = [] - const rvrKeepUswtrData: lineChartDataProps[] = [] - const indstUswtrData: lineChartDataProps[] = [] - rawData.forEach((item) => { - item.prfList.filter((e) => e.ym.slice(0, 4) === year) .forEach((element) => { - const month = Number(element.ym.slice(4, 6)) - lndwtrData.push({ label: `${month}월`, val: element.lndwtr, color: "red" }) - hydUswtrData.push({ label: `${month}월`, val: element.hydUswtr, color: "red" }) - ugwtChrData.push({ label: `${month}월`, val: element.ugwtChr, color: "red" }) - farmUswtrData.push({ label: `${month}월`, val: element.farmUswtr, color: "red" }) - rvrKeepUswtrData.push({ label: `${month}월`, val: element.rvrKeepUswtr, color: "red" }) - indstUswtrData.push({ label: `${month}월`, val: element.indstUswtr, color: "red" }) - }, - ); - }) - setOutLineData({ - chartData1: lndwtrData, - chartData2: hydUswtrData, - chartData3: ugwtChrData, - chartData4: farmUswtrData, - chartData5: rvrKeepUswtrData, - chartData6: indstUswtrData, - }) - } - }, [rawData, year]) useEffect(() => { if (outLineData?.chartData1) { @@ -526,6 +449,16 @@ export default function PbnstPrfmncSttn() { setbdstTable(prfmncRes); }, [prfmncRes]); + const [searchYear, setSearchYear] = useState( + String(new Date().getFullYear()) + ); + + useEffect(() => { + if (pbnRuseNm.length > 1) + pbnNmSearch("1", "23", ref.current, pbnRuseNm, searchYear); + }, [pbnRuseNm]); + + return ( <> @@ -566,13 +499,17 @@ export default function PbnstPrfmncSttn() { value={toDate} onSelectValue={(val: string | number) => setToDate(String(val))} />
- { - setSwtrmtFcltNm(e); - }} /> + { + setPbnRuseNm(searchNm || ""); + }} + setRtnData={function (rtnData: any[]): void { + setbdstTable(rtnData); + }} + searchList={pbnstSttn.pbnstSearchData || []} + > { }} + excelClick={excelClick} initClick={function (): void { }} btnClass={btnClass} ref={ref} isAdmin={false} /> @@ -680,7 +617,7 @@ export default function PbnstPrfmncSttn() { - + ) } diff --git a/apps/wr/app/store/common/code/index.ts b/apps/wr/app/store/common/code/index.ts index 6caabcb5c..74001b27c 100644 --- a/apps/wr/app/store/common/code/index.ts +++ b/apps/wr/app/store/common/code/index.ts @@ -31,18 +31,18 @@ const bdstUsgCd: SelectDataType[] = [ { val: '16', text: "기타" }, ]; //빗물 집수면 종류 용도 -const rainFcltCd = [ - { val: "1", text: "지붕" }, - { val: "2", text: "건물옥상" }, - { val: "3", text: "골프장 연못" }, - { val: "4", text: "운동장 바닥" }, - { val: "5", text: "운동장 지붕" }, - { val: "6", text: "주차장" }, - { val: "7", text: "태양광패널" }, - { val: "8", text: "연못" }, - { val: "9", text: "기타" }, - { val: "10", text: "확인불가" }, -]; +// const rainFcltCd = [ +// { val: "1", text: "지붕" }, +// { val: "2", text: "건물옥상" }, +// { val: "3", text: "골프장 연못" }, +// { val: "4", text: "운동장 바닥" }, +// { val: "5", text: "운동장 지붕" }, +// { val: "6", text: "주차장" }, +// { val: "7", text: "태양광패널" }, +// { val: "8", text: "연못" }, +// { val: "9", text: "기타" }, +// { val: "10", text: "확인불가" }, +// ]; // 중수도 필수 원수종류 const rswtBdstType: SelectDataType[] = [ { text: "숙박업", val: "17" }, @@ -138,6 +138,19 @@ export const buildingType = { HTB:"HTB" } +const rainFcltCd = [ + { val: "지붕", text: "지붕" }, + { val: "건물옥상", text: "건물옥상" }, + { val: "골프장 연못", text: "골프장 연못" }, + { val: "운동장 바닥", text: "운동장 바닥" }, + { val: "운동장 지붕", text: "운동장 지붕" }, + { val: "주차장", text: "주차장" }, + { val: "태양광패널", text: "태양광패널" }, + { val: "연못", text: "연못" }, + { val: "기타", text: "기타" }, + { val: "확인불가", text: "확인불가" }, +]; + export type comCodeState = { code: { isInit: boolean; 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/headList.tsx b/apps/wr/app/store/matDmd/coMatRvw/headList.tsx index b13796950..7b43e4b00 100644 --- a/apps/wr/app/store/matDmd/coMatRvw/headList.tsx +++ b/apps/wr/app/store/matDmd/coMatRvw/headList.tsx @@ -187,13 +187,13 @@ export const rateFeeHeadListExport: CommonTableProps[] = [ ]; export const usageProcData = [ - { usage: "청소", process: "총인처리시설 + 염소소독" }, - { usage: "화장실용수", process: "총인처리시설 + 염소소독" }, - { usage: "세척", process: "총인처리시설 + UV소독" }, - { usage: "살수", process: "총인처리시설 + UV소독" }, - { usage: "조경", process: "총인처리시설 + UV소독" }, - { usage: "농업", process: "총인처리시설 + UV소독" }, - { usage: "하천", process: "총인처리시설 + UV소독" }, - { usage: "지하수", process: "전처리시설 + RO" }, - { usage: "공업", process: "전처리시설 + RO" }, + { usage: "청소", process: "총인처리시설+염소소독" }, + { usage: "화장실용수", process: "총인처리시설+염소소독" }, + { usage: "세척", process: "총인처리시설+UV소독" }, + { usage: "살수", process: "총인처리시설+UV소독" }, + { usage: "조경", process: "총인처리시설+UV소독" }, + { usage: "농업", process: "총인처리시설+UV소독" }, + { usage: "하천", process: "총인처리시설+UV소독" }, + { usage: "지하수", process: "전처리시설+RO" }, + { usage: "공업", process: "전처리시설+RO" }, ]; diff --git a/apps/wr/app/store/matDmd/coMatRvw/type.tsx b/apps/wr/app/store/matDmd/coMatRvw/type.tsx index b4990c7eb..9f146c0fb 100644 --- a/apps/wr/app/store/matDmd/coMatRvw/type.tsx +++ b/apps/wr/app/store/matDmd/coMatRvw/type.tsx @@ -62,7 +62,7 @@ import { z } from "zod"; dmdInfoSn: z.number(), usgPrcsProcs: z.string().nullish(), cstrnCst: z.number(), - fcltSbsdEpsTrf: z.number(), + fcltSbsdCstrnCst: z.number(), prcsFcltCpctCstrnCst: z.number() }); @@ -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(), @@ -93,6 +93,8 @@ import { z } from "zod"; demandMatching: DemandMatchingSchema.nullish(), demandCst: DemandCstSchema, ruseUtztnFcltNm:z.string().nullish(), + totalConstCost:z.number().nullish(), + }); @@ -113,7 +115,7 @@ export type DedMatUpdateType = dmdInfoSn: number; usgPrcsProcs: string; cstrnCst: number; - fcltSbsdEpsTrf: number; + fcltSbsdCstrnCst: number; prcsFcltCpctCstrnCst: number; rgtr: string; } diff --git a/apps/wr/app/store/matDmd/ruseRvwHstry/index.tsx b/apps/wr/app/store/matDmd/ruseRvwHstry/index.tsx index 698a49abb..3338bc467 100644 --- a/apps/wr/app/store/matDmd/ruseRvwHstry/index.tsx +++ b/apps/wr/app/store/matDmd/ruseRvwHstry/index.tsx @@ -8,6 +8,7 @@ import { ruseHstryHeadListExport } from "./headList"; import { fetchType, getFetch, postFectch, putFectch } from "@/components/lib/api"; import type { DmdCoReqType } from "../coMatRvw/type"; import toast from "react-hot-toast"; +import { TEST_UUID } from "../../ruseFcltMng/fcltReg/rainReg"; const ruseHistHeadList = ruseHstryHeadListExport; @@ -29,6 +30,21 @@ export const ruseHstryStateExport: ruseHstryState = { export type ruseHstryType = ruseHstryState & ruseHstryActions; +// +export const addRgtrAndMdfrToDemandObj = (data: DmdCoReqType) => { + // 최상위 demand 객체 + // demandCo가 있을 경우 + if (data.demandCo) { + data.demandCo.rgtr = TEST_UUID; + data.demandCo.mdfr = TEST_UUID; + } + + + return data; +}; + + + type ruseHstryActions = { ruseRvwHistInit: ( pageNo: number, @@ -54,7 +70,7 @@ type ruseHstryActions = { endYear: string, sggCd: string ) => void; - ruseRvwComplete:( data: string[]) => void; + ruseRvwComplete:( data: Number[]) => void; }; const irvwHistInit = async ( @@ -62,14 +78,13 @@ const irvwHistInit = async ( pageCnt: number, startYear: string, endYear: string, - sggCd?: string ) => { let url = `/reuseFc/request/infoList/matched/${pageNo}/${pageCnt}/${startYear}/${endYear}`; - console.log("sggCd ", sggCd); - if (sggCd) { - url += `/${sggCd}`; - } + // console.log("sggCd ", sggCd); + // if (sggCd) { + // url += `/${sggCd}`; + // } const rvwHistRes = await getFetch(fetchType.WR, url); @@ -92,7 +107,7 @@ export const ruseHstryActionsExport: (set: any) => ruseHstryActions = ( pageCnt, startYear, endYear, - sggCd + // sggCd ); return set((state: ruseHstryState) => ({ @@ -106,9 +121,11 @@ export const ruseHstryActionsExport: (set: any) => ruseHstryActions = ( }, ruseRvwCalUpdate: async (data: DmdCoReqType) => { try { + + const updatedData = addRgtrAndMdfrToDemandObj(data); const update = await putFectch( `/reuseFc/request/cst`, - JSON.stringify(data) + updatedData ); if (update.status === 200) { toast.success("매칭 계산 저장이 완료입니다."); @@ -117,7 +134,6 @@ export const ruseHstryActionsExport: (set: any) => ruseHstryActions = ( 10, new Date().getFullYear().toString(), new Date().getFullYear().toString(), - "0" ); return set((state: ruseHstryState) => ({ ...state, @@ -193,11 +209,11 @@ export const ruseHstryActionsExport: (set: any) => ruseHstryActions = ( console.log(" error ", e); } }, - ruseRvwComplete: async (data: string[]) => { + ruseRvwComplete: async (data: Number[]) => { try { const complet = await postFectch( `/reuseFc/request/completeCheck`, - JSON.stringify(data), + data, fetchType.WR ); if (complet.status === 200) { @@ -207,7 +223,6 @@ export const ruseHstryActionsExport: (set: any) => ruseHstryActions = ( 10, new Date().getFullYear().toString(), new Date().getFullYear().toString(), - "0" ); } } catch (e) { diff --git a/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/index.tsx b/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/index.tsx index e72d6def6..37c010890 100644 --- a/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/index.tsx +++ b/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/index.tsx @@ -4,6 +4,7 @@ import type { pubHasuType } from "../../ruseFcltMng/fcltReg/pbnstReg/type"; import type { FcPrfType, PrfType } from "./type"; import type { TableUpperProps } from "../../common/type/header"; import { ToastFormUi } from "@/components/ui/toast/toastFromUi"; +import toast from "react-hot-toast"; const pbnstPrfmncHeadList = pbnstPrfmncHeadListExport; const monthHeadList = monthHeadListExport; @@ -94,18 +95,13 @@ export const pbnstPrfmncActionsExport: (set: any) => pbnstPrfmncActions = ( console.log('ressponse ', ressponse) if(ressponse.status === 200){ - ToastFormUi({ - body: "하수재이용 시설 실적 등록이 완료되었습니다. ", - title: "하수재이용 시설 실적 등록", - }); + + toast.success("하수재이용 시설 실적 등록이 완료되었습니다.") } }catch(e){ console.log(e) - ToastFormUi({ - body: "하수재이용 시설 실적 등록이 실패하였습니다. ", - title: "하수재이용 시설 실적 등록", - }); + toast.error("하수재이용 시설 실적 등록이 실패하였습니다.") } }, diff --git a/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/type.tsx b/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/type.tsx index 3bd741663..f6d5ff43f 100644 --- a/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/type.tsx +++ b/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/type.tsx @@ -164,6 +164,9 @@ export const initValInUsage = [ "11월": 0, "12월": 0, }, +]; + +export const initValOutUsage = [ { usage: "resn", 용수명: "세척살수용수", @@ -198,9 +201,6 @@ export const initValInUsage = [ "11월": 0, "12월": 0, }, -]; - -export const initValOutUsage = [ { usage: "lndwtr", 용수명: "조경용수", diff --git a/apps/wr/app/store/prfmncSttn/pbnstPrfmncSttn/excel.tsx b/apps/wr/app/store/prfmncSttn/pbnstPrfmncSttn/excel.tsx new file mode 100644 index 000000000..113a35289 --- /dev/null +++ b/apps/wr/app/store/prfmncSttn/pbnstPrfmncSttn/excel.tsx @@ -0,0 +1,24 @@ +export const excelPrfmncSttnParsing = ( + data: any[] +): string[][] => { + const excelExportData: string[][] = []; + data.forEach((item) => { + excelExportData.push([ + item.용수명, + item.total, + item["1월"], + item["2월"], + item["3월"], + item["4월"], + item["5월"], + item["6월"], + item["7월"], + item["8월"], + item["9월"], + item["10월"], + item["11월"], + item["12월"], + ]); + }); + return excelExportData; +}; \ No newline at end of file diff --git a/apps/wr/app/store/prfmncSttn/pbnstPrfmncSttn/index.tsx b/apps/wr/app/store/prfmncSttn/pbnstPrfmncSttn/index.tsx index e47301b48..d0e958785 100644 --- a/apps/wr/app/store/prfmncSttn/pbnstPrfmncSttn/index.tsx +++ b/apps/wr/app/store/prfmncSttn/pbnstPrfmncSttn/index.tsx @@ -86,7 +86,7 @@ export const pbnstPrfmncSttnActionsExport: (set: any) => pbnstPrfmncSttnActions yearHead[0].title = i + "년도" } yearHeader = [...yearHeader, ...yearHead] - selectList.push({text: i + "년도", val: String(i)} ) + selectList.push({ text: i + "년도", val: String(i) }) } set((state: pbnstPrfmncSttnState) => { return { @@ -142,7 +142,6 @@ export const pbnstPrfmncSttnActionsExport: (set: any) => pbnstPrfmncSttnActions bscFctCdList, `wr`, ) - let inUsageSum = 0; let outUsageSum = 0; let usageSum = 0; @@ -176,9 +175,6 @@ export const pbnstPrfmncSttnActionsExport: (set: any) => pbnstPrfmncSttnActions resData.push({ ...data, ...acc }) } }) - - - return set((state: pbnstPrfmncSttnState) => ({ ...state, pbnstPrfmncSttn: { diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx index 9fde9c092..fb799c26c 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx @@ -24,6 +24,7 @@ import { fcOrgwtsHeadListExport, } from "./headList"; import type { TableUpperProps } from "@/app/store/common/type/header"; +import toast from "react-hot-toast"; const selectLabel: SelectDataType[] = [{ text: "test", val: "1" }]; const pubFacHeadList = pubFacHeadListExport; @@ -62,9 +63,9 @@ type pubFacActions = { appendRuseFclt(array: customPbnst[]): void; fileDelete: (atflCd: string) => void; fileDownLoad: (atflCd: string) => void; - pbnstMngData: (data: customPbnst[]) => void; - pbnstBizData(data: fcBizType): void; - getBizCycle: (pbnstObj: customPbnst) => void; + //pbnstMngData: (data: customPbnst[]) => void; + //pbnstBizData(data: fcBizType): void; + // getBizCycle: (pbnstObj: customPbnst) => void; getpbnstInsertIndex: (data: pbnstInsertIndex) => void; pbnstRuseFcltUpdate: (ruseRes: customPbnst[]) => void; pbnstRuseBizUpdate: (ruseRes: fcBizType[]) => void; @@ -100,14 +101,20 @@ const checkWrRegList = async () => { const hasuListFetch = async (page: string, sggOrCity: string, searchTxt?:string) => { const checkWrRegListRes = await checkWrRegList(); -let url = `/prcsFclt/ruseInfo/${page ? page : 1}/10/A/${sggOrCity ? sggOrCity : "11"}/0/1/SW`; + + console.log(' checkWrRegListRes ', checkWrRegListRes) +let url = `/prcsFclt/ruseInfo/${page ? page : 1}/10/A/${sggOrCity? sggOrCity : "11"}/0/1/SW`; + + +const data = checkWrRegListRes.filter((item:string) => item !== "") + console.log(' checkWrRegListRes ' ) if(searchTxt){ url= url +`/${searchTxt}` } const rainRes = await postFectch( url, - checkWrRegListRes, + data, fetchType.COMMON ); @@ -200,7 +207,6 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { pbnstRegClick: async (pubHasuRes: pubHasuType) => { try { const pbnstRes = await initFetch(pubHasuRes.bscFctCd); - console.log('pbnstRes ' , pbnstRes) return set((state: pubFacState) => ({ ...state, pbnst: { @@ -234,14 +240,19 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { const response = await postFectch( `/reuseFc/pubFc`, - JSON.stringify( pbnstRes) + pbnstRes ); + if( response.status === 200) { + toast.success(`${pbnstRes.ruseUtztnFcltNm} 하수재이용 시설이 등록되었습니다.`); + } + const pbnstHasuRes = await hasuListFetch('1', '0'); + return set((state: pubFacState) => ({ ...state, pbnst: { ...state.pbnst, - pbnstRes: response.data, + pbnstRes: pbnstHasuRes, isInit: false, }, })); @@ -334,41 +345,41 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { } }, - pbnstMngData: (data: customPbnst[]) => { - if (data.length > 0) { - } - return set((state: pubFacState) => { - state.pbnst.pbnstMngRegData = data; - state.pbnst.pbnstBizCycle = - data.length <= 0 - ? [{ text: "없음", val: "1" }] - : state.pbnst.pbnstBizCycle; - return state; - }); - }, + // pbnstMngData: (data: customPbnst[]) => { + // if (data.length > 0) { + // } + // return set((state: pubFacState) => { + // state.pbnst.pbnstMngRegData = data; + // state.pbnst.pbnstBizCycle = + // data.length <= 0 + // ? [{ text: "없음", val: "1" }] + // : state.pbnst.pbnstBizCycle; + // return state; + // }); + // }, - pbnstBizData: (data: fcBizType) => { - return set((state: pubFacState) => { - if (state.pbnst.pbnstMngRegData) { - const regData = state.pbnst.pbnstMngRegData.find( - (item) => data.pbnstRuseFcltFk === item.pbnstRuseFcltPk - ); - if (regData) { - const bizIdx = regData.fcBizs.findIndex( - (item) => item.pbnstRuseFcltBizPk == data.pbnstRuseFcltBizPk - ); + // pbnstBizData: (data: fcBizType) => { + // return set((state: pubFacState) => { + // if (state.pbnst.pbnstMngRegData) { + // const regData = state.pbnst.pbnstMngRegData.find( + // (item) => data.pbnstRuseFcltFk === item.pbnstRuseFcltPk + // ); + // if (regData) { + // const bizIdx = regData.fcBizs.findIndex( + // (item) => item.pbnstRuseFcltBizPk == data.pbnstRuseFcltBizPk + // ); - if (bizIdx >= 0) { - regData.fcBizs[bizIdx] = data; - const pbnstData = state.pbnst.pbnstMngRegData - state.pbnst.pbnstMngRegData= [...pbnstData] + // if (bizIdx >= 0) { + // regData.fcBizs[bizIdx] = data; + // const pbnstData = state.pbnst.pbnstMngRegData + // state.pbnst.pbnstMngRegData= [...pbnstData] - } - } - } - return state; - }); - }, + // } + // } + // } + // return state; + // }); + // }, getpbnstInsertIndex: async (data: pbnstInsertIndex) => { return set((state: pubFacState) => { state.pbnst.pbnsUpdateIndex = data; diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx index fb9515bcf..a34985810 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx @@ -57,7 +57,7 @@ export type PbnstDemandComType = { dmdAplyPswd: string | ''; splyCpct: number | 0; splyFmYn:string|'Y' - dmdInfoFk:string|'' +// dmdInfoFk:string|'' } const pubHasuZod = z.object({ @@ -129,14 +129,14 @@ const fcOrgwtSchema = z.object({ }); const dmdColist = z.object({ - dmdInfoFk: z.string().default(''), + dmdInfoPk: z.string().default(''), dmdCoNm: z.string().default(''), daddr: z.string(), - useUsgCd: z.string().default(""), + useUsgCd: z.string().nullish(), splyBgngDay: zDateDefaultNow, splyEndDay: zDateDefaultNow, splyCpct: zNumDefaultZero, - splyFmYn: z.string().default('Y'), + splyFmYn: z.string().nullish(), rgtr: z.string().nullish(), mdfr: z.string().nullish(), pbnstRuseFcltBizPk: zNumDefaultZero, @@ -208,7 +208,7 @@ export const fcBizSchema = z.object({ ruseFcltCstClcln: zNumNullish, fcOrgwts: z.array(fcOrgwtSchema).nullish(), pplInstls: z.array(pplInstlSchema).nullish(), - fcDemands: z.array(dmdColist).default([]).nullish(), + fcDemands: z.array(dmdColist).nullish(), flg: z.string().nullish(), regDt: z.string().nullish(), rgtr: z.string().nullish(), diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/htdflSttn/excel.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/htdflSttn/excel.tsx index 671eacae8..591623911 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltSttn/htdflSttn/excel.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/htdflSttn/excel.tsx @@ -1,30 +1,34 @@ +import type { SelectDataType } from "@common/business_components/ui"; import type { customHtdflBdst } from "../../fcltReg/htdflReg"; -export const excelHtdflSttnParsing = (data: customHtdflBdst[]): string[][] => { +export const excelHtdflSttnParsing = ( + data: customHtdflBdst[], + sidoCode: SelectDataType[], + sggCode: SelectDataType[] +): string[][] => { const excelExportData: string[][] = []; data.forEach((item) => { excelExportData.push([ - String(item.cityText??""), - String(item.sggText??""), + sidoCode.find((sido) => sido.val === item.ctpvCd.toString())?.text ?? "", + sggCode.find((sgg) => sgg.val === item.sggCd.toString())?.text ?? "", item.bdstNm ?? "", item.daddr ?? "", String(item.frstArchPrmsnDt ?? ""), String(item.reuseBuilding?.[0]?.htdflObj.etgtType ?? ""), String(item.reuseBuilding?.[0]?.htdflObj.fclCpct ?? ""), // fix: added missing parenthesis - String(item.reuseBuilding?.[0]?.htdflObj.plwtYn ? "Y" :"N"), // fix: added missing parenthesis + String(item.reuseBuilding?.[0]?.htdflObj.plwtYn ? "Y" : "N"), // fix: added missing parenthesis String(item.reuseBuilding?.[0]?.htdflObj.orgwtWtritSpt ?? ""), // fix: added missing parenthesis String(item.reuseBuilding?.[0]?.htdflObj.wtritEntrcTp ?? ""), // fix: removed as it doesn't exist in the provided context String(item.reuseBuilding?.[0]?.htdflObj.orgwtOcrnProcs ?? ""), // fix: removed as it doesn't exist in the provided context - String( item.reuseBuilding?.[0]?.htdflObj?.amtgnr ?? ""), // fix: removed as it doesn't exist in the provided context + String(item.reuseBuilding?.[0]?.htdflObj?.amtgnr ?? ""), // fix: removed as it doesn't exist in the provided context String(item.reuseBuilding?.[0]?.htdflObj?.prcsProcsYn ?? ""), // fix: removed as it doesn't exist in the provided context - String( '컬럼확인'), // fix: removed as it doesn't exist in the provided context String(item.reuseBuilding?.[0]?.htdflObj?.prcsFcltCpct ?? ""), // fix: removed as it doesn't exist in the provided context String(item.reuseBuilding?.[0]?.htdflObj?.fmYn ?? ""), // fix: removed as it doesn't exist in the provided context String(item.reuseBuilding?.[0]?.htdflObj?.utztnCpct ?? ""), // fix: removed as it doesn't exist in the provided context String(item.reuseBuilding?.[0]?.htdflObj?.utztnUsg ?? ""), // fix: removed as it doesn't exist in the provided context String(item.reuseBuilding?.[0]?.htdflObj?.emsnExitTp ?? ""), // fix: removed as it doesn't exist in the provided context - ]); - }); - return excelExportData; + ]); + }); + return excelExportData; }; diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/htdflSttn/headList.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/htdflSttn/headList.tsx index 8de673f16..756c47b9b 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltSttn/htdflSttn/headList.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/htdflSttn/headList.tsx @@ -70,13 +70,6 @@ export const htdflSttHeadListExport: z.infer = [ title: "처리공정여부", visible: true, }, - { - id: "prcsProcstest", - title: "처리공정여부??", - visible: true, - }, - - { id: "prcsFcltCpct", title: "처리시설용량(m³)", @@ -259,36 +252,15 @@ export const htdflSttNodeListExport: CommonTableProps[] = [ rowSpan: 2, colSpan: 1, }, - { - id: "prcsProcs", - title: "처리공정", - upName: "htdflMngInfo", - visible: true, - row: 2, - rowSpan: 1, - colSpan: 2, - }, { id: "prcsProcsYn", title: "처리공정여부", upName: "prcsProcs", visible: true, - row: 3, - rowSpan: 1, + row: 2, + rowSpan: 2, colSpan: 1, }, - - { - id: "prcsProcstest", - title: "처리공정여부??", - upName: "prcsProcs", - visible: true, - row: 3, - rowSpan: 1, - colSpan: 1, - }, - - { id: "prcsFcltCpct", title: "처리시설용량(m³)", 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/app/store/ruseFcltMng/fcltSttn/rainSttn/excel.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/excel.tsx index 8ae786488..13530a81f 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/excel.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/excel.tsx @@ -1,18 +1,23 @@ +import type { SelectDataType } from "@common/business_components/ui"; import type { customRainBdst } from "../../fcltReg/rainReg"; -export const excelRainSttnParsing = (data: customRainBdst[]): string[][] => { +export const excelRainSttnParsing = ( + data: customRainBdst[], + sidoCode: SelectDataType[], + sggCode: SelectDataType[] +): string[][] => { const excelExportData: string[][] = []; data.forEach((item) => { excelExportData.push([ - String(item.ctpvCd), - String(item.sggCd), + sidoCode.find((sido) => sido.val === item.ctpvCd.toString())?.text ?? "", + sggCode.find((sgg) => sgg.val === item.sggCd.toString())?.text ?? "", item.bdstNm ?? "", item.daddr ?? "", String(item.bdstInfoPk ?? ""), String(item.frstArchPrmsnDt ?? ""), String(item.archArea ?? ""), - String(item.chgBuilding.length>0 ? "Y" :"N"), + String(item.chgBuilding.length > 0 ? "Y" : "N"), String(item.reuseBuilding?.[0]?.lawTrgtYn ?? ""), String(item.reuseBuilding?.[0]?.instlCmptnDt ?? ""), String(item.reuseBuilding?.[0]?.instlCst ?? ""), @@ -28,8 +33,8 @@ export const excelRainSttnParsing = (data: customRainBdst[]): string[][] => { String(item.reuseBuilding?.[0]?.grntchBdstCertYr ?? ""), String(item.reuseBuilding?.[0]?.grntchBdstCertNo ?? ""), String(item.reuseBuilding?.[0]?.grntchBdstCertGrd ?? "") - ]); - }); - return excelExportData; + ]); + }); + return excelExportData; }; diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/index.tsx index 853298d51..5aa54ee48 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/index.tsx @@ -13,6 +13,7 @@ import { } from "./headList"; import type { z } from "zod"; import type { CommonTableProps } from "@/app/store/common/type/header"; +import type { SelectDataType } from "@common/business_components/ui"; // 테이블 헤드 리스트 const rainSttHeadList = rainSttHeadListExport; @@ -101,7 +102,7 @@ export type rainSttnState = { }; type rainSttnActions = { rainSttnInit:(con:string) => void - rainSttnSearch: (page: number, total: string, con: string) => void; + rainSttnSearch: (page: number, total: string, con: string, sidoCode: SelectDataType[], sggCode: SelectDataType[]) => void; rainChSttnHead: ( headList: z.infer, ) => void; @@ -148,14 +149,16 @@ export const rainSttnActionsExport: (set: any) => rainSttnActions = ( console.log(e) } }, - rainSttnSearch: async (page: number, total: string, con: string) => { + rainSttnSearch: async (page: number, total: string, con: string, + sidoCode: SelectDataType[], + sggCode: SelectDataType[]) => { try { const rainSttnRes = await getFetch( fetchType.WR, `/reuseFc/rainyInfoList/${page}/${total}/${con}` ); if (Number(total) > 9000) { - const rainExcel = excelRainSttnParsing(rainSttnRes); + const rainExcel = excelRainSttnParsing(rainSttnRes, sidoCode, sggCode); set((state: rainSttnState) => { return { ...state, diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/rswtSttn/excel.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/rswtSttn/excel.tsx index 5c0ecf0b3..ac57a8016 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltSttn/rswtSttn/excel.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/rswtSttn/excel.tsx @@ -1,19 +1,25 @@ +import type { SelectDataType } from "@common/business_components/ui"; import type { customRswtBdst } from "../../fcltReg/rswtReg"; +import { useWrStore } from "@/app/store"; -export const excelRSwtSttnParsing = (data: customRswtBdst[]): string[][] => { +export const excelRSwtSttnParsing = ( + data: customRswtBdst[], + sidoCode: SelectDataType[], + sggCode: SelectDataType[] +): string[][] => { const excelExportData: string[][] = []; data.forEach((item) => { excelExportData.push([ - String(item.ctpvCd), - String(item.sggCd), + sidoCode.find((sido) => sido.val === item.ctpvCd.toString())?.text ?? "", + sggCode.find((sgg) => sgg.val === item.sggCd.toString())?.text ?? "", item.bdstNm ?? "", item.daddr ?? "", String(item.bdstUsgText ?? ""), String(item.frstArchPrmsnDt ?? ""), String(item.archArea ?? ""), String(item.reuseBuilding?.[0]?.rswtrObj.wtrUsqty ?? "0"), //물사용량 - String(item.chgBuilding.length>0 ? "Y" :"N"), //중축・개축・재축여부 + String(item.chgBuilding.length > 0 ? "Y" : "N"), //중축・개축・재축여부 String(item.reuseBuilding?.[0]?.lawTrgtYn ?? ""), //법적의무대상여부 String(item.reuseBuilding?.[0]?.rswtrObj.oblgTrgtWtrUsqty ?? ""), //의무대상물사용량 String(item.reuseBuilding?.[0]?.instlCmptnDt ?? ""), //설치완료일시 @@ -28,7 +34,7 @@ export const excelRSwtSttnParsing = (data: customRswtBdst[]): string[][] => { String(item.reuseBuilding?.[0]?.grntchBdstCertYr ?? ""), String(item.reuseBuilding?.[0]?.grntchBdstCertNo ?? ""), String(item.reuseBuilding?.[0]?.grntchBdstCertGrd ?? "") - ]); - }); - return excelExportData; + ]); + }); + return excelExportData; }; \ No newline at end of file diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/rswtSttn/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/rswtSttn/index.tsx index 775e22e0c..301cd965e 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltSttn/rswtSttn/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/rswtSttn/index.tsx @@ -6,6 +6,7 @@ import { controlHeadView } from "../rainSttn"; import type { sttnHeadListType } from "../rainSttn/headList"; import { excelRSwtSttnParsing } from "./excel"; import { rswtSttHeadListExport, rswtSttNodeListExport } from "./headList"; +import type { SelectDataType } from "@common/business_components/ui"; @@ -26,11 +27,10 @@ export type rswtSttnState = { }; }; - - type rswtSttnActions = { rswtSttnInit: (con: string) => void; - rswtSttnSearch: (page: number, total: string, con: string) => void; + rswtSttnSearch: (page: number, total: string, con: string, sidoCode: SelectDataType[], + sggCode: SelectDataType[]) => void; rswtChSttnHead: ( headList: z.infer, ) => void; @@ -38,8 +38,6 @@ type rswtSttnActions = { export type rswtSttnType = rswtSttnState & rswtSttnActions; - - export const rswtSttnStateExport: rswtSttnState = { rswtSttn: { rswtSttHeadList: rswtSttHeadList, @@ -77,14 +75,16 @@ export const rswtSttnActionsExport: (set: any) => rswtSttnActions = ( console.log(e) } }, - rswtSttnSearch: async (page: number, total: string, con: string) => { + rswtSttnSearch: async (page: number, total: string, con: string, + sidoCode: SelectDataType[], + sggCode: SelectDataType[]) => { try { const rswtSttnRes = await getFetch( fetchType.WR, `/reuseFc/waterreuseFc/${page}/${total}/${con}` ); if (Number(total) > 9000) { - const rswtExcel = excelRSwtSttnParsing(rswtSttnRes); + const rswtExcel = excelRSwtSttnParsing(rswtSttnRes, sidoCode, sggCode); set((state: rswtSttnState) => { return { ...state, diff --git a/apps/wr/components/lib/config/index.ts b/apps/wr/components/lib/config/index.ts index d0e076d81..f85f7bad9 100644 --- a/apps/wr/components/lib/config/index.ts +++ b/apps/wr/components/lib/config/index.ts @@ -8,7 +8,7 @@ export const LOCAL_URL_WR = `http://localhost:${LOCAL_PORT}/api/v1`; export const DEV_URL_WR = `http://con.mind-one.co.kr:${DEV_PORT}/api/v1`; // export const DEV_URL_WR = `http://192.168.0.91:8880/api/v1`; -// export const DEV_URL_FO = `http://192.168.0.91:8882/api/v1`; +/// export const DEV_URL_FO = `http://192.168.0.91:8882/api/v1`; export const DEV_URL_FO = `http://con.mind-one.co.kr:${DEV_PORT_NEW}/api/v1`; diff --git a/apps/wr/components/lib/func/calculateConstCost .tsx b/apps/wr/components/lib/func/calculateConstCost .tsx new file mode 100644 index 000000000..5e9387385 --- /dev/null +++ b/apps/wr/components/lib/func/calculateConstCost .tsx @@ -0,0 +1,101 @@ +export const findBounds = ( + data: any[], + fctCd: string, + dataCode: string, + qtyCode:string, + qty: number +): { lower: any; upper: any } => { + + + 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[qtyCode]) > Number(acc[qtyCode]) ? curr : acc + ) + : undefined; + + 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 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 = ( + rawData: any, + dmndQtyYear: number +): any => { + const result: any = {}; + + for (const key in rawData) { + const item = rawData[key]; + + const range = { + Lower: { + fctCpc: item.lower?.stdCost, + stdCost: item.lower?.rt, + }, + Upper: { + fctCpc: item.upper?.stdCost, + stdCost: item.upper?.rt, + }, + }; + result[key] = getInterpolation(range.Upper, range.Lower, dmndQtyYear); + } + + return result; +}; + +export const getConstFctCode = (fctCd: string) => { + const fctMap: { [key: string]: string } = { + 총인처리시설: "001", + 염소소독: "002", + UV소독: "003", + 전처리시설: "004", + RO: "005", + }; + + return fctMap[fctCd]; +}; diff --git a/apps/wr/components/lib/func/commom.tsx b/apps/wr/components/lib/func/commom.tsx index ba0f5c588..85e1a36b0 100644 --- a/apps/wr/components/lib/func/commom.tsx +++ b/apps/wr/components/lib/func/commom.tsx @@ -153,3 +153,6 @@ export const getdmdMatFlag = (flag: string|undefined) => { } 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 21746c099..b22f9474e 100644 --- a/apps/wr/components/ui/form/coMat/conCostForm/conCostForm.tsx +++ b/apps/wr/components/ui/form/coMat/conCostForm/conCostForm.tsx @@ -6,6 +6,12 @@ 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 { + findBounds, + getConstFctCode, + getInterpolation, + transformAndInterpolate, +} from "@/components/lib/func/calculateConstCost "; import { ConstCostFeeTable } from "@/components/ui/modal/coMat/constCostFeeTable"; import { RateFeeTableModal } from "@/components/ui/modal/coMat/rateFeeModal"; import { @@ -17,8 +23,10 @@ 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, useRef, useState } from "react"; +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, @@ -27,7 +35,14 @@ export default function ConCostForm({ form: UseFormReturn; type: string; }) { - const { coMatRvwUpdate, ruseRvwCalUpdate,getRateFee ,getConstCostFee} = useWrStore((state) => state); + const { + constCostRes, + rateFeeRes, + coMatRvwUpdate, + ruseRvwCalUpdate, + getRateFee, + getConstCostFee, + } = useWrStore((state) => state); const ref = useRef(false); @@ -38,15 +53,7 @@ export default function ConCostForm({ getRateFee(String(currentYear)); ref.current = true; } - }, [ref, getConstCostFee ,getRateFee ]); - - - const [isTrfMo, setIsTrfMo] = useState<{ - isModal: boolean; - }>({ isModal: false }); - const [isCmpttnMo, setIsCmpttnMo] = useState<{ - isModal: boolean; - }>({ isModal: false }); + }, [ref, getConstCostFee, getRateFee]); const zipDowonLoad = () => { fetch(`/2024_constarctFeeProgram.zip`, {}).then(async (response) => { @@ -59,25 +66,88 @@ export default function ConCostForm({ link.click(); }); }; + const usgPrcsProcsWatch = form.watch("demandCst.usgPrcsProcs"); + const dmndQtyWatch = form.watch("dmndQty"); + const totalConstCost = form.watch("totalConstCost"); + const cstrnCst = form.watch("demandCst.cstrnCst"); + const calculateConstCost = useCallback(() => { + const usgPrcsProcs = usgPrcsProcsWatch; + const dmndQtyYear = dmndQtyWatch * 365; + if (usgPrcsProcs && usgPrcsProcs?.length > 0) { + const firstProc = getConstFctCode(usgPrcsProcs?.split("+")[0] || "") || ""; + const secondProc = getConstFctCode(usgPrcsProcs?.split("+")[1] || "") || ""; + + const { lower: firstLower, upper: firstUpper } = findBounds( + constCostRes, + firstProc || "", + 'fctCd', + 'fctCpc', + Number(dmndQtyYear) + ); + const { lower: secondLower, upper: secondUpper } = findBounds( + constCostRes, + secondProc || "", + 'fctCd', + 'fctCpc', + Number(dmndQtyYear) + ); + + const firstConstFee = getInterpolation( + firstUpper, + firstLower, + dmndQtyYear + ); + const secondConstFee = getInterpolation( + secondUpper, + secondLower, + dmndQtyYear + ); + const result = Math.round(firstConstFee + secondConstFee) / 100; + + const groupCodes = ["BD", "CE", "SE", "WD"]; + const groupedBounds: { [key: string]: { lower?: any; upper?: any } } = {}; + for (const code of groupCodes) { + + groupedBounds[code] = findBounds(rateFeeRes, code, 'incExpCd', 'stdCost',result); + } + const resultRate = transformAndInterpolate(groupedBounds, result); + const fcltSbsdCstrnCst = (result* (resultRate.BD + resultRate.CE + resultRate.SE + resultRate.WD) / 100); + const realResult = result + fcltSbsdCstrnCst; + + form.setValue("demandCst.prcsFcltCpctCstrnCst", Math.round(result) ); + form.setValue("demandCst.fcltSbsdCstrnCst", Math.round(fcltSbsdCstrnCst)) ; + form.setValue("totalConstCost", Math.round(realResult)); + } + }, [constCostRes, rateFeeRes, usgPrcsProcsWatch, dmndQtyWatch]); const onSubmit = (value: DmdCoReqType) => { + + if( !form.getValues('demandCst.prcsFcltCpctCstrnCst') ){ + toast.error('공사비 계산 진행 후 저장을 눌러주새요') + return + } if (type === "mat") { const data: DedMatUpdateType = { dmdInfoSn: form.getValues("dmdInfoSn"), usgPrcsProcs: form.getValues("demandCst.usgPrcsProcs"), cstrnCst: form.getValues("demandCst.cstrnCst"), - fcltSbsdEpsTrf: form.getValues("demandCst.fcltSbsdEpsTrf"), + fcltSbsdCstrnCst: form.getValues("demandCst.fcltSbsdCstrnCst"), prcsFcltCpctCstrnCst: form.getValues("demandCst.prcsFcltCpctCstrnCst"), rgtr: TEST_UUID, }; - coMatRvwUpdate("11000SW001R1", form.getValues("dmdInfoFk"), data); + coMatRvwUpdate("11000SW001R1", form.getValues("dmdInfoFk"), data); } else if (type === "hist") { + + delete value.totalConstCost + delete value.ruseUtztnFcltNm + + ruseRvwCalUpdate(value); } }; useEffect(() => { - console.log(" form ", form.formState.errors); + console.log(" form ", form.formState.errors); }, [form.formState]); return ( @@ -90,12 +160,21 @@ export default function ConCostForm({

처리시설 표준공사비 산정

- - + +

기본사항

@@ -111,7 +190,7 @@ export default function ConCostForm({ placeholder="" type="text" onChange={(e) => { - field.onChange((e.target.value)); + field.onChange(e.target.value); }} value={field.value ?? ""} /> @@ -194,9 +273,10 @@ export default function ConCostForm({ type="number" step="0.001" onChange={(e) => { - field.onChange(Number(e.target.value)); + //field.onChange(Number(e.target.value) * 365 ); }} value={Number(field.value) * 365 || 0} + readOnly /> )} @@ -207,14 +287,23 @@ export default function ConCostForm({
- - + + + + } + childrenBody={ + <> + {}} + > + + } + bodyClassName={"w-[40vw] h-full"} + >
)} @@ -236,17 +326,27 @@ export default function ConCostForm({
- - + + + + } + childrenBody={ + <> + {}} + > + + } + bodyClassName={"w-[22vw]"} + >
( )} @@ -286,16 +387,22 @@ export default function ConCostForm({ } bodyClassName={"w-[22vw]"} > - {}} - value={ - form.getValues("demandCst.prcsFcltCpctCstrnCst") + - form.getValues("demandCst.fcltSbsdEpsTrf") || 0 - } + ( + + {}} + value={field.value ?? 0} + readOnly + /> + + )} />
@@ -323,75 +430,37 @@ export default function ConCostForm({ />
- ( - - { - field.onChange(Number(e.target.value)); - }} - value={field.value ?? 0} - /> - - )} - /> -
-
- ( - - )} - /> -
-
- - -
+ ( + + { + field.onChange(Number(e.target.value)); + }} + value={field.value ?? 0} + /> + + )} + /> + +
+ + +
- {}}>} - bodyClass="w-[40vw] h-[40vh] " - open={isTrfMo.isModal} - onOpenChange={(open) => { - setIsTrfMo({ isModal: open }); - }} - /> - {}}>} - bodyClass="w-[40vw] max-w-none h-[40vh]" - open={isCmpttnMo.isModal} - onOpenChange={(open) => { - setIsCmpttnMo({ isModal: open }); - }} - /> ); diff --git a/apps/wr/components/ui/form/fcltReg/htdflReg/htdflRegForm.tsx b/apps/wr/components/ui/form/fcltReg/htdflReg/htdflRegForm.tsx index 9f6869706..70e62eb7f 100644 --- a/apps/wr/components/ui/form/fcltReg/htdflReg/htdflRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/htdflReg/htdflRegForm.tsx @@ -27,9 +27,11 @@ import { formH1Class } from "@/components/lib/class/comClass"; export default function HtdflRegForm({ htdflForm, isModal, + readonly = false }: { htdflForm: customHtdflBdst; isModal: boolean; + readonly?: boolean; }) { const { code, htdflBdstUpdate, htdflBdstReg } = useWrStore((state) => state); @@ -42,9 +44,9 @@ export default function HtdflRegForm({ const onSubmit = (values: z.infer) => { if (isModal) { - htdflBdstReg(values,'41'); + htdflBdstReg(values, '41'); } else { - htdflBdstUpdate(values ,'41'); + htdflBdstUpdate(values, '41'); } }; @@ -84,520 +86,549 @@ export default function HtdflRegForm({ return (
-
- - {/*
*/} -
-
-

온배수 시설 정보

- -
-
- - {isModal && htdflForm != undefined ? : <>} - {isModal ? ( -

- 온배수 시설 정보{" "} -

- ) : ( - <> - )} - -
-
- ( - - - + + + {/*
*/} +
+
+

온배수 시설 정보

+ {!readonly && ( + )} - /> +
-
- ( - - { - handleCommaNumberChange(e, field.onChange); - }} - value={formatCommaNumber(field.value)} - /> - - )} - /> -
-
- ( - - - - )} - /> -
-
-
-

- 온배수 시설 운영현황 -

-
+ {isModal && htdflForm != undefined ? : <>} + {isModal ? ( +

+ 온배수 시설 정보{" "} +

+ ) : ( + <> + )} -
-
- ( - - { - field.onChange(Number(e.target.value)); - }} - /> - - )} - /> -
-
- ( - - - - )} - /> -
-
- ( - - { - handleCommaNumberChange(e, field.onChange); - }} - value={formatCommaNumber(field.value)} - /> - - )} - /> -
-
- ( - - { - handleCommaNumberChange(e, field.onChange); - }} - value={formatCommaNumber(field.value)} - /> - - )} - /> -
-
- ( - - - - )} - /> -
-
- ( - - { - handleCommaNumberChange(e, field.onChange); - }} - value={formatCommaNumber(field.value)} - /> - - )} - /> -
-
- ( - - - - )} - /> -
-
- ( - - { - handleCommaNumberChange(e, field.onChange); - }} - value={formatCommaNumber(field.value)} - /> - - )} - /> -
-
- ( - - - - )} - /> -
-
+
+
+ ( + + { + if (!readonly) field.onChange(e) + }} + readOnly={readonly} + /> + + )} + /> +
-
-

- 요구수질 -

-
- -
-
- ( - - { - handleCommaNumberChange(e, field.onChange); - }} - value={formatCommaNumber(field.value)} - /> - - )} - /> +
+ ( + + { + if (!readonly) handleCommaNumberChange(e, field.onChange); + }} + value={formatCommaNumber(field.value)} + readOnly={readonly} + /> + + )} + /> +
+
+ ( + + { } : field.onChange} + value={field.value ?? code.yn[0]?.val} + readOnly={readonly} + /> + + )} + /> +
+
+
+

+ 온배수 시설 운영현황 +

-
- ( - - { - handleCommaNumberChange(e, field.onChange); - }} - value={formatCommaNumber(field.value)} - /> - - )} - /> -
-
- -
-
- ( - - { - handleCommaNumberChange(e, field.onChange); - }} - value={formatCommaNumber(field.value)} - /> - - )} - /> +
+
+ ( + + { + if (!readonly) field.onChange(Number(e.target.value)); + }} + readOnly={readonly} + /> + + )} + /> +
+
+ ( + + { + if (!readonly) field.onChange + }} + readOnly={readonly} + /> + + )} + /> +
+
+ ( + + { + if (!readonly) handleCommaNumberChange(e, field.onChange); + }} + value={formatCommaNumber(field.value)} + readOnly={readonly} + /> + + )} + /> +
+
+ ( + + { + if (!readonly) handleCommaNumberChange(e, field.onChange); + }} + value={formatCommaNumber(field.value)} + readOnly={readonly} + /> + + )} + /> +
+
+ ( + + { } : field.onChange} + value={field.value ?? code.yn[0]?.val} + readOnly={readonly} + /> + + )} + /> +
+
+ ( + + { + if (!readonly) handleCommaNumberChange(e, field.onChange); + }} + value={formatCommaNumber(field.value)} + readOnly={readonly} + /> + + )} + /> +
+
+ ( + + { } : field.onChange} + value={field.value ?? code.yn[0]?.val} + readOnly={readonly} + /> + + )} + /> +
+
+ ( + + { + if (!readonly) handleCommaNumberChange(e, field.onChange); + }} + value={formatCommaNumber(field.value)} + readOnly={readonly} + /> + + )} + /> +
+
+ ( + + { + if (!readonly) field.onChange + }} + readOnly={readonly} + /> + + )} + /> +
-
- ( - - { - handleCommaNumberChange(e, field.onChange); - }} - value={formatCommaNumber(field.value)} - /> - - )} - /> -
-
- -
-
- ( - - { - handleCommaNumberChange(e, field.onChange); - }} - value={formatCommaNumber(field.value)} - /> - - )} - /> +
+

+ 요구수질 +

-
- ( - - { - handleCommaNumberChange(e, field.onChange); - }} - value={formatCommaNumber(field.value)} - /> - - )} - /> -
-
+
+
+ ( + + { + if (!readonly) handleCommaNumberChange(e, field.onChange); + }} + value={formatCommaNumber(field.value)} + readOnly={readonly} + /> + + )} + /> +
-
-
- ( - - { - handleCommaNumberChange(e, field.onChange); - }} - value={formatCommaNumber(field.value)} - /> - - )} - /> +
+ ( + + { + if (!readonly) handleCommaNumberChange(e, field.onChange); + }} + value={formatCommaNumber(field.value)} + readOnly={readonly} + /> + + )} + /> +
-
- ( - - { - handleCommaNumberChange(e, field.onChange); - }} - value={formatCommaNumber(field.value)} - /> - - )} - /> -
-
+
+
+ ( + + { + if (!readonly) handleCommaNumberChange(e, field.onChange); + }} + value={formatCommaNumber(field.value)} + readOnly={readonly} + /> + + )} + /> +
-
-
- ( - - { - handleCommaNumberChange(e, field.onChange); - }} - value={formatCommaNumber(field.value)} - /> - - )} - /> +
+ ( + + { + if (!readonly) handleCommaNumberChange(e, field.onChange); + }} + value={formatCommaNumber(field.value)} + readOnly={readonly} + /> + + )} + /> +
-
- ( - - { - handleCommaNumberChange(e, field.onChange); - }} - value={formatCommaNumber(field.value)} - /> - - )} - /> -
-
+
+
+ ( + + { + if (!readonly) handleCommaNumberChange(e, field.onChange); + }} + value={formatCommaNumber(field.value)} + readOnly={readonly} + /> + + )} + /> +
-
-
- ( - - { - handleCommaNumberChange(e, field.onChange); - }} - value={formatCommaNumber(field.value)} - /> - - )} - /> +
+ ( + + { + if (!readonly) handleCommaNumberChange(e, field.onChange); + }} + value={formatCommaNumber(field.value)} + readOnly={readonly} + /> + + )} + /> +
-
- ( - - { - handleCommaNumberChange(e, field.onChange); - }} - value={formatCommaNumber(field.value)} - /> - - )} - /> +
+
+ ( + + { + if (!readonly) handleCommaNumberChange(e, field.onChange); + }} + value={formatCommaNumber(field.value)} + readOnly={readonly} + /> + + )} + /> +
+ +
+ ( + + { + if (!readonly) handleCommaNumberChange(e, field.onChange); + }} + value={formatCommaNumber(field.value)} + readOnly={readonly} + /> + + )} + /> +
-
- - + +
+
+ ( + + { + if (!readonly) handleCommaNumberChange(e, field.onChange); + }} + value={formatCommaNumber(field.value)} + readOnly={readonly} + /> + + )} + /> +
+ +
+ ( + + { + if (!readonly) handleCommaNumberChange(e, field.onChange); + }} + value={formatCommaNumber(field.value)} + readOnly={readonly} + /> + + )} + /> +
+
+ +
+
+ ( + + { + if (!readonly) handleCommaNumberChange(e, field.onChange); + }} + value={formatCommaNumber(field.value)} + readOnly={readonly} + /> + + )} + /> +
+ +
+ ( + + { + if (!readonly) handleCommaNumberChange(e, field.onChange); + }} + value={formatCommaNumber(field.value)} + readOnly={readonly} + /> + + )} + /> +
+
+ +
); } diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx index 645a2fa07..df63b3520 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx @@ -11,7 +11,6 @@ import { } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/headList"; import { fcBizSchema, - type customPbnst, type fcBizType, type PbnstRegArrrayType, type ppInstlType, @@ -25,20 +24,9 @@ import { import FcOrgwtsRegModal from "@/components/ui/modal/fcltReg/fcOrgwtsRegModal/fcOrgwtsRegModal"; import RuseMngTable from "@/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable"; import { SelectBox } from "@common/business_components"; -import { - FormUi, - SearchInputSelect, - UiModal, - type SelectDataType, -} from "@common/business_components/ui"; +import { DatePicker, FormUi, UiModal } from "@common/business_components/ui"; import { Form, FormField } from "@common/business_components/ui/form"; -import { - Button, - DataTable, - DatePicker, - Input, - Label, -} from "@common/components"; +import { Button, DataTable, Input, Label } from "@common/components"; import { useEffect, useRef, useState } from "react"; import { useFieldArray, useForm, type UseFormReturn } from "react-hook-form"; import MngRegFormDetail from "../mngReg/mngRegFormDetail/mngRegFormDetail"; @@ -47,10 +35,9 @@ import SearchInputText from "@/components/ui/searchInput/searchInput"; import SdmInsertForm from "@common/business_components/ui/sdmInsertForm"; import type { DemandCompType } from "@common/business_components/ui/sdmInsertForm/form"; import RuseMngTableForm from "@/components/ui/table/pbnstReg/ruseMngTableForm/ruseMngTableForm"; +import type { SelectDataType } from "@common/business_components"; export function PbnstBuseForm({ - formType, - firstBizData, indexMng = 0, indexBiz = 0, setIndexBiz, @@ -68,14 +55,17 @@ export function PbnstBuseForm({ code, pbnst, demandCompList, - pbnstBizData, getpbnstInsertIndex, appendRuseFclt, - getBizCycle, getDemandCompList, regDemandCompany, } = useWrStore((state) => state); const { pbnstBizCycle, pbnstRes } = pbnst; + const { fields: fcBizs, append: appendBiz } = useFieldArray({ + control: form.control, + name: `items.${indexMng}.fcBizs`, + }); + const [bizCycle, setBizCycle] = useState("1"); const [ppiSelectList, setPpiSelectList] = useState<[{ name: string; val: SelectDataType[] }]>(); @@ -95,7 +85,6 @@ export function PbnstBuseForm({ data: DemandCompType; }>({ isMoal: false, data: {} as DemandCompType }); - useEffect(() => { const total = (form.getValues(`items.${indexMng}.fcBizs.${indexBiz}.gvsbs`) ?? 0) + @@ -106,43 +95,29 @@ export function PbnstBuseForm({ }, [ form.getValues(`items.${indexMng}.fcBizs.${indexBiz}.gvsbs`), form.getValues(`items.${indexMng}.fcBizs.${indexBiz}.lcep`), - form.getValues(`items.${indexMng}.fcBizs.${indexBiz}.cusrAlotm`) + form.getValues(`items.${indexMng}.fcBizs.${indexBiz}.cusrAlotm`), ]); - // const form = useForm({ - // resolver: zodResolver(fcBizSchema), - // defaultValues: - // formType === "reg" && - // pbnst.pbnstMngRegData && - // pbnst.pbnstMngRegData[0]?.fcBizs - // ? (pbnst.pbnstMngRegData[0].fcBizs[0] ?? {}) - // : formType === "update" && - // typeof pbnst.pbnsUpdateIndex.biz === "number" && - // pbnst.pbnsUpdateIndex.biz >= 0 && - // pbnst.pbnstRes - // ? pbnst.pbnstRes[pbnst.pbnsUpdateIndex.mng]?.fcBizs[ - // pbnst.pbnsUpdateIndex.biz - // ] - // : fcBizSchema.parse({}), - // mode: "onChange", - // }); - - + // fcBizs 데이터가 변경될 때마다 차수 선택 목록을 업데이트합니다. useEffect(() => { - if (form) { - const cycleLength = form.getValues(`items.${indexMng}.fcBizs`).length; - setSelectBizCycle( - Array.from({ length: cycleLength }, (_, index) => ({ - text: `${index + 1}차`, // ✅ index + 1 - val: index, // 이건 그대로 유지 (value로는 0부터 시작) - })) - ); + const cycleLength = fcBizs.length; + const newSelectBizCycle = Array.from( + { length: cycleLength }, + (_, index) => ({ + text: `${index + 1}차`, + val: index, + }) + ); + setSelectBizCycle(newSelectBizCycle); + + // 현재 차수 인덱스가 유효하지 않게 되면 마지막 인덱스로 조정합니다. + if (indexBiz >= cycleLength && cycleLength > 0) { + setIndexBiz(cycleLength - 1); } - }, [indexMng, form]); + }, [fcBizs, indexBiz, setIndexBiz]); // 2. Define a submit handler. function addRuseFcltObj() { const formRuse = form.getValues(`items.${indexMng}`); - const formBizs = form.getValues(`items.${indexMng}.fcBizs`); const pbnstBizCycle = formBizs.length; @@ -154,25 +129,13 @@ export function PbnstBuseForm({ pplInstls: undefined, fcDemands: undefined, }); - const index = pbnst.pbnsUpdateIndex.mng; appendBiz(newItem); - const cycleLength = form.getValues(`items.${indexMng}.fcBizs`).length; - setSelectBizCycle( - Array.from({ length: cycleLength }, (_, index) => ({ - text: `${index + 1}차`, // ✅ index + 1 - val: index, // 이건 그대로 유지 (value로는 0부터 시작) - })) - ); + setIndexBiz(pbnstBizCycle); // 새로 추가된 차수로 포커스 이동 } useEffect(() => { - console.log("form ", form.watch()); + //console.log("form ", form.watch()); }, [form.formState]); - const { fields: fcBizs, append: appendBiz } = useFieldArray({ - control: form.control, - name: `items.${indexMng}.fcBizs`, - }); - const { fields: fcDemands, append: appendDemand, @@ -186,7 +149,6 @@ export function PbnstBuseForm({ control: form.control, name: `items.${indexMng}.fcBizs.${indexBiz}.fcOrgwts`, }); - console.log(" fcOrgwtFiled ", fcOrgwtFiled); const { fields: pplInstls, append: appendPpl, @@ -202,10 +164,6 @@ export function PbnstBuseForm({ } }, [ppiYn, indexMng, indexBiz]); - useEffect(() => { - console.log("pbnst. bug pbnstMngRegData ", pbnst.pbnstMngRegData); - }, [pbnst.pbnstMngRegData]); - const plusHist = () => { if ( form.getValues(`items.${indexMng}.fcBizs.${indexBiz}.pbnstRuseFcltBizPk`) @@ -245,7 +203,7 @@ export function PbnstBuseForm({ form.getValues( `items.${indexMng}.fcBizs.${indexBiz}.pbnstRuseFcltFk` ) ?? "", - dmdInfoFk: "", + dmdInfoPk: "", //telno: "", }); }; @@ -278,9 +236,6 @@ export function PbnstBuseForm({ } }, [code]); - useEffect(() => { - console.log(" demandCompList ", demandCompList); - }, [demandCompList]); useEffect(() => { console.log("form errors:", form.formState.errors); }, [form.formState.errors]); @@ -295,441 +250,488 @@ export function PbnstBuseForm({ setSumCpct(sum); }, [form.formState, indexMng, indexBiz]); + // // 차수별 정보(fcBizs)가 하나도 없을 경우 플레이스홀더 UI를 보여줍니다. + // if (fcBizs.length === 0) { + // return ( + //
+ //

등록된 차수별 정보가 없습니다.

+ //

아래 버튼을 눌러 신규 차수 정보를 등록해주세요.

+ // + //
+ // ); + // } + + const pbnstBiz = form.watch(`items.${indexMng}.fcBizs`); return ( <> -
- {/* 차수별 등록 현황 폼 */} -
-
- -
-

-
-

등록차수

+ {pbnstBiz && pbnstBiz?.length > 0 ? ( +
+ {/* 차수별 등록 현황 폼 */} +
+ + +
+

+
+

등록차수

- { - setIndexBiz(Number(val)); - }} - > + { + setIndexBiz(Number(val)); + }} + > - -
-
- - - - - - - -

재이용 원수취수 현황

-
-
- -
- -
-

재이용 공급관로 설치 현황

-
- - setPpiYn(String(val))} - /> - - - {ppiYn === "Y" ? ( - <> +
+
+ + + + + + + +

재이용 원수취수 현황

+
+
+ - - - ) : ( - <> - )} -
-
- + +
+

재이용 공급관로 설치 현황

+
+ + setPpiYn(String(val))} + /> + + + {ppiYn === "Y" ? ( + <> + + + + ) : ( + <> + )} +
+
+ { + const pplSum = form.getValues( + `items.${indexMng}.fcBizs.${indexBiz}.pplInstls` + ); + if (!pplSum) return; + let sum = 0; + pplSum.forEach((item) => { + sum += Number(item.cpct) || 0; + }); + setSumCpct(sum); + }} + /> +
+ + { - const pplSum = form.getValues( - `items.${indexMng}.fcBizs.${indexBiz}.pplInstls` - ); - if (!pplSum) return; - let sum = 0; - pplSum.forEach((item) => { - sum += Number(item.cpct) || 0; - }); - setSumCpct(sum); - }} /> -
- - -
-

{"하수처리수 재이용수 수요처"}

-
- - -
- {( - form.getValues( - `items.${indexMng}.fcBizs.${indexBiz}.fcDemands` - ) || [] - ).map((field, index) => ( -
-
- ( - - { - f.onChange(val); - if (val && val.length > 2) { - getDemandCompList(val, 3); - } - }} - setRtnData={(valList: any) => { - if (valList) { - form.setValue( - `items.${indexMng}.fcBizs.${indexBiz}.fcDemands.${index}.dmdInfoFk`, - valList.dmdInfoPk - ); - form.setValue( - `items.${indexMng}.fcBizs.${indexBiz}.fcDemands.${index}.daddr`, - valList.daddr - ); - form.setValue( - `items.${indexMng}.fcBizs.${indexBiz}.fcDemands.${index}.useUsgCd`, - valList.useUsgCd - ); - form.setValue( - `items.${indexMng}.fcBizs.${indexBiz}.fcDemands.${index}.splyCpct`, - valList.splyCpct - ); - form.setValue( - `items.${indexMng}.fcBizs.${indexBiz}.fcDemands.${index}.dmdInfoFk`, - valList.dmdInfoPk?.toString() - ); - } - }} - searchList={demandCompList?.map((item) => { - return { - ...item, - searchNm: item.dmdCoNm, - searchPk: item.dmdInfoPk, - }; - })} - > - - )} - /> -
-
- ( - - f.onChange(e.target.value)} - value={f.value} - className={selectClass} - /> - - )} - /> -
-
- ( - - - - )} - /> -
-
- ( - - - f.onChange(date) - } - className={"rounded-lg !w-full"} - /> - - )} - /> -
-
- ( - - - f.onChange(date) - } - className={"rounded-lg !w-full"} - /> - - )} - /> -
-
- ( - - { - f.onChange(Number(e.target.value)); - }} - /> - - )} - /> -
-
- ( - - - f.onChange(val) - } - value={f.value} - /> - - )} - /> -
+
+

+ {"하수처리수 재이용수 수요처"} +

+
+ +
- ))} -
- - + {( + form.getValues( + `items.${indexMng}.fcBizs.${indexBiz}.fcDemands` + ) || [] + ).map((field, index) => ( +
+
+ ( + + { + f.onChange(val); + if (val && val.length > 2) { + getDemandCompList(val, 3); + } + }} + setRtnData={(valList: any) => { + if (valList) { + form.setValue( + `items.${indexMng}.fcBizs.${indexBiz}.fcDemands.${index}.daddr`, + valList.daddr + ); + form.setValue( + `items.${indexMng}.fcBizs.${indexBiz}.fcDemands.${index}.useUsgCd`, + valList.useUsgCd + ); + form.setValue( + `items.${indexMng}.fcBizs.${indexBiz}.fcDemands.${index}.splyCpct`, + valList.splyCpct + ); + form.setValue( + `items.${indexMng}.fcBizs.${indexBiz}.fcDemands.${index}.dmdInfoPk`, + valList.dmdInfoPk?.toString() + ); + } + }} + searchList={demandCompList?.map((item) => { + return { + ...item, + searchNm: item.dmdCoNm, + searchPk: item.dmdInfoPk, + }; + })} + > + + )} + /> +
+
+ ( + + f.onChange(e.target.value)} + value={f.value} + className={selectClass} + /> + + )} + /> +
+
+ ( + + + + )} + /> +
+
+ ( + + + f.onChange(date), + }} + selectClass={"rounded-lg !w-full"} + /> + + )} + /> +
+
+ ( + + + f.onChange(date) + } + field={{ + value: safeDate(f.value) || new Date(), + onChange: (date: Date | undefined) => + f.onChange(date), + }} + selectClass={"rounded-lg !w-full"} + /> + + )} + /> +
+
+ ( + + { + f.onChange(Number(e.target.value)); + }} + /> + + )} + /> +
+
+ ( + + + f.onChange(val) + } + value={f.value ?? code.yn[0]?.val} + /> + + )} + /> +
+
+ ))} +
+ + +
+ + setIsFcOrgwts(open)} + bodyClass={"w-[50vw] max-w-none h-[90vh]"} + body={ + { + setIsFcOrgwts(false); + }} + onRightSet={(val) => { + form.setValue( + `items.${indexMng}.fcBizs.${indexBiz}.fcOrgwts`, + val + ); + }} + > + } + > + + { + setIsDmdModal({ isMoal: false, data: {} as DemandCompType }); + }} + body={ + { + getDemandCompList(searchText, pageCnt); + }} + rtnInputData={(data) => { + regDemandCompany(data as DemandCompType); + setIsDmdModal({ + isMoal: false, + data: data as DemandCompType, + }); + }} + bodyClassNm={"w-full mx-auto bg-white rounded-lg shadow-md p-6"} + > + } + >
- - setIsFcOrgwts(open)} - bodyClass={"w-[50vw] max-w-none h-[90vh]"} - body={ - { - setIsFcOrgwts(false); - }} - onRightSet={(val) => { - form.setValue( - `items.${indexMng}.fcBizs.${indexBiz}.fcOrgwts`, - val - ); - }} - > - } - > - - { - setIsDmdModal({ isMoal: false, data: {} as DemandCompType }); - }} - body={ - { - getDemandCompList(searchText, pageCnt); - }} - rtnInputData={(data) => { - regDemandCompany(data as DemandCompType); - setIsDmdModal({ isMoal: false, data: data as DemandCompType }); - }} - bodyClassNm={"w-full mx-auto bg-white rounded-lg shadow-md p-6"} - > - } - > -
+ ) : ( +
+

등록된 차수별 정보가 없습니다.

+

+ 아래 버튼을 눌러 신규 차수 정보를 등록해주세요. +

+ +
+ )} ); } 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..d07d24a23 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, @@ -37,11 +37,10 @@ export type FilesType = { export function PbnstMngForm({ form, formType, - firstFcltData, - indexMng , + indexMng, setIndexMng, }: { -form: UseFormReturn<{items:PbnstRegArrrayType}>; + form: UseFormReturn<{ items: PbnstRegArrrayType }>; formType: string; firstFcltData?: customPbnst; indexMng: number; @@ -51,12 +50,8 @@ form: UseFormReturn<{items:PbnstRegArrrayType}>; code, pbnst, pbnstInsert, - pbnstMngData, fileDelete, fileDownLoad, - getBizCycle, - getpbnstInsertIndex, - appendRuseFclt, } = useWrStore((state) => state); const { pbnstRes } = pbnst; @@ -64,37 +59,9 @@ 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 +71,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 +170,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 +187,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,63 +199,39 @@ 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); }, [pbnst.pbnstMngRegData]); useEffect(() => { - if (pbnst.pbnstRes && pbnst.pbnstRes?.length <= 0) return; - const fcltNmList = pbnst.pbnstRes?.map((item, index) => ({ - text: item.ruseUtztnFcltNm, - val: String(index), - })); - if (fcltNmList) setFcltNm(fcltNmList); + if (pbnst.pbnstRes && pbnst.pbnstRes?.length >= 0) { + + const fcltNmList = pbnst.pbnstRes?.map((item, index) => ({ + text: item.ruseUtztnFcltNm, + val: String(index), + })); + + + console.log(' fcltNmList ', fcltNmList) + if (fcltNmList) setFcltNm(fcltNmList); + }else{ + setFcltNm(null); + } }, [pbnst.pbnstRes]); // 2. Define a submit handler. function onSubmit(values: z.infer) { - values.fcOpers = []; + values.fcOpers = []; values.fcFiles = regFileList || []; pbnstInsert(values); } @@ -325,7 +247,6 @@ form: UseFormReturn<{items:PbnstRegArrrayType}>; } }, [planFiles]); - useEffect(() => { if (code.ruseMngMtd) { setMngMtdCode([{ name: "ruseMngMtd", val: code.ruseMngMtd }]); @@ -333,7 +254,15 @@ form: UseFormReturn<{items:PbnstRegArrrayType}>; }, [code]); + useEffect(() =>{ + // console.log(' fcltNm ', watchedItem?.ruseUtztnFcltNm) + },[watchedItem]) + + useEffect(() => { + console.log(" form indexMng ", indexMng); + }, [indexMng]); + return (
@@ -347,33 +276,29 @@ form: UseFormReturn<{items:PbnstRegArrrayType}>; {formType === "update" ? ( - ( - - { - setIndexMng(Number(val)); - field.onChange(val); - }} - value={field.value ?? ""} - className={""} - selectClass={undefined} - /> - - )} - /> + + { + setIndexMng(Number(val)); + }} + value={String(indexMng)} + className={""} + selectClass={undefined} + /> + ) : ( ( ; field.onChange(String(e.target.value)); }} value={field.value ?? ""} + readOnly={formType === "sttn" ? true : false} /> )} @@ -393,28 +319,41 @@ form: UseFormReturn<{items:PbnstRegArrrayType}>;
재이용시설 운영정보 -
- - -
+ {formType === "sttn" ? ( + <> + ) : ( +
+ + +
+ )}
{ + return { + ...item, + readonly: true, + }; + }) + : pbnst.pbnstMngUpHeadList + } upHeadList={pbnst.pbnstMngNm} code={mngMtdCode || []} onTableSet={(val) => { @@ -423,7 +362,7 @@ form: UseFormReturn<{items:PbnstRegArrrayType}>; indexMng={indexMng} form={form} formNm={"fcOpers"} - // ref={ref} + // ref={ref} >
@@ -445,6 +384,7 @@ form: UseFormReturn<{items:PbnstRegArrrayType}>; field.onChange(Number(e.target.value)); }} value={field.value ?? 0} + readOnly={formType === "sttn" ? true : false} /> )} @@ -453,19 +393,20 @@ form: UseFormReturn<{items:PbnstRegArrrayType}>;
( { field.onChange(Number(e.target.value)); }} value={field.value ?? 0} + readOnly={formType === "sttn" ? true : false} /> )} @@ -473,19 +414,20 @@ form: UseFormReturn<{items:PbnstRegArrrayType}>;
( { field.onChange(Number(e.target.value)); }} value={field.value ?? 0} + readOnly={formType === "sttn" ? true : false} /> )} @@ -497,40 +439,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/form/fcltReg/rainReg/rainRegForm.tsx b/apps/wr/components/ui/form/fcltReg/rainReg/rainRegForm.tsx index 8c6f5f1db..08f2b073e 100644 --- a/apps/wr/components/ui/form/fcltReg/rainReg/rainRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/rainReg/rainRegForm.tsx @@ -4,36 +4,36 @@ import { useWrStore } from "@/app/store"; import { rainZod, selectClass, - TEST_UUID, - type customRainBdst, + type customRainBdst } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; -import { DatePicker, FormUi } from "@common/business_components"; -import { Form, FormField, SelectBox } from "@common/business_components/ui"; -import { Button, Input } from "@common/components/ui"; -import { zodResolver } from "@hookform/resolvers/zod"; -import { useEffect, useState } from "react"; -import { useForm, useWatch, type UseFormReturn } from "react-hook-form"; -import { z } from "zod"; -import BdstReg from "../bdstReg/bdstReg"; +import { formH1Class, formH2Class } from "@/components/lib/class/comClass"; import { formatCommaNumber, handleCommaNumberChange, } from "@/components/lib/func/commom"; -import { formH1Class, formH2Class } from "@/components/lib/class/comClass"; +import { DatePicker, FormUi } from "@common/business_components"; +import { Form, FormField, SelectBox } from "@common/business_components/ui"; +import { Button, Input } from "@common/components/ui"; +import { zodResolver } from "@hookform/resolvers/zod"; +import { useEffect } from "react"; +import { useForm } from "react-hook-form"; +import { z } from "zod"; +import BdstReg from "../bdstReg/bdstReg"; export default function RainRegForm({ rainForm, isModal, + readonly = false }: { rainForm: customRainBdst; isModal: boolean; + readonly?: boolean; }) { const { code, rainBdstReg, rainBdstUpdate, rain } = useWrStore( (state) => state ); const { rainFcltCd } = code; const defaultValues: z.infer = rainZod.parse({}); - const form = useForm>({ resolver: zodResolver(rainZod), defaultValues: defaultValues, @@ -60,8 +60,8 @@ export default function RainRegForm({ typeof item?.grntchBdstCertYr === "string" ? item?.grntchBdstCertYr : "", // null → "" - rainObj: { - ...item?.rainObj, + rainyObj: { + ...item?.rainyObj, }, })), }; @@ -84,8 +84,6 @@ export default function RainRegForm({ useEffect(() => { const subscription = form.watch((value) => { }); - - return () => subscription.unsubscribe(); }, [form]); @@ -105,7 +103,6 @@ export default function RainRegForm({ if (rainZod) form.reset(cleanRainData(rainForm)); }, [rainForm]); - return (
@@ -115,9 +112,11 @@ export default function RainRegForm({

{isModal ? "건축물 운영정보" : "빗물이용시설 정보"}

- + {!readonly && ( + + )}
{isModal && rainForm != undefined ? : <>} @@ -147,8 +146,10 @@ export default function RainRegForm({ ? new Date(field.value) : new Date(), // Provide a default Date value onChange: (date) => field.onChange(date), + }} selectClass={"w-full"} + readOnly={readonly} /> )} @@ -166,9 +167,10 @@ export default function RainRegForm({ placeholder="1,000,000" type="text" onChange={(e) => { - handleCommaNumberChange(e, field.onChange); + if (!readonly) handleCommaNumberChange(e, field.onChange); }} value={formatCommaNumber(field.value)} + readOnly={readonly} /> )} @@ -195,8 +197,9 @@ export default function RainRegForm({ selectClass={selectClass} label={""} selectArray={rainFcltCd} - onSelectValue={field.onChange} + onSelectValue={readonly ? () => { } : field.onChange} value={field.value ?? rainFcltCd[0]?.val} + readOnly={readonly} /> )} @@ -213,9 +216,10 @@ export default function RainRegForm({ placeholder="1,000,000" type="text" onChange={(e) => { - handleCommaNumberChange(e, field.onChange); + if (!readonly) handleCommaNumberChange(e, field.onChange); }} value={formatCommaNumber(field.value)} + readOnly={readonly} /> )} @@ -238,8 +242,9 @@ export default function RainRegForm({ selectClass={selectClass} label={""} selectArray={code.yn} - onSelectValue={field.onChange} + onSelectValue={readonly ? () => { } : field.onChange} value={field.value ?? code.yn[0]?.val} + readOnly={readonly} /> )} @@ -256,7 +261,7 @@ export default function RainRegForm({ placeholder="1,000,000" type="text" onChange={(e) => { - handleCommaNumberChange(e, field.onChange); + if (!readonly) handleCommaNumberChange(e, field.onChange); }} value={formatCommaNumber(field.value)} readOnly={filtrTrtmfctYn !== "Y"} @@ -276,7 +281,9 @@ export default function RainRegForm({ placeholder="1,000,000" type="" value={field.value ?? ""} - onChange={field.onChange} + onChange={(e) => { + if (!readonly) handleCommaNumberChange(e, field.onChange); + }} readOnly={filtrTrtmfctYn !== "Y"} /> @@ -304,8 +311,9 @@ export default function RainRegForm({ selectClass={selectClass} label={""} selectArray={code.yn} - onSelectValue={field.onChange} + onSelectValue={readonly ? () => { } : field.onChange} value={field.value ?? code.yn[0]?.val} + readOnly={readonly} /> )} @@ -322,7 +330,7 @@ export default function RainRegForm({ placeholder="1,000,000" type="text" onChange={(e) => { - handleCommaNumberChange(e, field.onChange); + if (!readonly) handleCommaNumberChange(e, field.onChange); }} value={formatCommaNumber(field.value)} readOnly={instlCstSprtYn !== "Y"} @@ -348,7 +356,7 @@ export default function RainRegForm({ selectClass={selectClass} label={""} selectArray={code.yn} - onSelectValue={field.onChange} + onSelectValue={readonly ? () => { } : field.onChange} value={field.value ?? code.yn[0]?.val} /> @@ -366,7 +374,9 @@ export default function RainRegForm({ placeholder="2024" type="" value={field.value ?? ""} - onChange={field.onChange} + onChange={(e) => { + if (!readonly) field.onChange(e); + }} readOnly={grntchBdstCertYn !== "Y"} /> @@ -384,7 +394,9 @@ export default function RainRegForm({ placeholder="ab1234678" type="" value={field.value ?? ""} - onChange={field.onChange} + onChange={(e) => { + if (!readonly) field.onChange(e); + }} readOnly={grntchBdstCertYn !== "Y"} /> @@ -402,7 +414,9 @@ export default function RainRegForm({ placeholder="A" type="" value={field.value ?? ""} - onChange={field.onChange} + onChange={(e) => { + if (!readonly) field.onChange(e); + }} readOnly={grntchBdstCertYn !== "Y"} /> diff --git a/apps/wr/components/ui/form/fcltReg/rswtrReg/rswtrRegForm.tsx b/apps/wr/components/ui/form/fcltReg/rswtrReg/rswtrRegForm.tsx index f72e640e3..a4f29477a 100644 --- a/apps/wr/components/ui/form/fcltReg/rswtrReg/rswtrRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/rswtrReg/rswtrRegForm.tsx @@ -28,9 +28,11 @@ import BdstReg from "../bdstReg/bdstReg"; export default function RswtrRegForm({ rswtForm, isModal, + readonly = false }: { rswtForm: customRswtBdst; isModal: boolean; + readonly?: boolean; }) { const { rswt, code, rswtBdstUpdate, rswtBdstReg } = useWrStore( (state) => state @@ -78,6 +80,10 @@ export default function RswtrRegForm({ }; }; + useEffect(()=>{ + console.log("rswtForm:", rswtForm) + }, [rswtForm]) + useEffect(() => { console.log("form errors:", form.formState.errors); }, [form.formState.errors]); @@ -105,13 +111,11 @@ export default function RswtrRegForm({

건축물 운영정보

- + {!readonly && ( + + )}
@@ -141,6 +145,7 @@ export default function RswtrRegForm({ onChange: (date) => field.onChange(date), }} selectClass={"w-full"} + readOnly={readonly} /> )} @@ -158,9 +163,10 @@ export default function RswtrRegForm({ placeholder="1,000,000" type="text" onChange={(e) => { - handleCommaNumberChange(e, field.onChange); + if (!readonly) handleCommaNumberChange(e, field.onChange); }} value={formatCommaNumber(field.value)} + readOnly={readonly} /> )} @@ -179,9 +185,10 @@ export default function RswtrRegForm({ placeholder="1,000,000" type="text" onChange={(e) => { - handleCommaNumberChange(e, field.onChange); + if (!readonly) handleCommaNumberChange(e, field.onChange); }} value={formatCommaNumber(field.value)} + readOnly={readonly} /> )} @@ -199,9 +206,10 @@ export default function RswtrRegForm({ placeholder="1,000,000" type="text" onChange={(e) => { - handleCommaNumberChange(e, field.onChange); + if (!readonly) handleCommaNumberChange(e, field.onChange); }} value={formatCommaNumber(field.value)} + readOnly={readonly} /> )} @@ -225,8 +233,9 @@ export default function RswtrRegForm({ type="number" value={field.value ?? 0} onChange={(e) => { - field.onChange(Number(e.target.value)); + if (!readonly) field.onChange(Number(e.target.value)); }} + readOnly={readonly} /> )} @@ -243,8 +252,9 @@ export default function RswtrRegForm({ label={""} selectClass={selectClass} selectArray={code.orgwtKndCd} - onSelectValue={field.onChange} + onSelectValue={readonly ? () => { } : field.onChange} value={field.value ?? code.orgwtKndCd[0]?.val} + readOnly={readonly} /> )} @@ -261,7 +271,10 @@ export default function RswtrRegForm({ placeholder="" type="" value={field.value ?? ""} - onChange={field.onChange} + onChange={(e) => { + if (!readonly) field.onChange + }} + readOnly={readonly} /> )} @@ -287,8 +300,9 @@ export default function RswtrRegForm({ selectClass={selectClass} label={""} selectArray={code.yn} - onSelectValue={field.onChange} + onSelectValue={readonly ? () => { } : field.onChange} value={field.value ?? code.yn[0]?.val} + readOnly={readonly} /> )} @@ -305,7 +319,7 @@ export default function RswtrRegForm({ placeholder="1,000,000" type="text" onChange={(e) => { - handleCommaNumberChange(e, field.onChange); + if (!readonly) handleCommaNumberChange(e, field.onChange); }} value={formatCommaNumber(field.value)} readOnly={instlCstSprtYn !== "Y"} @@ -331,8 +345,9 @@ export default function RswtrRegForm({ selectClass={selectClass} label={""} selectArray={code.yn} - onSelectValue={field.onChange} + onSelectValue={readonly ? () => { } : field.onChange} value={field.value ?? code.yn[0]?.val} + readOnly={readonly} /> )} @@ -350,7 +365,9 @@ export default function RswtrRegForm({ type="text" {...field} value={field.value ?? ""} - onChange={field.onChange} + onChange={(e) => { + if (!readonly) field.onChange(e) + }} readOnly={grntchBdstCertYn !== "Y"} /> @@ -368,7 +385,9 @@ export default function RswtrRegForm({ placeholder="ab1234678" type="" value={field.value ?? ""} - onChange={field.onChange} + onChange={(e) => { + if (!readonly) field.onChange(e) + }} readOnly={grntchBdstCertYn !== "Y"} /> @@ -386,7 +405,9 @@ export default function RswtrRegForm({ placeholder="A" type="" value={field.value ?? ""} - onChange={field.onChange} + onChange={(e) => { + if (!readonly) field.onChange(e) + }} readOnly={grntchBdstCertYn !== "Y"} /> 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 6748ef487..efd47c69b 100644 --- a/apps/wr/components/ui/modal/coMat/constCostFeeTable.tsx +++ b/apps/wr/components/ui/modal/coMat/constCostFeeTable.tsx @@ -23,12 +23,12 @@ export function ConstCostFeeTable({ const [constCostData, setConstCostData] = useState([]); - function getFctDescription(fctCd: string) { + const getFctDescription = (fctCd: string) => { const fctMap: { [key: string]: string } = { - "001": "총인", - "002": "염소.소독", - "003": "uv소독", - "004": "생물학적탈질", + "001": "총인처리시설", + "002": "염소소독", + "003": "UV소독", + "004": "전처리시설", "005": "RO", }; @@ -61,7 +61,6 @@ export function ConstCostFeeTable({ }, [] ); - console.log("tableData", tableData); const formattedTableData = tableData?.map((item: ContCostMap) => { return { ...item, @@ -73,7 +72,7 @@ export function ConstCostFeeTable({ return ( <> - +

공사비 산정표 보기

@@ -89,7 +88,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..ee82420a8 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,18 @@ export function RateFeeTableModal({ 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); @@ -81,28 +79,26 @@ export function RateFeeTableModal({ return ( <> - +

요율표 보기


-
- - setYear(String(val))} +
+ + {}} + value={new Date().getFullYear() || ""} />
-
- +
-
diff --git a/apps/wr/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal.tsx b/apps/wr/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal.tsx index d7ecee90a..b930a36bb 100644 --- a/apps/wr/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal.tsx +++ b/apps/wr/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal.tsx @@ -26,7 +26,7 @@ export function PbnstRegModal({ data: pubHasuType; form: UseFormReturn<{ items: PbnstRegArrrayType }>; }) { - const { pbnst, pbnstInsert, pbnstMngData } = useWrStore((state) => { + const { pbnst, pbnstInsert } = useWrStore((state) => { return state; }); const [pbnstBdstForm, setPbnstBdstForm] = useState( @@ -57,48 +57,18 @@ export function PbnstRegModal({ useEffect(() => { if (data) { + const firstForm = form.getValues("items"); - - console.log('mngIndex ', firstForm.length) - setIndexMng(firstForm.length - 1) - // console.log(' firstForm ', firstForm) - // let regData; - // if (pbnstRes && pbnstRes?.length > 0) { - // regData = { - // swtrmtFcltFk: String(data.bscFctCd), - // pbnstRuseFcltPk: String(data.bscFctCd) + String(pbnstRes.length + 1), - // fcBizs: [ - // { - // pbnstRuseFcltFk: - // String(data.bscFctCd) + String(pbnstRes.length + 1), - // cycl: 1, - // } as unknown as fcBizType, - // ], - // }; - // //regData= pbnstRegZod.parse(regData) - // //setPbnstBdstForm(regData as unknown as customPbnst); - // // pbnstMngData([regData] as unknown as customPbnst[]) - // } else { - // regData = { - // swtrmtFcltFk: String(data.bscFctCd), - // pbnstRuseFcltPk: String(data.bscFctCd + "1"), - // fcBizs: [ - // { - // pbnstRuseFcltFk: String(data.bscFctCd + "1"), - // cycl: 1, - // } as unknown as fcBizType, - // ], - // }; - // //regData= pbnstRegZod.parse(regData) - // // setPbnstBdstForm(regData as unknown as customPbnst); - - // // pbnstMngData([regData] as unknown as customPbnst[]) - // } - // regData = pbnstRegZod.parse(regData); - // setPbnstBdstForm(regData as unknown as customPbnst); - } + setIndexMng(firstForm.length - 1) } }, [data, form]); + + + useEffect(() => { + console.log(' form.getValues() ' ,form.getValues()) + + }, [form.getValues()]); + return ( <>

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/modal/sttn/sttnDetailModal/sttnDetailModal.tsx b/apps/wr/components/ui/modal/sttn/sttnDetailModal/sttnDetailModal.tsx index 0ebd03ae2..0f7dbf706 100644 --- a/apps/wr/components/ui/modal/sttn/sttnDetailModal/sttnDetailModal.tsx +++ b/apps/wr/components/ui/modal/sttn/sttnDetailModal/sttnDetailModal.tsx @@ -90,10 +90,10 @@ export default function SttnDetailModal({ : "온배수시설 상세정보"}> 0?"h-[80vh]":"h-[70vh]"} > {type === "RNB" ? ( - + ) : type === "RST" ? ( - - ) : ()} + + ) : ()} {detailData.data.length>0? ( ({ 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]); - return ( <> @@ -107,6 +92,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); + } }} + readOnly ={head.readonly ? true : false} + // 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"} + readOnly ={head.readonly ? true : false} /> ) : head.type === "checkbox" ? ( ( checked={ field.value || false} onCheckedChange={(checked) => { field.onChange(checked); - }} > ) : ( diff --git a/apps/wr/public/sample_pbnstPrfmncSttn.xlsx b/apps/wr/public/sample_pbnstPrfmncSttn.xlsx new file mode 100644 index 000000000..183434984 Binary files /dev/null and b/apps/wr/public/sample_pbnstPrfmncSttn.xlsx differ diff --git a/packages/common/business_components/src/ui/date_picker/index.tsx b/packages/common/business_components/src/ui/date_picker/index.tsx index d3a6a05c1..9df32b3b5 100644 --- a/packages/common/business_components/src/ui/date_picker/index.tsx +++ b/packages/common/business_components/src/ui/date_picker/index.tsx @@ -12,37 +12,39 @@ import { FormControl } from "../form"; import { ko } from "date-fns/locale"; import { useState } from "react"; -type DatePickerProps = DayPickerSingleProps & { field: { value: Date; onChange: (date: Date | undefined) => void } ,selectClass:string|undefined }; - - -export function DatePicker({ field, selectClass }: DatePickerProps) { +type DatePickerProps = DayPickerSingleProps & { field: { value: Date; onChange: (date: Date | undefined) => void }, selectClass: string | undefined, readOnly?: boolean }; +export function DatePicker({ field, selectClass, readOnly = false, ...props }: DatePickerProps) { const [open, setOpen] = useState(false); const handleSelect = (date: Date | undefined) => { - field.onChange(date); // React Hook Form 업데이트 - setOpen(false); - }; + if (!readOnly) { // readOnly가 아닐 때만 변경 허용 + field.onChange(date); // React Hook Form 업데이트 + setOpen(false); + } + }; + return ( - +