From 94a05453f8b1a771402c2f63eeee9941b1e4a72c Mon Sep 17 00:00:00 2001 From: leedj312 Date: Thu, 27 Mar 2025 11:08:03 +0900 Subject: [PATCH] =?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/rainReg/page.tsx | 13 ++- .../ruseFcltMng/fcltReg/rainReg/index.tsx | 2 +- .../lib/type/zod/fcltReg/controlZod.ts | 73 ++++++++++++++ .../ui/form/fcltReg/bdstReg/bdstRegForm.tsx | 63 ------------ .../ui/form/fcltReg/bdstReg/component.tsx | 32 ++++++ .../ui/form/fcltReg/rainReg/component.tsx | 63 +++++------- .../components/ui/modal/bdstReg/component.tsx | 97 +++++++++++++------ 7 files changed, 203 insertions(+), 140 deletions(-) create mode 100644 apps/wr/components/lib/type/zod/fcltReg/controlZod.ts delete mode 100644 apps/wr/components/ui/form/fcltReg/bdstReg/bdstRegForm.tsx create mode 100644 apps/wr/components/ui/form/fcltReg/bdstReg/component.tsx diff --git a/apps/wr/app/ruseFcltMng/fcltReg/rainReg/page.tsx b/apps/wr/app/ruseFcltMng/fcltReg/rainReg/page.tsx index 88fdab5e7..2f2c72546 100644 --- a/apps/wr/app/ruseFcltMng/fcltReg/rainReg/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltReg/rainReg/page.tsx @@ -1,10 +1,9 @@ 'use client' import { useWrStore } from "@/app/store"; -import type { bdstType, rainRuseType, TableUpperProps } from "@/app/store/ruseFcltMng/fcltReg/rainReg" -import { BdstReg } from "@/components/ui/form/fcltReg/bdstReg/bdstRegForm"; -import { RainRegForm } from "@/components/ui/form/fcltReg/rainReg/component"; -import { BdstRegModal } from "@/components/ui/modal/bdstReg/component"; -import { ScrollArea, SearchDiv, SearchInput, UiModal, UiTable } from "@common/business_components"; +import type { bdstType, rainRuseBd, TableUpperProps } from "@/app/store/ruseFcltMng/fcltReg/rainReg" +import { RainRegForm } from "@/components/ui/form/fcltReg/rainReg/component"; +import { BdstReg } from "@/components/ui/modal/bdstReg/component"; +import { ScrollArea, SearchDiv, SearchInput, Title, UiModal, UiTable } from "@common/business_components"; import { Button, TableHead, TableRow } from "@common/components"; import { useEffect, useState } from "react"; @@ -26,7 +25,7 @@ export default function Home() { return state }); const {bdstObj, rainRuseObj } =rain - const [rinBdstForm, setRinBdstForm] = useState (); + const [rinBdstForm, setRinBdstForm] = useState (); const [bdstTable, setbdstTable] = useState (); const nodeList = headMakeColSpan(rain.upHeadList); const headName = () => { @@ -70,7 +69,7 @@ export default function Home() { <>
-

빗물이용시설 등록

+ <div className="m-8"> <SearchDiv > <div className='w-4/5 grid grid-cols-12 gap-1 mx-4'> diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/rainReg/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/rainReg/index.tsx index ffed7b0d0..7624a4ee9 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/rainReg/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/rainReg/index.tsx @@ -50,7 +50,7 @@ export type TableUpperProps = { }; -type rainRuseBd={ +export type rainRuseBd={ bdstRuseFcltPk: number, // 건축물 재이용시설 기본키 bdstInfoFk: number, // 건축물 정보 외부키 operMngCd:number|null, // 운영관리 코드 tb_wr_bdst_ruse_fclt 삭제 요망 diff --git a/apps/wr/components/lib/type/zod/fcltReg/controlZod.ts b/apps/wr/components/lib/type/zod/fcltReg/controlZod.ts new file mode 100644 index 000000000..52e2d8181 --- /dev/null +++ b/apps/wr/components/lib/type/zod/fcltReg/controlZod.ts @@ -0,0 +1,73 @@ +import { z } from "zod"; + + +const rainZod = { + instlCmptnDt: z.date(), + instlCst: z.number(), + pntfColKnd: z.string(), + pntfColArea: z.number(), + filtrTrtmfctPrs: z.string(), + filtrTrtmfctYn: z.string(), + filtrTrtmfctCpct: z.string(), + instlCstSprtYn: z.string(), + instlCstSprtAmt: z.string(), + grntchCstSprtYn: z.string(), + grntchCstSprtCst: z.string(), + grntchBdstCertYn: z.string(), + grntchBdstCertYr: z.string(), + grntchBdstCertNo: z.string(), + grntchBdstCertGrd: z.string(), +} + + +const rainDefZod= { + instlCmptnDt: new Date(), + instlCst: 0, + pntfColKnd: "", + pntfColArea: 0, + filtrTrtmfctYn: "N", + filtrTrtmfctCpct: "", + filtrTrtmfctPrs: "", + instlCstSprtYn: "", + instlCstSprtAmt: "", + grntchCstSprtYn: "", + grntchCstSprtCst: "", + grntchBdstCertYn: "", + grntchBdstCertYr: "", + grntchBdstCertNo: "", + grntchBdstCertGrd: "", +} +const bdstZod ={ + ctpvCd: z.string(), // 시도 + sggCd: z.string(), // 시군구 + daddr: z.string(), // 위치 + bdstUsgCd: z.string(), // 건축물용도 + frstArchPrmsnDt: z.string(), // 최초건축허가일 + archArea: z.string(), // 건축면적 + lawTrgtYn: z.string(), // 법적의무대상여부 + archChgPrmsnDt: z.string(), // 건축변경 허가일시 + archChgArea: z.string(), // 변경 면적 + //bdstInfoPk: number; + bdstNm: z.string(), + } + +const bdstDefZod={ + ctpvCd: '', // 시도 + sggCd: '', // 시군구 + daddr: '', // 위치 + bdstUsgCd: '', // 건축물용도 + frstArchPrmsnDt: '', // 최초건축허가일 + archArea: '', // 건축면적 + lawTrgtYn: '', // 법적의무대상여부 + archChgPrmsnDt: '', // 건축변경 허가일시 + archChgArea: '', // 변경 면적 + //bdstInfoPk: number; + bdstNm: '', +} + +export const rainForm = z.object({ + ...rainZod, + ...bdstZod +}); +export const rainDefault= {...rainDefZod,bdstDefZod}; + \ No newline at end of file diff --git a/apps/wr/components/ui/form/fcltReg/bdstReg/bdstRegForm.tsx b/apps/wr/components/ui/form/fcltReg/bdstReg/bdstRegForm.tsx deleted file mode 100644 index f889cb6c5..000000000 --- a/apps/wr/components/ui/form/fcltReg/bdstReg/bdstRegForm.tsx +++ /dev/null @@ -1,63 +0,0 @@ -'use client' -import { headMakeColSpan } from "@/app/ruseFcltMng/fcltReg/rainReg/page"; -import { useWrStore } from "@/app/store"; -import { selectClass, type bdstType } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; -import { SelectBox, UiTable } from "@common/business_components"; -import { Button, Input } from "@common/components"; -import { useEffect, useState } from "react"; - -export function BdstReg(){ - - const { rain, code,init } = useWrStore((state) => { - return state - }); - - const[bdstTable, setbdstTable] = useState <bdstType[]> (); - const {bdstObj, rainRuseObj } =rain - const getCity =(val:string|number)=>{ - - console.log(val) - } - - const getSgg =(val:string|number)=>{ - - console.log(val) - } - - useEffect ( () => { - if(code.sggCd.length>0){ - const table= bdstObj.map((item) => { - const sggText= code.sggCd.find((cd)=>cd.val.toString() === item.sggCd )?.text; - const cityText= code.cityCd.find((cd)=>cd.val.toString() === item.ctpvCd )?.text; - return( - {...item, - sggText:sggText, - cityText:cityText - }) - }) - setbdstTable(table) - } - }, [code,bdstObj]); - - const cellClick = ()=>{ - - } - const nodeList = headMakeColSpan(rain.upHeadList) - return( - <> - <h2>건축물조회</h2> < h2/> - <div className="grid grid-cols-12 gap-2"> - - <SelectBox className='col-span-3' label={''} selectClass={selectClass} selectArray={code.cityCd} onSelectValue={getCity } > </SelectBox> - <SelectBox className='col-span-3' label={""} selectClass={selectClass} selectArray={code.sggCd} onSelectValue={getSgg }> </SelectBox> - <Input className='col-span-3'></Input> - <Button className='col-span-1'> 조회</Button> - </div> - <div> - <UiTable tableData={bdstTable || []} headlist={rain.upHeadList} pageSize={-10} total={-1} headName={undefined} cellClick={cellClick}> - {nodeList} - </UiTable> - </div> - </> - ) -} \ No newline at end of file diff --git a/apps/wr/components/ui/form/fcltReg/bdstReg/component.tsx b/apps/wr/components/ui/form/fcltReg/bdstReg/component.tsx new file mode 100644 index 000000000..cbc099cb9 --- /dev/null +++ b/apps/wr/components/ui/form/fcltReg/bdstReg/component.tsx @@ -0,0 +1,32 @@ +import { FormField, FormUi } from "@common/business_components"; +import { Input } from "@common/components"; + + +export default function BdstReg(form:any){ + + + + + return( + <> + <div className="grid grid-cols-4 gap-2 mt-4 pl-6"> + <div className="col-span-2"> + <FormField + control={form.control} + name="instlCmptnDt" + render={({ field }) => ( + <FormUi label="설치완료일"> + <Input + className="" + type="date" + onChange={(e) => field.onChange(e.target.value ? new Date(e.target.value) : undefined)} + value={field.value ? field?.value.toString().split('T')[0] : ""} + /> + </FormUi> + )} + /> + </div> + </div> + </> + ) +} \ No newline at end of file diff --git a/apps/wr/components/ui/form/fcltReg/rainReg/component.tsx b/apps/wr/components/ui/form/fcltReg/rainReg/component.tsx index 74b59d9d5..49ca89fc2 100644 --- a/apps/wr/components/ui/form/fcltReg/rainReg/component.tsx +++ b/apps/wr/components/ui/form/fcltReg/rainReg/component.tsx @@ -7,63 +7,48 @@ import { useForm } from "react-hook-form"; import { z } from "zod"; import { FormUi } from "@common/business_components"; import { useWrStore } from "@/app/store"; -import { selectClass, type rainRuseType } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; +import { selectClass, type rainRuseBd, } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; import { useEffect } from "react"; +import { rainDefault, rainForm } from "@/components/lib/type/zod/fcltReg/controlZod"; -const formSchema = z - .object({ - instlCmptnDt: z.date(), - instlCst: z.number(), - pntfColKnd: z.string(), - pntfColArea: z.number(), - filtrTrtmfctPrs: z.string(), - filtrTrtmfctYn: z.string(), - filtrTrtmfctCpct: z.string(), - instlCstSprtYn: z.string(), - instlCstSprtAmt: z.string(), - grntchCstSprtYn: z.string(), - grntchCstSprtCst: z.string(), - grntchBdstCertYn: z.string(), - grntchBdstCertYr: z.string(), - grntchBdstCertNo: z.string(), - grntchBdstCertGrd: z.string(), - }) +const formSchema = rainForm; -export function RainRegForm({data}:{data:rainRuseType[]} ) { +console.log(formSchema) +export function RainRegForm({data}:{data:rainRuseBd[]} ) { const { rain ,code} = useWrStore((state) => state); const {rainFcltCd } = code useEffect(() => { - console.log("form data:", data); if (data && data.length > 0) { + console.log(data) const selectedOption = rainFcltCd.find(item => item.val === String(data[0].pntfColKnd)); const formData = { ...data[0], pntfColKnd: selectedOption ? selectedOption.val : "" }; - console.log("Setting form data:", formData); form.reset(formData); } }, [data, rainFcltCd]); const form = useForm<z.infer<typeof formSchema>>({ resolver: zodResolver(formSchema), - defaultValues: { - instlCmptnDt: new Date(), - instlCst: 0, - pntfColKnd: "", - pntfColArea: 0, - filtrTrtmfctYn: "N", - filtrTrtmfctCpct: "", - filtrTrtmfctPrs: "", - instlCstSprtYn: "", - instlCstSprtAmt: "", - grntchCstSprtYn: "", - grntchCstSprtCst: "", - grntchBdstCertYn: "", - grntchBdstCertYr: "", - grntchBdstCertNo: "", - grntchBdstCertGrd: "", - }, + defaultValues: rainDefault + // { + // instlCmptnDt: new Date(), + // instlCst: 0, + // pntfColKnd: "", + // pntfColArea: 0, + // filtrTrtmfctYn: "N", + // filtrTrtmfctCpct: "", + // filtrTrtmfctPrs: "", + // instlCstSprtYn: "", + // instlCstSprtAmt: "", + // grntchCstSprtYn: "", + // grntchCstSprtCst: "", + // grntchBdstCertYn: "", + // grntchBdstCertYr: "", + // grntchBdstCertNo: "", + // grntchBdstCertGrd: "", + // }, }); // form 값이 변경될 때마다 로그 출력 diff --git a/apps/wr/components/ui/modal/bdstReg/component.tsx b/apps/wr/components/ui/modal/bdstReg/component.tsx index bef2873af..13ab4df08 100644 --- a/apps/wr/components/ui/modal/bdstReg/component.tsx +++ b/apps/wr/components/ui/modal/bdstReg/component.tsx @@ -1,33 +1,70 @@ -import { Button, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from "@common/components"; +'use client' +import { headMakeColSpan } from "@/app/ruseFcltMng/fcltReg/rainReg/page"; +import { useWrStore } from "@/app/store"; +import { selectClass, type bdstType } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; +import { ScrollArea, SelectBox, UiTable } from "@common/business_components"; +import { Button, Input } from "@common/components"; +import { useEffect, useState } from "react"; +import { RainRegForm } from "../../form/fcltReg/rainReg/component"; +export function BdstReg(){ -type ModalType={ - bodyClass:string - butNm:string - title:string - body:React.ReactNode -} -export function BdstRegModal({bodyClass,butNm,title ,body}:ModalType ) { - return ( - <> - <Dialog > - <DialogTrigger asChild> - <Button className="mr-4 rounded-lg">{butNm}</Button> - </DialogTrigger> - <DialogContent className="sm:max-w-7xl"> - <DialogHeader> - <DialogTitle>{title}</DialogTitle> - <DialogDescription> - </DialogDescription> - </DialogHeader> - {body} + const { rain, code,init } = useWrStore((state) => { + return state + }); - - <DialogFooter className="sm:justify-start"> - - </DialogFooter> - </DialogContent> - </Dialog> - </> - ); -} + const[bdstTable, setbdstTable] = useState <bdstType[]> (); + const [rainBdstForm, setRainBdstForm] = useState<[]>() + const {bdstObj, rainRuseObj } =rain + const getCity =(val:string|number)=>{ + + console.log(val) + } + + const getSgg =(val:string|number)=>{ + + console.log(val) + } + + useEffect ( () => { + if(code.sggCd.length>0){ + const table= bdstObj.map((item) => { + const sggText= code.sggCd.find((cd)=>cd.val.toString() === item.sggCd )?.text; + const cityText= code.cityCd.find((cd)=>cd.val.toString() === item.ctpvCd )?.text; + return( + {...item, + sggText:sggText, + cityText:cityText + }) + }) + setbdstTable(table) + } + }, [code,bdstObj]); + + const cellClick = ()=>{ + + } + const nodeList = headMakeColSpan(rain.upHeadList) + return( + <> + <h2>건축물조회</h2> < h2/> + <div className="grid grid-cols-12 gap-2"> + + <SelectBox className='col-span-3' label={''} selectClass={selectClass} selectArray={code.cityCd} onSelectValue={getCity } > </SelectBox> + <SelectBox className='col-span-3' label={""} selectClass={selectClass} selectArray={code.sggCd} onSelectValue={getSgg }> </SelectBox> + <Input className='col-span-3'></Input> + <Button className='col-span-1'> 조회</Button> + </div> + <div> + <UiTable tableData={bdstTable || []} headlist={rain.upHeadList} pageSize={-10} total={-1} headName={undefined} cellClick={cellClick}> + {nodeList} + </UiTable> + </div> + <div> + <ScrollArea> + <RainRegForm data={rainBdstForm || []} ></RainRegForm> + </ScrollArea> + </div> + </> + ) +} \ No newline at end of file