diff --git a/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList.tsx b/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList.tsx index 6cd3cd340..356d513c1 100644 --- a/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList.tsx +++ b/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList.tsx @@ -111,22 +111,6 @@ export type splRuseWaterType = { ruse11: number; ruse12: number; }; -export type polutionType = { - chkgdnDtlFk:number; - utztnUsgCd: string; - node: number; - grssClfgUswtr: number; - combResdch: number; - trbt: number; - bod: number; - smll: number; - crmty: number; - tph: number; - tn: number; - ph: number; - clIonQnt: number; -}; - export const rainHeadNmExport: chHeadType[] = [ { headNm: "useQuilty", text: "이용수질(필요시)", length: 4 }, @@ -149,14 +133,21 @@ export const rainChkgdnHeadListExport: TableUpperProps[] = [ { id: "utztnUsgCd", title: "이용용도" }, { id: "totalSplyUswtrUtztnQnt", title: "연간보급수이용량(m³)" }, { id: "totalRuseFcltUtztnQnt", title: "연간빗물이용량(m³)" }, - { id: "ph", title: "PH", upName: "useQuilty", upSequnce: 1, type: "number" ,edit:true}, + { + id: "ph", + title: "PH", + upName: "useQuilty", + upSequnce: 1, + type: "number", + edit: true, + }, { id: "trbt", title: "탁도", upName: "useQuilty", upSequnce: 2, type: "number", - edit:true + edit: true, }, { id: "grssClfg", @@ -164,7 +155,7 @@ export const rainChkgdnHeadListExport: TableUpperProps[] = [ upName: "useQuilty", upSequnce: 3, type: "number", - edit:true + edit: true, }, { id: "etc", @@ -172,7 +163,7 @@ export const rainChkgdnHeadListExport: TableUpperProps[] = [ upName: "useQuilty", upSequnce: 4, type: "number", - edit:true + edit: true, }, { id: "vltnDt", @@ -180,7 +171,7 @@ export const rainChkgdnHeadListExport: TableUpperProps[] = [ upName: "feeHist", upSequnce: 1, type: "text", - edit:true + edit: true, }, { id: "vltnMttr", @@ -188,7 +179,7 @@ export const rainChkgdnHeadListExport: TableUpperProps[] = [ upName: "feeHist", upSequnce: 2, type: "text", - edit:true + edit: true, }, { id: "levyAmt", @@ -196,42 +187,42 @@ export const rainChkgdnHeadListExport: TableUpperProps[] = [ upName: "feeHist", upSequnce: 3, type: "number", - edit:true + edit: true, }, ]; export const ruseHeadListExport: TableUpperProps[] = [ { id: "utztnUsgCd", title: "이용용도" }, - { id: "ruseTotal", title: "계", upName: "ruseWater", upSequnce: 1 }, - { id: "ruse01", title: "1월", upName: "ruseWater", upSequnce: 2 }, - { id: "ruse02", title: "2월", upName: "ruseWater", upSequnce: 3 }, - { id: "ruse03", title: "3월", upName: "ruseWater", upSequnce: 4 }, - { id: "ruse04", title: "4월", upName: "ruseWater", upSequnce: 5 }, - { id: "ruse05", title: "5월", upName: "ruseWater", upSequnce: 6 }, - { id: "ruse06", title: "6월", upName: "ruseWater", upSequnce: 7 }, - { id: "ruse07", title: "7월", upName: "ruseWater", upSequnce: 8 }, - { id: "ruse08", title: "8월", upName: "ruseWater", upSequnce: 9 }, - { id: "ruse09", title: "9월", upName: "ruseWater", upSequnce: 10 }, - { id: "ruse10", title: "10월", upName: "ruseWater", upSequnce: 11 }, - { id: "ruse11", title: "11월", upName: "ruseWater", upSequnce: 12 }, - { id: "ruse12", title: "12월", upName: "ruseWater", upSequnce: 13 }, + { id: "ruseTotal", title: "계", upName: "ruseWater", upSequnce: 1 }, + { id: "ruse01", title: "1월", upName: "ruseWater", upSequnce: 2 , edit: true }, + { id: "ruse02", title: "2월", upName: "ruseWater", upSequnce: 3 , edit: true }, + { id: "ruse03", title: "3월", upName: "ruseWater", upSequnce: 4 , edit: true }, + { id: "ruse04", title: "4월", upName: "ruseWater", upSequnce: 5 , edit: true }, + { id: "ruse05", title: "5월", upName: "ruseWater", upSequnce: 6 , edit: true }, + { id: "ruse06", title: "6월", upName: "ruseWater", upSequnce: 7 , edit: true }, + { id: "ruse07", title: "7월", upName: "ruseWater", upSequnce: 8 , edit: true }, + { id: "ruse08", title: "8월", upName: "ruseWater", upSequnce: 9 , edit: true }, + { id: "ruse09", title: "9월", upName: "ruseWater", upSequnce: 10, edit: true }, + { id: "ruse10", title: "10월", upName: "ruseWater", upSequnce: 11 , edit: true }, + { id: "ruse11", title: "11월", upName: "ruseWater", upSequnce: 12 , edit: true }, + { id: "ruse12", title: "12월", upName: "ruseWater", upSequnce: 13 , edit: true }, ]; export const splHeadListExport: TableUpperProps[] = [ { id: "utztnUsgCd", title: "이용용도" }, - { id: "splTotal", title: "계", upName: "splWater", upSequnce: 1 }, - { id: "spl01", title: "1월", upName: "splWater", upSequnce: 2 }, - { id: "spl02", title: "2월", upName: "splWater", upSequnce: 3 }, - { id: "spl03", title: "3월", upName: "splWater", upSequnce: 4 }, - { id: "spl04", title: "4월", upName: "splWater", upSequnce: 5 }, - { id: "spl05", title: "5월", upName: "splWater", upSequnce: 6 }, - { id: "spl06", title: "6월", upName: "splWater", upSequnce: 7 }, - { id: "spl07", title: "7월", upName: "splWater", upSequnce: 8 }, - { id: "spl08", title: "8월", upName: "splWater", upSequnce: 9 }, - { id: "spl09", title: "9월", upName: "splWater", upSequnce: 10 }, - { id: "spl10", title: "10월", upName: "splWater", upSequnce: 11 }, - { id: "spl11", title: "11월", upName: "splWater", upSequnce: 12 }, - { id: "spl12", title: "12월", upName: "splWater", upSequnce: 13 }, + { id: "splTotal", title: "계", upName: "splWater", upSequnce: 1}, + { id: "spl01", title: "1월", upName: "splWater", upSequnce: 2, edit: true }, + { id: "spl02", title: "2월", upName: "splWater", upSequnce: 3, edit: true }, + { id: "spl03", title: "3월", upName: "splWater", upSequnce: 4, edit: true }, + { id: "spl04", title: "4월", upName: "splWater", upSequnce: 5, edit: true }, + { id: "spl05", title: "5월", upName: "splWater", upSequnce: 6, edit: true }, + { id: "spl06", title: "6월", upName: "splWater", upSequnce: 7, edit: true }, + { id: "spl07", title: "7월", upName: "splWater", upSequnce: 8, edit: true }, + { id: "spl08", title: "8월", upName: "splWater", upSequnce: 9, edit: true }, + { id: "spl09", title: "9월", upName: "splWater", upSequnce: 10, edit: true }, + { id: "spl10", title: "10월", upName: "splWater", upSequnce: 11, edit: true }, + { id: "spl11", title: "11월", upName: "splWater", upSequnce: 12, edit: true }, + { id: "spl12", title: "12월", upName: "splWater", upSequnce: 13, edit: true }, ]; export const rswtDetailHeadListExport: TableUpperProps[] = [ diff --git a/apps/wr/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/headList.tsx b/apps/wr/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/headList.tsx index a0dc1754c..846838c38 100644 --- a/apps/wr/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/headList.tsx +++ b/apps/wr/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/headList.tsx @@ -2,6 +2,22 @@ import type { TableUpperProps } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; import { z } from "zod"; import { guideDetail, type chHeadType } from "../rainChkgdn/headList"; +export type polutionType = { + chkgdnDtlFk: number; + utztnUsgCd: string; + node: number; + grssClfgUswtr: number; + combResdch: number; + trbt: number; + bod: number; + smll: number; + crmty: number; + tph: number; + tn: number; + ph: number; + clIonQnt: number; + edit?:boolean +}; const reuseBuildingZod = z.object({ bdstRuseFcltPk: z.number().nullish(), bdstInfoFk: z.number().nullish(), @@ -54,6 +70,7 @@ export const rswtrPolutionsZode = z.object({ rgtr: z.string().nullish(), mdfcnDt: z.string().nullish(), mdfr: z.string().nullish(), + edit:z.boolean().nullish() }); export const rswtChkgdZod = z.object({ diff --git a/apps/wr/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/index.tsx b/apps/wr/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/index.tsx index 983fa7625..85f3c5be5 100644 --- a/apps/wr/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/index.tsx +++ b/apps/wr/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/index.tsx @@ -33,7 +33,7 @@ export type rswtChkgdnState = { rswtHeadNm: chHeadType[]; excelList: [typeof sheetParameter]; rswtChkRes: rswtChkZodType[]; - rswtChkPolGuide:rswtChkZodType[]; + rswtChkPolGuide: rswtChkZodType[]; isInit: boolean; }; }; @@ -47,7 +47,8 @@ type rswtChkgdnActions = { rswtChkExceDataUpload: (excelData: rswtChkZodType[]) => void; rswtChkDelete: (chkgdnPks: number[]) => void; rswtChkDetilUpdate: (rswtChk: rswtChkZodType[]) => void; - rswtChkPolAndGuide:(chkGdnPk:number)=>void; + rswtChkPolAndGuide: (chkGdnPk: number) => void; + rwstUpdatePolAndGuide:(rswtChk: rswtChkZodType[]) => void; }; export type rswtChkgdnType = rswtChkgdnState & rswtChkgdnActions; @@ -58,7 +59,7 @@ export const rswtChkgdnStateExport: rswtChkgdnState = { rswtHeadNm: rswtHeadNm, excelList: [{ data: [[]], headerNum: 0, headerRange: "A1:V3" }], rswtChkRes: [], - rswtChkPolGuide:[], + rswtChkPolGuide: [], isInit: false, }, }; @@ -73,7 +74,7 @@ const initFetch = async (year: string | undefined, sgg: string | undefined) => { return rswtChkRes; }; -const makeMdfrChk = (data: rswtChkZodType[], type: string, toDo: string) => { +const makeMdfrChk = (data: rswtChkZodType[], type: string) => { const chData = data.map((item) => { item.mdfr = TEST_UUID; item.rgtr = TEST_UUID; @@ -82,10 +83,10 @@ const makeMdfrChk = (data: rswtChkZodType[], type: string, toDo: string) => { item.mdfr = TEST_UUID; item.rgtr = TEST_UUID; }); - } else { - } - }); - + } + return item; + } +); return chData; }; @@ -161,7 +162,7 @@ export const rswtChkgdnActionsExport: (set: any) => rswtChkgdnActions = ( }, rswtChkDetilUpdate: async (rswtChk: rswtChkZodType[]) => { try { - const chData = await makeMdfrChk(rswtChk, "rain", "rainDetil"); + const chData = await makeMdfrChk(rswtChk, "rswtrDetail"); const res = await postFectch("/reuseChk/reuseWater", chData); if (res.ok) { @@ -204,14 +205,14 @@ export const rswtChkgdnActionsExport: (set: any) => rswtChkgdnActions = ( } catch (error) { ToastFormUi({ body: "삭제를 실패했습니다.. ", title: "지도점검 삭제" }); } - }, rswtChkPolAndGuide: async (chkGdnPk: number) => { + }, + rswtChkPolAndGuide: async (chkGdnPk: number) => { try { const rswtChkPolGuide = await getFetch( "wr", `/reuseChk/reuseWater/${chkGdnPk}` ); - return set((state: rswtChkgdnState) => ({ ...state, rswtChkgdn: { @@ -219,7 +220,30 @@ export const rswtChkgdnActionsExport: (set: any) => rswtChkgdnActions = ( rswtChkPolGuide: rswtChkPolGuide, }, })); + } catch (error) {} + }, + rwstUpdatePolAndGuide: async (rswtChk: rswtChkZodType[]) => { + try { + const chData = await makeMdfrChk(rswtChk, "rswtrDetail"); + console.log("chData" , chData) + const res = await postFectch("/reuseChk/reuseWater", chData); + if (res.ok) { + ToastFormUi({ + body: "지도점검 연간 수질 및 보급수/중수도 수정이 완료되었습니다. ", + title: "지도점검 수정", + }); + } + const rswtChkRes = await initFetch("2024", "0"); + return set((state: rswtChkgdnState) => ({ + ...state, + rswtChkgdn: { + ...state.rswtChkgdn, + rswtChkRes: rswtChkRes, + }, + })); } catch (error) { + console.log(error); + alert("수정에 실패하였습니다."); } }, }; diff --git a/apps/wr/components/ui/form/fcltReg/rainReg/rainRegForm.tsx b/apps/wr/components/ui/form/fcltReg/rainReg/rainRegForm.tsx index 30249fa68..e1a1617a2 100644 --- a/apps/wr/components/ui/form/fcltReg/rainReg/rainRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/rainReg/rainRegForm.tsx @@ -15,7 +15,10 @@ import { useEffect, useState } from "react"; import { useForm, useWatch, type UseFormReturn } from "react-hook-form"; import { z } from "zod"; import BdstReg from "../bdstReg/bdstReg"; -import { formatCommaNumber, handleCommaNumberChange } from "@/components/lib/func/commom"; +import { + formatCommaNumber, + handleCommaNumberChange, +} from "@/components/lib/func/commom"; export default function RainRegForm({ rainForm, @@ -24,7 +27,9 @@ export default function RainRegForm({ rainForm: customRainBdst; isModal: boolean; }) { - const { code, rainBdstReg, rainBdstUpdate, rain } = useWrStore((state) => state); + const { code, rainBdstReg, rainBdstUpdate, rain } = useWrStore( + (state) => state + ); const { rainFcltCd } = code; const defaultValues: z.infer = rainZod.parse({}); @@ -39,43 +44,47 @@ export default function RainRegForm({ "reuseBuilding.0.rainyObj.filtrTrtmfctYn", ]); - const cleanRainData =(raw: any): z.infer =>{ - return { - ...raw, - frstArchPrmsnDt: new Date(raw?.frstArchPrmsnDt||null), - archChgPrmsnDt: raw?.archChgPrmsnDt ? new Date(raw?.archChgPrmsnDt) : null, - reuseBuilding: (raw?.reuseBuilding || []).map((item: any) => ({ - ...item, - instlCmptnDt: new Date(item?.instlCmptnDt), - operMngCd: item?.operMngCd ?? "", // null → "" - grntchBdstCertYr: typeof item?.grntchBdstCertYr === "string" + const cleanRainData = (raw: any): z.infer => { + return { + ...raw, + frstArchPrmsnDt: new Date(raw?.frstArchPrmsnDt || null), + archChgPrmsnDt: raw?.archChgPrmsnDt + ? new Date(raw?.archChgPrmsnDt) + : null, + reuseBuilding: (raw?.reuseBuilding || []).map((item: any) => ({ + ...item, + instlCmptnDt: new Date(item?.instlCmptnDt), + operMngCd: item?.operMngCd ?? "", // null → "" + grntchBdstCertYr: + typeof item?.grntchBdstCertYr === "string" ? item?.grntchBdstCertYr : "", // null → "" - rainObj: { - ...item?.rainObj - } - })) - }; + rainObj: { + ...item?.rainObj, + }, + })), + }; + }; + + useEffect(() => { + if (grntchBdstCertYn === "N") { + form.setValue("reuseBuilding.0.grntchBdstCertYr", ""); + form.setValue("reuseBuilding.0.grntchBdstCertNo", ""); + form.setValue("reuseBuilding.0.grntchBdstCertGrd", ""); + } else if (instlCstSprtYn === "N") { + form.setValue("reuseBuilding.0.instlCstSprtAmt", 0); + } else if (filtrTrtmfctYn === "N") { + form.setValue("reuseBuilding.0.rainyObj.filtrTrtmfctCpct", 0); + form.setValue("reuseBuilding.0.rainyObj.filtrTrtmfctPrs", ""); } - -useEffect(() =>{ - if(grntchBdstCertYn ==='N'){ - form.setValue('reuseBuilding.0.grntchBdstCertYr' ,"" ) - form.setValue('reuseBuilding.0.grntchBdstCertNo' ,"" ) - form.setValue('reuseBuilding.0.grntchBdstCertGrd' ,"" ) - - }else if(instlCstSprtYn ==='N'){ - form.setValue('reuseBuilding.0.instlCstSprtAmt' ,0 ) - }else if(filtrTrtmfctYn ==='N'){ - form.setValue('reuseBuilding.0.rainyObj.filtrTrtmfctCpct' ,0 ) - form.setValue('reuseBuilding.0.rainyObj.filtrTrtmfctPrs' ,"" ) - } -},[grntchBdstCertYn,instlCstSprtYn ,filtrTrtmfctYn]) - + }, [grntchBdstCertYn, instlCstSprtYn, filtrTrtmfctYn]); // form 값이 변경될 때마다 로그 출력 useEffect(() => { - const subscription = form.watch((value) => {}); + const subscription = form.watch((value) => { + }); + + return () => subscription.unsubscribe(); }, [form]); @@ -83,26 +92,19 @@ useEffect(() =>{ console.log("form errors:", form.formState.errors); }, [form.formState.errors]); - - - - const onSubmit =(values: z.infer)=> { + const onSubmit = (values: z.infer) => { if (isModal) { - rainBdstReg(values ,'41'); + rainBdstReg(values, "41"); } else { - rainBdstUpdate(values, '41'); - } - } - + rainBdstUpdate(values, "41"); + } + }; useEffect(() => { - if(rainZod) - form.reset( cleanRainData(rainForm)) + if (rainZod) form.reset(cleanRainData(rainForm)); }, [rainForm]); - - - const inputClass = '!text-lg' + const inputClass = "!text-lg"; return (
@@ -137,7 +139,7 @@ useEffect(() =>{ name="reuseBuilding.0.instlCmptnDt" render={({ field }) => ( - { : new Date(), // Provide a default Date value onChange: (date) => field.onChange(date), }} - selectClass={'w-full'} + selectClass={"w-full"} /> )} @@ -160,11 +162,13 @@ useEffect(() =>{ render={({ field }) => ( {handleCommaNumberChange(e, field.onChange) }} - value={formatCommaNumber(field.value)} + className={selectClass} + placeholder="1,000,000" + type="text" + onChange={(e) => { + handleCommaNumberChange(e, field.onChange); + }} + value={formatCommaNumber(field.value)} /> )} @@ -193,7 +197,6 @@ useEffect(() =>{ selectArray={rainFcltCd} onSelectValue={field.onChange} value={field.value ?? rainFcltCd[0]?.val} - /> )} @@ -209,7 +212,9 @@ useEffect(() =>{ className={selectClass} placeholder="1,000,000" type="text" - onChange={(e) => {handleCommaNumberChange(e, field.onChange) }} + onChange={(e) => { + handleCommaNumberChange(e, field.onChange); + }} value={formatCommaNumber(field.value)} /> @@ -250,10 +255,11 @@ useEffect(() =>{ className={selectClass} placeholder="1,000,000" type="text" - onChange={(e) => {handleCommaNumberChange(e, field.onChange) }} + onChange={(e) => { + handleCommaNumberChange(e, field.onChange); + }} value={formatCommaNumber(field.value)} - readOnly={filtrTrtmfctYn!=='Y'} - + readOnly={filtrTrtmfctYn !== "Y"} /> )} @@ -268,10 +274,10 @@ useEffect(() =>{ )} @@ -300,7 +306,6 @@ useEffect(() =>{ selectArray={code.yn} onSelectValue={field.onChange} value={field.value ?? code.yn[0]?.val} - /> )} @@ -316,9 +321,11 @@ useEffect(() =>{ className={selectClass} placeholder="1,000,000" type="text" - onChange={(e) => {handleCommaNumberChange(e, field.onChange) }} + onChange={(e) => { + handleCommaNumberChange(e, field.onChange); + }} value={formatCommaNumber(field.value)} - readOnly={instlCstSprtYn !== 'Y'} + readOnly={instlCstSprtYn !== "Y"} /> )} @@ -354,10 +361,14 @@ useEffect(() =>{ name="reuseBuilding.0.grntchBdstCertYr" render={({ field }) => ( - + )} /> @@ -374,7 +385,7 @@ useEffect(() =>{ type="" value={field.value ?? ""} onChange={field.onChange} - readOnly={grntchBdstCertYn!=='Y'} + readOnly={grntchBdstCertYn !== "Y"} /> )} @@ -386,10 +397,14 @@ useEffect(() =>{ name="reuseBuilding.0.grntchBdstCertGrd" render={({ field }) => ( - + readOnly={grntchBdstCertYn !== "Y"} + /> )} /> diff --git a/apps/wr/components/ui/modal/chkgd/chkgdModal/chkgdModal.tsx b/apps/wr/components/ui/modal/chkgd/chkgdModal/chkgdModal.tsx index 4ec22d8b7..d12de4cee 100644 --- a/apps/wr/components/ui/modal/chkgd/chkgdModal/chkgdModal.tsx +++ b/apps/wr/components/ui/modal/chkgd/chkgdModal/chkgdModal.tsx @@ -1,27 +1,33 @@ import { useWrStore } from "@/app/store"; -import { ScrollArea, Title, UiTable } from "@common/business_components/ui"; +import { ScrollArea, Title } from "@common/business_components/ui"; import { Button } from "@common/components/ui"; import { useEffect, useState } from "react"; import { headMakeprfmnc } from "@/app/ruseFcltMng/prfmncReg/chkgdnReg/TableHead"; import { GuideDetailsTable } from "@/components/ui/table/chkgdTable/guideDetailTable/guideDetailTable"; -import type { - polutionType, - splRuseWaterType, -} from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList"; +import type { splRuseWaterType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList"; import type { rswtrPolutionsZode } from "@/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/headList"; import type { z } from "zod"; +import React from "react"; export default function ChkgdModal({ type, obj }: { type: string; obj: any }) { - const { rainChkgdn, rainChkDetilUpdate, rainChkGuidUpdate } = useWrStore( + const { rainChkgdn, rainChkGuidUpdate ,rwstUpdatePolAndGuide } = useWrStore( (state) => state ); const [guidData, setGuidData] = useState(); + const [polutionData, setPolutionData] = useState>({ - "1": [], - "2": [], - "3": [], - "4": [], + "1": [] as z.infer[], + "2": [] as z.infer[], + "3": [] as z.infer[], + "4": [] as z.infer[], }); + const [upPolutionData, setUpPolutionData] = useState>({ + "1": [] as z.infer[], + "2": [] as z.infer[], + "3": [] as z.infer[], + "4": [] as z.infer[], + }); + const rswtnodeList = headMakeprfmnc( rainChkgdn?.rswtDetailHeadList, @@ -80,7 +86,7 @@ export default function ChkgdModal({ type, obj }: { type: string; obj: any }) { "3": [], "4": [], }; - obj.rswtrPollution.forEach((item: any) => { + obj.rswtrPollution.forEach((item: z.infer) => { const nodeKey = String(item.node); resultPolution[nodeKey]?.push(item); }); @@ -106,6 +112,7 @@ export default function ChkgdModal({ type, obj }: { type: string; obj: any }) { const average = { utztnUsgCd: "평균", + edit: false, grssClfgUswtr: total.grssClfgUswtr / onlyData.length, combResdch: total.combResdch / onlyData.length, trbt: total.trbt / onlyData.length, @@ -128,7 +135,6 @@ export default function ChkgdModal({ type, obj }: { type: string; obj: any }) { } }, [obj]); - const cellClick = (val: number | undefined, headId: string) => {}; const setChGuidData = (data: splRuseWaterType[]) => { if (data.length > 0) { @@ -136,7 +142,7 @@ export default function ChkgdModal({ type, obj }: { type: string; obj: any }) { } }; - const guidDataUpdate = () => { + const allDataUpdate = () => { const realGuideDetail = obj.guideDetails; if (updateData === undefined || updateData.length === 0) return; @@ -167,18 +173,37 @@ export default function ChkgdModal({ type, obj }: { type: string; obj: any }) { }); obj.guideDetails = realGuideDetail; - rainChk.map((item: any) => { - if (item.chkgdnPk === obj.chkgdnPk) { - item.guideDetails = realGuideDetail; - } - }); + - rainChkGuidUpdate(obj); + if(type ==='RNB'){ + + rainChkGuidUpdate(obj); + }else{ + + + const polution = Object.values(upPolutionData).flat() ; + obj.rswtrPollution = polution; + + console.log("obj ", obj) + rwstUpdatePolAndGuide([obj]); + } }; - useEffect(() => { - console.log("/polutionData ", polutionData); - }, [polutionData]); + + + const getPolutionData = (data: z.infer[]) => { + console.log("data " ,data) + const getNode = Number(data[0]?.node) + setUpPolutionData((prevPolutionData) => ({ + ...prevPolutionData, + [getNode]: data, + })); + + }; + + useEffect(() =>{ + console.log('upPolutionData ', upPolutionData) + },[upPolutionData]) return ( <> @@ -197,23 +222,32 @@ export default function ChkgdModal({ type, obj }: { type: string; obj: any }) { {"○" + "" + `(${"11"})`} -
+
+

+ {`연간보급수이용량`} +

+
{ setChGuidData(data); }} /> - +
+

+ {type === "RNB" ? `연간빗물 이용량` : "연간중수도 이용량"} +

+
{ @@ -221,60 +255,29 @@ export default function ChkgdModal({ type, obj }: { type: string; obj: any }) { }} /> - {type !== "RNB" ? ( -
-
-

- {"연간이용수질 1분기"} -

-
- { - setChGuidData(data); - }} - /> -
-

- {"연간이용수질 2분기"} -

-
- { - setChGuidData(data); - }} - /> -
-

- {"연간이용수질 3분기"} -

-
- { - setChGuidData(data); - }} - /> -
-

- {"연간이용수질 4분기"} -

-
- { - setChGuidData(data); - }} - /> + {type !== "RNB" && polutionData !== undefined ? ( +
+ {Object.entries(polutionData).map(([key, value]) => { + const keyNum = Number(key); + + return ( + +
+

+ {`연간이용수질 ${keyNum}분기`} +

+
+ { + getPolutionData(data); + }} + /> +
+ ); + })}
) : ( <> diff --git a/apps/wr/components/ui/table/chkgdTable/guideDetailTable/guideDetailTable.tsx b/apps/wr/components/ui/table/chkgdTable/guideDetailTable/guideDetailTable.tsx index abcc28cbe..b66a24abf 100644 --- a/apps/wr/components/ui/table/chkgdTable/guideDetailTable/guideDetailTable.tsx +++ b/apps/wr/components/ui/table/chkgdTable/guideDetailTable/guideDetailTable.tsx @@ -3,7 +3,6 @@ import { headMakeprfmnc } from "@/app/ruseFcltMng/prfmncReg/chkgdnReg/TableHead" import { useWrStore } from "@/app/store"; import type { } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn"; -import type { splRuseWaterType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList"; import type { TableUpperProps } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; import { Input, @@ -13,7 +12,7 @@ import { TableHeader, TableRow, } from "@common/components/ui"; -import { use, useEffect, useState } from "react"; +import { useEffect, useState } from "react"; export function GuideDetailsTable({ chgRes, @@ -22,7 +21,7 @@ export function GuideDetailsTable({ setChGuidData, }: { chgRes: any[]; - headList: TableUpperProps[]; + headList: TableUpperProps[]; type: string; setChGuidData: (chgRes: any[]) => void; }) { @@ -58,14 +57,25 @@ export function GuideDetailsTable({ {chgRes.map((data, dataIndex) => ( {headList.map((head, headIndex) => ( - + + {head.edit ===true && data.edit !==false? - (dataIndex, head.id as any, e.target.value) + handleChange(dataIndex, head.id, e.target.value) } value={data[head.id as keyof any] || ""} - /> + /> : ( +
+ {data[head.id as keyof any] || ""} +
+ ) + }
))}