물 하수재이용 등록 사업 작업중
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import { SelectBox } from "@common/business_components";
|
||||
import { FormUi } from "@common/business_components/ui";
|
||||
import { FormUi, type SelectDataType } from "@common/business_components/ui";
|
||||
import { Form, FormField } from "@common/business_components/ui/form";
|
||||
import { Button, Input, Label, TableHead, TableRow } from "@common/components";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
@@ -27,51 +27,64 @@ import {
|
||||
ruseWaterQulityList,
|
||||
wasteWaterFcltINfo,
|
||||
} from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/headList";
|
||||
import { fcBizSchema, pbnstRegZod, type fcBizType, type fcOrgwtType, type ppInstlType } 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({data} :{data: fcBizType[]} ) {
|
||||
export function PbnstBuseForm({ data }: { data: fcBizType[] }) {
|
||||
const { code, pbnst } = useWrStore((state) => state);
|
||||
const { pbnstBizCycle, pbnstRes
|
||||
} = pbnst;
|
||||
const [getBizCycle, setBizCycle] = useState('1');
|
||||
const [orgwtData ,setOrgwtData] = useState<fcOrgwtType[]>([]);
|
||||
const [ppistlData ,setPpistlData] = useState<ppInstlType[]>([]);
|
||||
|
||||
const { pbnstBizCycle, pbnstRes } = pbnst;
|
||||
const [getBizCycle, setBizCycle] = useState("1");
|
||||
const [ppiSelectList, setPpiSelectList] =
|
||||
useState<[{ name: string; val: SelectDataType[] }]>();
|
||||
const [ppiYn, setPpiYn] = useState("Y");
|
||||
const form = useForm<fcBizType>({
|
||||
resolver: zodResolver(fcBizSchema),
|
||||
});
|
||||
|
||||
|
||||
// 2. Define a submit handler.
|
||||
function onSubmit(values: fcBizType) {
|
||||
console.log(values);
|
||||
}
|
||||
const onSelectValue = (val: string) => {
|
||||
console.log(val);
|
||||
};
|
||||
|
||||
|
||||
const { fields: fcOrgwtFiled } = useFieldArray({
|
||||
const { fields: fcOrgwtFiled } = useFieldArray({
|
||||
control: form.control,
|
||||
name: "fcOrgwts",
|
||||
});
|
||||
|
||||
const { fields: pplInstls } = useFieldArray({
|
||||
const { fields: pplInstls } = useFieldArray({
|
||||
control: form.control,
|
||||
name: "pplInstls",
|
||||
});
|
||||
useEffect(() => {
|
||||
if(data){
|
||||
|
||||
const index = Number(getBizCycle) -1
|
||||
if (data) {
|
||||
const index = Number(getBizCycle) - 1;
|
||||
form.reset(data[index]);
|
||||
}
|
||||
|
||||
}, [ getBizCycle,data]);
|
||||
}, [getBizCycle, data]);
|
||||
|
||||
useEffect(() => {
|
||||
}, [pbnstBizCycle]);
|
||||
const ppl = [];
|
||||
if (code.pplLenght) {
|
||||
ppl.push({ name: "pplLenght", val: code.pplLenght });
|
||||
}
|
||||
if (code.pplLenght) {
|
||||
ppl.push({ name: "pplQulity", val: code.pplQulity });
|
||||
}
|
||||
if (ppl.length > 0) {
|
||||
setPpiSelectList(ppl);
|
||||
}
|
||||
}, [code]);
|
||||
|
||||
useEffect(() => {
|
||||
console.log("ppiSelectList:", ppiSelectList);
|
||||
}, [ppiSelectList]);
|
||||
|
||||
useEffect(() => {
|
||||
console.log("form errors:", form.formState.errors);
|
||||
}, [form.formState.errors]);
|
||||
@@ -93,13 +106,10 @@ export function PbnstBuseForm({data} :{data: fcBizType[]} ) {
|
||||
<SelectBox
|
||||
label=""
|
||||
selectArray={pbnstBizCycle}
|
||||
value={
|
||||
getBizCycle?? pbnstBizCycle[0]?.val
|
||||
}
|
||||
value={getBizCycle ?? pbnstBizCycle[0]?.val}
|
||||
className={""}
|
||||
selectClass={selectClass}
|
||||
onSelectValue={(val) => {
|
||||
|
||||
setBizCycle(String(val));
|
||||
}}
|
||||
></SelectBox>
|
||||
@@ -117,8 +127,6 @@ export function PbnstBuseForm({data} :{data: fcBizType[]} ) {
|
||||
|
||||
<MngRegFormDetail
|
||||
formList={businessMoneyInfo}
|
||||
|
||||
|
||||
h1Title={"사업비"}
|
||||
form={form}
|
||||
moClass="grid grid-cols-12 gap-4"
|
||||
@@ -180,8 +188,9 @@ export function PbnstBuseForm({data} :{data: fcBizType[]} ) {
|
||||
|
||||
<div>
|
||||
<RuseMngTable
|
||||
tableData={ pplInstls}
|
||||
tableData={pplInstls}
|
||||
headList={pbnst.pplInstlsHeadLisat}
|
||||
code={ppiSelectList ?? []}
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { headMakeprfmnc } from "@/app/ruseFcltMng/prfmncReg/chkgdnReg/TableHead";
|
||||
import type { chHeadType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList";
|
||||
import type { TableUpperProps } from "@/app/store/ruseFcltMng/fcltReg/rainReg";
|
||||
import { selectClass, type TableUpperProps } from "@/app/store/ruseFcltMng/fcltReg/rainReg";
|
||||
import { SelectBox, type SelectDataType } from "@common/business_components/ui";
|
||||
import {
|
||||
Input,
|
||||
Table,
|
||||
@@ -15,11 +16,16 @@ export default function RuseMngTable({
|
||||
tableData,
|
||||
headList,
|
||||
upHeadList,
|
||||
code = [],
|
||||
}: {
|
||||
tableData: any[];
|
||||
headList: TableUpperProps[];
|
||||
upHeadList?: chHeadType[];
|
||||
code?:{name:string, val:SelectDataType[] }[]
|
||||
}) {
|
||||
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
<Table variant="secondary">
|
||||
@@ -53,7 +59,21 @@ export default function RuseMngTable({
|
||||
onChange={(e) => {}}
|
||||
value={item[head.id] || ""}
|
||||
/>
|
||||
) : (
|
||||
) : head.type === "select" ? (
|
||||
<SelectBox
|
||||
label=""
|
||||
selectArray={code.find(item => item.name === head.selectData)?.val ?? []}
|
||||
value={
|
||||
tableData[index][item[head.id]]
|
||||
}
|
||||
className={""}
|
||||
selectClass={selectClass}
|
||||
onSelectValue={(val) => {
|
||||
tableData[index][head.id] = val;
|
||||
}}
|
||||
></SelectBox>
|
||||
)
|
||||
: (
|
||||
`${item[head.id] || ""}`
|
||||
)}
|
||||
</TableCell>
|
||||
|
||||
Reference in New Issue
Block a user