지도점검 현황 작업중
This commit is contained in:
@@ -97,6 +97,10 @@ export default function ChkgdExcel({ type }: { type: string }) {
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
console.log("total data ", totalData)
|
||||
|
||||
console.log("polutionData data ", polutionData)
|
||||
const guideKey = new Set(guideData.map(keyGenerator));
|
||||
|
||||
const onlypolution = polutionData.filter(
|
||||
@@ -107,8 +111,7 @@ export default function ChkgdExcel({ type }: { type: string }) {
|
||||
...totalData,
|
||||
...onlypolution
|
||||
]
|
||||
|
||||
setExcelRswtData(listTotalData);
|
||||
setExcelRswtData(listTotalData);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -10,9 +10,8 @@ import type { z } from "zod";
|
||||
import React from "react";
|
||||
|
||||
export default function ChkgdModal({ type, obj }: { type: string; obj: any }) {
|
||||
const { rainChkgdn, rainChkGuidUpdate ,rwstUpdatePolAndGuide } = useWrStore(
|
||||
(state) => state
|
||||
);
|
||||
const { rainChkgdn, rswtChkgdn, rainChkGuidUpdate, rwstPolAndGuideUpdate } =
|
||||
useWrStore((state) => state);
|
||||
const [guidData, setGuidData] = useState<splRuseWaterType[]>();
|
||||
|
||||
const [polutionData, setPolutionData] = useState<Record<string, any[]>>({
|
||||
@@ -28,12 +27,6 @@ export default function ChkgdModal({ type, obj }: { type: string; obj: any }) {
|
||||
"4": [] as z.infer<typeof rswtrPolutionsZode>[],
|
||||
});
|
||||
|
||||
|
||||
const rswtnodeList = headMakeprfmnc(
|
||||
rainChkgdn?.rswtDetailHeadList,
|
||||
rainChkgdn?.rainHeadNm
|
||||
);
|
||||
|
||||
const { rainChk, ruseHeadList, splHeadList } = rainChkgdn;
|
||||
const [updateData, setUpdateData] = useState<splRuseWaterType[]>();
|
||||
|
||||
@@ -79,17 +72,19 @@ export default function ChkgdModal({ type, obj }: { type: string; obj: any }) {
|
||||
}, []);
|
||||
setGuidData(result);
|
||||
|
||||
if (obj.rswtrPollution) {
|
||||
if (obj.rswtrPollutions) {
|
||||
const resultPolution: Record<string, any[]> = {
|
||||
"1": [],
|
||||
"2": [],
|
||||
"3": [],
|
||||
"4": [],
|
||||
};
|
||||
obj.rswtrPollution.forEach((item: z.infer<typeof rswtrPolutionsZode>) => {
|
||||
const nodeKey = String(item.node);
|
||||
resultPolution[nodeKey]?.push(item);
|
||||
});
|
||||
obj.rswtrPollutions.forEach(
|
||||
(item: z.infer<typeof rswtrPolutionsZode>) => {
|
||||
const nodeKey = String(item.node);
|
||||
resultPolution[nodeKey]?.push(item);
|
||||
}
|
||||
);
|
||||
|
||||
// 각 노드에 대해 합계/평균 추가
|
||||
Object.entries(resultPolution).forEach(([nodeKey, items]) => {
|
||||
@@ -135,7 +130,6 @@ export default function ChkgdModal({ type, obj }: { type: string; obj: any }) {
|
||||
}
|
||||
}, [obj]);
|
||||
|
||||
|
||||
const setChGuidData = (data: splRuseWaterType[]) => {
|
||||
if (data.length > 0) {
|
||||
setUpdateData(data);
|
||||
@@ -152,10 +146,6 @@ export default function ChkgdModal({ type, obj }: { type: string; obj: any }) {
|
||||
);
|
||||
|
||||
const month = item.ym?.slice(4);
|
||||
|
||||
if (month === undefined || month === null) {
|
||||
console.log("month ", month);
|
||||
}
|
||||
if (findObj) {
|
||||
const ruseMonthKey = `ruse${month}` as keyof splRuseWaterType;
|
||||
const splMonthKey = `spl${month}` as keyof splRuseWaterType;
|
||||
@@ -172,39 +162,25 @@ export default function ChkgdModal({ type, obj }: { type: string; obj: any }) {
|
||||
}
|
||||
});
|
||||
obj.guideDetails = realGuideDetail;
|
||||
|
||||
|
||||
|
||||
if(type ==='RNB'){
|
||||
|
||||
if (type === "RNB") {
|
||||
rainChkGuidUpdate(obj);
|
||||
}else{
|
||||
|
||||
|
||||
const polution = Object.values(upPolutionData).flat() ;
|
||||
obj.rswtrPollution = polution;
|
||||
|
||||
console.log("obj ", obj)
|
||||
rwstUpdatePolAndGuide([obj]);
|
||||
} else {
|
||||
const polution = Object.values(upPolutionData)
|
||||
.flat()
|
||||
.filter((item) => item.utztnUsgCd !== "평균");
|
||||
obj.rswtrPollutions = polution;
|
||||
rwstPolAndGuideUpdate([obj]);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
const getPolutionData = (data: z.infer<typeof rswtrPolutionsZode>[]) => {
|
||||
console.log("data " ,data)
|
||||
const getNode = Number(data[0]?.node)
|
||||
const getPolutionData = (data: z.infer<typeof rswtrPolutionsZode>[]) => {
|
||||
const getNode = Number(data[0]?.node);
|
||||
setUpPolutionData((prevPolutionData) => ({
|
||||
...prevPolutionData,
|
||||
[getNode]: data,
|
||||
}));
|
||||
|
||||
};
|
||||
|
||||
useEffect(() =>{
|
||||
console.log('upPolutionData ', upPolutionData)
|
||||
},[upPolutionData])
|
||||
|
||||
return (
|
||||
<>
|
||||
<div>
|
||||
@@ -219,12 +195,15 @@ export default function ChkgdModal({ type, obj }: { type: string; obj: any }) {
|
||||
</div>
|
||||
<div className="flex justify-between">
|
||||
<h3 className="text-2xl font-bold text-gray-900">
|
||||
{"○" + "" + `(${"11"})`}
|
||||
{"○" + "" + `(${obj.bdstNm})`}
|
||||
</h3>
|
||||
|
||||
<Button className="" onClick={allDataUpdate}>
|
||||
저장
|
||||
</Button>
|
||||
{!rainChkgdn.isSttn ? (
|
||||
<Button className="" onClick={allDataUpdate}>
|
||||
저장
|
||||
</Button>
|
||||
) : (
|
||||
<></>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<ScrollArea className="h-[60vh]">
|
||||
@@ -269,7 +248,7 @@ export default function ChkgdModal({ type, obj }: { type: string; obj: any }) {
|
||||
</div>
|
||||
<GuideDetailsTable
|
||||
chgRes={value}
|
||||
headList={rainChkgdn?.rswtDetailHeadList}
|
||||
headList={rswtChkgdn?.rswtDetailHeadList}
|
||||
type={""}
|
||||
setChGuidData={(data) => {
|
||||
getPolutionData(data);
|
||||
|
||||
@@ -9,8 +9,9 @@ import type { customHtdflBdst } from "@/app/store/ruseFcltMng/fcltReg/htdflReg";
|
||||
import { useWrStore } from "@/app/store";
|
||||
import { useEffect, useState } from "react";
|
||||
import type { CommonTableProps } from "@/app/store/common/type/headder";
|
||||
import { rainChkTableData } from "@/components/lib/func/TableData";
|
||||
import { rainChkTableData, rswtChkTableData } from "@/components/lib/func/TableData";
|
||||
import { HeadMakeColSpan } from "@common/business_components/ui/table/HeadMakeColSpan";
|
||||
import type { rswtChkZodType } from "@/app/store/prfmncReg/chkgdnReg/rswrtChkgdn";
|
||||
|
||||
export default function SttnDetailModal({
|
||||
type,
|
||||
@@ -19,7 +20,7 @@ export default function SttnDetailModal({
|
||||
type: string;
|
||||
formObj: any;
|
||||
}) {
|
||||
const { code, rainSttn, rswtSttn, rainSttnChkSearch } = useWrStore(
|
||||
const { code, rainSttn, rswtSttn, rainSttnChkSearch,rswtChkPolAndGuide } = useWrStore(
|
||||
(state) => state
|
||||
);
|
||||
const [detailData, setDetailData] = useState({
|
||||
@@ -33,6 +34,7 @@ export default function SttnDetailModal({
|
||||
rainSttnChkSearch(formObj.reuseBuilding[0].bdstRuseFcltPk);
|
||||
|
||||
} else if (type === "RST") {
|
||||
// rswtChkPolAndGuide(formObj.reuseBuilding[0].bdstRuseFcltPk)
|
||||
}
|
||||
}, [type, formObj]);
|
||||
|
||||
@@ -62,7 +64,16 @@ export default function SttnDetailModal({
|
||||
node:rainSttn.rainSttnDetailNodeList,
|
||||
data: data,
|
||||
});
|
||||
} else if (type === "RST") {
|
||||
} else if (type === "RST" && rswtSttn.rswtSttnRes) {
|
||||
// const tableTotalData = rswtChkTableData(rswtSttn.rswtSttnRes as unknown as rswtChkZodType[]);
|
||||
|
||||
// setDetailData({
|
||||
// head: rswtSttn.rswtSttHeadList,
|
||||
// node:rswtSttn.rswtSttNodeList,
|
||||
// // data: tableTotalData,
|
||||
// });
|
||||
|
||||
|
||||
}
|
||||
}, [rainSttn.rainChkRes]);
|
||||
|
||||
|
||||
@@ -50,8 +50,10 @@ export default function RainChkgdTable({
|
||||
headId === "totalSplyUswtrUtztnQnt" ||
|
||||
headId === "totalRuseFcltUtztnQnt"
|
||||
) {
|
||||
|
||||
handleClick(makeTableData[index])
|
||||
}
|
||||
|
||||
},[makeTableData, handleClick]);
|
||||
|
||||
|
||||
|
||||
@@ -1,27 +1,35 @@
|
||||
"use client";
|
||||
|
||||
import { headMakeprfmnc } from "@/app/ruseFcltMng/prfmncReg/chkgdnReg/TableHead";
|
||||
import { useWrStore } from "@/app/store";
|
||||
import type { rswtChkZodType } from "@/app/store/prfmncReg/chkgdnReg/rswrtChkgdn";
|
||||
import type {
|
||||
rswtrChkDetailsZodType,
|
||||
} from "@/app/store/prfmncReg/chkgdnReg/rswrtChkgdn";
|
||||
import { tableData } from "@/components/lib/func/commom";
|
||||
import { chRowspanTable, rswtChkTableData } from "@/components/lib/func/TableData";
|
||||
import {
|
||||
chRowspanTable,
|
||||
rswtChkTableData,
|
||||
} from "@/components/lib/func/TableData";
|
||||
import { Table, TableBody, TableHeader } from "@common/components/ui";
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
|
||||
export default function RswtChkgdTable({
|
||||
detaiRswtlUpdate,
|
||||
handleRswtClick = () => {},
|
||||
deleteRswtData,
|
||||
}: {
|
||||
detaiRswtlUpdate: (data: rswtChkZodType[]) => void;
|
||||
detaiRswtlUpdate: (data: rswtrChkDetailsZodType[]) => void;
|
||||
handleRswtClick?: (data: any) => void;
|
||||
deleteRswtData: (selectedIds: number[]) => void;
|
||||
}) {
|
||||
const { code, rswtChkgdn, rswtChkgdnInit,rswtChkPolAndGuide } = useWrStore((state) => state);
|
||||
const { code, rswtChkgdn, rswtChkgdnInit, rswtChkPolAndGuide } = useWrStore(
|
||||
(state) => state
|
||||
);
|
||||
|
||||
const [makeTableData, setMakeTableData] = useState<any[]>([]);
|
||||
const [selectedIds, setSelectedIds] = useState<number[]>([]);
|
||||
const [upRaintDetail, setUpRaintDetail] = useState<rswtChkZodType[]>([]);
|
||||
const [upRswttDetail, setUpRswttDetail] = useState<rswtrChkDetailsZodType[]>(
|
||||
[]
|
||||
);
|
||||
const toggleSelection = (pk: number, checked: boolean) => {
|
||||
setSelectedIds((prev) =>
|
||||
checked ? [...prev, pk] : prev.filter((item) => item !== pk)
|
||||
@@ -41,93 +49,57 @@ export default function RswtChkgdTable({
|
||||
|
||||
const handleCellClick = useCallback(
|
||||
(index: number, headId: string) => {
|
||||
if (
|
||||
headId === "splyUswtrUtztnQnt" ||
|
||||
headId === "ruseFcltUtztnQnt"
|
||||
) {
|
||||
//handleRswtClick(makeTableData[index]);
|
||||
rswtChkPolAndGuide(makeTableData[index].chkgdnPk)
|
||||
if (headId === "splyUswtrUtztnQnt" || headId === "ruseFcltUtztnQnt") {
|
||||
rswtChkPolAndGuide(makeTableData[index].chkgdnPk);
|
||||
}
|
||||
},
|
||||
[makeTableData, handleRswtClick]
|
||||
);
|
||||
useEffect(() =>{
|
||||
if(rswtChkgdn.rswtChkPolGuide.length > 0)
|
||||
handleRswtClick(rswtChkgdn.rswtChkPolGuide[0])
|
||||
},[rswtChkgdn.rswtChkPolGuide])
|
||||
useEffect(() => {
|
||||
if (rswtChkgdn.rswtChkPolGuide.length > 0)
|
||||
handleRswtClick(rswtChkgdn.rswtChkPolGuide[0]);
|
||||
}, [rswtChkgdn.rswtChkPolGuide]);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
//데이터를 평탄화 한것중에 체크박스 선택한 테이블만 선택
|
||||
const selectedData = makeTableData.filter((item) =>selectedIds.includes(item.chkgdnPk));
|
||||
|
||||
if (selectedData.length > 0) {
|
||||
const updateTableData = makeTableData
|
||||
.map((rc) => {
|
||||
const newRswtDetail = rc.rswtrDetail
|
||||
.map((rd:any) => {
|
||||
|
||||
// 변경 데이터는 평탄화한 데이터 즉 루트에 변경되어 있음 이용용도까지 잇음 그걸로 찾기
|
||||
const findRswt = selectedData.find(
|
||||
(sd) =>
|
||||
rd.chkgdnFk === sd.chkgdnPk && rd.utztnUsgCd === sd.utztnUsgCd
|
||||
);
|
||||
|
||||
if (findRswt != undefined) {
|
||||
console.log(findRswt)
|
||||
return {
|
||||
...rd,
|
||||
vltnDt: findRswt.vltnDt,
|
||||
vltnMttr: findRswt.vltnMttr,
|
||||
levyAmt: Number(findRswt.levyAmt),
|
||||
};
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
})
|
||||
.filter(Boolean);
|
||||
if (newRswtDetail[0] != undefined) {
|
||||
return {
|
||||
...rc,
|
||||
rswtrDetail: newRswtDetail,
|
||||
};
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
})
|
||||
.filter(Boolean);
|
||||
|
||||
|
||||
setUpRaintDetail(updateTableData as rswtChkZodType[]);
|
||||
}
|
||||
}, [makeTableData,selectedIds]);
|
||||
|
||||
useEffect(() => {
|
||||
setSelectedIds([])// 셀렉트 초기화를 위한 작업
|
||||
const tableTotalData = rswtChkTableData(rswtChkgdn.rswtChkRes)
|
||||
const rswtChkData = tableTotalData.map((item: any) => {
|
||||
const bud = tableData([item.building], { code });
|
||||
useEffect(() => {
|
||||
const selectedData = makeTableData
|
||||
.map((item) => {
|
||||
return {
|
||||
...item,
|
||||
...bud[0],
|
||||
rowspan: item.rswtrDetail?.length,
|
||||
chkgdnFk: item.chkgdnFk,
|
||||
utztnUsgCd: item.utztnUsgCd,
|
||||
vltnDt: item.vltnDt,
|
||||
vltnMttr: item.vltnMttr,
|
||||
levyAmt: Number(item.levyAmt),
|
||||
};
|
||||
});
|
||||
setMakeTableData(rswtChkData);
|
||||
}, [rswtChkgdn.rswtChkRes, code]);
|
||||
})
|
||||
.filter((item) => selectedIds.includes(item.chkgdnFk));
|
||||
|
||||
useEffect(() => {
|
||||
detaiRswtlUpdate(upRaintDetail);
|
||||
}, [upRaintDetail]);
|
||||
|
||||
useEffect(() =>{
|
||||
if(selectedIds.length >0){
|
||||
// 삭제를 위한 데이터 삽입
|
||||
deleteRswtData(selectedIds )
|
||||
}
|
||||
},[selectedIds])
|
||||
|
||||
if (selectedData) setUpRswttDetail(selectedData);
|
||||
}, [makeTableData, selectedIds]);
|
||||
|
||||
useEffect(() => {
|
||||
setSelectedIds([]); // 셀렉트 초기화를 위한 작업
|
||||
const tableTotalData = rswtChkTableData(rswtChkgdn.rswtChkRes);
|
||||
const rswtChkData = tableTotalData.map((item: any) => {
|
||||
const bud = tableData([item.building], { code });
|
||||
return {
|
||||
...item,
|
||||
...bud[0],
|
||||
rowspan: item.rswtrDetails?.length,
|
||||
};
|
||||
});
|
||||
setMakeTableData(rswtChkData);
|
||||
}, [rswtChkgdn.rswtChkRes, code]);
|
||||
|
||||
useEffect(() => {
|
||||
detaiRswtlUpdate(upRswttDetail);
|
||||
}, [upRswttDetail]);
|
||||
|
||||
useEffect(() => {
|
||||
if (selectedIds.length > 0) {
|
||||
// 삭제를 위한 데이터 삽입
|
||||
deleteRswtData(selectedIds);
|
||||
}
|
||||
}, [selectedIds]);
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
Reference in New Issue
Block a user