From c28dd728c51f58dd50f55e99c797d0fdc7f0a3de Mon Sep 17 00:00:00 2001 From: leedj312 Date: Tue, 3 Jun 2025 19:24:33 +0900 Subject: [PATCH] =?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({ ); } +