하수재이용 실적 등록 테스트 완료
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { useWrStore } from "@/app/store";
|
||||
import { excelToPbnPrfData } from "@/app/store/prfmncReg/pbnstPrfmncReg/excel";
|
||||
import { pbnPrfRegExcelZod } from "@/app/store/prfmncReg/pbnstPrfmncReg/headList";
|
||||
import type { FcPrfType, PrfType } from "@/app/store/prfmncReg/pbnstPrfmncReg/type";
|
||||
import { yearOptions } from "@/components/lib/func/commom";
|
||||
import { ToastFormUi } from "@/components/ui/toast/toastFromUi";
|
||||
import {
|
||||
@@ -13,19 +14,17 @@ import {
|
||||
type SelectDataType,
|
||||
filePicked,
|
||||
} from "@common/business_components/ui";
|
||||
import { Button } from "@common/components/ui";
|
||||
import { Button, Input } from "@common/components/ui";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import type { z } from "zod";
|
||||
|
||||
export default function PbnPrfExcelModal() {
|
||||
const { code, prfmnc, searchFclts } = useWrStore((state) => state);
|
||||
export default function PbnPrfExcelModal({ data }: { data: FcPrfType }) {
|
||||
const { prfmnRegData } = useWrStore((state) => state);
|
||||
|
||||
|
||||
const [bscFctNmList, setBscFctNmList] = useState<SelectDataType[] | null>(null);
|
||||
const [files, setFiles] = useState<File[] | null>(null);
|
||||
const [excelData, setExcelData] = useState<any[]>();
|
||||
const [excelData, setExcelData] = useState<PrfType[]>();
|
||||
const form = useForm<z.infer<typeof pbnPrfRegExcelZod>>({
|
||||
resolver: zodResolver(pbnPrfRegExcelZod),
|
||||
defaultValues: {
|
||||
@@ -34,27 +33,24 @@ const [excelData, setExcelData] = useState<any[]>();
|
||||
});
|
||||
const onSubmit = (values: z.infer<typeof pbnPrfRegExcelZod>) => {
|
||||
console.log(values);
|
||||
|
||||
prfmnRegData(excelData )
|
||||
|
||||
|
||||
};
|
||||
useEffect(() => {
|
||||
|
||||
if(prfmnc.prfmncRes.length > 0){
|
||||
if (data && data.bscFctNm)
|
||||
form.setValue("pbnstRuseFcltFk", data.pbnstRuseFcltPk);
|
||||
form.setValue("bscFctNm", data.bscFctNm || "");
|
||||
form.setValue("pbnstRuseFcltNm", data.ruseUtztnFcltNm);
|
||||
}, [data]);
|
||||
|
||||
const basFctNmList = prfmnc.prfmncRes.map((item)=>(
|
||||
{
|
||||
val:item.bscFctCd,
|
||||
text:item.bscFctNm
|
||||
}
|
||||
))
|
||||
setBscFctNmList(basFctNmList)
|
||||
}
|
||||
|
||||
}, [prfmnc.prfmncRes]);
|
||||
|
||||
|
||||
useEffect(()=>{
|
||||
|
||||
if(files){
|
||||
useEffect(() => {
|
||||
console.log("excelData", excelData);
|
||||
}, [excelData]);
|
||||
|
||||
useEffect(() => {
|
||||
if (files) {
|
||||
const file = files[0];
|
||||
if (form.getValues("ym").length < 1) {
|
||||
ToastFormUi({
|
||||
@@ -65,15 +61,13 @@ const [excelData, setExcelData] = useState<any[]>();
|
||||
return;
|
||||
}
|
||||
|
||||
if(file)
|
||||
filePicked(file, 0).then((res) => {
|
||||
if (res !== undefined)
|
||||
console.log(excelToPbnPrfData(res, form.getValues("ym")))
|
||||
});
|
||||
|
||||
|
||||
if (file)
|
||||
filePicked(file, 0).then((res) => {
|
||||
if (res !== undefined)
|
||||
setExcelData(excelToPbnPrfData(res as any, form.getValues("ym"),form.getValues('pbnstRuseFcltFk') ))
|
||||
});
|
||||
}
|
||||
},[files])
|
||||
}, [files]);
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -116,13 +110,11 @@ const [excelData, setExcelData] = useState<any[]>();
|
||||
name="bscFctNm"
|
||||
render={({ field }) => (
|
||||
<FormUi label="시설명">
|
||||
<SelectBox
|
||||
<Input
|
||||
className="w-1/4 text-3xl"
|
||||
selectClass={""}
|
||||
label=""
|
||||
selectArray={bscFctNmList || [] }
|
||||
value={field.value}
|
||||
onSelectValue={(val) => field.onChange(String(val))}
|
||||
onChange={field.onChange}
|
||||
readOnly
|
||||
/>
|
||||
</FormUi>
|
||||
)}
|
||||
@@ -132,13 +124,11 @@ const [excelData, setExcelData] = useState<any[]>();
|
||||
name="pbnstRuseFcltNm"
|
||||
render={({ field }) => (
|
||||
<FormUi label="재이용시설명">
|
||||
<SelectBox
|
||||
<Input
|
||||
className="w-1/4 text-3xl"
|
||||
selectClass={""}
|
||||
label=""
|
||||
selectArray={yearOptions}
|
||||
value={field.value}
|
||||
onSelectValue={(val) => field.onChange(String(val))}
|
||||
onChange={field.onChange}
|
||||
readOnly
|
||||
/>
|
||||
</FormUi>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user