Merge commit 'fba296d77de6c7e17cfcad234d1b0871d28a8ab6' into iipbs/wr/hasuReg
This commit is contained in:
@@ -60,7 +60,7 @@ useEffect(() => {
|
||||
if (selectRow) {
|
||||
setSelectedRow(selectRow);
|
||||
}
|
||||
if (pbnstRes !== null){
|
||||
if (pbnstRes === null){
|
||||
alert("등록된 재이용시설 정보가 없습니다. 신규등록 하십시오.")
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ export type pubFacState = {
|
||||
pbnstMngUpHeadList: TableUpperProps[];
|
||||
pbnstMngNm: chHeadType[];
|
||||
pbnstHasuRes: pubHasuType[];
|
||||
pbnstRes: customPbnst | null; // 배열에서 단일 객체 또는 null로 변경
|
||||
pbnstRes: customPbnst[] | null; // 배열에서 단일 객체 또는 null로 변경
|
||||
pbnstBizCycle: SelectDataType[];
|
||||
selectLabel: SelectDataType[];
|
||||
pbnstOrgwtHeadList: TableUpperProps[];
|
||||
@@ -158,7 +158,7 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => {
|
||||
...state,
|
||||
pbnst: {
|
||||
...state.pbnst,
|
||||
pbnstRes: pbnstRes,
|
||||
pbnstRes: [pbnstRes],
|
||||
pbnstBizCycle: pbnstBizCycle,
|
||||
isInit: false,
|
||||
},
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import { useWrStore } from "@/app/store";
|
||||
import { FileUpload, FormUi } from "@common/business_components/ui";
|
||||
import { FileUpload, FormUi, SelectBox } from "@common/business_components/ui";
|
||||
import { Form, FormField } from "@common/business_components/ui/form";
|
||||
import { Button, Input } from "@common/components";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
@@ -23,28 +23,29 @@ import {
|
||||
type fcFileType,
|
||||
type operType,
|
||||
type ruseFcltType,
|
||||
type selectLabel,
|
||||
} from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type";
|
||||
import { TEST_UUID } from "@/app/store/ruseFcltMng/fcltReg/rainReg";
|
||||
import { Label } from "@common/business_components/ui/form/lib/label";
|
||||
export type FilesType = {
|
||||
atflCd: string;
|
||||
file: File;
|
||||
};
|
||||
|
||||
export function PbnstMngForm({ data }: { data: customPbnst }) {
|
||||
const { pbnst, pbnstUpdate, fileDelete, pbnstMngData } = useWrStore(
|
||||
(state) => state
|
||||
);
|
||||
export function PbnstMngForm({ data }: { data: customPbnst[] }) {
|
||||
|
||||
const [planFiles, setPlanFiles] = useState<FilesType[] | null>(null);
|
||||
const [relationfiles, setRelationFiles] = useState<FilesType[] | null>(null);
|
||||
const [regFileList, setRegFileList] = useState<fcFileType[] | null>(null);
|
||||
const { pbnst, pbnstUpdate ,pbnstMngData, fileDelete} = useWrStore((state) => state);
|
||||
const [planFiles, setPlanFiles] = useState<FilesType[] | null>(null);
|
||||
const [relationfiles, setRelationFiles] = useState<FilesType[] | null>(null);
|
||||
const [fcltNm, setFcltNm] = useState<selectLabel[] | null>(null);
|
||||
const [progress, setProgress] = useState(0);
|
||||
//const new File([] as BlobPart[], "") 파일 다운로드 활용
|
||||
const handleProgress = (percentage: string) => {
|
||||
setProgress(Number(percentage));
|
||||
};
|
||||
|
||||
const ref = useRef<operType[] | null>(data?.fcOpers ?? null);
|
||||
const ref = useRef<operType[] | null>( null);
|
||||
const form = useForm<z.infer<typeof pbnstRegZod>>({
|
||||
resolver: zodResolver(pbnstRegZod),
|
||||
defaultValues: pbnstRegZod.parse({}),
|
||||
@@ -102,24 +103,22 @@ export function PbnstMngForm({ data }: { data: customPbnst }) {
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (data) {
|
||||
console.log(" data ", data )
|
||||
console.log(" pbnst.pbnstMngRegData ", pbnst.pbnstMngRegData)
|
||||
form.reset(data);
|
||||
form.setValue("pbnstRuseFcltPk", data.pbnstRuseFcltPk);
|
||||
ref.current = data.fcOpers;
|
||||
}
|
||||
}, [data]);
|
||||
if (!data) return;
|
||||
//form.reset(data);
|
||||
const fcltNmList = data.map((item, index) => ({
|
||||
text: item.ruseUtztnFcltNm,
|
||||
val: String(index)
|
||||
}))
|
||||
ref.current = data[0]?.fcOpers ?? null;
|
||||
setFcltNm(fcltNmList)
|
||||
}, [data])
|
||||
|
||||
// useEffect(() => {
|
||||
// if (pbnst.pbnstMngRegData && !mountCheck.current) {
|
||||
// console.log('pbnst.pbnstMngRegData ', pbnst.pbnstMngRegData)
|
||||
// mountCheck.current=true
|
||||
// // form.reset(data);
|
||||
// // form.setValue("pbnstRuseFcltPk", data.pbnstRuseFcltPk);
|
||||
// // ref.current = data.fcOpers || [];
|
||||
// }
|
||||
// }, [ ]);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
if (!fcltNm || fcltNm.length === 0) return;
|
||||
form.reset(data[0]);
|
||||
}, [fcltNm, data]);
|
||||
// 2. Define a submit handler.
|
||||
function onSubmit(values: z.infer<typeof pbnstRegZod>) {
|
||||
values.fcOpers = ref.current || [];
|
||||
@@ -194,7 +193,8 @@ export function PbnstMngForm({ data }: { data: customPbnst }) {
|
||||
mdfr: TEST_UUID,
|
||||
}));
|
||||
return [...planDatas, ...data];
|
||||
};
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (relationfiles) {
|
||||
setRegFileList(regFileFilter(relationfiles, "계통도", regFileList || []));
|
||||
@@ -217,14 +217,15 @@ export function PbnstMngForm({ data }: { data: customPbnst }) {
|
||||
<form onSubmit={form.handleSubmit(onSubmit)}>
|
||||
<div className="flex justify-between items-center mx-3 mb-3">
|
||||
<div className="col-span-2 flex items-top">
|
||||
<h2 className={formTableName + "pr-3 col-span-10 "}>
|
||||
재이용 시설명
|
||||
</h2>
|
||||
<span className="mt-4 ml-2">
|
||||
{form.getValues("ruseUtztnFcltNm")
|
||||
? ": " + form.getValues("ruseUtztnFcltNm")
|
||||
: ""}
|
||||
</span>
|
||||
<Label className={formTableName + "pr-3 col-span-2 "}>재이용 시설명</Label>
|
||||
<SelectBox
|
||||
label=""
|
||||
className="mt-4 ml-2"
|
||||
selectClass={undefined}
|
||||
selectArray={fcltNm ?? []}
|
||||
onSelectValue={(val) => {console.log("val", val)}}
|
||||
value={""}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<Button type="submit" size={commonButonSize}>
|
||||
|
||||
Reference in New Issue
Block a user