From f06fa0f9abb846fcb7ff1c24e3c9df4364ace56d Mon Sep 17 00:00:00 2001 From: leedj312 Date: Sun, 13 Jul 2025 20:54:12 +0900 Subject: [PATCH] =?UTF-8?q?=ED=95=98=EC=88=98=EC=9E=AC=EC=9D=B4=EC=9A=A9?= =?UTF-8?q?=20=EC=8B=9C=EC=84=A4=20=EB=93=B1=EB=A1=9D=20=EC=9A=B4=EC=98=81?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=20=EC=98=A4=EB=A5=98=EC=88=98=EC=A0=95=20,?= =?UTF-8?q?=20=ED=85=8C=EC=9D=B4=EB=B8=94=EC=97=90=20=EC=9E=A5=EB=82=B4,?= =?UTF-8?q?=EC=9E=A5=EC=99=B8=20=EC=95=88=EB=82=98=EB=8A=94=EA=B1=B0=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ruseFcltMng/fcltReg/pbnstReg/page.tsx | 116 ++++++------------ .../ruseFcltMng/fcltReg/pbnstReg/utilsZod.tsx | 55 +++++---- .../prfmncReg/pbnstPrfmncReg/page.tsx | 2 +- apps/wr/app/store/common/type/header.tsx | 1 + .../store/prfmncReg/pbnstPrfmncReg/type.tsx | 37 +++++- .../prfmncSttn/pbnstPrfmncSttn/headList.tsx | 26 +++- .../prfmncSttn/pbnstPrfmncSttn/index.tsx | 34 ++--- .../ruseFcltMng/fcltReg/pbnstReg/headList.tsx | 4 +- .../ruseFcltMng/fcltReg/pbnstReg/index.tsx | 29 +---- .../ruseFcltMng/fcltReg/pbnstReg/type.tsx | 33 +++-- .../fcltReg/pbnstReg/mngReg/mngRegForm.tsx | 58 +++++---- .../mngRegFormDetail/mngRegFormDetail.tsx | 3 + .../fcltReg/pbnstRegModal/pbnstRegModal.tsx | 5 +- .../sttn/pbnstSttnModal/pbnstSttnModal.tsx | 38 ++++-- .../ruseMngTableForm/ruseMngTableForm.tsx | 3 +- 15 files changed, 239 insertions(+), 205 deletions(-) diff --git a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx index 0d99d15cf..1b6b7e76f 100644 --- a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx @@ -24,7 +24,6 @@ import type { import { pbnstRegZod, pbnstRegArrayZod, - fcBizSchema, } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; import { PbnstMngForm } from "@/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm"; import { PbnstBuseForm } from "@/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm"; @@ -36,8 +35,7 @@ import { zodResolver } from "@hookform/resolvers/zod"; import { z } from "zod"; import { createDefaultPbnstItem } from "./utilsZod"; - - +import { flushSync } from "react-dom"; export default function PublicReuseFaciltyInsert() { const { @@ -55,7 +53,7 @@ export default function PublicReuseFaciltyInsert() { const [isRuseReg, setIsRuseReg] = useState<{ isModal: boolean; }>({ isModal: false }); - + const [resetPage, isResetPage] = useState(false); const [indexMng, setIndexMng] = useState(0); const [indexBiz, setIndexBiz] = useState(0); const [searchTxt, setSearchTxt] = useState(); @@ -92,13 +90,13 @@ export default function PublicReuseFaciltyInsert() { if (!isDirty) { toast.error("변경사항이 없습니다."); // 변경사항이 없으면 메시지 표시 return; - } const data = writeRgtrAndMdfr(valuse.items); + } + const data = writeRgtrAndMdfr(valuse.items); let bizs = [] as fcBizType[]; data.forEach((fclt) => { bizs = [...bizs, ...fclt.fcBizs]; }); - const pbnst = data.map((fclt) => { return { pbnstRuseFcltPk: fclt.pbnstRuseFcltPk, @@ -112,42 +110,34 @@ export default function PublicReuseFaciltyInsert() { }; }); - Promise.allSettled([ pbnstRuseFcltUpdate(pbnst as customPbnst[]), - pbnstRuseBizUpdate(bizs) + pbnstRuseBizUpdate(bizs), ]).then(([resFclt, resBiz]) => { const isFcltSuccess = resFclt.status === "fulfilled"; const isBizSuccess = resBiz.status === "fulfilled"; - if (isFcltSuccess && isBizSuccess) { - toast.success('하수 재이용 시설 및 사업이 수정되었습니다. ') + toast.success("하수 재이용 시설 및 사업이 수정되었습니다. "); // 메시지 표시, 페이지 이동 등 } else { - - let message = '' + let message = ""; // ✅ 각각 어떤 항목이 실패했는지도 로그/알림 처리 if (!isFcltSuccess) { - message = '하수재이용 시설 ' + message = "하수재이용 시설 "; } if (!isBizSuccess) { - message += '하수재이용 시설 사업 ' + message += "하수재이용 시설 사업 "; } - - toast.error(message + '오류 입니다 ') + toast.error(message + "오류 입니다 "); pubHasuInit("1", "41"); } - - }); - - }; // 폼 유효성 검사 실패 시 호출될 함수 - const onInvalid = (errors: FieldErrors<{ items: z.infer[] }>) => { - console.log("errors:", errors); - + const onInvalid = ( + errors: FieldErrors<{ items: z.infer[] }> + ) => { const findAllErrors = ( errorObject: any, path: (string | number)[] = [] @@ -181,7 +171,9 @@ export default function PublicReuseFaciltyInsert() { if (itemsIndex > -1 && path.length > itemsIndex + 1) { const itemIdx = path[itemsIndex + 1] as number; - const facilityName = form.getValues(`items.${itemIdx}.ruseUtztnFcltNm`); + const facilityName = form.getValues( + `items.${itemIdx}.ruseUtztnFcltNm` + ); if (facilityName) { prefix += `[${facilityName}] `; } @@ -189,13 +181,14 @@ export default function PublicReuseFaciltyInsert() { const fcBizsIndex = path.indexOf("fcBizs"); if (fcBizsIndex > -1 && path.length > fcBizsIndex + 1) { const bizIdx = path[fcBizsIndex + 1] as number; - const cycle = form.getValues(`items.${itemIdx}.fcBizs.${bizIdx}.cycl`); + const cycle = form.getValues( + `items.${itemIdx}.fcBizs.${bizIdx}.cycl` + ); if (cycle) { prefix += `[${cycle}차수] `; } } } - // 최종 오류 메시지 출력 toast.error(`${prefix}${message}`); }); @@ -205,6 +198,10 @@ export default function PublicReuseFaciltyInsert() { console.log("form errors:", form.formState.errors); }, [form.formState.errors]); + useEffect(() => { + console.log("formState", items); + }, [items]); + useEffect(() => { if (code.sggCd.length && pbnstHasuRes.length > 0) { setbdstTable(tableData(pbnstHasuRes, { code })); @@ -226,6 +223,12 @@ export default function PublicReuseFaciltyInsert() { setCurrentTab(value); }; + useEffect(() => { + if (indexMng) { + setIndexBiz(0); + } + }, [indexMng]); + useEffect(() => { if (pbnst.pbnstRes && pbnst.pbnstRes?.length > 0) { form.reset({ items: pbnst.pbnstRes }); @@ -234,67 +237,25 @@ export default function PublicReuseFaciltyInsert() { form.reset({ items: [] }); } }, [pbnst.pbnstRes]); - useEffect(() => { - if (indexMng) { - setIndexBiz(0); - } - }, [indexMng]); - - - - - useEffect(() => { - console.log("form errors:", form.formState.errors); - }, [form.formState.errors]); const appendPbnstRuseFclt = useCallback(() => { - const selecTableRow = selectRow; if (pbnstRes && pbnstRes.length > 0) { - const lastPbnst = pbnstRes[pbnstRes.length - 1]; - if (lastPbnst && selecTableRow) { - // append( - // pbnstRegZod.parse({ - // pbnstRuseFcltPk: - // String(selecTableRow.bscFctCd) + String(pbnstRes.length + 1), - // ruseUtztnFcltNm: null, - // fcBizs: [ - // fcBizSchema.parse({ - // pbnstRuseFcltFk: - // String(lastPbnst.pbnstRuseFcltPk) + - // String(pbnstRes.length + 1), - // cycl: 1, - // }), - // ] as fcBizType[], - // }) - // ); - append(createDefaultPbnstItem(selecTableRow, pbnstRes.length)); - + if (selectRow) { // pbnstRes.length를 사용하여 새로운 항목의 인덱스를 결정 + append(createDefaultPbnstItem(selectRow, pbnstRes.length)); setIsRuseReg({ isModal: true }); } } else { - if (selecTableRow) { - append(createDefaultPbnstItem(selecTableRow, 0) - // { - // pbnstRuseFcltPk: String(selecTableRow.bscFctCd) + "1", - // ruseUtztnFcltNm: "", - // regDt: null, - // mdfcnDt: null, - // fcBizs: [ - // fcBizSchema.parse({ - // pbnstRuseFcltFk: String(selecTableRow.bscFctCd) + "1", - // cycl: 1, - // }), - // ] as fcBizType[], - // } - // ) - ); + if (selectRow) { // pbnstRes가 비어있으면 첫 항목이므로 인덱스 0 + + append(createDefaultPbnstItem(selectRow, 0)); setIsRuseReg({ isModal: true }); } } - }, [pbnstRegZod, pbnstRes, append, selectRow, form]); + }, [pbnstRes, append, selectRow]); useEffect(() => { pubHasuInit(String(pageNation), "41"); + isResetPage(false); }, [pageNation, pubHasuInit]); return ( @@ -321,6 +282,7 @@ export default function PublicReuseFaciltyInsert() { searchTxt && searchTxt?.length > 0 ? pubHasuSearch(String(pageNation), "41", searchTxt) : pubHasuInit(String(pageNation), "41"); + isResetPage(true); }} > 조회 @@ -363,6 +325,7 @@ export default function PublicReuseFaciltyInsert() { cellClick={cellClick} onPageChange={setPageNation} children={undefined} + resetPageNo={resetPage} /> @@ -407,7 +370,6 @@ export default function PublicReuseFaciltyInsert() { indexBiz={indexBiz} /> - ) : ( @@ -438,7 +400,6 @@ export default function PublicReuseFaciltyInsert() { - )} } diff --git a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/utilsZod.tsx b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/utilsZod.tsx index 3433a62c5..f5db32812 100644 --- a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/utilsZod.tsx +++ b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/utilsZod.tsx @@ -1,28 +1,37 @@ -import type { fcBizType, pubHasuType } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; +import type { fcBizType, operType, pubHasuType } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; -export function createDefaultPbnstItem( - selecTableRow: pubHasuType, - index: number - ) { - const pk = String(selecTableRow.bscFctCd) + String(index + 1); - +export function createDefaultPbnstItem(row: pubHasuType, index: number) { + const pk = row.bscFctCd + String(index + 1); + + return JSON.parse(JSON.stringify({ + pbnstRuseFcltPk: pk, + swtrmtFcltFk: "", + ruseUtztnFcltNm: "", + fcltCpct: 0, + ruseCpct: 0, + splyExtraCpct: 0, + regDt: null, + rgtr: "", + mdfcnDt: null, + mdfr: "", + fcFiles: [], + fcBizs: [createDefaultBiz(pk, 1)], + fcOpers: [], // 빈 배열 강제 + })); +} + + + export function createDefaultOper(pbnstRuseFcltFk: string): operType { return { - pbnstRuseFcltPk: pk, - swtrmtFcltFk: "", - ruseUtztnFcltNm: "", // 필수 입력이므로 빈 문자열로 - fcltCpct: 0, - ruseCpct: 0, - splyExtraCpct: 0, - regDt: null, - rgtr: "test", - mdfcnDt: null, - mdfr: "test", - fcFiles: [], - fcBizs: [ - createDefaultBiz(pk, 1), // 첫 차수 - ], - fcOpers: [], - }; + pbnstRuseFcltFk, + operMthd: "", + rprtvBzenty: "", + bgngDt: new Date(), + endDt: new Date(), + choose: false, + rgtr: "", + mdfr: "", + } as operType; } diff --git a/apps/wr/app/ruseFcltMng/prfmncReg/pbnstPrfmncReg/page.tsx b/apps/wr/app/ruseFcltMng/prfmncReg/pbnstPrfmncReg/page.tsx index 5ea418634..d5e9412d4 100644 --- a/apps/wr/app/ruseFcltMng/prfmncReg/pbnstPrfmncReg/page.tsx +++ b/apps/wr/app/ruseFcltMng/prfmncReg/pbnstPrfmncReg/page.tsx @@ -75,6 +75,7 @@ export default function prfmncPrfmncReg() { searchYear, pbnstRuseFcltPk ) as unknown as PrfType + ,searchYear ); // cellClick(cellNum) } @@ -298,7 +299,6 @@ export default function prfmncPrfmncReg() { {"하수처리수재이용 실적(m3) 등록결과"} - {headMakeprfmnc(monthHeadList, [])} diff --git a/apps/wr/app/store/common/type/header.tsx b/apps/wr/app/store/common/type/header.tsx index f064b7580..29780ba03 100644 --- a/apps/wr/app/store/common/type/header.tsx +++ b/apps/wr/app/store/common/type/header.tsx @@ -22,6 +22,7 @@ export type TableUpperProps = { selectData ?:string; // type 이 seelct 일경우 selectarray 정하기 위해 row?:number; mergeCell?:boolean // 셀을 합칠경우 + maxLength?:number readonly?:boolean }; diff --git a/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/type.tsx b/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/type.tsx index f6d5ff43f..742a17c16 100644 --- a/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/type.tsx +++ b/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/type.tsx @@ -2,6 +2,20 @@ import { z } from "zod"; import type { TableUpperProps } from "../../common/type/header"; import { fcOperSchema } from "../../ruseFcltMng/fcltReg/pbnstReg/type"; + + +type Month = `${1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12}월`; + +export type PrfUsageSummary = { + 구분: string; + usage: string; + 용수명?: string; + total: number; + edit?:boolean +} & Record; + + + export const PrfSchema = z.object({ pbnstRuseFcltFk: z.string(), ym: z.string(), // 예: "202310" @@ -44,8 +58,9 @@ export const FcPrfSchema = z.object({ export type FcPrfType = z.infer; export type PrfType = z.infer; -export const initValInUsage = [ +export const initValInUsage:PrfUsageSummary[] = [ { + 구분: "장내용수", usage: "wshwtr", 용수명: "세척수", total: 0, @@ -63,6 +78,7 @@ export const initValInUsage = [ "12월": 0, }, { + 구분: "장내용수", usage: "coolUswtr", 용수명: "냉각수", total: 0, @@ -80,6 +96,7 @@ export const initValInUsage = [ "12월": 0, }, { + 구분: "장내용수", usage: "cleanUswtr", 용수명: "청소수", total: 0, @@ -97,6 +114,7 @@ export const initValInUsage = [ "12월": 0, }, { + 구분: "장내용수", usage: "drwtUswtr", 용수명: "식수대", total: 0, @@ -114,6 +132,7 @@ export const initValInUsage = [ "12월": 0, }, { + 구분: "장내용수", usage: "dltnUswtr", 용수명: "희석용수", total: 0, @@ -131,6 +150,7 @@ export const initValInUsage = [ "12월": 0, }, { + 구분: "장내용수", usage: "ithlRswtr", 용수명: "중수도", total: 0, @@ -148,6 +168,7 @@ export const initValInUsage = [ "12월": 0, }, { + 구분: "장내용수", usage: "ithlEtcUswtr", 용수명: "기타", total: 0, @@ -166,8 +187,9 @@ export const initValInUsage = [ }, ]; -export const initValOutUsage = [ +export const initValOutUsage: PrfUsageSummary[] = [ { + 구분: "장외용수", usage: "resn", 용수명: "세척살수용수", total: 0, @@ -185,6 +207,7 @@ export const initValOutUsage = [ "12월": 0, }, { + 구분: "장외용수", usage: "cleanToilUswtr", 용수명: "청소화장실용수", total: 0, @@ -202,6 +225,7 @@ export const initValOutUsage = [ "12월": 0, }, { + 구분: "장외용수", usage: "lndwtr", 용수명: "조경용수", total: 0, @@ -219,6 +243,7 @@ export const initValOutUsage = [ "12월": 0, }, { + 구분: "장외용수", usage: "hydUswtr", 용수명: "친수용수", total: 0, @@ -236,6 +261,7 @@ export const initValOutUsage = [ "12월": 0, }, { + 구분: "장외용수", usage: "ugwtChr", 용수명: "지하수충전", total: 0, @@ -253,6 +279,7 @@ export const initValOutUsage = [ "12월": 0, }, { + 구분: "장외용수", usage: "farmUswtr", 용수명: "농업용수", total: 0, @@ -271,6 +298,7 @@ export const initValOutUsage = [ }, { + 구분: "장외용수", usage: "rvrKeepUswtr", 용수명: "하천등유지용수", total: 0, @@ -289,6 +317,7 @@ export const initValOutUsage = [ }, { + 구분: "장외용수", usage: "indstUswtr", 용수명: "공업용수", total: 0, @@ -307,7 +336,7 @@ export const initValOutUsage = [ }, ]; -export const subTotalObj = { +export const subTotalObj:PrfUsageSummary = { usage: "subtotal", 용수명: "소계", edit: false, @@ -326,7 +355,7 @@ export const subTotalObj = { "12월": 0, }; -export const totalObj = { +export const totalObj:PrfUsageSummary = { usage: "total", 용수명: "총합계", edit: false, diff --git a/apps/wr/app/store/prfmncSttn/pbnstPrfmncSttn/headList.tsx b/apps/wr/app/store/prfmncSttn/pbnstPrfmncSttn/headList.tsx index d04ef7b20..9095d96b9 100644 --- a/apps/wr/app/store/prfmncSttn/pbnstPrfmncSttn/headList.tsx +++ b/apps/wr/app/store/prfmncSttn/pbnstPrfmncSttn/headList.tsx @@ -1,5 +1,4 @@ -import { z } from "zod"; -import type { TableUpperProps } from "../../ruseFcltMng/fcltReg/rainReg"; +import type { TableUpperProps } from "../../common/type/header"; export const pbnstPrfmncSttnHeadListExport: TableUpperProps[] = [ { @@ -37,6 +36,7 @@ export const pbnstPrfmncSttnHeadListExport: TableUpperProps[] = [ export const pbnstYearHeadListExport: TableUpperProps[] = [ { + id: "year", title: "년도", colSpan: 3, row: 0 @@ -57,3 +57,25 @@ export const pbnstYearHeadListExport: TableUpperProps[] = [ row: 1 }, ] + + + + + +export const monthSttnHeadListExport: TableUpperProps[] = [ + { id: "구분", title: "구분", mergeCell: true }, + { id: "용수명", title: "용수명" }, + { id: "total", title: "계" }, + { id: "1월", title: "1월" }, + { id: "2월", title: "2월" }, + { id: "3월", title: "3월" }, + { id: "4월", title: "4월" }, + { id: "5월", title: "5월" }, + { id: "6월", title: "6월" }, + { id: "7월", title: "7월" }, + { id: "8월", title: "8월" }, + { id: "9월", title: "9월" }, + { id: "10월", title: "10" }, + { id: "11월", title: "11월" }, + { id: "12월", title: "12월", }, +]; \ 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 db8b6a717..4cb485e40 100644 --- a/apps/wr/app/store/prfmncSttn/pbnstPrfmncSttn/index.tsx +++ b/apps/wr/app/store/prfmncSttn/pbnstPrfmncSttn/index.tsx @@ -1,6 +1,6 @@ import { fetchType, getFetch, postFectch } from "@/components/lib/api"; import type { TableUpperProps } from "../../common/type/header"; -import { pbnstPrfmncSttnHeadListExport, pbnstYearHeadListExport } from "./headList"; +import { monthSttnHeadListExport, pbnstPrfmncSttnHeadListExport, pbnstYearHeadListExport } from "./headList"; import type { FcPrfType, PrfType } from "../../prfmncReg/pbnstPrfmncReg/type"; import type { pubHasuType, selectLabel } from "../../ruseFcltMng/fcltReg/pbnstReg/type"; import type { ReturnType } from "@common/business_components"; @@ -22,6 +22,7 @@ export type pbnstPrfmncSttnState = { isInit: boolean; rawData: any[]; selectYearList: selectLabel[] + monthSttnHeadList:TableUpperProps[]; } } @@ -34,7 +35,8 @@ export const pbnstPrfmncSttnExport: pbnstPrfmncSttnState = { prfmncRes: prfmncRes, isInit: false, rawData: [], - selectYearList: [] + selectYearList: [], + monthSttnHeadList:monthSttnHeadListExport } } @@ -147,15 +149,15 @@ export const pbnstPrfmncSttnActionsExport: (set: any) => pbnstPrfmncSttnActions let outUsageSum = 0; let usageSum = 0; let year = ""; - const yearsData = [] + const yearsData = [] as any - res.data.forEach((item) => { + res.data.forEach((item : any) => { if (item.prfList.length === 0) { - const year = ""; // 연도 정보가 없으면 빈 문자열, 필요시 item에서 추출 - const yearVal = { year: year, pbnstRuseFcltPk: item.pbnstRuseFcltPk ?? "", ruseUtztnFcltNm : item.ruseUtztnFcltNm ?? "" }; - yearVal[year + "inUsage"] = 0; - yearVal[year + "outUsage"] = 0; - yearVal[year + "total"] = 0; + const year: string = ""; // 연도 정보가 없으면 빈 문자열, 필요시 item에서 추출. + const yearVal: { [key: string]: any } = { year: year, pbnstRuseFcltPk: item.pbnstRuseFcltPk ?? "", ruseUtztnFcltNm : item.ruseUtztnFcltNm ?? "" }; + yearVal[`${year}inUsage`] = 0; + yearVal[`${year}outUsage`] = 0; + yearVal[`${year}total`] = 0; yearsData.push(yearVal); } item.prfList.forEach((acc) => { @@ -184,14 +186,14 @@ export const pbnstPrfmncSttnActionsExport: (set: any) => pbnstPrfmncSttnActions ); if (yearData) { - yearData[year + "inUsage"] += inUsageSum; - yearData[year + "outUsage"] += outUsageSum; - yearData[year + "total"] += (inUsageSum + outUsageSum); + yearData[`${year}inUsage`] += inUsageSum; + yearData[`${year}outUsage`] += outUsageSum; + yearData[`${year}total`] += (inUsageSum + outUsageSum); } else { - const yearVal = { year: year, pbnstRuseFcltPk: acc.pbnstRuseFcltFk, ruseUtztnFcltNm : item.ruseUtztnFcltNm ?? "" }; - yearVal[year + "inUsage"] = inUsageSum; - yearVal[year + "outUsage"] = outUsageSum; - yearVal[year + "total"] = inUsageSum + outUsageSum; + const yearVal: { [key: string]: any } = { year: year, pbnstRuseFcltPk: acc.pbnstRuseFcltFk, ruseUtztnFcltNm : item.ruseUtztnFcltNm ?? "" }; + yearVal[`${year}inUsage`] = inUsageSum; + yearVal[`${year}outUsage`] = outUsageSum; + yearVal[`${year}total`] = inUsageSum + outUsageSum; yearsData.push(yearVal); } }); diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx index 569fad381..84413fbc2 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx @@ -14,8 +14,8 @@ export const pubFacHeadListExport: TableUpperProps[] = [ export const pbnstMngUpHeadListExport: TableUpperProps[] = [ { id: "choose", title: "선택", type: "checkbox" }, - { id: "operMthd", title: "운영방식",type: "select", selectData: "ruseMngMtd" }, - { id: "rprtvBzenty", title: "대행업체", edit: true }, + { id: "operMthd", title: "운영방식",type: "select", selectData: "ruseMngMtd" }, + { id: "rprtvBzenty", title: "대행업체", edit: true ,maxLength:10 }, { id: "bgngDt", title: "시작일", diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx index 9f4b6e859..f34353add 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx @@ -65,7 +65,6 @@ type pubFacActions = { appendRuseFclt(array: customPbnst[]): void; fileDelete: (atflCd: string) => void; fileDownLoad: (atflCd: string) => void; - getpbnstInsertIndex: (data: pbnstInsertIndex) => void; pbnstRuseFcltUpdate: (ruseRes: customPbnst[]) => void; pbnstRuseBizUpdate: (ruseRes: fcBizType[]) => void; pubHasuSearch :(page: string, sggOrCity: string , searchTxt:string) => void @@ -314,33 +313,7 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { } }, - fileInfoUpdate:async(atflCd: string)=>{ - - const WrTableInfo={ - "lnkgDmnNm": "tbWrRuseFcltFile", - "lnkgDmnId": "fileTkn" - } - - try{ - const response = await putFectch( - `/attach-service/api/v1/atfl/attachments/${atflCd}/info`, - WrTableInfo, - fetchType.CS - ) - if (!response.ok) { - throw new Error(`Error downloading file: ${response.statusText}`); - } - }catch(e){ - - } - }, - - getpbnstInsertIndex: async (data: pbnstInsertIndex) => { - return set((state: pubFacState) => { - state.pbnst.pbnsUpdateIndex = data; - return state; - }); - }, + appendRuseFclt: async (array: customPbnst[]) => { try { return set((state: pubFacState) => ({ diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx index ad3496a54..a08c5301a 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx @@ -82,6 +82,10 @@ const zNum = z.preprocess( (v) => (v !== null && v !== undefined ? Number(v) : v), z.number() ); +const zNumGte = z.preprocess( + (v) => (v !== null && v !== undefined ? Number(v) : v), + z.number().gt(0, { message: "0보다 큰 숫자만 가능합니다" }) +); const zNumNullish = zNum.nullish(); const zNumDefaultZero = zNum.default(0).nullish(); @@ -151,7 +155,6 @@ const dmdColist = z.object({ export const fcBizSchema = z.object({ pbnstRuseFcltBizPk: zNumNullish, pbnstRuseFcltFk: z.string().nullish(), - superkey: z.string().default("").nullish(), cycl: zNum.default(1), seCd: z.string().max(10, "구분은 10자를 초과할 수 없습니다.").default(""), bizMthdCd: z.string().default(""), @@ -236,25 +239,31 @@ export const fcBizSchema = z.object({ export const pbnstRegZod = z.object({ pbnstRuseFcltPk: z.string().default(""), swtrmtFcltFk: z.string().default(""), - ruseUtztnFcltNm: z - .preprocess( + ruseUtztnFcltNm: //z.string().default(''), + z.preprocess( (v) => (v !== null && v !== undefined ? String(v).trim() : ""), // null/undefined → "", 공백 제거 z.string().min(1, "시설 이름을 입력하세요")), - fcltCpct: zNumDefaultZero, - ruseCpct: zNumDefaultZero, - splyExtraCpct: zNumDefaultZero, + fcltCpct: z.preprocess( + (v) => (v !== null && v !== undefined ? Number(v) : v), + z.number().gte(0, { message: "재이용시설 용량은 0보다 크거나 같아야 합니다" }) + ), + ruseCpct: z.preprocess( + (v) => (v !== null && v !== undefined ? Number(v) : v), + z.number().gte(0, { message: "재이용시설 재이용수 공급량은 0보다 크거나 같아야 합니다" }) + ), + splyExtraCpct: z.preprocess( + (v) => (v !== null && v !== undefined ? Number(v) : v), + z.number().gte(0, { message: "재이용시설 공급가능량은 0보다 크거나 같아야 합니다" }) + ), regDt: zDateDefaultNow, rgtr: z.string().default("test"), mdfcnDt: zDateDefaultNow, mdfr: z.string().default("test"), fcFiles: z.array(fcFileSchema).default([]).nullish(), fcBizs: z.array(fcBizSchema).default([]), - fcOpers: z - .array(fcOperSchema) - .refine((val) => val.length >= 1, { - message: "재이용시설의 운영정보를 최소 하나를 등록해주세요", - }) - .default([]), // 기본값 설정 + fcOpers://z.array(fcOperSchema).default([]), + z .array(fcOperSchema) + .min(1, { message: "재이용시설의 운영정보를 최소 하나를 등록해주세요" }) }); export const pbnstRegArrayZod = z.array(pbnstRegZod); 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 cef483bfb..bb7987501 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx @@ -48,7 +48,7 @@ export function PbnstMngForm({ indexMng: number; setIndexMng: (index: number) => void; }) { - const { code, pbnst, fileDelete, fileDownLoad } = useWrStore( + const { code, pbnst, fileDelete, fileDownLoad } = useWrStore( (state) => state ); const { pbnstRes } = pbnst; @@ -57,6 +57,10 @@ export function PbnstMngForm({ const [planFiles, setPlanFiles] = useState(null); const [relationfiles, setRelationFiles] = useState(null); const [fcltNm, setFcltNm] = useState(null); + const [opersKey, setOpersKey] = useState(0); + useEffect(() => { + setOpersKey((prev) => prev + 1); + }, [indexMng]); const [mngMtdCode, setMngMtdCode] = useState<{ name: string; val: SelectDataType[] }[]>(); @@ -69,6 +73,11 @@ export function PbnstMngForm({ name: `items.${indexMng}.fcOpers`, }); + const { fields: mngRegForm } = useFieldArray({ + control: form.control, + name: `items`, + }); + const plusHist = () => { prepend({ choose: false, @@ -81,6 +90,8 @@ export function PbnstMngForm({ bgngDt: new Date(), endDt: new Date(), }); + //trigger(`items.${indexMng}.fcOpers`); + }; const removeSelected = () => { @@ -166,7 +177,6 @@ export function PbnstMngForm({ useEffect(() => { const currentItem = form.getValues(`items.${indexMng}`); const currentKey = JSON.stringify(currentItem); - const isNewItem = !fileInitRef.current || fileInitRef.current.index !== indexMng || @@ -207,19 +217,21 @@ export function PbnstMngForm({ }; }, [indexMng, form.getValues(`items.${indexMng}`)]); - - useEffect(() => { - if (pbnst.pbnstRes && pbnst.pbnstRes?.length >= 0) { - const fcltNmList = pbnst.pbnstRes?.map((item, index) => ({ - text: item.ruseUtztnFcltNm, - val: String(index), - })); - - if (fcltNmList) setFcltNm(fcltNmList); - } else { - setFcltNm(null); - } - }, [pbnst.pbnstRes]); + useEffect( + () => { + //폼이 들어오면 폼에 대한 이름 셀렉트박스를만들기 위해 + if (mngRegForm && mngRegForm.length >= 0) { + const fcltNmList = mngRegForm?.map((item, index) => ({ + text: item.ruseUtztnFcltNm, + val: String(index), + })); + if (fcltNmList) setFcltNm(fcltNmList); + } else { + setFcltNm(null); + } + }, //pbnst.pbnstRes + [mngRegForm] + ); useEffect(() => { if (regFileList && regFileList?.length > 0) { @@ -238,12 +250,6 @@ export function PbnstMngForm({ } }, [planFiles]); - useEffect(() => { - if (regFileList && regFileList?.length > 0) { - form.setValue(`items.${indexMng}.fcFiles`, regFileList); - } - }, [regFileList, indexMng]); - useEffect(() => { if (code.ruseMngMtd) { setMngMtdCode([{ name: "ruseMngMtd", val: code.ruseMngMtd }]); @@ -329,7 +335,8 @@ export function PbnstMngForm({
{ @@ -365,6 +372,7 @@ export function PbnstMngForm({ { if (formType !== "sttn") @@ -388,6 +396,7 @@ export function PbnstMngForm({ { if (formType !== "sttn") @@ -410,6 +419,7 @@ export function PbnstMngForm({ { if (formType !== "sttn") @@ -509,3 +519,7 @@ export function PbnstMngForm({
); } +function trigger(arg0: string) { + throw new Error("Function not implemented."); +} + diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegFormDetail/mngRegFormDetail.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegFormDetail/mngRegFormDetail.tsx index 234efa7c7..5bac0c3f4 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegFormDetail/mngRegFormDetail.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegFormDetail/mngRegFormDetail.tsx @@ -110,6 +110,9 @@ export default function MngRegFormDetail({ void; onInvalid:(errors: FieldErrors<{ items: z.infer[] }>) => void }) { - const { pbnstInsert } = useWrStore((state) => { - return state; - }); + const [pbnstBdstForm, setPbnstBdstForm] = useState( {} as customPbnst ); @@ -126,6 +124,7 @@ export function PbnstRegModal({ }, [form.formState.errors]); useEffect(() => { + const firstForm = form.getValues("items"); if (firstForm) { setIndexMng(firstForm.length - 1); diff --git a/apps/wr/components/ui/modal/sttn/pbnstSttnModal/pbnstSttnModal.tsx b/apps/wr/components/ui/modal/sttn/pbnstSttnModal/pbnstSttnModal.tsx index cec8babd0..498019cd7 100644 --- a/apps/wr/components/ui/modal/sttn/pbnstSttnModal/pbnstSttnModal.tsx +++ b/apps/wr/components/ui/modal/sttn/pbnstSttnModal/pbnstSttnModal.tsx @@ -1,3 +1,4 @@ +import { headMakeprfmnc } from "@/app/ruseFcltMng/prfmncReg/chkgdnReg/TableHead"; import { useWrStore } from "@/app/store"; import type { TableUpperProps } from "@/app/store/common/type/header"; import { @@ -14,8 +15,10 @@ import { type fcBizType, } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; import { formH1Class } from "@/components/lib/class/comClass"; +import { InputTableBody } from "@/components/lib/func/TableData"; import { PbnstMngForm } from "@/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm"; import { ScrollArea, Title, UiTable } from "@common/business_components/ui"; +import ListDiv from "@common/business_components/ui/list_div"; import { HeadMakeColSpan } from "@common/business_components/ui/table/HeadMakeColSpan"; import { Tabs, @@ -23,6 +26,9 @@ import { TabsTrigger, Button, TabsContent, + TableHeader, + TableBody, + Table, } from "@common/components/ui"; import { zodResolver } from "@hookform/resolvers/zod"; import { useEffect, useState } from "react"; @@ -30,7 +36,7 @@ import { set, useForm } from "react-hook-form"; import { z } from "zod"; export function PbnstSttnModal({ data, titleVisible }: { data: customPbnst; titleVisible?: boolean }) { - const { code, pbnstSttn, prfmnc } = useWrStore((state) => state); + const { code, pbnstSttn, prfmnc , pbnstPrfmncSttn} = useWrStore((state) => state); const [fcltTab, setFcltTab] = useState("fclt"); const [ruseTab, setRuseTab] = useState("totalPrf"); const [ruseBizData, setRuseBizData] = useState<{ @@ -180,6 +186,7 @@ export function PbnstSttnModal({ data, titleVisible }: { data: customPbnst; titl const usageKey = inData.usage; const value = (prfItem as any)[usageKey] ?? 0; + inData[monthKey] = value; inData.total += value; @@ -231,7 +238,6 @@ export function PbnstSttnModal({ data, titleVisible }: { data: customPbnst; titl )?.prfList; if (prfList) { - console.log("prfList", prfList); getTablePrfData(prfList); } @@ -324,17 +330,23 @@ export function PbnstSttnModal({ data, titleVisible }: { data: customPbnst; titl {prfData && ( - + + +
+

+ {"하수처리수재이용 실적(m3) 등록결과"} +

+
+
+ + {headMakeprfmnc(pbnstPrfmncSttn.monthSttnHeadList, [])} + + + {InputTableBody(prfData[ruseTab as keyof typeof prfData] || [], pbnstPrfmncSttn.monthSttnHeadList, setPrfData as any)} + +
+ + )} diff --git a/apps/wr/components/ui/table/pbnstReg/ruseMngTableForm/ruseMngTableForm.tsx b/apps/wr/components/ui/table/pbnstReg/ruseMngTableForm/ruseMngTableForm.tsx index 577e7ce46..efc4e1dd6 100644 --- a/apps/wr/components/ui/table/pbnstReg/ruseMngTableForm/ruseMngTableForm.tsx +++ b/apps/wr/components/ui/table/pbnstReg/ruseMngTableForm/ruseMngTableForm.tsx @@ -56,7 +56,7 @@ const RuseMngTableForm = React.forwardRef( ) => { return ( <> - +
{upHeadList ? ( headMakeprfmnc(headList, upHeadList) @@ -114,6 +114,7 @@ const RuseMngTableForm = React.forwardRef( : field.value || "" } readOnly={head.readonly ? true : false} + maxLength={head.maxLength?head.maxLength:15} /> ) : head.type === "select" ? (