하수재이용 시설 차수 등록 버튼 수정 및 빗물 지도점검 데이터 유형 변경 (ph) 수정
This commit is contained in:
@@ -24,10 +24,11 @@ import { SelectBox } from "@common/business_components";
|
||||
import { DatePicker, FormUi, UiModal } from "@common/business_components/ui";
|
||||
import { Form, FormField } from "@common/business_components/ui/form";
|
||||
import { Button, Input, Label } from "@common/components";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { useCallback, useEffect, useRef, useState } from "react";
|
||||
import { useFieldArray, type UseFormReturn } from "react-hook-form";
|
||||
import MngRegFormDetail from "../mngReg/mngRegFormDetail/mngRegFormDetail";
|
||||
import {
|
||||
//confirmToast,
|
||||
formatCommaNumber,
|
||||
handleCommaNumberChange,
|
||||
safeDate,
|
||||
@@ -38,6 +39,9 @@ import type { DemandCompType } from "@common/business_components/ui/sdmInsertFor
|
||||
import RuseMngTableForm from "@/components/ui/table/pbnstReg/ruseMngTableForm/ruseMngTableForm";
|
||||
import type { SelectDataType } from "@common/business_components";
|
||||
import { BuseWaterQulity } from "./buseWaterQulity/buseWaterQulity";
|
||||
import toast from "react-hot-toast";
|
||||
import { useTranslation } from "react-i18next";
|
||||
//import { useTranslation } from "react-i18next";
|
||||
|
||||
export function PbnstBuseForm({
|
||||
indexMng = 0,
|
||||
@@ -54,6 +58,8 @@ export function PbnstBuseForm({
|
||||
setIndexBiz: (index: number) => void;
|
||||
readonly?: boolean;
|
||||
}) {
|
||||
const { t } = useTranslation("base");
|
||||
|
||||
const {
|
||||
code,
|
||||
pbnst,
|
||||
@@ -157,22 +163,25 @@ export function PbnstBuseForm({
|
||||
}
|
||||
}, [fcBizs, indexBiz, setIndexBiz]);
|
||||
// 2. Define a submit handler.
|
||||
function addRuseFcltObj() {
|
||||
const addRuseFcltObj = useCallback(async () => {
|
||||
|
||||
const formRuse = form.getValues(`items.${indexMng}`);
|
||||
const formBizs = form.getValues(`items.${indexMng}.fcBizs`);
|
||||
const pbnstBizCycle = formBizs.length;
|
||||
|
||||
// 🧩 새로운 fcBizs 기본 객체 생성 (필수값만 채우고 나머지는 default로)
|
||||
const newItem = fcBizSchema.parse({
|
||||
cycl: pbnstBizCycle + 1,
|
||||
pbnstRuseFcltId: formRuse.pbnstRuseFcltId,
|
||||
fcOrgwts: undefined,
|
||||
pplInstls: undefined,
|
||||
fcDemands: undefined,
|
||||
});
|
||||
appendBiz(newItem);
|
||||
setIndexBiz(pbnstBizCycle); // 새로 추가된 차수로 포커스 이동
|
||||
}
|
||||
const newItem = fcBizSchema.parse({
|
||||
cycl: pbnstBizCycle + 1,
|
||||
pbnstRuseFcltId: formRuse.pbnstRuseFcltId,
|
||||
fcOrgwts: [],
|
||||
|
||||
pplInstls: [],
|
||||
fcDemands: [],
|
||||
});
|
||||
await appendBiz(newItem);
|
||||
toast.success(t('insertRuseBiz',{cycle: pbnstBizCycle + 1}))
|
||||
setIndexBiz(pbnstBizCycle);
|
||||
}, [form, indexMng, indexBiz, appendBiz, setIndexBiz]);
|
||||
|
||||
const { fields: fcDemands, append: appendDemand } = useFieldArray({
|
||||
control: form.control,
|
||||
name: `items.${indexMng}.fcBizs.${indexBiz}.fcDemands`,
|
||||
@@ -206,7 +215,7 @@ export function PbnstBuseForm({
|
||||
}
|
||||
}, [ppiYn, indexMng, indexBiz]);
|
||||
|
||||
const plusHist = () => {
|
||||
const plusHist = useCallback(() => {
|
||||
if (
|
||||
form.getValues(`items.${indexMng}.fcBizs.${indexBiz}.pbnstRuseFcltBizSn`)
|
||||
) {
|
||||
@@ -227,9 +236,9 @@ export function PbnstBuseForm({
|
||||
cpct: 0,
|
||||
});
|
||||
}
|
||||
};
|
||||
}, [indexMng, indexBiz, appendPpl, form]);
|
||||
|
||||
const plusArray = () => {
|
||||
const plusArray = useCallback(() => {
|
||||
appendDemand({
|
||||
dmdCoNm: "",
|
||||
daddr: "",
|
||||
@@ -248,7 +257,7 @@ export function PbnstBuseForm({
|
||||
dmdInfoId: "",
|
||||
//telno: "",
|
||||
});
|
||||
};
|
||||
}, [indexMng, indexBiz, appendDemand, form]);
|
||||
|
||||
const removeSelected = () => {
|
||||
const nowPPl = form.getValues(
|
||||
@@ -293,7 +302,7 @@ export function PbnstBuseForm({
|
||||
}, [form.formState, indexMng, indexBiz]);
|
||||
|
||||
useEffect(() => {
|
||||
console.log("form.formState ", form.formState);
|
||||
//console.log("form.formState ", form.formState);
|
||||
}, [form.formState]);
|
||||
|
||||
const pbnstBiz = form.watch(`items.${indexMng}.fcBizs`);
|
||||
@@ -489,17 +498,16 @@ export function PbnstBuseForm({
|
||||
</div>
|
||||
|
||||
<div>
|
||||
|
||||
<BuseWaterQulity
|
||||
h1Title={`하수처리수 재이용시설 보증수질 `}
|
||||
subTitle="※재처리시설이 있는 경우만 작성"
|
||||
form={form}
|
||||
moClass="grid grid-cols-12 gap-4"
|
||||
sonClass="col-span-4"
|
||||
indexMng={indexMng}
|
||||
indexBiz={indexBiz}
|
||||
readonly={readonly}
|
||||
/>
|
||||
<BuseWaterQulity
|
||||
h1Title={`하수처리수 재이용시설 보증수질 `}
|
||||
subTitle="※재처리시설이 있는 경우만 작성"
|
||||
form={form}
|
||||
moClass="grid grid-cols-12 gap-4"
|
||||
sonClass="col-span-4"
|
||||
indexMng={indexMng}
|
||||
indexBiz={indexBiz}
|
||||
readonly={readonly}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div key={"hasu"}>
|
||||
@@ -533,7 +541,10 @@ export function PbnstBuseForm({
|
||||
수요처 신규등록
|
||||
</Button>
|
||||
</div>
|
||||
<div ref={demandsContainerRef}>
|
||||
<div
|
||||
key={`fcDemands-${indexMng}-${indexBiz}`}
|
||||
ref={demandsContainerRef}
|
||||
>
|
||||
{fcDemands.map((field, index) => (
|
||||
<div
|
||||
key={field.id} // useFieldArray의 고유 id를 key로 사용
|
||||
|
||||
-1
@@ -39,7 +39,6 @@ export function BuseWaterQulity({
|
||||
form.getValues(`items.${indexMng}.pbnstRuseFcltId`) +
|
||||
String(form.getValues(`items.${indexMng}.fcBizs.${indexBiz}.cycl`));
|
||||
|
||||
console.log("checkPkAndCycle ", checkPkAndCycle);
|
||||
if (chekcPk !== checkPkAndCycle) {
|
||||
if (watchPH && watchPH !== undefined) {
|
||||
const [frontPH, backPH] = watchPH.split("~");
|
||||
|
||||
@@ -78,16 +78,26 @@ export default function RainChkgdTable({
|
||||
useEffect(() => {
|
||||
setSelectedIds([])// 셀렉트 초기화를 위한 작업
|
||||
if (rainChkData && rainChkData.length > 0) {
|
||||
|
||||
const rainChg = rainChkData?.map((item: any) => {
|
||||
const bud = tableData([item.building], { code });
|
||||
const rainyDetails= item.rainyDetails.map((detail)=>{
|
||||
return(
|
||||
{
|
||||
...detail,
|
||||
// 일단 테이블에서 사용하기 위해 넘버 전환
|
||||
ph: detail.ph&& !isNaN(detail.ph)?Number(detail.ph):detail.ph
|
||||
}
|
||||
)
|
||||
})
|
||||
return {
|
||||
...item,
|
||||
...bud[0],
|
||||
rainyDetails:rainyDetails,
|
||||
rowspan: item.rainyDetails?.length,
|
||||
};
|
||||
});
|
||||
|
||||
console.log('rainChg ', rainChg)
|
||||
setMakeTableData(rainChkTableData(rainChg));
|
||||
} else {
|
||||
setMakeTableData([]);
|
||||
@@ -116,7 +126,8 @@ export default function RainChkgdTable({
|
||||
if (findRain != undefined) {
|
||||
return {
|
||||
...rd,
|
||||
ph: Number(findRain.ph),
|
||||
// 조드 타입과 맞추기위해 스트링
|
||||
ph: String(findRain.ph),
|
||||
trbt: Number(findRain.trbt),
|
||||
grssClfg: Number(findRain.grssClfg),
|
||||
etc: findRain.etc,
|
||||
|
||||
Reference in New Issue
Block a user