diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx index a61b7552c..4f35c813c 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx @@ -17,10 +17,10 @@ export const pubFacHeadListExport: TableUpperProps[] = [ ]; export const pbnstMngUpHeadListExport: TableUpperProps[] = [ - { id: "operMthd", title: "운영방식" }, - { id: "rprtvBzenty", title: "대행업체" }, - { id: "bgngDt", title: "시작일", upName: "upChangeRe", upSequnce: 1 }, - { id: "endDt", title: "종료일", upName: "upChangeRe", upSequnce: 2 }, + { id: "operMthd", title: "운영방식", edit: true}, + { id: "rprtvBzenty", title: "대행업체", edit: true}, + { id: "bgngDt", title: "시작일", upName: "upChangeRe", upSequnce: 1, type: "date"}, + { id: "endDt", title: "종료일", upName: "upChangeRe", upSequnce: 2, type: "date"}, ]; diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx index 1aa1417e7..d84a5b3e6 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx @@ -28,13 +28,6 @@ export type publicReuseFacilityType = { register?: string; swtrmtFcltFk: string; }; -export type fcltOperInfoType = { - mng: string; - subCo: string; - startDay: string; - endDay: string; - pbnstRuseFcltPk: string; -}; export type ruseFcltType = { swtrmtFcltFk: string; @@ -74,8 +67,8 @@ const fcOperSchema = z.object({ pbnstRuseFcltFk: z.number().default(0), operMthd: z.string(), rprtvBzenty: z.string(), - bgngDt: z.string(), - endDt: z.string().default("20250501"), + bgngDt: z.date().default(new Date()), + endDt: z.date().default(new Date()), regDt: z.date().nullish(), rgtr: z.string(), mdfcnDt: z.date().nullish(), @@ -204,6 +197,7 @@ export const pbnstRegZod = z.object({ fcFiles: z.array(fcFileSchema).default([]), fcBizs: z.array(fcBizSchema).default([]), fcOpers: z.array(fcOperSchema).default([]), + hasuhasu: z.number().default(0), }); const pubHasuZod = z.object({ @@ -222,6 +216,7 @@ export const exampleData = { pbnstRuseFcltPk: 1, swtrmtFcltFk: "11000SW001R", ruseUtztnFcltNm: "재이용시설 A", + hasuhasu: 0, fcltCpct: "100", ruseCpct: "90", splyExtraCpct: "10", @@ -444,7 +439,8 @@ export const exampleData = { pbnstRuseFcltFk: 1, operMthd: "위탁", rprtvBzenty: "기관명", - bgngDt: "20230930", + bgngDt: new Date("2023-09-30"), + endDt: new Date("2023-12-31"), rgtr: TEST_UUID, mdfr: TEST_UUID, }, @@ -453,7 +449,8 @@ export const exampleData = { pbnstRuseFcltFk: 1, operMthd: "직영", rprtvBzenty: "기관명", - bgngDt: "20241130", + bgngDt: new Date("2024-11-30"), + endDt: new Date("2024-12-31"), rgtr:TEST_UUID , mdfr: TEST_UUID, }, diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx index 2028741de..e46390be5 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx @@ -5,7 +5,7 @@ import { FileUpload, FormUi, UiTable } from "@common/business_components/ui"; import { Form, FormField } from "@common/business_components/ui/form"; import { Button, Input, TableHead, TableRow } from "@common/components"; import { zodResolver } from "@hookform/resolvers/zod"; -import { useEffect, useState } from "react"; +import { use, useEffect, useRef, useState } from "react"; import { set, useFieldArray, useForm } from "react-hook-form"; import { nullable, z } from "zod"; import { useWrStore } from "@/app/store"; @@ -23,10 +23,10 @@ import { import RuseMngTable from "@/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable"; import { TusClientUpload } from "@/components/lib/useTus_wr/useTusWr"; import type { Upload } from "tus-js-client"; -import { pbnstRegZod, type customPbnst, type fcltOperInfoType, type operType, type ruseFcltType } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; +import { pbnstRegZod, type customPbnst, type operType, type ruseFcltType } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; export function PbnstMngForm({ data }: { data: customPbnst }) { - const { pbnst, pbnstUpdate } = useWrStore((state) => state); + const { pbnst ,pbnstUpdate} = useWrStore((state) => state); const { pbnstMngUpHeadList} = pbnst; const [ruseOperData, setRuseOperData] = useState(); const [planFiles, setPlanFiles] = useState(null); @@ -41,7 +41,10 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { setProgress(Number(percentage)); }; + + + const ref = useRef(data.fcOpers ?? null); const form = useForm>({ resolver: zodResolver(pbnstRegZod), defaultValues: pbnstRegZod.parse({}), @@ -56,15 +59,12 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { useEffect(() => { form.reset(data); - // setRuseOperData(data.fcOpers); + setRuseOperData(data.fcOpers); }, [data]); // 2. Define a submit handler. function onSubmit(values: z.infer) { - - - console.log("onSubmit values", values); - console.log( ' 212 ', values); + console.log("submit",values); pbnstUpdate(values); } @@ -137,6 +137,7 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { tableData={fcOpersField} headList={pbnst.pbnstMngUpHeadList} upHeadList={pbnst.pbnstMngNm} + ref={ref} > @@ -157,7 +158,7 @@ export function PbnstMngForm({ data }: { data: customPbnst }) {
( diff --git a/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx b/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx index 0774f6226..e5733406b 100644 --- a/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx +++ b/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx @@ -1,7 +1,8 @@ import { headMakeprfmnc } from "@/app/ruseFcltMng/prfmncReg/chkgdnReg/TableHead"; import type { chHeadType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList"; +import type { customPbnst, fcltOperInfoType, fcOrgwtType, operType, ppInstlType } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; import { selectClass, type TableUpperProps } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; -import { SelectBox, type SelectDataType } from "@common/business_components/ui"; +import { DatePicker, SelectBox, type SelectDataType } from "@common/business_components/ui"; import { Input, Table, @@ -11,77 +12,115 @@ import { TableHeader, TableRow, } from "@common/components/ui"; +import moment from "moment"; +import React, { useEffect, useState } from "react"; -export default function RuseMngTable({ - tableData, - headList, - upHeadList, - code = [], -}: { +type RuseMngTableProps = { tableData: any[]; headList: TableUpperProps[]; - upHeadList?: chHeadType[]; - code?:{name:string, val:SelectDataType[] }[] -}) { + upHeadList: chHeadType[]; + code?: { name: string, val: SelectDataType[] }[]; +}; +const RuseMngTable = React.forwardRef( + ({ + tableData, + headList, + upHeadList, + code = [] + }, ref) => { + const [tableState, setTableState] = useState([...tableData]); + useEffect(() => { + if (ref && typeof ref === "object" && "current" in ref) { + ref.current = tableState; + } + }, [tableState]); + useEffect(() => { + setTableState(tableData); + }, [tableData]); + return ( + <> + + + {upHeadList ? ( + headMakeprfmnc(headList, upHeadList) + ) : ( + + {headList.map((head) => ( + + {head.title} + + ))} + + )} + - return ( - <> -
- - {upHeadList ? ( - headMakeprfmnc(headList, upHeadList) - ) : ( - - {headList.map((head) => ( - - {head.title} - - ))} - - )} - - - - {tableData.map((item, index) => ( - - {headList.map((head, index) => ( - {}} - > - {head.edit === true ? ( - {}} - value={item[head.id] || ""} - /> - ) : head.type === "select" ? ( - item.name === head.selectData)?.val ?? []} - value={ - tableData[index][item[head.id]] - } - className={""} - selectClass={selectClass} - onSelectValue={(val) => { - tableData[index][head.id] = val; - }} - > - ) - : ( - `${item[head.id] || ""}` - )} - - ))} - - ))} - -
- - ); -} + + {tableState.map((item, i) => ( + + {headList.map((head, j) => ( + { }} + > + {head.edit === true ? ( + { + setTableState(prev => { + const next = [...prev]; + next[i] = { ...next[i], [head.id]: txt.target.value }; + return next; + }) + }} + value={tableState[i][head.id] || ""} + /> + ) : head.type === "select" ? ( + item.name === head.selectData)?.val ?? []} + value={ + item[head.id] + } + className={""} + selectClass={selectClass} + onSelectValue={(val) => { + setTableState((prev) => { + prev[i][head.id] = val + return [...prev] + }) + }} + > + ) : head.type === "date" ? ( + { + setTableState(prev => { + const next = [...prev]; + next[i] = { ...next[i], [head.id]: date }; + return next; + }) + } + } + } + selectClass={"w-full"} + /> + ) : ( + `${item[head.id] || ""}` + )} + + ))} + + ))} + + + + ); + }) +export default RuseMngTable; \ No newline at end of file diff --git a/apps/wr/package.json b/apps/wr/package.json index 58a01dc42..44ba5a06b 100644 --- a/apps/wr/package.json +++ b/apps/wr/package.json @@ -17,6 +17,7 @@ "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", "lucide-react": "^0.474.0", + "moment": "^2.30.1", "next": "15.1.7", "react-hook-form": "^7.54.2", "react-hot-toast": "^2.5.2",