중수도 작업중

This commit is contained in:
leedj312
2025-04-03 18:17:16 +09:00
parent 965accac4a
commit 6454ae1330
7 changed files with 249 additions and 145 deletions
@@ -4,6 +4,7 @@ import type {
RainyBuilding,
TableUpperProps,
} from "@/app/store/ruseFcltMng/fcltReg/rainReg";
import { tableData } from "@/components/lib/func/commom";
import { RainRegForm } from "@/components/ui/form/fcltReg/rainReg/component";
import { BdstReg } from "@/components/ui/modal/bdstReg/component";
import {
@@ -71,22 +72,8 @@ export default function Home() {
useEffect(() => {
if (code.sggCd.length > 0) {
const table = rainRes.map((item) => {
const sggText = code.sggCd.find(
(cd) => cd.val === Number(item.sggCd)
)?.text;
const cityText = code.cityCd.find(
(cd) => cd.val === Number(item.ctpvCd)
)?.text;
const bdstusgText = code.bdstUsgCd.find(
(cd) =>cd.val === item?.reuseBuilding[0]?.bdstUsgCd
)
return { ...item, sggText: sggText, cityText: cityText ,bdsgUsgText:bdstusgText };
});
setbdstTable(table);
setbdstTable( tableData(rainRes, { code }));
}
}, [code, rainRes]);
const cellClick: (val: number | undefined) => void = (val) => {
@@ -19,11 +19,14 @@ import { Button} from "@common/components";
import { headMakeColSpan } from "../rainReg/page";
import { useEffect, useState } from "react";
import type { RswtBuilding } from "@/app/store/ruseFcltMng/fcltReg/rswtReg";
import { tableData } from "@/components/lib/func/commom";
export default function Home() {
const { code,rswt,initRswt } = useWrStore((state) => state);
const nodeList = headMakeColSpan(rswt.upHeadList);
const [rswtForm, setRswtForm] = useState<RswtBuilding>();
const [bdstTable, setbdstTable] = useState<RswtBuilding[]>();
const {rswtRes} = rswt;
@@ -37,20 +40,18 @@ export default function Home() {
}, [rswt.isInit, initRswt]);
useEffect(() => {
if (code.sggCd.length > 0) {
console.log(rswtRes)
const table = rswtRes?.map((item) => {
const sggText = code.sggCd.find(
(cd) => cd.val === Number(item.sggCd)
)?.text;
const cityText = code.cityCd.find(
(cd) => cd.val === Number(item.ctpvCd)
)?.text;
return { ...item, sggText: sggText, cityText: cityText };
});
setbdstTable(table);
setbdstTable( tableData(rswtRes, { code }));
}
}, [code, rswtRes]);
const cellClick: (val: number | undefined) => void = (val) => {
if ((bdstTable ?? []).length > 0 && val !== undefined) {
{
setRswtForm(rswtRes[val]);
}
}
};
return (
<>
@@ -71,7 +72,6 @@ export default function Home() {
</SearchFormLeft>
<SearchFormRight>
<Button className="mr-4 rounded-lg">조회</Button>
<Button className="mr-4 rounded-lg">저장</Button>
<UiModal
butNm="신규등록"
title="건축물 시설 등록(중수도시설)"
@@ -92,7 +92,7 @@ export default function Home() {
pageSize={100}
total={10}
headName={"○건축물 목록"}
cellClick={undefined}
cellClick={cellClick}
>
{nodeList}
</UiTable>
@@ -101,7 +101,11 @@ export default function Home() {
<div className="col-span-2 max-h-full ovreflow-y-scroll">
<ListDiv>
<ScrollArea>
<RswtrRegForm></RswtrRegForm>
<RswtrRegForm
rswtForm={rswtForm || undefined}
isModal={false}
/>
</ScrollArea>
</ListDiv>
</div>
+31 -33
View File
@@ -43,41 +43,39 @@ export const rainFcltCd = [
{ val: "9", text: "기타" },
{ val: "10", text: "확인불가" },
];
//중수도 필수 원수종류
export const rswtBdstType :selectArray[]= [
{ text: "숙박업", val: "17" },
{ text: "목욕장업", val: "18" },
{ text: "공장", val: "19" },
{ text: "발전시설", val: "20" },
{ text: "관광단지개발사업", val: "21" },
{ text: "도시개발사업", val: "22" },
{ text: "산업단지개발사업", val: "23" },
{ text: "택지개발사업", val: "24" },
{ text: "대규모점포(대형마트)", val: "25" },
{ text: "대규모점포(전문점)", val: "26" },
{ text: "대규모점포(백화점)", val: "27" },
{ text: "대규모점포(쇼핑센터)", val: "28" },
{ text: "대규모점포(복합쇼핑몰)", val: "29" },
{ text: "물류시설", val: "30" },
{ text: "운수시설(여객자동차터미널)", val: "31" },
{ text: "운수시설(철도시설)", val: "32" },
{ text: "운수시설(공항시설)", val: "33" },
{ text: "운수시설(항만시설)", val: "34" },
{ text: "업무시설(공공업무시설)", val: "35" },
{ text: "업무시설(금융업소)", val: "36" },
{ text: "업무시설(사무소)", val: "37" },
{ text: "업무시설(결혼상담소 등 소개업소)", val: "38" },
{ text: "업무시설(출판사)", val: "39" },
{ text: "업무시설(신문사)", val: "40" },
{ text: "업무시설(오피스텔)", val: "41" },
{ text: "교정시설", val: "42" },
{ text: "방송국", val: "43" },
{ text: "전신전화국", val: "44" },
{ text: "기타", val: "45" },
// 중수도 필수 원수종류
export const rswtBdstType: selectArray[] = [
{ text: "숙박업", val: 17 },
{ text: "목욕장업", val: 18 },
{ text: "공장", val: 19 },
{ text: "발전시설", val: 20 },
{ text: "관광단지개발사업", val: 21 },
{ text: "도시개발사업", val: 22 },
{ text: "산업단지개발사업", val: 23 },
{ text: "택지개발사업", val: 24 },
{ text: "대규모점포(대형마트)", val: 25 },
{ text: "대규모점포(전문점)", val: 26 },
{ text: "대규모점포(백화점)", val: 27 },
{ text: "대규모점포(쇼핑센터)", val: 28 },
{ text: "대규모점포(복합쇼핑몰)", val: 29 },
{ text: "물류시설", val: 30 },
{ text: "운수시설(여객자동차터미널)", val: 31 },
{ text: "운수시설(철도시설)", val: 32 },
{ text: "운수시설(공항시설)", val: 33 },
{ text: "운수시설(항만시설)", val: 34 },
{ text: "업무시설(공공업무시설)", val: 35 },
{ text: "업무시설(금융업소)", val: 36 },
{ text: "업무시설(사무소)", val: 37 },
{ text: "업무시설(결혼상담소 등 소개업소)", val: 38 },
{ text: "업무시설(출판사)", val: 39 },
{ text: "업무시설(신문사)", val: 40 },
{ text: "업무시설(오피스텔)", val: 41 },
{ text: "교정시설", val: 42 },
{ text: "방송국", val: 43 },
{ text: "전신전화국", val: 44 },
{ text: "기타", val: 45 },
];
const orgwtKndCd = [
{ text: "오수(변기 오수 제외)", val: "1" },
{ text: "오수", val: "2" },
@@ -146,7 +146,7 @@ export const upHeadList: TableUpperProps[] = [
{ id: "sggText", title: "시군구" },
{ id: "bdstNm", title: "시설명" },
{ id: "daddr", title: "위치" },
{ id: "bdstUsgText", title: "건축물용도" },
{ id: "bdsgUsgText", title: "건축물용도" },
// { id: "bdstUsgCd", title: "건축물용도" },
{ id: "frstArchPrmsnDt", title: "최초건축허가일" },
{ id: "archArea", title: "건축면적" },
@@ -1,5 +1,65 @@
import { getFectch } from "@/components/lib/api";
import { upHeadList, type chgBuilding, type TableUpperProps } from "../rainReg";
import { rswtBdstType } from "@/app/store/common/code";
import { z } from "zod";
export const rswtZod = z.object({
bdstInfoPk: z.number().default(0),
ctpvCd: z.number().default(0),
sggCd: z.number().default(0),
daddr: z.string().default(""),
bdstNm: z.string().default(""),
frstArchPrmsnDt: z.coerce.date().default(() => new Date()),
archChgPrmsnDt: z.coerce.date().nullish().default(null),
archArea: z.number().default(0),
archChgArea: z.number().default(0),
reuseBuilding: z.array(
z.object({
bdstRuseFcltPk: z.number().default(0),
bdstInfoFk: z.number().default(0),
instlCmptnDt: z.coerce.date().default(() => new Date()),
instlCst: z.number().default(0),
operMngCd: z.string().nullish().default(""),
anlOperCst: z.number().default(0),
instlCstSprtYn: z.string().default(""),
instlCstSprtAmt: z.number().default(0),
grntchBdstCertYn: z.string().default(""),
grntchBdstCertYr: z.string()
.regex(/^\d{4}$/, "4자리 연도를 입력하세요")
.default(""),
grntchBdstCertNo: z.string().default(""),
grntchBdstCertGrd: z.string().default(""),
crgRdctYn: z.string().default(""),
crgRdctBss: z.string().default(""),
crgRdctAmt: z.number().default(0),
ruseFcltFlg: z.string().default(""),
bdstUsgCd: z.number().default(0),
lawTrgtYn: z.string().default(""),
rswtrObj: z.object({
bdstRuseFcltFk: z.number().default(0),
wtrUsqty: z.number().default(0),
oblgTrgtWtrUsqty: z.number().default(0),
orgwtKndCd: z.string().default(""),
filtrTrtmfctProcs: z.string().default(""),
filtrTrtmfctUsgCd: z.string().default(""),
rswtrUsqty: z.number().default(0),
altUswtrUtztnYn: z.string().default(""),
altUswtrKndCd: z.string().default(""),
altUswtrUtztnQnt: z.number().default(0),
altUswtrIdntyMthdCd: z.string().default("")
}).default({})
})
).default([])
});
export type RswtBuilding = {
bdstInfoPk: number;
@@ -45,6 +105,8 @@ export type rswtrObj = {
altUswtrIdntyMthdCd: string;
};
rswtBdstType
const rswtRes: RswtBuilding[] = [];
export type rswtFacState = {
@@ -71,7 +133,7 @@ export const rswtFacStateExport: rswtFacState = {
const initFetch = async (txt: string | undefined) => {
return await getFectch(
"wr",
`/reuseFc/waterreuseFc/1/20/01` + (txt ? `/${txt}` : "")
`/reuseFc/waterreuseFc/1/20/41` + (txt ? `/${txt}` : "")
);
};
export const rswtFacActionsExport: (set: any) => rswtFacSActions = (
+25 -1
View File
@@ -1,4 +1,5 @@
import type { selectArray } from "@/app/store/common/code";
import type { comCodeState, selectArray } from "@/app/store/common/code";
import type { RainyBuilding } from "@/app/store/ruseFcltMng/fcltReg/rainReg";
@@ -14,3 +15,26 @@ export const getCity = (val: string, sggCd: selectArray[]) => {
return data
};
// cd text 넣기
export const tableData = ( data: any,code:comCodeState)=>{
const chCode = code.code;
return data?.map((item: { sggCd: string; ctpvCd: string; reuseBuilding: { lawTrgtYn: any , bdstUsgCd:any}[]; }) => {
const sggText = chCode.sggCd.find(
(cd) => cd.val === Number(item.sggCd)
)?.text;
const cityText = chCode.cityCd.find(
(cd) => cd.val === Number(item.ctpvCd)
)?.text;
const bdsgUsgText = chCode.bdstUsgCd.find(
(cd) =>cd.val === item?.reuseBuilding[0]?.bdstUsgCd
)?.text
const lawTrgtYn = item?.reuseBuilding[0]?.lawTrgtYn
return { ...item, sggText: sggText, cityText: cityText ,bdsgUsgText:bdsgUsgText ,lawTrgtYn:lawTrgtYn};
});
}
@@ -1,72 +1,75 @@
"use client";
import {
DatePicker,
Form,
FormField,
FormUi,
SelectBox,
} from "@common/business_components/ui";
import { Input } from "@common/components/ui";
import { Button, Input } from "@common/components/ui";
import { zodResolver } from "@hookform/resolvers/zod";
import { useForm } from "react-hook-form";
import { useFieldArray, useForm } from "react-hook-form";
import { z } from "zod";
import { useWrStore } from "@/app/store";
import { selectClass } from "@/app/store/ruseFcltMng/fcltReg/rainReg";
import {
rswtZod,
type RswtBuilding,
} from "@/app/store/ruseFcltMng/fcltReg/rswtReg";
import { useEffect } from "react";
const formSchema = z.object({
facilityName: z.string().min(2).max(50),
instlCmptnDt: z.string(),
instlCst: z.string(),
wtrUsqty: z.string(),
oblgTrgtwtrUsqty: z.string(),
rswtrKndCd: z.string(),
rswrtProcs: z.string(),
utztmUsgCd: 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(),
});
export function RswtrRegForm({
rswtForm,
isModal,
}: {
rswtForm: RswtBuilding;
isModal: boolean;
}) {
const { rswt, code } = useWrStore((state) => state);
export function RswtrRegForm() {
const { rswt,code } = useWrStore((state) => state);
const form = useForm<z.infer<typeof formSchema>>({
resolver: zodResolver(formSchema),
defaultValues: {
facilityName: "",
instlCmptnDt: "",
instlCst: "",
wtrUsqty: "",
oblgTrgtwtrUsqty: "",
rswtrKndCd: "",
rswrtProcs: "",
utztmUsgCd: "",
instlCstSprtYn: "",
instlCstSprtAmt: "",
grntchCstSprtYn: "",
grntchCstSprtCst: "",
grntchBdstCertYn: "",
grntchBdstCertYr: "",
grntchBdstCertNo: "",
grntchBdstCertGrd: "",
},
const form = useForm<z.infer<typeof rswtZod>>({
resolver: zodResolver(rswtZod),
});
// 2. Define a submit handler.
function onSubmit(values: z.infer<typeof formSchema>) {
function onSubmit(values: z.infer<typeof rswtZod>) {
// Do something with the form values.
// ✅ This will be type-safe and validated.
console.log(values);
}
const onSelectValue = (val: string) => {
const onSelectValue = (val: string | number) => {
console.log(val);
};
function cleanRswtData(raw: any): z.infer<typeof rswtZod> {
return {
...raw,
frstArchPrmsnDt: new Date(raw?.frstArchPrmsnDt),
archChgPrmsnDt: raw?.archChgPrmsnDt ? new Date(raw?.archChgPrmsnDt) : null,
reuseBuilding: (raw?.reuseBuilding || []).map((item: any) => ({
...item,
instlCmptnDt: new Date(item?.instlCmptnDt),
operMngCd: item?.operMngCd ?? "", // null → ""
grntchBdstCertYr: typeof item?.grntchBdstCertYr === "string"
? item?.grntchBdstCertYr
: "", // null → ""
rswtrObj: {
...item?.rswtrObj
}
}))
};
}
useEffect(() => {
if(rswtZod)
form.reset( cleanRswtData(rswtForm))
}, [rswtForm]);
return (
<div className="">
<Form {...form}>
@@ -75,6 +78,9 @@ export function RswtrRegForm() {
<div>
<div>
<h1 className="pl-3 text-xl ">○ 중수도 시설 운영정보</h1>
<Button type="submit" className="mr-4 rounded-lg col-span-2">
저장
</Button>
</div>
</div>
<h1 className="bg-gray-400 text-xl text-center border-2 p-2 mt-4 ">
@@ -84,14 +90,19 @@ export function RswtrRegForm() {
<div className="col-span-2">
<FormField
control={form.control}
name="instlCmptnDt"
name="reuseBuilding.0.instlCmptnDt"
render={({ field }) => (
<FormUi label="설치완료일">
<Input
className=""
placeholder="1,000,000"
type=""
{...field}
<DatePicker
mode="single"
field={{
value:
field.value && !isNaN(new Date(field.value).getTime())
? new Date(field.value)
: new Date(), // Provide a default Date value
onChange: (date) => field.onChange(date),
}}
selectClass={selectClass}
/>
</FormUi>
)}
@@ -101,14 +112,15 @@ export function RswtrRegForm() {
<div className="col-span-2">
<FormField
control={form.control}
name="instlCst"
name="reuseBuilding.0.instlCst"
render={({ field }) => (
<FormUi label="설치비">
<Input
className=""
placeholder="1,000,000"
type=""
{...field}
type="text"
value={field.value ?? ""}
onChange={field.onChange}
/>
</FormUi>
)}
@@ -119,14 +131,15 @@ export function RswtrRegForm() {
<div className="col-span-2">
<FormField
control={form.control}
name="wtrUsqty"
name="reuseBuilding.0.rswtrObj.wtrUsqty"
render={({ field }) => (
<FormUi label="물사용량(m³)">
<Input
className=""
placeholder="1,000,000"
type=""
{...field}
value={field.value ?? ""}
onChange={field.onChange}
/>
</FormUi>
)}
@@ -136,14 +149,15 @@ export function RswtrRegForm() {
<div className="col-span-2">
<FormField
control={form.control}
name="oblgTrgtwtrUsqty"
name="reuseBuilding.0.rswtrObj.oblgTrgtWtrUsqty"
render={({ field }) => (
<FormUi label="의무대상 물사용량(m³)">
<Input
className=""
placeholder="1,000,000"
type=""
{...field}
type="text"
value={field.value ?? ""}
onChange={field.onChange}
/>
</FormUi>
)}
@@ -160,14 +174,16 @@ export function RswtrRegForm() {
<div className="col-span-5 pl-6">
<FormField
control={form.control}
name="rswtrKndCd"
name="reuseBuilding.0.rswtrObj.orgwtKndCd"
render={({ field }) => (
<FormUi label="필수 종류">
<FormUi label="원수 종류">
<SelectBox
className={""}
label={""}
selectClass={selectClass}
selectArray={code.orgwtKndCd}
onSelectValue={onSelectValue}
{...field}
onSelectValue={field.onChange}
value={field.value ??code.orgwtKndCd[0]?.val }
/>
</FormUi>
)}
@@ -176,20 +192,20 @@ export function RswtrRegForm() {
<div className="col-span-5">
<FormField
control={form.control}
name="rswrtProcs"
name="reuseBuilding.0.rswtrObj.filtrTrtmfctProcs"
render={({ field }) => (
<FormUi label="주요처리공정">
<Input
className=""
placeholder="1,000,000"
type=""
{...field}
value={field.value ??""}
onChange={field.onChange}
/>
</FormUi>
)}
/>
</div>
</div>
<div className=" my-2">
@@ -204,15 +220,17 @@ export function RswtrRegForm() {
<div className="col-span-1 pl-6">
<FormField
control={form.control}
name="instlCstSprtYn"
name="reuseBuilding.0.instlCstSprtYn"
render={({ field }) => (
<FormUi label="설치비 지원여부">
<SelectBox
className={""}
selectClass={selectClass}
label={""}
selectArray={code.yn}
onSelectValue={onSelectValue}
{...field}
value={field.value ??code.yn[0]?.val }
onChange={field.onChange}
/>
</FormUi>
)}
@@ -221,14 +239,15 @@ export function RswtrRegForm() {
<div className="col-span-1">
<FormField
control={form.control}
name="instlCstSprtAmt"
name="reuseBuilding.0.instlCstSprtAmt"
render={({ field }) => (
<FormUi label="지원금액(원)">
<Input
className=""
placeholder="1,000,000"
type=""
{...field}
value={field.value ??"" }
onChange={field.onChange}
/>
</FormUi>
)}
@@ -243,15 +262,17 @@ export function RswtrRegForm() {
<div className="col-span-3 pl-6">
<FormField
control={form.control}
name="grntchCstSprtYn"
name="reuseBuilding.0.grntchBdstCertYn"
render={({ field }) => (
<FormUi label="인증여부">
<SelectBox
className={""}
selectClass={selectClass}
label={""}
selectArray={code.yn}
onSelectValue={onSelectValue}
{...field}
value={field.value ??code.yn[0]?.val }
onChange={field.onChange}
/>
</FormUi>
)}
@@ -260,10 +281,17 @@ export function RswtrRegForm() {
<div className="col-span-3">
<FormField
control={form.control}
name="grntchBdstCertYr"
name="reuseBuilding.0.grntchBdstCertYr"
render={({ field }) => (
<FormUi label="인증년도">
<Input className="" placeholder="2024" type="" {...field} />
<Input
className=""
placeholder="2024"
type=""
{...field}
value={field.value ?? ""}
onChange={field.onChange}
/>
</FormUi>
)}
/>
@@ -271,14 +299,15 @@ export function RswtrRegForm() {
<div className="col-span-3 pl-6">
<FormField
control={form.control}
name="grntchBdstCertNo"
name="reuseBuilding.0.grntchBdstCertNo"
render={({ field }) => (
<FormUi label="인증번호">
<Input
className=""
placeholder="ab1234678"
type=""
{...field}
value={field.value ??""}
onChange={field.onChange}
/>
</FormUi>
)}
@@ -287,10 +316,10 @@ export function RswtrRegForm() {
<div className="col-span-3">
<FormField
control={form.control}
name="grntchBdstCertGrd"
name="reuseBuilding.0.grntchBdstCertGrd"
render={({ field }) => (
<FormUi label="인증등급">
<Input className="" placeholder="A" type="" {...field} />
<Input className="" placeholder="A" type="" value={field.value ??"" } onChange={field.onChange} />
</FormUi>
)}
/>