공급관로 유무에 따른 컨트롤

This commit is contained in:
jyha00
2025-05-30 16:19:46 +09:00
parent 6314b8059e
commit 43d80be24b
@@ -34,7 +34,7 @@ import MngRegFormDetail from "../mngReg/mngRegFormDetail/mngRegFormDetail";
export function PbnstBuseForm({ data }: { data: fcBizType[] }) {
// const ref = useRef<ppInstlType[] | null>(data[0]?.pplInstls ?? null);
const ref = useRef<ppInstlType[] |null>( null);
const ref = useRef<ppInstlType[] | null>(null);
const { code, pbnst, pbnstBizData } = useWrStore((state) => state);
const { pbnstBizCycle, pbnstRes } = pbnst;
const [getBizCycle, setBizCycle] = useState("1");
@@ -72,12 +72,19 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) {
const formData = form.watch()
formData.pplInstls = ref.current? [...ref.current]:[] // ← form 내부 상태 기준으로 복사
formData.pplInstls = ref.current ? [...ref.current] : [] // ← form 내부 상태 기준으로 복사
console.log("formData pplReg", formData)
pbnstBizData(formData as fcBizType);
}, [form.formState]);
useEffect(() => {
if (ppiYn === "N") {
form.setValue('pplInstls', [])
}
}, [ppiYn, pbnst.pplInstlsHeadLisat])
useEffect(() => {
console.log("pbnst.pbnstMngRegData ", pbnst.pbnstMngRegData);
}, [pbnst.pbnstMngRegData]);
@@ -89,8 +96,8 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) {
};
const plusHist = () => {
const regData ={
ruseFcltBizFk: ref.current?.[0]?.ruseFcltBizFk??"",
const regData = {
ruseFcltBizFk: ref.current?.[0]?.ruseFcltBizFk ?? "",
choose: false,
ppMqlt: "",
pdmt: '',
@@ -107,7 +114,7 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) {
};
const plusArray = () => {
}
const removeSelected = () => {
@@ -119,17 +126,17 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) {
};
useEffect(() => {
if(getBizCycle){
if (getBizCycle) {
const index = Number(getBizCycle) - 1;
form.reset(pbnst.pbnstResObj?.fcBizs[index]);
ref.current = pbnst.pbnstResObj?.fcBizs[index]?.pplInstls ?? [];
}
}, [getBizCycle,pbnst.pbnstResObj]);
}, [getBizCycle, pbnst.pbnstResObj]);
useEffect(() => {
const ppl = [];
if (code.pplLenght) {
@@ -218,116 +225,120 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) {
sonClass="col-span-4"
/>
<h1 className={formH1Class}>재이용 원수취수 현황</h1>
<div>
<div className="text-right mb-3">
<Button
type="button"
onClick={
// () => {
// setIsFcOrgwts(true)
// setModalData(modalData)
// }
buttonClick
}
size={commonButonSize}
className="">
추가등록
</Button>
</div>
<RuseMngTable
<h1 className={formH1Class}>재이용 원수취수 현황</h1>
<div>
<div className="text-right mb-3">
<Button
type="button"
onClick={
// () => {
// setIsFcOrgwts(true)
// setModalData(modalData)
// }
buttonClick
}
size={commonButonSize}
className="">
추가등록
</Button>
</div>
<RuseMngTable
tableData={fcOrgwtFiled}
headList={pbnst.pbnstOrgwtHeadList}
upHeadList={[]} />
</div>
<h1 className={formH1Class}>재이용 공급관로 설치 현황</h1>
<div className="flex items-center gap-4 mx-3 mb-3">
<Label className="text-right">공급관로설치유무</Label>
<SelectBox
label=""
selectArray={code.yn}
value={ppiYn}
className="w-32"
selectClass="w-full"
onSelectValue={(val) => setPpiYn(String(val))}
/>
<Label className="text-right">합계</Label>
<Input
type="text"
value={sumCpct}
readOnly={true}
className="w-32 border-gray-300 rounded pr-8 "
/>
<Button
type="button"
size={commonButonSize}
className="!text-xl"
onClick={plusHist}
>
추가등록
</Button>
<Button
type="button"
size={commonButonSize}
className="!text-xl !bg-red-500 !text-white ml-1"
onClick={removeSelected}
>
삭제
</Button>
</div>
<div>
<RuseMngTable
tableData={pplInstls}
headList={pbnst.pplInstlsHeadLisat}
code={ppiSelectList ?? []}
ref={ref}
upHeadList={[]}
onTableSet={(val) => {
if (!ref.current) return;
let sum = 0;
ref.current.forEach(item => {
sum += Number(item.cpct) || 0;
});
setSumCpct(sum);
}}
/>
</div>
<MngRegFormDetail
formList={ruseWaterQulityList}
h1Title={"하수처리수 재이용시설 보증수질"}
form={form}
moClass="grid grid-cols-12 gap-4"
sonClass="col-span-4"
/>
<h1 className={formH1Class}>하수처리수 재이용수 수요처</h1>
<div>
<div className="text-right mb-3">
<Input
type="text"
className="!text-xl w-1/3"
onClick={plusArray}
placeholder="수요처 추가"
>
</Input>
headList={pbnst.pbnstOrgwtHeadList}
upHeadList={[]} />
</div>
<h1 className={formH1Class}>재이용 공급관로 설치 현황</h1>
<div className="flex items-center gap-4 mx-3 mb-3">
<Label className="text-right">공급관로설치유무</Label>
<SelectBox
label=""
selectArray={code.yn}
value={ppiYn}
className="w-32"
selectClass="w-full"
onSelectValue={(val) => setPpiYn(String(val))}
/>
<Label className="text-right">합계</Label>
<Input
type="text"
value={sumCpct}
readOnly={true}
className="w-32 border-gray-300 rounded pr-8 "
/>
{ppiYn === 'Y' ? <>
<Button
type="button"
size={commonButonSize}
className="!text-xl"
onClick={plusHist}
>
추가등록
</Button>
<Button
type="button"
size={commonButonSize}
className="!text-xl !bg-red-500 !text-white ml-1"
onClick={removeSelected}
>
삭제
</Button>
</> : <>
</>
}
</div>
<div>
<RuseMngTable
tableData={pplInstls}
headList={pbnst.pplInstlsHeadLisat}
code={ppiSelectList ?? []}
ref={ref}
upHeadList={[]}
onTableSet={(val) => {
if (!ref.current) return;
let sum = 0;
ref.current.forEach(item => {
sum += Number(item.cpct) || 0;
});
setSumCpct(sum);
}}
/>
</div>
<RuseMngTable
tableData={[]}
headList={pbnst.pbnstDemandHeadList}
/>
</div>
</form>
</Form>
</div>
<UiModal
open={isFcOrgwts}
onOpenChange={(open: boolean) => setIsFcOrgwts(open)}
bodyClass={"w-[50vw] max-w-none h-[60vh]"}
body={<FcOrgwtsRegModal data={modalData ? [modalData] : []} onRightSet={(val) => { console.log("val", val); return {}; }} ></FcOrgwtsRegModal>}
></UiModal>
</div>
<MngRegFormDetail
formList={ruseWaterQulityList}
h1Title={"하수처리수 재이용시설 보증수질"}
form={form}
moClass="grid grid-cols-12 gap-4"
sonClass="col-span-4"
/>
<h1 className={formH1Class}>하수처리수 재이용수 수요처</h1>
<div>
<div className="text-right mb-3">
<Input
type="text"
className="!text-xl w-1/3"
onClick={plusArray}
placeholder="수요처 추가"
>
</Input>
</div>
<RuseMngTable
tableData={[]}
headList={pbnst.pbnstDemandHeadList}
/>
</div>
</form>
</Form>
</div>
<UiModal
open={isFcOrgwts}
onOpenChange={(open: boolean) => setIsFcOrgwts(open)}
bodyClass={"w-[50vw] max-w-none h-[60vh]"}
body={<FcOrgwtsRegModal data={modalData ? [modalData] : []} onRightSet={(val) => { console.log("val", val); return {}; }} ></FcOrgwtsRegModal>}
></UiModal>
</div>
</>
);
}