From 93beaa7a67351249695269d73b35a6a861985bd0 Mon Sep 17 00:00:00 2001 From: leedj312 Date: Mon, 26 May 2025 09:59:07 +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=82=AC=EC=97=85=20=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8=20?= =?UTF-8?q?=EC=9E=91=EC=97=85=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ruseFcltMng/fcltReg/pbnstReg/page.tsx | 15 ++- .../ruseFcltMng/fcltSttn/pbnstSttn/page.tsx | 4 +- .../prfmncReg/chkgdnReg/rswrtChkgdn/index.tsx | 6 +- .../ruseFcltMng/fcltReg/pbnstReg/headList.tsx | 35 ++++- .../ruseFcltMng/fcltReg/pbnstReg/index.tsx | 19 ++- .../ruseFcltMng/fcltReg/pbnstReg/type.tsx | 50 ++++++-- .../ruseFcltMng/fcltSttn/pbnstSttn/index.tsx | 2 +- .../fcltReg/pbnstReg/buseReg/bugRegForm.tsx | 120 +++++++++++++----- .../mngRegFormDetail/mngRegFormDetail.tsx | 23 ++-- .../pbnstReg/ruseMngTable/ruseMngTable.tsx | 2 +- 10 files changed, 212 insertions(+), 64 deletions(-) diff --git a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx index 4a7da579d..57f77dfff 100644 --- a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx @@ -14,9 +14,10 @@ import { Tabs, TabsList, TabsTrigger, TabsContent } from "@common/components"; import { useEffect, useState } from "react"; import ListDiv from "@common/business_components/ui/list_div"; import { tableData } from "@/components/lib/func/commom"; -import type { customPbnst, ruseFcltType } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; +import type { customPbnst, fcBizSchema, fcBizType, ruseFcltType } 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"; +import { z } from "zod"; export default function PublicReuseFaciltyInsert() { const { code, pbnst, pubHasuInit,pbnstRegInit } = useWrStore((state) => state); @@ -26,6 +27,8 @@ export default function PublicReuseFaciltyInsert() { const {pbnstRes} = pbnst const [currentTab, setCurrentTab] = useState("mng"); const [fcltMng, setFcltMng] = useState(); + const [pbnstBiz, setPbnstBiz] = useState(); + const [searchTxt, setSearchTxt] = useState(); const [bdstTable, setbdstTable] = useState(); @@ -53,8 +56,9 @@ useEffect(() => { console.log(val); }; const cellClick = (val: number | undefined) => { - if (val === undefined) return; + + setPbnstBiz(pbnstRes?.fcBizs) setFcltMng([]); }; const resetContents = () => { @@ -65,6 +69,11 @@ useEffect(() => { setCurrentTab(value); }; + useEffect(() => { + + console.log("pbnstBiz", pbnstBiz); + },[pbnstBiz]) + return ( <> @@ -129,7 +138,7 @@ useEffect(() => { - + diff --git a/apps/wr/app/ruseFcltMng/fcltSttn/pbnstSttn/page.tsx b/apps/wr/app/ruseFcltMng/fcltSttn/pbnstSttn/page.tsx index c294bdf93..a662ffb7a 100644 --- a/apps/wr/app/ruseFcltMng/fcltSttn/pbnstSttn/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltSttn/pbnstSttn/page.tsx @@ -14,7 +14,7 @@ import { Button } from "@common/components/ui"; import HeadChModal from "@/components/ui/modal/sttn/headChModal/headChModal"; import { useCallback, useEffect, useRef, useState } from "react"; import { HeadMakeColSpan } from "@common/business_components/ui/table/HeadMakeColSpan"; -import type { customPbnst } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg"; +import type { customPbnst } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; export default function PbnstSttn() { const { code, pbnstSttn } = useWrStore( @@ -26,10 +26,8 @@ export default function PbnstSttn() { const [pageNation, setPageNation] = useState(1); const [isChHead, setIsChHead] = useState(false); const [bdstTable, setBdstTable] = useState(); - // const nodeList = headMakeprfmnc(pbnstSttn.pbnSttHeadList, pbnstSttn.pbnSttHeadNm); const excelClick = useCallback(() => { - // if (codeData) pbnstSttnSearch(1, "10000", codeData); }, []); return ( diff --git a/apps/wr/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/index.tsx b/apps/wr/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/index.tsx index 110c684bf..c6737b31e 100644 --- a/apps/wr/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/index.tsx +++ b/apps/wr/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/index.tsx @@ -66,7 +66,11 @@ export const rswtChkgdnStateExport: rswtChkgdnState = { rswtChkHeadList: rswtChkHeadList, rswtDetailHeadList: rswtDetailHeadList, rswtHeadNm: rswtHeadNm, - excelList: [{ data: [[]], headerNum: 0, headerRange: "A1:V3" }], + excelList: [{ + data: [[]], headerNum: 0, headerRange: "A1:V3", + sheetName: "", + startCol: 0 + }], rswtChkRes: [], rswtChkPolGuide: [], isInit: false, diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx index 8aa75fd28..d3a0e5f0e 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx @@ -24,6 +24,24 @@ export const pbnstMngUpHeadListExport: TableUpperProps[] = [ ]; +export const pplInstlsHeadListExport: TableUpperProps[] = [ + { id: "ppMqlt", title: "관재질", }, + { id: "pdmt", title: "관경" }, + { id: "cpct", title: "연장", }, +]; + + +export const pbnstDemandHeadListExport: TableUpperProps[] = [ + { id: "dmdCoNm", title: "수요처명" }, + { id: "daddr", title: "위치(주소)" }, + { id: "useUsgCd", title: "사용용도", }, + { id: "splyBgngDay", title: "공급시작일", }, + { id: "splyEndDay", title: "공급종료일", }, + { id: "splyCpct", title: "공급량(m³/일)", }, + { id: "splyFmYon", title: "공급유량계 유무", }, +]; + + export const pbnstOrgwtHeadListRxport: TableUpperProps[] = [ { id: "ruseUtztnFcltNm", title: "운영방식" }, { id: "orgwtWtritQnt", title: "원수취수량" }, @@ -31,7 +49,6 @@ export const pbnstOrgwtHeadListRxport: TableUpperProps[] = [ { id: "dschgFmYn", title: "하수처리장 방류 유량계 전·후​", }, { id: "dtlPstnExpln", title: "상세위치 설명", }, ]; -const date = new Date(); export const pbnstMngNmExport: chHeadType[] = [ { headNm: "upChangeRe", text: "운영대행기간", length: 2 }, @@ -72,7 +89,7 @@ export const businessMoneyInfo:formDetailType[]=[ {id:'gvsbs' , lable:'국고'}, {id:'lcep' , lable:'지방비'}, {id:'username' , lable:'민간투자비'}, - {id:'cusr_alotm' , lable:'원인자부담금'}, + {id:'cusrAlotm' , lable:'원인자부담금'}, {id:'etc' , lable:'기타'}, {id:'totalMoney' , lable:'합계'}, ] @@ -90,4 +107,18 @@ export const ruseFcltIntakeList:formDetailType[]=[ {id:'bizMthdCd' , lable:'사업방식'}, {id:'bizCmcnDay' , lable:'사업준공일' ,type:'date'}, {id:'instlAprvSncnDt' , lable:'설치승인인가일' ,type:'date'} , +] + +export const ruseWaterQulityList:formDetailType[]=[ + {id:'bod' , lable:'BOD(mg/L)'}, + {id:'grssClfg' , lable:'총대장균군수(개/mg)'}, + {id:'combResdch' , lable:'결합잔류염소(mh/L)'}, + {id:'trbt' , lable:'탁도(NTU)'}, + {id:'smll' , lable:'냄새'}, + {id:'crmty' , lable:'색도'}, + {id:'tn' , lable:'총질소(mg/L)'}, + {id:'tph' , lable:'총인(mg/L)'}, + {id:'ph' , lable:'수소이온농도'}, + {id:'clIonQnt' , lable:'염화물(mg/L)'}, + {id:'cdtnv' , lable:'전기전도도(μs/cm)​'}, ] \ No newline at end of file diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx index a4ee07a95..d69adc713 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx @@ -4,7 +4,7 @@ import { getFetch } from "@/components/lib/api"; import type { chHeadType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList"; import { exampleData, fcBizSchema, type customPbnst, type pubHasuType } from "./type"; import type { SelectDataType } from "@common/business_components/ui"; -import { pbnstMngUpHeadListExport, pbnstOrgwtHeadListRxport, pbnstMngNmExport, pubFacHeadListExport } from "./headList"; +import { pbnstMngUpHeadListExport, pbnstOrgwtHeadListRxport, pbnstMngNmExport, pubFacHeadListExport, pplInstlsHeadListExport, pbnstDemandHeadListExport } from "./headList"; const selectLabel: SelectDataType[] = [{ text: "test", val: "1" }]; @@ -12,6 +12,8 @@ const pubFacHeadList= pubFacHeadListExport; const pbnstMngUpHeadList = pbnstMngUpHeadListExport const pbnstOrgwtHeadList =pbnstOrgwtHeadListRxport const pbnstMngNm= pbnstMngNmExport; +const pplInstlsHeadLisat =pplInstlsHeadListExport +const pbnstDemandHeadList= pbnstDemandHeadListExport export type pubFacState = { @@ -21,10 +23,12 @@ export type pubFacState = { pbnstMngUpHeadList: TableUpperProps[]; pbnstMngNm: chHeadType[]; pbnstHasuRes: pubHasuType[] - pbnstRes: customPbnst[]; + pbnstRes: customPbnst | null; // 배열에서 단일 객체 또는 null로 변경 pbnstBizCycle: SelectDataType[]; selectLabel: SelectDataType[]; pbnstOrgwtHeadList:TableUpperProps[] + pplInstlsHeadLisat:TableUpperProps[] + pbnstDemandHeadList:TableUpperProps[] }; }; type pubFacActions = { @@ -44,9 +48,11 @@ export const pubFacStateExport: pubFacState = { pbnstMngNm: pbnstMngNm, pbnstOrgwtHeadList:pbnstOrgwtHeadList, pbnstHasuRes: [], - pbnstRes: [], + pbnstRes: null, // 초기값을 null로 변경 pbnstBizCycle:[{text:'없음', val:'1'}], selectLabel: selectLabel, + pplInstlsHeadLisat:pplInstlsHeadLisat, + pbnstDemandHeadList:pbnstDemandHeadList, }, }; @@ -95,7 +101,7 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { const pbnstRes = exampleData; - const pbnstBizCycle = getBizCycle(pbnstRes?.fcBizs); + const pbnstBizCycle = pbnstRes ? getBizCycle(pbnstRes.fcBizs) : []; // pbnstRes가 null일 수 있으므로 체크 return set((state: pubFacState) => ({ ...state, @@ -116,7 +122,10 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { "wr", `/api/v1/reuseFc/pubFc` + (txt ? `/${txt}` : "") + `/${sgg}` ); - const pbnstBizCycle = getBizCycle(pbnstRes.fcBizs); + // API 응답이 pbnstRegZod 타입의 단일 객체라고 가정 + const pbnstBizCycle = pbnstRes && pbnstRes.fcBizs ? getBizCycle(pbnstRes.fcBizs) : []; + + return set((state: pubFacState) => ({ ...state, pbnst: { diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx index 1a8f1479f..043c8fedf 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx @@ -45,6 +45,12 @@ export type ruseFcltType = { splyExtraCpct: number; }; +export type fcBizType = z.infer; +export type fcOrgwtType = z.infer; +export type ppInstlType = z.infer; + +export type operType = z.infer; + const pplInstlSchema = z.object({ ruseFcltBizFk: z.string(), pdmt: z.string(), @@ -185,18 +191,18 @@ export const fcBizSchema = z.object({ export const pbnstRegZod = z.object({ pbnstRuseFcltPk: z.number().default(0), - swtrmtFcltFk: z.string(), - ruseUtztnFcltNm: z.string(), - fcltCpct: z.string(), - ruseCpct: z.string(), - splyExtraCpct: z.string(), + swtrmtFcltFk: z.string().default(""), + ruseUtztnFcltNm: z.string().default(""), + fcltCpct: z.string().default(""), + ruseCpct: z.string().default(""), + splyExtraCpct: z.string().default(""), regDt: z.date().default(new Date()), rgtr: z.string().default("test"), mdfcnDt: z.date().default(new Date()), mdfr: z.string().default("test"), - fcFiles: z.array(fcFileSchema), - fcBizs: z.array(fcBizSchema), - fcOpers: z.array(fcOperSchema), + fcFiles: z.array(fcFileSchema).default([]), + fcBizs: z.array(fcBizSchema).default([]), + fcOpers: z.array(fcOperSchema).default([]), }); const pubHasuZod = z.object({ @@ -286,6 +292,20 @@ export const exampleData = { archCstClcln: "380", pplCstClcln: "290", ruseFcltCstClcln: "4800", + pplInstls:[ + { + ruseFcltBizFk: "10", + pdmt: "관경", + ppMqlt: "1", + cpct: "100", + }, + { + ruseFcltBizFk: "10", + pdmt: "관경", + ppMqlt: "2", + cpct: "200", + }, + ], fcOrgwts: [ { pbnstRuseFcltBizFk: 10, @@ -380,6 +400,20 @@ export const exampleData = { archCstClcln: "380", pplCstClcln: "290", ruseFcltCstClcln: "4800", + pplInstls:[ + { + ruseFcltBizFk: "11", + pdmt: "관경", + ppMqlt: "1", + cpct: "100", + }, + { + ruseFcltBizFk: "11", + pdmt: "관경", + ppMqlt: "2", + cpct: "200", + }, + ], fcOrgwts: [ { pbnstRuseFcltBizFk: 11, diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/index.tsx index 09b5a0cad..e1a60d921 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/index.tsx @@ -1,5 +1,4 @@ import type { CommonTableProps } from "@/app/store/common/type/headder"; -import type { customPbnst } from "../../fcltReg/pbnstReg"; import type { z } from "zod"; import { pbnSttHeadListExport, @@ -8,6 +7,7 @@ import { import { fetchType, getFetch } from "@/components/lib/api"; import { controlHeadView } from "../rainSttn"; import type { sttnHeadListType } from "../rainSttn/headList"; +import type { customPbnst } from "../../fcltReg/pbnstReg/type"; const pbnstSttHeadList = pbnSttHeadListExport; const pbnstSttNodeList = pbnstSttNodeListExport; 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 d566fec8f..7e7adb03d 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx @@ -3,10 +3,10 @@ import { SelectBox } from "@common/business_components"; import { FormUi } from "@common/business_components/ui"; import { Form, FormField } from "@common/business_components/ui/form"; -import { Button, Input, TableHead, TableRow } from "@common/components"; +import { Button, Input, Label, TableHead, TableRow } from "@common/components"; import { zodResolver } from "@hookform/resolvers/zod"; import { use, useEffect, useState } from "react"; -import { useForm } from "react-hook-form"; +import { useFieldArray, useForm } from "react-hook-form"; import { z } from "zod"; import { useWrStore } from "@/app/store"; import { @@ -24,43 +24,57 @@ import { businessSttnInfo, concentratedWaterInfo, ruseFcltinfo, + ruseWaterQulityList, wasteWaterFcltINfo, } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/headList"; -import { pbnstRegZod } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; +import { fcBizSchema, pbnstRegZod, type fcBizType, type fcOrgwtType, type ppInstlType } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; import RuseMngTable from "@/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable"; -export function PbnstBuseForm() { +export function PbnstBuseForm({data} :{data: fcBizType[]} ) { const { code, pbnst } = useWrStore((state) => state); - const { pbnstBizCycle } = pbnst; - const [getBizCycle, setBizCycle] = useState([{ text: "없음", val: "1" }]); + const { pbnstBizCycle, pbnstRes + } = pbnst; + const [getBizCycle, setBizCycle] = useState('1'); + const [orgwtData ,setOrgwtData] = useState([]); + const [ppistlData ,setPpistlData] = useState([]); - const form = useForm>({ - resolver: zodResolver(pbnstRegZod), + const [ppiYn, setPpiYn] = useState("Y"); + const form = useForm({ + resolver: zodResolver(fcBizSchema), }); - + // 2. Define a submit handler. - function onSubmit(values: z.infer) { - // Do something with the form values. - // ✅ This will be type-safe and validated. + function onSubmit(values: fcBizType) { console.log(values); } const onSelectValue = (val: string) => { console.log(val); }; - const [instlAprvDate, setInstlAprvDate] = useState(new Date()); - const [bizCmcnDate, setBizCmcnDate] = useState(new Date()); - const [files, setFiles] = useState(null); + + const { fields: fcOrgwtFiled } = useFieldArray({ + control: form.control, + name: "fcOrgwts", + }); + + const { fields: pplInstls } = useFieldArray({ + control: form.control, + name: "pplInstls", + }); useEffect(() => { - console.log("getBizCycle", getBizCycle); - if (getBizCycle) { - form.reset(); + if(data){ + + const index = Number(getBizCycle) -1 + form.reset(data[index]); } - }, [getBizCycle]); + + }, [ getBizCycle,data]); useEffect(() => { - console.log("pbnstBizCycle", pbnstBizCycle); }, [pbnstBizCycle]); + useEffect(() => { + console.log("form errors:", form.formState.errors); + }, [form.formState.errors]); return (
@@ -80,14 +94,13 @@ export function PbnstBuseForm() { label="" selectArray={pbnstBizCycle} value={ - pbnstBizCycle.length > 0 && pbnstBizCycle[0] - ? pbnstBizCycle[0].val - : "" + getBizCycle?? pbnstBizCycle[0]?.val } className={""} selectClass={selectClass} onSelectValue={(val) => { - setBizCycle; + + setBizCycle(String(val)); }} > @@ -104,6 +117,8 @@ export function PbnstBuseForm() { 재이용 원수취수 현황
- - 추가등록 + +
+

재이용 공급관로 설치 현황

+
+ + setPpiYn(String(val))} + /> + + + + +
+ +
+ +
+ + + +

하수처리수 재이용수 수요처

+
+ +
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 1c3a6dfb2..9edc93046 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 @@ -10,11 +10,13 @@ export default function MngRegFormDetail({ form, moClass, sonClass, + cycle, }: { formList: formDetailType[]; h1Title: string; form: any; moClass?: string; + cycle?:string sonClass?: string; }) { return ( @@ -22,11 +24,13 @@ export default function MngRegFormDetail({

{h1Title}

{formList?.map((item, index) => { + + const fieldId = cycle? `${cycle}.${item.id}`: item.id; return (
( {item.type === "select" ? ( @@ -34,17 +38,16 @@ export default function MngRegFormDetail({ ) : item.type === "date" ? ( - field.onChange(date), - }} - selectClass={"rounded-lg w-full"} - > + selected={safeDate(field.value) || new Date()} + onSelect={(date: Date | undefined) => + field.onChange(date) + } + className={"rounded-lg w-full"} + /> ) : item.type === "number" ? ( - + ) : ( - + )} )} diff --git a/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx b/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx index 121ad80f4..0f5557821 100644 --- a/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx +++ b/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx @@ -29,7 +29,7 @@ export default function RuseMngTable({ ) : ( {headList.map((head) => ( - + {head.title} ))}