하수재이용 사업 업데이트 작업중

This commit is contained in:
leedj312
2025-05-26 09:59:07 +09:00
parent bf6ad4ee79
commit 93beaa7a67
10 changed files with 212 additions and 64 deletions
@@ -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<string>("mng");
const [fcltMng, setFcltMng] = useState<ruseFcltType[]>();
const [pbnstBiz, setPbnstBiz] = useState<fcBizType[]>();
const [searchTxt, setSearchTxt] = useState<string>();
const [bdstTable, setbdstTable] = useState<customPbnst[]>();
@@ -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 (
<>
<ContentsDiv>
@@ -129,7 +138,7 @@ useEffect(() => {
<PbnstMngForm data={fcltMng || []} />
</TabsContent>
<TabsContent className="max-h-full" value="buse">
<PbnstBuseForm />
<PbnstBuseForm data={pbnstBiz || []} />
</TabsContent>
</Tabs>
</ScrollArea>
@@ -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<customPbnst[]>();
// const nodeList = headMakeprfmnc(pbnstSttn.pbnSttHeadList, pbnstSttn.pbnSttHeadNm);
const excelClick = useCallback(() => {
// if (codeData) pbnstSttnSearch(1, "10000", codeData);
}, []);
return (
@@ -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,
@@ -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)​'},
]
@@ -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: {
@@ -45,6 +45,12 @@ export type ruseFcltType = {
splyExtraCpct: number;
};
export type fcBizType = z.infer<typeof fcBizSchema>;
export type fcOrgwtType = z.infer<typeof fcOrgwtSchema>;
export type ppInstlType = z.infer<typeof pplInstlSchema>;
export type operType = z.infer<typeof fcOperSchema>;
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,
@@ -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;
@@ -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<fcOrgwtType[]>([]);
const [ppistlData ,setPpistlData] = useState<ppInstlType[]>([]);
const form = useForm<z.infer<typeof pbnstRegZod>>({
resolver: zodResolver(pbnstRegZod),
const [ppiYn, setPpiYn] = useState("Y");
const form = useForm<fcBizType>({
resolver: zodResolver(fcBizSchema),
});
// 2. Define a submit handler.
function onSubmit(values: z.infer<typeof pbnstRegZod>) {
// 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 (
<div className=" !mx-[1.6rem] !p-0r">
@@ -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));
}}
></SelectBox>
@@ -104,6 +117,8 @@ export function PbnstBuseForm() {
<MngRegFormDetail
formList={businessMoneyInfo}
h1Title={"사업비"}
form={form}
moClass="grid grid-cols-12 gap-4"
@@ -133,13 +148,58 @@ export function PbnstBuseForm() {
<h1 className={formH1Class}>재이용 원수취수 현황</h1>
<div>
<Button size={commonButonSize}>
추가등록
</Button>
<RuseMngTable
tableData={[]}
headList={pbnst.pbnstOrgwtHeadList}
<Button size={commonButonSize}>추가등록</Button>
<RuseMngTable
tableData={fcOrgwtFiled}
headList={pbnst.pbnstOrgwtHeadList}
/>
</div>
<h1 className={formH1Class}>재이용 공급관로 설치 현황</h1>
<div className="flex items-center gap-4 mx-3 mb-3">
<Label className="text-right">공급관로설치유무</Label>
<SelectBox
label=""
selectArray={code.yn}
value={ppiYn}
className="w-32"
selectClass="w-full"
onSelectValue={(val) => setPpiYn(String(val))}
/>
<Label className="text-right">합계</Label>
<Input
type="text"
value={""}
readOnly
className="w-32 border-gray-300 rounded pr-8 "
/>
<Button className="ml-7" size={commonButonSize}>
추가등록
</Button>
<Button size={commonButonSize}>삭제</Button>
</div>
<div>
<RuseMngTable
tableData={ pplInstls}
headList={pbnst.pplInstlsHeadLisat}
/>
</div>
<MngRegFormDetail
formList={ruseWaterQulityList}
h1Title={"하수처리수 재이용시설 보증수질"}
form={form}
moClass="grid grid-cols-12 gap-4"
sonClass="col-span-4"
/>
<h1 className={formH1Class}>하수처리수 재이용수 수요처</h1>
<div>
<Button size={commonButonSize}>수요처 추가</Button>
<RuseMngTable
tableData={[]}
headList={pbnst.pbnstDemandHeadList}
/>
</div>
</form>
</Form>
@@ -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({
<h1 className={formH1Class}>{h1Title}</h1>
<div className={moClass}>
{formList?.map((item, index) => {
const fieldId = cycle? `${cycle}.${item.id}`: item.id;
return (
<div className={sonClass} key={index + `${item.id}`}>
<FormField
control={form.control}
name={item.id}
name={fieldId}
render={({ field }) => (
<FormUi label={item.lable}>
{item.type === "select" ? (
@@ -34,17 +38,16 @@ export default function MngRegFormDetail({
) : item.type === "date" ? (
<DatePicker
mode={"single"}
field={{
value: safeDate(field.value) || new Date(),
onChange: (date: Date | undefined) =>
field.onChange(date),
}}
selectClass={"rounded-lg w-full"}
></DatePicker>
selected={safeDate(field.value) || new Date()}
onSelect={(date: Date | undefined) =>
field.onChange(date)
}
className={"rounded-lg w-full"}
/>
) : item.type === "number" ? (
<Input placeholder="" type="number" {...field} />
<Input placeholder="" type="number" value={field.value??0} onChange={field.onChange} />
) : (
<Input placeholder="" type="" {...field} />
<Input placeholder="" type="text" value={field.value??''} onChange={field.onChange} />
)}
</FormUi>
)}
@@ -29,7 +29,7 @@ export default function RuseMngTable({
) : (
<TableRow key={"table-row-test"}>
{headList.map((head) => (
<TableHead className={`border border-gray-600 px-2 py-1 `}>
<TableHead key = {head.id} className={`border border-gray-600 px-2 py-1 `}>
{head.title}
</TableHead>
))}