From 618d2cb00cfb70649c3b5c683797c9e857eacff2 Mon Sep 17 00:00:00 2001 From: leedj312 Date: Tue, 3 Jun 2025 15:19:16 +0900 Subject: [PATCH 1/3] =?UTF-8?q?=EC=88=98=EC=9A=94=EC=B2=98=20=EB=93=B1?= =?UTF-8?q?=EB=A1=9D=20=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 | 4 +- .../ruseFcltMng/fcltReg/pbnstReg/index.tsx | 12 ++-- .../ruseFcltMng/fcltReg/pbnstReg/type.tsx | 66 +++++++++++-------- .../fcltReg/pbnstReg/buseReg/bugRegForm.tsx | 37 ++++++++++- .../fcltReg/pbnstReg/mngReg/mngRegForm.tsx | 6 +- .../mngRegFormDetail/mngRegFormDetail.tsx | 4 +- 6 files changed, 85 insertions(+), 44 deletions(-) diff --git a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx index 70f41af7b..f818a494f 100644 --- a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx @@ -35,7 +35,7 @@ export default function PublicReuseFaciltyInsert() { pbnst, searchFclts, pubHasuInit, - pbnstRegInit, + pbnstRegClick, getSwtrmtFcltNm, pbnstMngData, } = useWrStore((state) => state); @@ -72,7 +72,7 @@ export default function PublicReuseFaciltyInsert() { const selectRow = pbnstHasuRes?.[val]; if (selectRow) { setIsRuseReg({ ...isRuseReg, data: selectRow }); - pbnstRegInit(selectRow); + pbnstRegClick(selectRow); } }; diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx index 6eb722257..d4dce6d09 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx @@ -57,7 +57,7 @@ export type pubFacState = { }; type pubFacActions = { pubHasuInit: (page: string, sggOrCity: string) => void; - pbnstRegInit: (pubHasuRes: pubHasuType) => void; + pbnstRegClick: (pubHasuRes: pubHasuType) => void; pbnstReg: (txt: string | undefined) => void; pbnstInsert(pbnstRes: customPbnst): Promise; appendRuseFclt(array: customPbnst[]): void; @@ -117,8 +117,8 @@ const hasuListFetch = async (page: string, sggOrCity: string) => { return hasuList; }; -const initFetch = async (code: string | undefined) => { - const pbnstRes = await getFetch("wr", `${code}`); +const initFetch = async (ruseFcltPk: string | undefined) => { + const pbnstRes = await getFetch("wr", `/reuseFc/pubFc/${ruseFcltPk}`); return pbnstRes; }; @@ -169,11 +169,9 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { } }, - pbnstRegInit: async (pubHasuRes: pubHasuType) => { + pbnstRegClick: async (pubHasuRes: pubHasuType) => { try { - //const pbnstRes = await initFetch(txt); - const pbnstRes = exampleData; - + const pbnstRes = await initFetch(pubHasuRes.bscFctCd); 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 a70e5030e..17b99afcc 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx @@ -99,6 +99,42 @@ const fcOrgwtSchema = z.object({ }); + +const pubHasuZod = z.object({ + choose: z.boolean().default(false), + bscFctCd: z.string(), + sido: z.string().default(""), + gugun: z.string().default(""), + bscFctNm: z.string().default(""), + efflWqltStndrdNm: z.string().default(""), + fctCpc: z.number().default(0), + addr:z.string().nullish() +}); + +const demandInfoList = z.object({ + +}) + + +export type pubHasuType = z.infer; + + + +const dmdColist = z.object({ + dmdCoNm: z.boolean().default(false), + daddr: z.string(), + useUsgCd: z.string().default(""), + splyBgngDay: z.string().default(""), + splyEndDay: z.string().default(""), + splyCpct: z.string().default(""), + splyFmYn: z.number().default(0), + telno:z.string().default('') +}); + + + + + export const fcBizSchema = z.object({ pbnstRuseFcltBizPk: z.number().default(1), pbnstRuseFcltFk: z.string().nullish(), @@ -164,40 +200,13 @@ export const fcBizSchema = z.object({ ruseFcltCstClcln: z.number().nullish(), fcOrgwts: z.array(fcOrgwtSchema).nullish(), pplInstls: z.array(pplInstlSchema).nullish(), + demandInfo: z.array(dmdColist).default([]).nullish(), flg: z.string().nullish(), regDt: z.string().nullish(), rgtr: z.string().nullish(), mdfcnDt: z.string().nullish(), mdfr: z.string().nullish(), }); - - -const pubHasuZod = z.object({ - choose: z.boolean().default(false), - bscFctCd: z.string(), - sido: z.string().default(""), - gugun: z.string().default(""), - bscFctNm: z.string().default(""), - efflWqltStndrdNm: z.string().default(""), - fctCpc: z.number().default(0), - addr:z.string().nullish() -}); - -export type pubHasuType = z.infer; - - - -const dmdColist = z.object({ - dmdCoNm: z.boolean().default(false), - daddr: z.string(), - useUsgCd: z.string().default(""), - splyBgngDay: z.string().default(""), - splyEndDay: z.string().default(""), - splyCpct: z.string().default(""), - splyFmYn: z.number().default(0), -}); - - export const pbnstRegZod = z.object({ pbnstRuseFcltPk: z.string().default(''), swtrmtFcltFk: z.string().default(""), @@ -212,7 +221,6 @@ export const pbnstRegZod = z.object({ fcFiles: z.array(fcFileSchema).default([]), fcBizs: z.array(fcBizSchema).default([]), fcOpers: z.array(fcOperSchema).default([]), - fcDemands: z.array(dmdColist).default([]).nullish(), hasuhasu: z.number().default(0), }); 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 eccff62b5..f127579fc 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx @@ -56,6 +56,8 @@ export function PbnstBuseForm({ const [ppiYn, setPpiYn] = useState("Y"); const [isFcOrgwts, setIsFcOrgwts] = useState(false); const [sumCpct, setSumCpct] = useState(0); + const [searchDmdCo, setSeachDmdCo] = useState(); + const form = useForm({ resolver: zodResolver(fcBizSchema), @@ -103,9 +105,17 @@ export function PbnstBuseForm({ newPbnstRes[index]?.fcBizs?.length && newPbnstRes[index]?.fcBizs?.push(regData); getBizCycle(newPbnstRes[index] as customPbnst); appendRuseFclt(newPbnstRes); - } } + const { fields: demandInfo, + append:appendDemand, + remove:removeDemand } = useFieldArray({ + control: form.control, + name: "demandInfo", + }); + + + const { fields: fcOrgwtFiled } = useFieldArray({ control: form.control, name: "fcOrgwts", @@ -169,7 +179,21 @@ export function PbnstBuseForm({ ref.current = [...latestOpers]; }; - const plusArray = () => {}; + const plusArray = () => { +<> + { + setSeachDmdCo(val); + }} + /> + + + }; const removeSelected = () => { if (!ref.current) return; @@ -369,7 +393,7 @@ export function PbnstBuseForm({
+ + + + 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 53edfd14e..ed78452d0 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx @@ -260,12 +260,14 @@ export function PbnstMngForm({ }, [pbnst.pbnstMngRegData]); useEffect(() => { - if (!pbnst.pbnstRes) return; - const fcltNmList = pbnst.pbnstRes.map((item, index) => ({ + 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); }, [pbnst.pbnstRes]); 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 85dde2e3c..6793aacba 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 @@ -12,6 +12,7 @@ export default function MngRegFormDetail({ moClass, sonClass, cycle, + onIputData }: { formList: formDetailType[]; h1Title?: string; @@ -19,6 +20,7 @@ export default function MngRegFormDetail({ moClass?: string; cycle?:string sonClass?: string; + onIputData?: (data: any) => void; }) { const { code, } = useWrStore((state) => state); return ( @@ -58,7 +60,7 @@ export default function MngRegFormDetail({ value={field.value} /> ) : ( - + )} )} From c28dd728c51f58dd50f55e99c797d0fdc7f0a3de Mon Sep 17 00:00:00 2001 From: leedj312 Date: Tue, 3 Jun 2025 19:24:33 +0900 Subject: [PATCH 2/3] =?UTF-8?q?=EC=88=98=EC=9A=94=EC=B2=98=20=EB=93=B1?= =?UTF-8?q?=EB=A1=9D=20=EC=88=98=EC=9A=94=EC=B2=98=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruseFcltMng/fcltReg/pbnstReg/headList.tsx | 9 - .../ruseFcltMng/fcltReg/pbnstReg/index.tsx | 21 +- .../ruseFcltMng/fcltReg/pbnstReg/type.tsx | 10 +- .../fcltReg/pbnstReg/buseReg/bugRegForm.tsx | 220 ++++++++++++++---- .../mngRegFormDetail/mngRegFormDetail.tsx | 47 +++- 5 files changed, 240 insertions(+), 67 deletions(-) diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx index 465cad08b..186bfd3c0 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx @@ -64,15 +64,6 @@ export const fcOrgwtsHeadListExport: TableUpperProps[] = [ { id: "addr", title: "위치" }, ]; -export const dmdCoList: formDetailType[] = [ - { id: "dmdCoNm", lable: "수요처명" }, - { id: "daddr", lable: "위치(주소)" }, - { id: "useUsgCd", lable: "사용용도" }, - { id: "splyBgngDay", lable: "공급시작일", type: "date" }, - { id: "splyEndDay", lable: "공급종료일", type: "date" }, - { id: "splyCpct", lable: "(계약)공급량(m3/일)" }, - { id: "splyFmYn", lable: "공급 유량계 유무", type: "selectYn" }, -]; export const pbnstMngNmExport: chHeadType[] = [ { headNm: "upChangeRe", text: "운영대행기간", length: 2 }, diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx index d4dce6d09..62a6447f7 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx @@ -68,6 +68,7 @@ type pubFacActions = { getBizCycle: (pbnstObj: customPbnst) => void; getDmdCompany: (txt: string) => void; getpbnstInsertIndex: (data: pbnstInsertIndex) => void; + searchDmdColist:(txt:string) =>void }; export type pubFacType = pubFacState & pubFacActions; @@ -338,6 +339,24 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { } catch (e) { console.log(e); } - }, + },searchDmdColist:async (txt:string)=>{ + + try{ + console.log(' txt ', txt) + const coList = await getFetch(fetchType.WR, `reuseFc/request/${txt}/{3}`); + return set((state: pubFacState) => ({ + ...state, + pbnst: { + ...state.pbnst, + dmdCoList: coList, + isInit: false, + }, + })); + }catch(e){ + console.log(e) + + } + + } }; }; diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx index 17b99afcc..f3f695725 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx @@ -121,14 +121,14 @@ export type pubHasuType = z.infer; const dmdColist = z.object({ - dmdCoNm: z.boolean().default(false), + dmdCoNm: z.string().default(''), daddr: z.string(), useUsgCd: z.string().default(""), - splyBgngDay: z.string().default(""), - splyEndDay: z.string().default(""), + splyBgngDay: z.date().default(new Date()), + splyEndDay: z.date().default(new Date()), splyCpct: z.string().default(""), splyFmYn: z.number().default(0), - telno:z.string().default('') + //telno:z.string().default('') }); @@ -200,7 +200,7 @@ export const fcBizSchema = z.object({ ruseFcltCstClcln: z.number().nullish(), fcOrgwts: z.array(fcOrgwtSchema).nullish(), pplInstls: z.array(pplInstlSchema).nullish(), - demandInfo: z.array(dmdColist).default([]).nullish(), + fcDemands: z.array(dmdColist).default([]).nullish(), flg: z.string().nullish(), regDt: z.string().nullish(), rgtr: z.string().nullish(), 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 f127579fc..608b2ccab 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx @@ -5,7 +5,6 @@ import { businessMoneyInfo, businessSttnInfo, concentratedWaterInfo, - dmdCoList, ruseFcltinfo, ruseWaterQulityList, wasteWaterFcltINfo, @@ -25,13 +24,23 @@ 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 { UiModal, type SelectDataType } from "@common/business_components/ui"; -import { Form } from "@common/business_components/ui/form"; -import { Button, Input, Label } from "@common/components"; +import { + FormUi, + SearchInputSelect, + UiModal, + type SelectDataType, +} from "@common/business_components/ui"; +import { Form, FormField } from "@common/business_components/ui/form"; +import { Button, DatePicker, Input, Label } from "@common/components"; import { zodResolver } from "@hookform/resolvers/zod"; import { useEffect, useRef, useState } from "react"; import { useFieldArray, useForm } from "react-hook-form"; import MngRegFormDetail from "../mngReg/mngRegFormDetail/mngRegFormDetail"; +import { + handleCommaNumberChange, + formatCommaNumber, + safeDate, +} from "@/components/lib/func/commom"; export function PbnstBuseForm({ formType, @@ -48,6 +57,7 @@ export function PbnstBuseForm({ getpbnstInsertIndex, appendRuseFclt, getBizCycle, + searchDmdColist, } = useWrStore((state) => state); const { pbnstBizCycle, pbnstRes } = pbnst; const [bizCycle, setBizCycle] = useState("1"); @@ -58,7 +68,6 @@ export function PbnstBuseForm({ const [sumCpct, setSumCpct] = useState(0); const [searchDmdCo, setSeachDmdCo] = useState(); - const form = useForm({ resolver: zodResolver(fcBizSchema), defaultValues: @@ -90,7 +99,7 @@ export function PbnstBuseForm({ if ( pbnst.pbnstRes && pbnst.pbnstRes[pbnst.pbnsUpdateIndex.mng] && - pbnst.pbnstRes[pbnst.pbnsUpdateIndex.mng]?.fcBizs + pbnst.pbnstRes[pbnst.pbnsUpdateIndex.mng]?.fcBizs ) { regData = { pbnstRuseFcltFk: @@ -102,20 +111,22 @@ export function PbnstBuseForm({ } as fcBizType; const newPbnstRes = [...(pbnst.pbnstRes as customPbnst[])]; - newPbnstRes[index]?.fcBizs?.length && newPbnstRes[index]?.fcBizs?.push(regData); + newPbnstRes[index]?.fcBizs?.length && + newPbnstRes[index]?.fcBizs?.push(regData); getBizCycle(newPbnstRes[index] as customPbnst); appendRuseFclt(newPbnstRes); + } } - const { fields: demandInfo, - append:appendDemand, - remove:removeDemand } = useFieldArray({ + const { + fields: fcDemands, + append: appendDemand, + remove: removeDemand, + } = useFieldArray({ control: form.control, - name: "demandInfo", + name: "fcDemands", }); - - const { fields: fcOrgwtFiled } = useFieldArray({ control: form.control, name: "fcOrgwts", @@ -151,6 +162,10 @@ export function PbnstBuseForm({ } }, [firstBizData, form.formState, formType]); + useEffect(() => { + console.log("searchDmdCo ", searchDmdCo); + }, [searchDmdCo]); + useEffect(() => { if (ppiYn === "N") { form.setValue("pplInstls", []); @@ -180,19 +195,19 @@ export function PbnstBuseForm({ }; const plusArray = () => { -<> - { - setSeachDmdCo(val); - }} - /> - + console + .log('qweqwe ') + appendDemand({ + dmdCoNm: "", + daddr: "", + useUsgCd: "", + splyBgngDay: new Date(), + splyEndDay: new Date(), + splyCpct: "", + splyFmYn: 0, + //telno: "", + }); }; const removeSelected = () => { @@ -388,33 +403,154 @@ export function PbnstBuseForm({ moClass="grid grid-cols-12 gap-4" sonClass="col-span-4" /> -
+

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

- { - setSeachDmdCo(val); - }} - /> + {fcDemands.map((field, index) => ( +
+
+ ( + + { + searchDmdColist(val); + }} + textValue={f.value} + setText={(val) => { + setSeachDmdCo(val); + }} + selectValue={searchDmdCo} + > + + )} + /> +
+
+ ( + + f.onChange(e.target.value)} + value={f.value} + className={selectClass} + /> + + )} + /> +
+
+ ( + + 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} + /> + + )} + /> +
+
+ ))}
- - - - 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 6793aacba..7f9ff4fef 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 @@ -1,9 +1,17 @@ +'use client' import { useWrStore } from "@/app/store"; import type { formDetailType } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/headList"; import { formH1Class } from "@/components/lib/class/comClass"; import { safeDate } from "@/components/lib/func/commom"; -import { FormField, FormUi, SelectBox } from "@common/business_components/ui"; +import { + FormField, + FormUi, + SearchInputSelect, + SelectBox, + type SelectDataType, +} from "@common/business_components/ui"; import { DatePicker, Input } from "@common/components/ui"; +import { useState } from "react"; export default function MngRegFormDetail({ formList, @@ -12,24 +20,28 @@ export default function MngRegFormDetail({ moClass, sonClass, cycle, - onIputData + onIputData, + searchSelectData }: { formList: formDetailType[]; h1Title?: string; form: any; moClass?: string; - cycle?:string + cycle?: string; sonClass?: string; onIputData?: (data: any) => void; + searchSelectData?: SelectDataType[]; }) { - const { code, } = useWrStore((state) => state); + const { code } = useWrStore((state) => state); + + const [searchData, setSearchData]= useState('') + return ( <> - { h1Title ?

