Merge commit '858486c36a2e09c12118f6e6c86e107eb0e77853' into iipbs/wr/hasuReg

This commit is contained in:
leedj312
2025-05-30 17:02:14 +09:00
4 changed files with 157 additions and 112 deletions
@@ -64,6 +64,16 @@ export const fcOrgwtsHeadListExport: TableUpperProps[] = [
{ id: "addr", title: "위치" },
];
export const dmdCoList: formDetailType[] = [
{ id: "dmdCoNm", lable: "수요처명" },
{ id: "daddr", lable: "위치(주소)" },
{ id: "useUsgCd", lable: "사용용도" },
{ id: "splyBgngDay", lable: "공급시작일", type: "date" },
{ id: "splyEndDay", lable: "공급종료일", type: "date" },
{ id: "splyCpct", lable: "(계약)공급량(m3/일)" },
{ id: "splyFmYn", lable: "공급 유량계 유무", type: "selectYn" },
];
export const pbnstMngNmExport: chHeadType[] = [
{ headNm: "upChangeRe", text: "운영대행기간", length: 2 },
];
@@ -5,6 +5,7 @@ import {
businessMoneyInfo,
businessSttnInfo,
concentratedWaterInfo,
dmdCoList,
ruseFcltinfo,
ruseWaterQulityList,
wasteWaterFcltINfo,
@@ -34,7 +35,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");
@@ -43,6 +44,7 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) {
const [ppiYn, setPpiYn] = useState("Y");
const [isFcOrgwts, setIsFcOrgwts] = useState<boolean>(false);
const [modalData, setModalData] = useState<fcOrgwtType | null>(null);
const [sumCpct, setSumCpct] = useState<number>(0);
const form = useForm<fcBizType>({
resolver: zodResolver(fcBizSchema),
@@ -50,7 +52,7 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) {
// 2. Define a submit handler.
function onSubmit(values: fcBizType) {
console.log(values);
// console.log(values);
}
const { fields: fcOrgwtFiled } = useFieldArray({
@@ -71,12 +73,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]);
@@ -88,8 +97,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: '',
@@ -106,7 +115,7 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) {
};
const plusArray = () => {
}
const removeSelected = () => {
@@ -118,16 +127,16 @@ 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 = [];
@@ -217,108 +226,127 @@ 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={""}
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={[]}
/>
</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">
<Button
type="button"
onClick={() => {}}
size={commonButonSize}
className="">
수요처 추가
</Button>
</div>
<MngRegFormDetail
formList={dmdCoList}
h1Title={"하수처리수 재이용수 수요처"}
form={form}
moClass="grid grid-cols-12 gap-4 mt-3"
sonClass="col-span-4"
/>
{/* <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>
</>
);
}
@@ -14,7 +14,7 @@ export default function MngRegFormDetail({
cycle,
}: {
formList: formDetailType[];
h1Title: string;
h1Title?: string;
form: any;
moClass?: string;
cycle?:string
@@ -23,7 +23,7 @@ export default function MngRegFormDetail({
const { code, } = useWrStore((state) => state);
return (
<>
<h1 className={formH1Class}>{h1Title}</h1>
{ h1Title ? <h1 className={formH1Class}>{h1Title}</h1> : <></>}
<div className={moClass}>
{formList?.map((item, index) => {
@@ -21,6 +21,7 @@ type RuseMngTableProps = {
headList: TableUpperProps[];
upHeadList: chHeadType[];
code?: { name: string, val: SelectDataType[] }[];
onTableSet?:(item:any)=> void;
};
const RuseMngTable = React.forwardRef<any, RuseMngTableProps>(
@@ -28,14 +29,20 @@ const RuseMngTable = React.forwardRef<any, RuseMngTableProps>(
tableData,
headList,
upHeadList,
code
code,
onTableSet
}, ref) => {
const [tableState, setTableState] = useState([...tableData]);
useEffect(() => {
if (ref && typeof ref === "object" && "current" in ref) {
ref.current = tableState;
}
}, [tableState]);
if(onTableSet)
onTableSet (tableState)
}, [tableState,onTableSet]);
useEffect(() => {
if(tableData)