Co-authored-by: truthplumage <truthplumage@users.noreply.github.com>
This commit is contained in:
@@ -15,7 +15,7 @@ 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, fcBizSchema, fcBizType, ruseFcltType } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type";
|
||||
import type { customPbnst, fcBizSchema, fcBizType, pubHasuType, 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";
|
||||
@@ -31,9 +31,9 @@ export default function PublicReuseFaciltyInsert() {
|
||||
const [issNewReg, setIsNewReg] = useState<boolean>(false);
|
||||
|
||||
const [searchTxt, setSearchTxt] = useState<string>();
|
||||
const [bdstTable, setbdstTable] = useState<customPbnst[]>();
|
||||
const [bdstTable, setbdstTable] = useState<pubHasuType[]>();
|
||||
const [selectBdst, setSelectBdst] = useState<customPbnst | null>(null);
|
||||
const [selectedRow, setSelectedRow] = useState<customPbnst | null>(null);
|
||||
const [selectedRow, setSelectedRow] = useState<pubHasuType | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (!pbnst.isInit ) {
|
||||
@@ -46,7 +46,6 @@ useEffect(() => {
|
||||
useEffect(() => {
|
||||
|
||||
|
||||
console.log("pbnstHasuRes", pbnstHasuRes);
|
||||
if (code.sggCd.length > 0 && pbnstHasuRes.length > 0) {
|
||||
setbdstTable(tableData(pbnstHasuRes, { code }));
|
||||
}
|
||||
@@ -57,16 +56,14 @@ useEffect(() => {
|
||||
};
|
||||
const cellClick = (val: number | undefined) => {
|
||||
if (val === undefined) return;
|
||||
console.log("pbnstRes", pbnstRes)
|
||||
const selectRow = pbnstHasuRes?.[val];
|
||||
setSelectedRow(selectRow);
|
||||
console.log("아제발", selectRow)
|
||||
if (pbnstRes === null){
|
||||
if (pbnstRes !== null){
|
||||
alert("등록된 재이용시설 정보가 없습니다. 신규등록 하십시오.")
|
||||
return;
|
||||
}
|
||||
setSelectBdst(pbnstRes);
|
||||
setPbnstBiz(pbnstRes?.fcBizs)
|
||||
// setSelectBdst(pbnstRes);
|
||||
// setPbnstBiz(pbnstRes?.fcBizs)
|
||||
};
|
||||
const resetContents = () => {
|
||||
setFcltMng([]); // 빈 배열로 설정하여 신규 모드로 전환
|
||||
@@ -135,11 +132,17 @@ useEffect(() => {
|
||||
</ListDiv>
|
||||
</div>
|
||||
<ListDiv className="col-span-2 pr-6 ">
|
||||
|
||||
<ScrollArea className="h-[60vh]">
|
||||
|
||||
|
||||
<Tabs defaultValue="mng" onValueChange={handleTabChange}>
|
||||
<TabsList className="">
|
||||
<TabsTrigger className="!text-xl" value="mng">시설정보</TabsTrigger>
|
||||
<TabsTrigger className="!text-xl" value="buse">차수별정보</TabsTrigger>
|
||||
<Button size={"sm"} className="!justify-end">
|
||||
저장
|
||||
</Button>
|
||||
</TabsList>
|
||||
<TabsContent className="max-h-full" value="mng">
|
||||
<PbnstMngForm data={selectBdst || []} />
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
import { z } from "zod";
|
||||
import type { TableUpperProps } from "../rainReg";
|
||||
import { deleteFectch, fetchType, getFetch, postFectch } from "@/components/lib/api";
|
||||
import {
|
||||
deleteFectch,
|
||||
fetchType,
|
||||
getFetch,
|
||||
postFectch,
|
||||
} from "@/components/lib/api";
|
||||
import type { chHeadType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList";
|
||||
import {
|
||||
exampleData,
|
||||
fcBizSchema,
|
||||
type customPbnst,
|
||||
type fcBizType,
|
||||
type pubHasuType,
|
||||
} from "./type";
|
||||
import type { SelectDataType } from "@common/business_components/ui";
|
||||
@@ -26,8 +32,7 @@ const pbnstOrgwtHeadList = pbnstOrgwtHeadListRxport;
|
||||
const pbnstMngNm = pbnstMngNmExport;
|
||||
const pplInstlsHeadLisat = pplInstlsHeadListExport;
|
||||
const pbnstDemandHeadList = pbnstDemandHeadListExport;
|
||||
const fcOrgwtsHeadList=fcOrgwtsHeadListExport
|
||||
|
||||
const fcOrgwtsHeadList = fcOrgwtsHeadListExport;
|
||||
|
||||
export type pubFacState = {
|
||||
pbnst: {
|
||||
@@ -43,6 +48,7 @@ export type pubFacState = {
|
||||
pplInstlsHeadLisat: TableUpperProps[];
|
||||
pbnstDemandHeadList: TableUpperProps[];
|
||||
fcOrgwtsHeadList: TableUpperProps[];
|
||||
pbnstMngRegData: customPbnst[];
|
||||
};
|
||||
};
|
||||
type pubFacActions = {
|
||||
@@ -50,9 +56,11 @@ type pubFacActions = {
|
||||
pbnstRegInit: (sgg: string) => void;
|
||||
pbnstRegSearch: (txt: string | undefined, sgg: string) => void;
|
||||
pbnstReg: (txt: string | undefined) => void;
|
||||
pbnstUpdate(pbnstRes: customPbnst) : Promise<void>;
|
||||
fileDelete:(atflCd:string)=>void
|
||||
fileDownLoad: (atflCd: string) => void
|
||||
pbnstUpdate(pbnstRes: customPbnst): Promise<void>;
|
||||
fileDelete: (atflCd: string) => void;
|
||||
fileDownLoad: (atflCd: string) => void;
|
||||
pbnstMngData: (data: customPbnst[]) => void;
|
||||
pbnstBizData(data: fcBizType): void;
|
||||
};
|
||||
|
||||
export type pubFacType = pubFacState & pubFacActions;
|
||||
@@ -71,6 +79,7 @@ export const pubFacStateExport: pubFacState = {
|
||||
pplInstlsHeadLisat: pplInstlsHeadLisat,
|
||||
pbnstDemandHeadList: pbnstDemandHeadList,
|
||||
fcOrgwtsHeadList: fcOrgwtsHeadList,
|
||||
pbnstMngRegData: [],
|
||||
},
|
||||
};
|
||||
|
||||
@@ -110,8 +119,8 @@ const getBizCycle = (fcBizs: z.infer<typeof fcBizSchema>[]) => {
|
||||
return pbnstBizCycle;
|
||||
};
|
||||
|
||||
const initFetch = async (code:string|undefined) => {
|
||||
const pbnstRes =await getFetch("wr", `${code}`);
|
||||
const initFetch = async (code: string | undefined) => {
|
||||
const pbnstRes = await getFetch("wr", `${code}`);
|
||||
return pbnstRes;
|
||||
};
|
||||
|
||||
@@ -159,12 +168,10 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => {
|
||||
},
|
||||
pbnstRegSearch: async (txt: string | undefined, sgg: string) => {
|
||||
try {
|
||||
|
||||
|
||||
const pbnstRes = await getFetch(
|
||||
"wr",
|
||||
''
|
||||
// `/api/v1/prcsFclt/ruseInfo/${pageNo}/${pageCnt}/${searchingCd}/${nameCd}/${fcltCpct}/{oprtngSttsCd}/{bscFctClsCd}/{swtrmtFcltNm}` + (txt ? `/${txt}` : "") + `/${sgg}`
|
||||
""
|
||||
// `/api/v1/prcsFclt/ruseInfo/${pageNo}/${pageCnt}/${searchingCd}/${nameCd}/${fcltCpct}/{oprtngSttsCd}/{bscFctClsCd}/{swtrmtFcltNm}` + (txt ? `/${txt}` : "") + `/${sgg}`
|
||||
);
|
||||
// API 응답이 pbnstRegZod 타입의 단일 객체라고 가정
|
||||
const pbnstBizCycle =
|
||||
@@ -216,7 +223,8 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => {
|
||||
} catch (error) {
|
||||
console.error("Error updating pbnst:", error);
|
||||
}
|
||||
},fileDelete: async (atflCd:string)=>{
|
||||
},
|
||||
fileDelete: async (atflCd: string) => {
|
||||
try {
|
||||
const response = await deleteFectch(
|
||||
`/attach-service/api/v1/atfl/attachments/atflCd//${atflCd}`,
|
||||
@@ -231,24 +239,46 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => {
|
||||
...state.pbnst,
|
||||
isInit: false,
|
||||
},
|
||||
}));;
|
||||
|
||||
}));
|
||||
} catch (error) {
|
||||
|
||||
console.error("Error deleting file:", error);
|
||||
}
|
||||
},fileDownLoad: async (atflCd: string) => {
|
||||
|
||||
try{
|
||||
const response = await getFetch( fetchType.CS , `/api/v1/atflcd/download/${atflCd}`)
|
||||
|
||||
},
|
||||
fileDownLoad: async (atflCd: string) => {
|
||||
try {
|
||||
const response = await getFetch(
|
||||
fetchType.CS,
|
||||
`/api/v1/atflcd/download/${atflCd}`
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Error downloading file: ${response.statusText}`);
|
||||
}
|
||||
}catch(error){
|
||||
} catch (error) {
|
||||
console.error("Error downloading file:", error);
|
||||
}
|
||||
},
|
||||
pbnstMngData: (data: customPbnst[]) => {
|
||||
return set((state: pubFacState) => {
|
||||
state.pbnst.pbnstMngRegData = data;
|
||||
return state;
|
||||
});
|
||||
},
|
||||
pbnstBizData:(data:fcBizType)=>{
|
||||
return set((state:pubFacState)=>{
|
||||
if(state.pbnst.pbnstMngRegData){
|
||||
const regData = state.pbnst.pbnstMngRegData.find(item=>
|
||||
data.pbnstRuseFcltFk===item.pbnstRuseFcltPk
|
||||
)
|
||||
if(regData){
|
||||
const bizIdx = regData.fcBizs.findIndex(item=>item.pbnstRuseFcltBizPk==data.pbnstRuseFcltBizPk)
|
||||
if(bizIdx>=0){
|
||||
regData.fcBizs[bizIdx] = data;
|
||||
}
|
||||
}
|
||||
}
|
||||
return state;
|
||||
})
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -49,6 +49,7 @@ export type fcFileType = z.infer<typeof fcFileSchema>;
|
||||
|
||||
const pplInstlSchema = z.object({
|
||||
ruseFcltBizFk: z.string(),
|
||||
choose:z.boolean().default(false),
|
||||
pdmt: z.string(),
|
||||
ppMqlt: z.string(),
|
||||
cpct: z.string(),
|
||||
@@ -117,7 +118,7 @@ const fcPrfmncSchema = z.object({
|
||||
|
||||
export const fcBizSchema = z.object({
|
||||
pbnstRuseFcltBizPk: z.number().default(0),
|
||||
pbnstRuseFcltFk: z.number().default(0),
|
||||
pbnstRuseFcltFk: z.string().default(''),
|
||||
cycl: z.string(),
|
||||
seCd: z.string(),
|
||||
bizMthdCd: z.string(),
|
||||
@@ -187,7 +188,7 @@ export const fcBizSchema = z.object({
|
||||
});
|
||||
|
||||
export const pbnstRegZod = z.object({
|
||||
pbnstRuseFcltPk: z.number().default(0),
|
||||
pbnstRuseFcltPk: z.string().default(""),
|
||||
swtrmtFcltFk: z.string().default(""),
|
||||
ruseUtztnFcltNm: z.string().default(""),
|
||||
fcltCpct: z.string().default(""),
|
||||
|
||||
@@ -13,11 +13,9 @@ import {
|
||||
fcBizSchema,
|
||||
type fcBizType,
|
||||
type fcOrgwtType,
|
||||
type ppInstlType
|
||||
type ppInstlType,
|
||||
} from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type";
|
||||
import {
|
||||
selectClass
|
||||
} from "@/app/store/ruseFcltMng/fcltReg/rainReg";
|
||||
import { selectClass } from "@/app/store/ruseFcltMng/fcltReg/rainReg";
|
||||
import {
|
||||
commonButonSize,
|
||||
formH1Class,
|
||||
@@ -26,10 +24,7 @@ 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 { UiModal, type SelectDataType } from "@common/business_components/ui";
|
||||
import { Form } from "@common/business_components/ui/form";
|
||||
import { Button, Input, Label } from "@common/components";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
@@ -39,10 +34,8 @@ import MngRegFormDetail from "../mngReg/mngRegFormDetail/mngRegFormDetail";
|
||||
|
||||
export function PbnstBuseForm({ data }: { data: fcBizType[] }) {
|
||||
// const ref = useRef<ppInstlType[] | null>(data[0]?.pplInstls ?? null);
|
||||
const ref = useRef<ppInstlType[] | null>(
|
||||
Array.isArray(data) && data.length > 0 ? data[0]?.pplInstls ?? null : null
|
||||
);
|
||||
const { code, pbnst } = useWrStore((state) => state);
|
||||
const ref = useRef<ppInstlType[] |null>( null);
|
||||
const { code, pbnst, pbnstBizData } = useWrStore((state) => state);
|
||||
const { pbnstBizCycle, pbnstRes } = pbnst;
|
||||
const [getBizCycle, setBizCycle] = useState("1");
|
||||
const [ppiSelectList, setPpiSelectList] =
|
||||
@@ -51,8 +44,6 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) {
|
||||
const [isFcOrgwts, setIsFcOrgwts] = useState<boolean>(false);
|
||||
const [modalData, setModalData] = useState<fcOrgwtType | null>(null);
|
||||
|
||||
|
||||
|
||||
const form = useForm<fcBizType>({
|
||||
resolver: zodResolver(fcBizSchema),
|
||||
});
|
||||
@@ -67,30 +58,49 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) {
|
||||
name: "fcOrgwts",
|
||||
});
|
||||
|
||||
const { fields: pplInstls, append, remove } = useFieldArray({
|
||||
const {
|
||||
fields: pplInstls,
|
||||
append,
|
||||
remove,
|
||||
} = useFieldArray({
|
||||
control: form.control,
|
||||
name: "pplInstls",
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
pbnstBizData(form.watch() as fcBizType);
|
||||
}, [form.formState]);
|
||||
|
||||
useEffect(() => {
|
||||
console.log("pbnst.pbnstMngRegData ", pbnst.pbnstMngRegData);
|
||||
}, [pbnst.pbnstMngRegData]);
|
||||
|
||||
const buttonClick = () => {
|
||||
console.log("머임?", data[0]?.fcOrgwts)
|
||||
setIsFcOrgwts(true);
|
||||
const moData = data[0]?.fcOrgwts;
|
||||
const moData = data[0]?.fcOrgwts?.[0] ?? null;
|
||||
setModalData(moData);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const plusHist = () => {
|
||||
append({
|
||||
const plusHist = () => {
|
||||
const regData ={
|
||||
ruseFcltBizFk: ref.current?.[0]?.ruseFcltBizFk??"",
|
||||
choose: false,
|
||||
ppMqlt: "",
|
||||
pdmt: "",
|
||||
cpct: "",
|
||||
}
|
||||
const currentTableDataFromRef = ref.current ? [...ref.current] : [];
|
||||
const newDataForRHF = [...currentTableDataFromRef, regData];
|
||||
form.setValue("pplInstls", newDataForRHF, {
|
||||
shouldValidate: true, // 필요하다면 유효성 검사 실행
|
||||
shouldDirty: true, // 폼 상태를 dirty로 변경
|
||||
});
|
||||
const latestOpers = form.getValues("pplInstls");
|
||||
ref.current = [...latestOpers];
|
||||
};
|
||||
|
||||
const removeSelected = () => {
|
||||
if(!ref.current) return;
|
||||
if (!ref.current) return;
|
||||
const selectedIdxs = ref.current
|
||||
.map((item, idx) => (item.choose ? idx : -1))
|
||||
.filter((idx) => idx !== -1);
|
||||
@@ -101,10 +111,9 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) {
|
||||
if (data) {
|
||||
const index = Number(getBizCycle) - 1;
|
||||
form.reset(data[index]);
|
||||
ref.current = data[index]?.pplInstls ?? null;
|
||||
ref.current = data[index]?.pplInstls ?? [];
|
||||
console.log("form reset with data:", data[index]);
|
||||
|
||||
|
||||
}
|
||||
}, [getBizCycle, data]);
|
||||
|
||||
@@ -131,161 +140,165 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) {
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className=" !mx-[1.6rem] !p-0r">
|
||||
{/* 차수별 등록 현황 폼 */}
|
||||
<div className="justify-between">
|
||||
<Form {...form}>
|
||||
<form
|
||||
onSubmit={form.handleSubmit(onSubmit)}
|
||||
className="space-y-8 mx-auto w-full mt-7"
|
||||
>
|
||||
<div className="flex justify-between items-center mx-3 mb-3">
|
||||
<h1 className=" text-xl"></h1>
|
||||
<div className="flex items-center gap-2 mx-3">
|
||||
<h1 className={formTableName}>등록차수</h1>
|
||||
<div className=" !mx-[1.6rem] !p-0r">
|
||||
{/* 차수별 등록 현황 폼 */}
|
||||
<div className="justify-between">
|
||||
<Form {...form}>
|
||||
<form
|
||||
onSubmit={form.handleSubmit(onSubmit)}
|
||||
className="space-y-8 mx-auto w-full mt-7"
|
||||
>
|
||||
<div className="flex justify-between items-center mx-3 mb-3">
|
||||
<h1 className=" text-xl"></h1>
|
||||
<div className="flex items-center gap-2 mx-3">
|
||||
<h1 className={formTableName}>등록차수</h1>
|
||||
|
||||
<SelectBox
|
||||
label=""
|
||||
selectArray={pbnstBizCycle}
|
||||
value={getBizCycle ?? pbnstBizCycle[0]?.val}
|
||||
className={""}
|
||||
selectClass={selectClass}
|
||||
onSelectValue={(val) => {
|
||||
setBizCycle(String(val));
|
||||
}}
|
||||
></SelectBox>
|
||||
|
||||
<Button type="submit" size={commonButonSize}>
|
||||
저장
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<MngRegFormDetail
|
||||
formList={businessSttnInfo}
|
||||
h1Title={"사업현황"}
|
||||
form={form}
|
||||
moClass="grid grid-cols-12 gap-4"
|
||||
sonClass="col-span-4"
|
||||
/>
|
||||
|
||||
<MngRegFormDetail
|
||||
formList={businessMoneyInfo}
|
||||
h1Title={"사업비"}
|
||||
form={form}
|
||||
moClass="grid grid-cols-12 gap-4"
|
||||
sonClass="col-span-4"
|
||||
/>
|
||||
<MngRegFormDetail
|
||||
formList={ruseFcltinfo}
|
||||
h1Title={"재처리시설"}
|
||||
form={form}
|
||||
moClass="grid grid-cols-12 gap-4"
|
||||
sonClass="col-span-4"
|
||||
/>
|
||||
<MngRegFormDetail
|
||||
formList={concentratedWaterInfo}
|
||||
h1Title={"농축수관리"}
|
||||
form={form}
|
||||
moClass="grid grid-cols-12 gap-4"
|
||||
sonClass="col-span-4"
|
||||
/>
|
||||
<MngRegFormDetail
|
||||
formList={wasteWaterFcltINfo}
|
||||
h1Title={"폐수배출시설 정보"}
|
||||
form={form}
|
||||
moClass="grid grid-cols-12 gap-4"
|
||||
sonClass="col-span-4"
|
||||
/>
|
||||
|
||||
<h1 className={formH1Class}>재이용 원수취수 현황</h1>
|
||||
<div>
|
||||
<Button
|
||||
type="button"
|
||||
onClick={
|
||||
// () => {
|
||||
// setIsFcOrgwts(true)
|
||||
// setModalData(modalData)
|
||||
// }
|
||||
buttonClick
|
||||
}
|
||||
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={pbnstBizCycle}
|
||||
value={getBizCycle ?? pbnstBizCycle[0]?.val}
|
||||
className={""}
|
||||
selectClass={selectClass}
|
||||
onSelectValue={(val) => {
|
||||
setBizCycle(String(val));
|
||||
}}
|
||||
></SelectBox>
|
||||
|
||||
<Button type ="submit" size={commonButonSize}>저장</Button>
|
||||
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
|
||||
type="button"
|
||||
size={commonButonSize}
|
||||
className="!text-xl"
|
||||
onClick={plusHist}
|
||||
>
|
||||
추가등록
|
||||
</Button>
|
||||
<Button
|
||||
type="button"
|
||||
size={commonButonSize}
|
||||
className="!text-xl !bg-red-500 !text-white ml-1"
|
||||
onClick={removeSelected}
|
||||
>
|
||||
삭제
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<MngRegFormDetail
|
||||
formList={businessSttnInfo}
|
||||
h1Title={"사업현황"}
|
||||
form={form}
|
||||
moClass="grid grid-cols-12 gap-4"
|
||||
sonClass="col-span-4"
|
||||
/>
|
||||
|
||||
<MngRegFormDetail
|
||||
formList={businessMoneyInfo}
|
||||
h1Title={"사업비"}
|
||||
form={form}
|
||||
moClass="grid grid-cols-12 gap-4"
|
||||
sonClass="col-span-4"
|
||||
/>
|
||||
<MngRegFormDetail
|
||||
formList={ruseFcltinfo}
|
||||
h1Title={"재처리시설"}
|
||||
form={form}
|
||||
moClass="grid grid-cols-12 gap-4"
|
||||
sonClass="col-span-4"
|
||||
/>
|
||||
<MngRegFormDetail
|
||||
formList={concentratedWaterInfo}
|
||||
h1Title={"농축수관리"}
|
||||
form={form}
|
||||
moClass="grid grid-cols-12 gap-4"
|
||||
sonClass="col-span-4"
|
||||
/>
|
||||
<MngRegFormDetail
|
||||
formList={wasteWaterFcltINfo}
|
||||
h1Title={"폐수배출시설 정보"}
|
||||
form={form}
|
||||
moClass="grid grid-cols-12 gap-4"
|
||||
sonClass="col-span-4"
|
||||
/>
|
||||
<div>
|
||||
<RuseMngTable
|
||||
tableData={pplInstls}
|
||||
headList={pbnst.pplInstlsHeadLisat}
|
||||
code={ppiSelectList ?? []}
|
||||
ref={ref}
|
||||
upHeadList={[]}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<h1 className={formH1Class}>재이용 원수취수 현황</h1>
|
||||
<div>
|
||||
<Button
|
||||
type="button"
|
||||
onClick={
|
||||
// () => {
|
||||
// setIsFcOrgwts(true)
|
||||
// setModalData(modalData)
|
||||
// }
|
||||
buttonClick
|
||||
}
|
||||
size={commonButonSize}>
|
||||
추가등록
|
||||
</Button>
|
||||
<RuseMngTable
|
||||
tableData={fcOrgwtFiled}
|
||||
headList={pbnst.pbnstOrgwtHeadList}
|
||||
<MngRegFormDetail
|
||||
formList={ruseWaterQulityList}
|
||||
h1Title={"하수처리수 재이용시설 보증수질"}
|
||||
form={form}
|
||||
moClass="grid grid-cols-12 gap-4"
|
||||
sonClass="col-span-4"
|
||||
/>
|
||||
</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
|
||||
type="button"
|
||||
size={commonButonSize}
|
||||
className="!text-xl"
|
||||
onClick={plusHist}
|
||||
>
|
||||
추가등록
|
||||
</Button>
|
||||
<Button
|
||||
type="button"
|
||||
size={commonButonSize}
|
||||
className="!text-xl !bg-red-500 !text-white ml-1"
|
||||
onClick={removeSelected}
|
||||
>
|
||||
삭제
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<RuseMngTable
|
||||
tableData={pplInstls}
|
||||
headList={pbnst.pplInstlsHeadLisat}
|
||||
code={ppiSelectList ?? []}
|
||||
ref={ref}
|
||||
upHeadList={[]} />
|
||||
</div>
|
||||
<h1 className={formH1Class}>하수처리수 재이용수 수요처</h1>
|
||||
<div>
|
||||
<Button size={commonButonSize}>수요처 추가</Button>
|
||||
<RuseMngTable
|
||||
tableData={[]}
|
||||
headList={pbnst.pbnstDemandHeadList}
|
||||
/>
|
||||
</div>
|
||||
</form>
|
||||
</Form>
|
||||
</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>
|
||||
<UiModal
|
||||
open={isFcOrgwts}
|
||||
onOpenChange={(open: boolean) => setIsFcOrgwts(open)}
|
||||
bodyClass={"w-[60vw] max-w-none h-[60vh]"}
|
||||
body={<FcOrgwtsRegModal data={modalData || []}></FcOrgwtsRegModal>}
|
||||
></UiModal>
|
||||
</div>
|
||||
|
||||
<UiModal
|
||||
open={isFcOrgwts}
|
||||
onOpenChange={(open: boolean) => setIsFcOrgwts(open)}
|
||||
bodyClass={"w-[60vw] max-w-none h-[60vh]"}
|
||||
body={<FcOrgwtsRegModal data={ modalData || []}></FcOrgwtsRegModal>}
|
||||
></UiModal>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,9 @@ export type FilesType = {
|
||||
};
|
||||
|
||||
export function PbnstMngForm({ data }: { data: customPbnst }) {
|
||||
const { pbnst, pbnstUpdate, fileDelete } = useWrStore((state) => state);
|
||||
const { pbnst, pbnstUpdate, fileDelete, pbnstMngData } = useWrStore(
|
||||
(state) => state
|
||||
);
|
||||
const { pbnstMngUpHeadList } = pbnst;
|
||||
const [ruseOperData, setRuseOperData] = useState<operType[]>();
|
||||
const [planFiles, setPlanFiles] = useState<FilesType[] | null>(null);
|
||||
@@ -50,6 +52,7 @@ export function PbnstMngForm({ data }: { data: customPbnst }) {
|
||||
const form = useForm<z.infer<typeof pbnstRegZod>>({
|
||||
resolver: zodResolver(pbnstRegZod),
|
||||
defaultValues: pbnstRegZod.parse({}),
|
||||
//mode:'onChange'
|
||||
});
|
||||
|
||||
const {
|
||||
@@ -61,9 +64,27 @@ export function PbnstMngForm({ data }: { data: customPbnst }) {
|
||||
name: "fcOpers",
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
console.log("ref.current", ref.current);
|
||||
},[ref.current])
|
||||
useEffect(() => {
|
||||
const formData = form.getValues();
|
||||
|
||||
// 기존 코드: formData.fcOpers = ref.current ? [...ref.current] : [];
|
||||
// 새 코드: 상태를 유지한 채 복사
|
||||
formData.fcOpers = form.getValues("fcOpers"); // ← form 내부 상태 기준으로 복사
|
||||
formData.fcFiles = regFileList ? [...regFileList] : [];
|
||||
|
||||
pbnstMngData([formData] as customPbnst[]);
|
||||
}, [form.formState, regFileList]);
|
||||
|
||||
useEffect(() => {
|
||||
console.log(" mngRegFrom ", pbnst.pbnstMngRegData);
|
||||
}, [pbnst.pbnstMngRegData]);
|
||||
|
||||
const fileDownload = (index: number) => {};
|
||||
const plusHist = () => {
|
||||
append({
|
||||
const regData = {
|
||||
choose: false,
|
||||
rgtr: "",
|
||||
mdfr: "",
|
||||
@@ -73,7 +94,15 @@ export function PbnstMngForm({ data }: { data: customPbnst }) {
|
||||
rprtvBzenty: "",
|
||||
bgngDt: new Date(),
|
||||
endDt: new Date(),
|
||||
};
|
||||
const currentTableDataFromRef = ref.current ? [...ref.current] : [];
|
||||
const newDataForRHF = [...currentTableDataFromRef, regData];
|
||||
form.setValue("fcOpers", newDataForRHF, {
|
||||
shouldValidate: true, // 필요하다면 유효성 검사 실행
|
||||
shouldDirty: true, // 폼 상태를 dirty로 변경
|
||||
});
|
||||
const latestOpers = form.getValues("fcOpers");
|
||||
ref.current = [...latestOpers];
|
||||
};
|
||||
|
||||
const removeSelected = () => {
|
||||
@@ -85,9 +114,11 @@ export function PbnstMngForm({ data }: { data: customPbnst }) {
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (!data) return;
|
||||
form.reset(data);
|
||||
setRuseOperData(data.fcOpers);
|
||||
if (data) {
|
||||
form.reset(data);
|
||||
form.setValue("pbnstRuseFcltPk", data.pbnstRuseFcltPk);
|
||||
ref.current = data.fcOpers || [];
|
||||
}
|
||||
}, [data]);
|
||||
|
||||
// 2. Define a submit handler.
|
||||
@@ -151,32 +182,32 @@ export function PbnstMngForm({ data }: { data: customPbnst }) {
|
||||
: setPlanFiles(setReFiles);
|
||||
}
|
||||
};
|
||||
const regFileFilter=(files:FilesType[], fileKnd:string, regFile:fcFileType[])=>{
|
||||
const planDatas = regFile?.filter(item=>item.fileKnd!==fileKnd) || [];
|
||||
const data = files.map((item) => ({
|
||||
fileTkn: item.atflCd,
|
||||
filePath: item.file.name,
|
||||
fileKnd: fileKnd,
|
||||
rgtr: TEST_UUID,
|
||||
mdfr: TEST_UUID,
|
||||
}));
|
||||
return [...planDatas, ...data]
|
||||
}
|
||||
const regFileFilter = (
|
||||
files: FilesType[],
|
||||
fileKnd: string,
|
||||
regFile: fcFileType[]
|
||||
) => {
|
||||
const planDatas = regFile?.filter((item) => item.fileKnd !== fileKnd) || [];
|
||||
const data = files.map((item) => ({
|
||||
fileTkn: item.atflCd,
|
||||
filePath: item.file.name,
|
||||
fileKnd: fileKnd,
|
||||
rgtr: TEST_UUID,
|
||||
mdfr: TEST_UUID,
|
||||
}));
|
||||
return [...planDatas, ...data];
|
||||
};
|
||||
useEffect(() => {
|
||||
console.log("relationfiles:", relationfiles);
|
||||
if (relationfiles) {
|
||||
setRegFileList(regFileFilter(relationfiles, "계통도", regFileList||[]));
|
||||
setRegFileList(regFileFilter(relationfiles, "계통도", regFileList || []));
|
||||
}
|
||||
}, [relationfiles]);
|
||||
useEffect(() => {
|
||||
if (planFiles) {
|
||||
setRegFileList(regFileFilter(planFiles, "평면도", regFileList||[]));
|
||||
setRegFileList(regFileFilter(planFiles, "평면도", regFileList || []));
|
||||
}
|
||||
}, [planFiles]);
|
||||
|
||||
useEffect(() => {
|
||||
console.log("regFileList:", regFileList);
|
||||
}, [regFileList]);
|
||||
|
||||
useEffect(() => {
|
||||
console.log("form errors:", form.formState.errors);
|
||||
|
||||
@@ -1,24 +1,41 @@
|
||||
"use client";
|
||||
|
||||
import { useWrStore } from "@/app/store";
|
||||
import type { customPbnst, fcBizType } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type";
|
||||
import type {
|
||||
customPbnst,
|
||||
fcBizType,
|
||||
pubHasuType,
|
||||
} from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type";
|
||||
import { selectClass } from "@/app/store/ruseFcltMng/fcltReg/rainReg";
|
||||
import { getCity } from "@/components/lib/func/commom";
|
||||
import { PbnstMngForm } from "@/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm";
|
||||
import { ScrollArea, SelectBox, UiTable, type SelectDataType } from "@common/business_components";
|
||||
import { Button, Input, Label, Tabs, TabsContent, TabsList, TabsTrigger } from "@common/components/ui";
|
||||
import {
|
||||
ScrollArea,
|
||||
SelectBox,
|
||||
UiTable,
|
||||
type SelectDataType,
|
||||
} from "@common/business_components";
|
||||
import {
|
||||
Button,
|
||||
Input,
|
||||
Label,
|
||||
Tabs,
|
||||
TabsContent,
|
||||
TabsList,
|
||||
TabsTrigger,
|
||||
} from "@common/components/ui";
|
||||
import { useEffect, useState } from "react";
|
||||
import type { objSearchType } from "../bdstRegModal/bdstRegModal";
|
||||
import { PbnstBuseForm } from "@/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm";
|
||||
|
||||
|
||||
export function PbnstRegModal({ data }: { data: customPbnst }) {
|
||||
|
||||
export function PbnstRegModal({ data }: { data: pubHasuType }) {
|
||||
const { code, pbnst } = useWrStore((state) => {
|
||||
return state;
|
||||
});
|
||||
const { pubFacHeadList, pbnstHasuRes, pbnstRes } = pbnst;
|
||||
const [pbnstBdstForm, setPbnstBdstForm] = useState<customPbnst>({} as customPbnst);
|
||||
const [pbnstBdstForm, setPbnstBdstForm] = useState<customPbnst>(
|
||||
{} as customPbnst
|
||||
);
|
||||
const [currentTab, setCurrentTab] = useState<string>("mng");
|
||||
// const nodeList = headMakeColSpan(pubFacHeadList.moUpHeadList);
|
||||
|
||||
@@ -27,32 +44,44 @@ export function PbnstRegModal({ data }: { data: customPbnst }) {
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (!data) return;
|
||||
console.log("데이터", data)
|
||||
|
||||
const regData = {
|
||||
pbnstRuseFcltPk: String(data.bscFctCd + "R" + "1"),
|
||||
fcBizs: [{ pbnstRuseFcltFk: String(data.bscFctCd + "R" + "1") } as unknown as fcBizType],
|
||||
};
|
||||
|
||||
console.log("regData ", regData)
|
||||
setPbnstBdstForm(regData as customPbnst);
|
||||
}, [data]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<h1 className="text-2xl font-medium text-label pl-8">하수재이용 시설 신규등록</h1>
|
||||
<h1 className="text-2xl font-medium text-label pl-8">
|
||||
하수재이용 시설 신규등록
|
||||
</h1>
|
||||
|
||||
<div className="border-t border-gray-300 my-4"></div>
|
||||
<ScrollArea className="h-[75vh]">
|
||||
<Tabs defaultValue="mng" onValueChange={handleTabChange}>
|
||||
<TabsList className="">
|
||||
<TabsTrigger className="!text-xl" value="mng">시설정보</TabsTrigger>
|
||||
<TabsTrigger className="!text-xl" value="buse">차수별정보</TabsTrigger>
|
||||
<TabsTrigger className="!text-xl" value="mng">
|
||||
시설정보
|
||||
</TabsTrigger>
|
||||
<TabsTrigger className="!text-xl" value="buse">
|
||||
차수별정보
|
||||
</TabsTrigger>
|
||||
<Button size={"sm"} className="!justify-end">
|
||||
저장
|
||||
</Button>
|
||||
</TabsList>
|
||||
<TabsContent className="max-h-full" value="mng">
|
||||
<PbnstMngForm mngForm={pbnstBdstForm as customPbnst} isModal={true} />
|
||||
<PbnstMngForm data={pbnstBdstForm} />
|
||||
</TabsContent>
|
||||
<TabsContent className="max-h-full" value="buse">
|
||||
<PbnstBuseForm buseForm={pbnstBdstForm as customPbnst} isModal={true} />
|
||||
<PbnstBuseForm data={pbnstBdstForm.fcBizs} />
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
</ScrollArea>
|
||||
</>
|
||||
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@ const RuseMngTable = React.forwardRef<any[], RuseMngTableProps>(
|
||||
}, ref) => {
|
||||
const [tableState, setTableState] = useState([...tableData]);
|
||||
useEffect(() => {
|
||||
console.log("tableState", tableState);
|
||||
if (ref && typeof ref === "object" && "current" in ref) {
|
||||
ref.current = tableState;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ export function middleware(req: NextRequest) {
|
||||
|
||||
if (pathname.startsWith("/attach-service")) {
|
||||
const requestHeaders = new Headers(req.headers);
|
||||
const token = "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhMGVjN2EwNy03NTJhLTRmN2YtODlhNi04NTRlNjNkMmUzYTAiLCJhdXRob3JpdGllcyI6IlJPTEVfQURNSU4sUk9MRV9BTk9OWU1PVVMiLCJleHAiOjE3NDg0MjU0NzJ9.rABGFEzyCEDYwnuzd-6V0lPtckSGx-h77-tJBYFz00KPowmWBpwMLrSynxmHpmtmga86ksIYxuoMkiT1_aI6Sw"
|
||||
const token = "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhMGVjN2EwNy03NTJhLTRmN2YtODlhNi04NTRlNjNkMmUzYTAiLCJhdXRob3JpdGllcyI6IlJPTEVfQURNSU4sUk9MRV9BTk9OWU1PVVMiLCJleHAiOjE3NDg0Mzc0OTF9.JM2NHEwTpgDW9nonZY3186IK_frIh667SyxMQfPwqa_lc-5mcTFNtrWXH5b72_ng39qiPSi504iF1roFEJ0c6w"
|
||||
const userId = 'a0ec7a07-752a-4f7f-89a6-854e63d2e3a0'
|
||||
//const token = req.cookies.get(CLAIM_NAME)?.value;
|
||||
//const userId = req.cookies.get(AUTH_USER_ID)?.value;
|
||||
|
||||
Reference in New Issue
Block a user