{h1Title}

: <>} + {h1Title ?

{h1Title}

: <>}
{formList?.map((item, index) => { - - const fieldId = cycle? `${cycle}.${item.id}`: item.id; + const fieldId = cycle ? `${cycle}.${item.id}` : item.id; return (
) : item.type === "number" ? ( - {field.onChange(Number(e.target.value))}} /> + { + field.onChange(Number(e.target.value)); + }} + /> ) : item.type === "selectYn" ? ( field.onChange(val)} + onSelectValue={(val: string | number) => + field.onChange(val) + } value={field.value} /> ) : ( - + )} )} @@ -72,3 +98,4 @@ export default function MngRegFormDetail({ ); } + From c49b2a8e08e64eab72be679627917df48375fc16 Mon Sep 17 00:00:00 2001 From: leedj312 Date: Tue, 3 Jun 2025 21:06:52 +0900 Subject: [PATCH 3/3] =?UTF-8?q?=ED=95=98=EC=88=98=EC=9E=AC=EC=9D=B4?= =?UTF-8?q?=EC=9A=A9=20=EC=8B=A4=EC=A0=81=20=EB=93=B1=EB=A1=9D=20=EC=97=91?= =?UTF-8?q?=EC=85=80=20=EB=93=B1=EB=A1=9D=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../prfmncReg/pbnstPrfmncReg/page.tsx | 240 ++++++++++-------- .../store/prfmncReg/pbnstPrfmncReg/excel.tsx | 43 ++++ .../prfmncReg/pbnstPrfmncReg/headList.tsx | 8 + .../pbnPrfExcelModal/pbnPrfExcelModal.tsx | 168 ++++++++++++ .../rainChjgdDetail/rainChkgdDetailTable.tsx | 0 5 files changed, 347 insertions(+), 112 deletions(-) create mode 100644 apps/wr/app/store/prfmncReg/pbnstPrfmncReg/excel.tsx create mode 100644 apps/wr/components/ui/modal/chkgd/pbnPrfExcelModal/pbnPrfExcelModal.tsx delete mode 100644 apps/wr/components/ui/table/chkgdTable/rainChjgdDetail/rainChkgdDetailTable.tsx diff --git a/apps/wr/app/ruseFcltMng/prfmncReg/pbnstPrfmncReg/page.tsx b/apps/wr/app/ruseFcltMng/prfmncReg/pbnstPrfmncReg/page.tsx index e3f3e9fe9..b62286b3d 100644 --- a/apps/wr/app/ruseFcltMng/prfmncReg/pbnstPrfmncReg/page.tsx +++ b/apps/wr/app/ruseFcltMng/prfmncReg/pbnstPrfmncReg/page.tsx @@ -3,125 +3,141 @@ import { useWrStore } from "@/app/store"; import type { pubHasuType } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; import { yearOptions } from "@/components/lib/func/commom"; -import { ContentsDiv, Title, SearchDiv, SearchFormLeft, SelectBox, SearchInput, SearchFormRight, ScrollArea, UiTable } from "@common/business_components/ui"; +import PbnPrfExcelModal from "@/components/ui/modal/chkgd/pbnPrfExcelModal/pbnPrfExcelModal"; +import { + ContentsDiv, + Title, + SearchDiv, + SearchFormLeft, + SelectBox, + SearchInput, + SearchFormRight, + ScrollArea, + UiTable, + UiModal, +} from "@common/business_components/ui"; import ListDiv from "@common/business_components/ui/list_div"; import { Button, Label } from "@common/components/ui"; import { useState, useEffect } from "react"; +import { set } from "react-hook-form"; +import { Toaster } from "react-hot-toast"; export default function prfmncPrfmncReg() { - const { code, prfmnc, prfmncHasuInit, searchFclts, } = useWrStore((state) => state); - const { pbnstPrfmncHeadList, monthHeadList,prfmncRes } = prfmnc; - const [bdstTable, setbdstTable] = useState(); - const [searchTxt, setSearchTxt] = useState(); + const { code, prfmnc, prfmncHasuInit, searchFclts } = useWrStore( + (state) => state + ); + const { pbnstPrfmncHeadList, monthHeadList, prfmncRes } = prfmnc; + const [bdstTable, setbdstTable] = useState(); + const [searchTxt, setSearchTxt] = useState(); + const [isExcelOpen, setIsExcelOPen] = useState(false); - const [searchYear, setSearchYear] = useState(String(new Date().getFullYear())); - useEffect(() => { - if (!prfmnc.isInit) { - prfmncHasuInit("1", "11"); - } - }, [prfmnc.isInit, prfmncHasuInit]); - useEffect(() => { - console.log("prfmnc.prfmncRes", prfmncRes) - },[prfmncRes]); + const [searchYear, setSearchYear] = useState( + String(new Date().getFullYear()) + ); + useEffect(() => { + if (!prfmnc.isInit) { + prfmncHasuInit("1", "11"); + } + }, [prfmnc.isInit, prfmncHasuInit]); + useEffect(() => { + console.log("prfmnc.prfmncRes", prfmncRes); + }, [prfmncRes]); - return ( - <> - -
-
- - <SearchDiv> - <SearchFormLeft> - <div className="col-span-2 flex flex-row space-x-2"> - <Label className="w-48 mt-2 text-xl text-gray-600">{'실적등록년도'}</Label> - <SelectBox - className="w-full h-full text-2xl" - label="" - selectClass={""} - selectArray={yearOptions} - value={searchYear} - onSelectValue={(val: string | number) => - setSearchYear(String(val)) - } - /> - </div> - <div className="col-span-2 flex flex-row space-x-2"> - <Label className="w-28 mt-2 text-xl text-gray-600">{'시설명'}</Label> - <SearchInput - className={"w-full text-2xl"} - label="" - textValue={searchTxt || ""} - setText={(e) => { - setSearchTxt(e); - }} - /> - </div> - </SearchFormLeft> - <SearchFormRight - className="w-2/12 mx-5 flex flex-col items-center justify-center space-x-2 "> - <div className="space-y"> - <div className="flex flex-row space-x-2"> - <Button - size={"sm"} - onClick={(e) => { }} - > - 조회 - </Button> - <Button - size={"sm"} - onClick={() => { }} - > - 저장 - </Button> - <Button - size={"sm"} - onClick={() => { }} - > - 파일등록 - </Button> - <Button color="green" size={"sm"} onClick={() => { }}> - 양식받기 - </Button> - </div> - </div> - </SearchFormRight> - </SearchDiv> - </div> + return ( + <> + <ContentsDiv> + <div className="grid grid-cols-4 gap-4"> + <div className="col-span-4"> + <Title title={"하수재이용 시설 등록"} /> + <SearchDiv> + <SearchFormLeft> + <div className="col-span-2 flex flex-row space-x-2"> + <Label className="w-48 mt-2 text-xl text-gray-600"> + {"실적등록년도"} + </Label> + <SelectBox + className="w-full h-full text-2xl" + label="" + selectClass={""} + selectArray={yearOptions} + value={searchYear} + onSelectValue={(val: string | number) => + setSearchYear(String(val)) + } + /> </div> - - <div className="grid grid-cols-12 gap-4 h-full"> - <div className="col-span-4 h-full min-h-0"> - <ListDiv className="min-h-0"> - <ScrollArea className="h-[60vh]"> - <UiTable - tableData={bdstTable || []} - headlist={pbnstPrfmncHeadList} - pageSize={100} - total={10} - headName={"하수재이용시설 목록"} - cellClick={() => { }} - onPageChange={(page: number) => { }} - children={undefined} - /> - </ScrollArea> - </ListDiv> - </div> - <ListDiv className="col-span-8 pr-6 "> - <ScrollArea className="h-[60vh]"> - <UiTable - tableData={[]} - headlist={monthHeadList} - pageSize={100} - total={10} - headName={"하수처리수재이용 실적(m3) 등록결과"} - cellClick={() => { }} - onPageChange={() => { }} - children={undefined} - /> - </ScrollArea> - </ListDiv> + <div className="col-span-2 flex flex-row space-x-2"> + <Label className="w-28 mt-2 text-xl text-gray-600"> + {"시설명"} + </Label> + <SearchInput + className={"w-full text-2xl"} + label="" + textValue={searchTxt || ""} + setText={(e) => { + setSearchTxt(e); + }} + /> </div> - </ContentsDiv> - </> - ); + </SearchFormLeft> + <SearchFormRight className="w-2/12 mx-5 flex flex-col items-center justify-center space-x-2 "> + <div className="space-y"> + <div className="flex flex-row space-x-2"> + <Button size={"sm"} onClick={(e) => {}}> + 조회 + </Button> + <Button size={"sm"} onClick={() => {}}> + 저장 + </Button> + <Button size={"sm"} onClick={() => {setIsExcelOPen(true)}}> + 파일등록 + </Button> + <Button color="green" size={"sm"} onClick={() => {}}> + 양식받기 + </Button> + </div> + </div> + </SearchFormRight> + </SearchDiv> + </div> + </div> + + <div className="grid grid-cols-12 gap-4 h-full"> + <div className="col-span-4 h-full min-h-0"> + <ListDiv className="min-h-0"> + <ScrollArea className="h-[60vh]"> + <UiTable + tableData={bdstTable || []} + headlist={pbnstPrfmncHeadList} + pageSize={100} + total={10} + headName={"하수재이용시설 목록"} + cellClick={() => {}} + onPageChange={(page: number) => {}} + children={undefined} + /> + </ScrollArea> + </ListDiv> + </div> + <ListDiv className="col-span-8 pr-6 "> + <ScrollArea className="h-[60vh]"> + <UiTable + tableData={[]} + headlist={monthHeadList} + pageSize={100} + total={10} + headName={"하수처리수재이용 실적(m3) 등록결과"} + cellClick={() => {}} + onPageChange={() => {}} + children={undefined} + /> + </ScrollArea> + </ListDiv> + </div> + </ContentsDiv> + <UiModal bodyClass={""} body={<PbnPrfExcelModal></PbnPrfExcelModal>} open={isExcelOpen} onOpenChange={() => {setIsExcelOPen(!isExcelOpen)}}></UiModal> + <Toaster position="top-center" /> + + </> + ); } diff --git a/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/excel.tsx b/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/excel.tsx new file mode 100644 index 000000000..b0cbb7724 --- /dev/null +++ b/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/excel.tsx @@ -0,0 +1,43 @@ +import { TEST_UUID } from "../../ruseFcltMng/fcltReg/rainReg"; + + + const nameMap = { + "세척수": "wshwtr", + "냉각수": "coolUswtr", + "청소수": "cleanUswtr", + "식수대": "drwtUswtr", + "희석용수": "dltnUswtr", + "중수도": "ithlRswtr", + "기타": "ithlEtcUswtr", + "청소화장실용수": "cleanToilUswtr", + "세척살수용수": "resn", + "조경용수": "lndwtr", + "친수용수": "hydUswtr", + "지하수충전": "ugwtChr", + "농업용수": "farmUswtr", + "하천등유지용수": "rvrKeepUswtr", + "공업용수": "indstUswtr" + }; + + +export const excelToPbnPrfData = (excelData: any[], year: string) => { + // 월별 데이터 하나로 병합 + const merged = {} as any; + excelData.forEach((item: any) => { + const key = nameMap[item["용수명"]]; + if (!key) return; + + for (let i = 1; i <= 12; i++) { + const month = i.toString().padStart(2, "0"); + const ym = year + month; + + if (!merged[ym]) merged[ym] = { ym }; + merged[ym][key] = Number(item[`${i}월`] ?? 0); + } + }); + + const pbnPrfData = Object.values(merged); + console.log(pbnPrfData); + + return pbnPrfData; +}; \ No newline at end of file diff --git a/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/headList.tsx b/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/headList.tsx index fd2fc9ada..a41eeba52 100644 --- a/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/headList.tsx +++ b/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/headList.tsx @@ -1,5 +1,13 @@ +import { z } from "zod"; import type { TableUpperProps } from "../../ruseFcltMng/fcltReg/rainReg"; +export const pbnPrfRegExcelZod = z.object({ + ym: z.string().default(""), + bscFctNm: z.string().default(""), + pbnstRuseFcltNm: z.string().default(""), + file: z.instanceof(File).optional(), +}); + export const pbnstPrfmncHeadListExport: TableUpperProps[] = [ { id: "sido", title: "시도" }, { id: "gugun", title: "시군구" }, diff --git a/apps/wr/components/ui/modal/chkgd/pbnPrfExcelModal/pbnPrfExcelModal.tsx b/apps/wr/components/ui/modal/chkgd/pbnPrfExcelModal/pbnPrfExcelModal.tsx new file mode 100644 index 000000000..8190b96e8 --- /dev/null +++ b/apps/wr/components/ui/modal/chkgd/pbnPrfExcelModal/pbnPrfExcelModal.tsx @@ -0,0 +1,168 @@ +import { useWrStore } from "@/app/store"; +import { excelToPbnPrfData } from "@/app/store/prfmncReg/pbnstPrfmncReg/excel"; +import { pbnPrfRegExcelZod } from "@/app/store/prfmncReg/pbnstPrfmncReg/headList"; +import { yearOptions } from "@/components/lib/func/commom"; +import { ToastFormUi } from "@/components/ui/toast/toastFromUi"; +import { + FileUpload, + FormField, + FormUi, + SelectBox, + Form, + Title, + type SelectDataType, + filePicked, +} from "@common/business_components/ui"; +import { Button } from "@common/components/ui"; +import { zodResolver } from "@hookform/resolvers/zod"; +import { useEffect, useState } from "react"; +import { useForm } from "react-hook-form"; +import type { z } from "zod"; + +export default function PbnPrfExcelModal() { + const { code, prfmnc, searchFclts } = useWrStore((state) => state); + + + const [bscFctNmList, setBscFctNmList] = useState<SelectDataType[] | null>(null); + const [files, setFiles] = useState<File[] | null>(null); +const [excelData, setExcelData] = useState<any[]>(); + const form = useForm<z.infer<typeof pbnPrfRegExcelZod>>({ + resolver: zodResolver(pbnPrfRegExcelZod), + defaultValues: { + ym: String(new Date().getFullYear()), + }, + }); + const onSubmit = (values: z.infer<typeof pbnPrfRegExcelZod>) => { + console.log(values); + }; + useEffect(() => { + + if(prfmnc.prfmncRes.length > 0){ + + const basFctNmList = prfmnc.prfmncRes.map((item)=>( + { + val:item.bscFctCd, + text:item.bscFctNm + } + )) + setBscFctNmList(basFctNmList) + } + + }, [prfmnc.prfmncRes]); + + + useEffect(()=>{ + + if(files){ + + const file = files[0]; + if (form.getValues("ym").length < 1) { + ToastFormUi({ + body: "파일업로드 이전에 등록년도를 작성해주세요 ", + title: "지도점검 등록", + }); + setFiles(null); + return; + } + + if(file) + filePicked(file, 0).then((res) => { + if (res !== undefined) + console.log(excelToPbnPrfData(res, form.getValues("ym"))) + }); + + + } + },[files]) + + return ( + <> + <div> + <Form {...form}> + <form onSubmit={form.handleSubmit(onSubmit)}> + <div> + <Title title={"하수재이용 실적등록"}> +
+
+

+ {"점검정보 입력"} +

+ + +
+ +
+ ( + + field.onChange(val)} + /> + + )} + /> + + ( + + field.onChange(String(val))} + /> + + )} + /> + ( + + field.onChange(String(val))} + /> + + )} + /> + + ( + + { + if (files) setFiles(files); + }} + fileTypes="xlsx" + > + + )} + /> +
+ + +
+ + ); +} diff --git a/apps/wr/components/ui/table/chkgdTable/rainChjgdDetail/rainChkgdDetailTable.tsx b/apps/wr/components/ui/table/chkgdTable/rainChjgdDetail/rainChkgdDetailTable.tsx deleted file mode 100644 index e69de29bb..000000000