온배수 현황 및 중수도 지도점검 작업중
This commit is contained in:
@@ -5,7 +5,7 @@ import type { rainChkZodType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn"
|
||||
import { tableData } from "@/components/lib/func/commom";
|
||||
import {
|
||||
chRowspanTable,
|
||||
rightTableData
|
||||
rainChkTableData
|
||||
} from "@/components/lib/func/TableData";
|
||||
import {
|
||||
Table,
|
||||
@@ -66,13 +66,11 @@ export default function RainChkgdTable({
|
||||
rowspan: item.rainyDetails?.length,
|
||||
};
|
||||
});
|
||||
const tableTotalData = rightTableData(rainChg)
|
||||
const tableTotalData = rainChkTableData(rainChg)
|
||||
setMakeTableData(tableTotalData);
|
||||
}, [rainChkgdn.rainChk, code]);
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
|
||||
//데이터를 평탄화 한것중에 체크박스 선택한 테이블만 선택
|
||||
const selectedData = makeTableData.filter((item) =>selectedIds.includes(item.chkgdnPk));
|
||||
|
||||
@@ -132,10 +130,6 @@ export default function RainChkgdTable({
|
||||
}
|
||||
},[selectedIds])
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
},[])
|
||||
|
||||
|
||||
return (
|
||||
<Table variant="secondary">
|
||||
|
||||
@@ -1,30 +1,79 @@
|
||||
'use client'
|
||||
"use client";
|
||||
|
||||
import { headMakeprfmnc } from "@/app/ruseFcltMng/prfmncReg/chkgdnReg/TableHead";
|
||||
import { useWrStore } from "@/app/store";
|
||||
import { UiTable } from "@common/business_components/ui";
|
||||
import type { rswtChkZodType } from "@/app/store/prfmncReg/chkgdnReg/rswrtChkgdn";
|
||||
import { chRowspanTable } from "@/components/lib/func/TableData";
|
||||
import { Table, TableBody, TableHeader } from "@common/components/ui";
|
||||
import { useCallback, useState } from "react";
|
||||
|
||||
export default function RswtChkgdTable() {
|
||||
export default function RswtChkgdTable({
|
||||
detaiRswtlUpdate,
|
||||
handleRswtClick = () => {},
|
||||
deleteRswtData,
|
||||
}: {
|
||||
detaiRswtlUpdate: (data: rswtChkZodType[]) => void;
|
||||
handleRswtClick?: (data: any) => void;
|
||||
deleteRswtData: (selectedIds: number[]) => void;
|
||||
}) {
|
||||
const { code, rswtChkgdn, rswtChkgdnInit } = useWrStore((state) => state);
|
||||
|
||||
const { rswtChkgdn} = useWrStore((state) => state);
|
||||
const nodeList = headMakeprfmnc(rswtChkgdn?.rswtChkgdnHeadList , rswtChkgdn?.rswtHeadNm );
|
||||
|
||||
const [makeTableData, setMakeTableData] = useState<any[]>([]);
|
||||
const [selectedIds, setSelectedIds] = useState<number[]>([]);
|
||||
const [upRaintDetail, setUpRaintDetail] = useState<rswtChkZodType[]>([]);
|
||||
const toggleSelection = (pk: number, checked: boolean) => {
|
||||
setSelectedIds((prev) =>
|
||||
checked ? [...prev, pk] : prev.filter((item) => item !== pk)
|
||||
);
|
||||
};
|
||||
const handleChange = (
|
||||
rowIndex: number,
|
||||
field: keyof (typeof makeTableData)[0],
|
||||
value: string | number
|
||||
) => {
|
||||
setMakeTableData((prev) =>
|
||||
prev.map((row, idx) => {
|
||||
return idx === rowIndex ? { ...row, [field]: value } : row;
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
return(
|
||||
|
||||
<>
|
||||
<UiTable
|
||||
tableData={[]}
|
||||
headlist={rswtChkgdn.rswtChkgdnHeadList}
|
||||
pageSize={100}
|
||||
total={10}
|
||||
headName={"지도점검 결과등록"}
|
||||
cellClick={() => { } } onPageChange={function (page: number): void {
|
||||
throw new Error("Function not implemented.");
|
||||
} } >
|
||||
{nodeList}
|
||||
</UiTable>
|
||||
</>
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
const handleCellClick = useCallback(
|
||||
(index: number, headId: string) => {
|
||||
if (
|
||||
headId === "totalSplyUswtrUtztnQnt" ||
|
||||
headId === "totalRuseFcltUtztnQnt"
|
||||
) {
|
||||
handleRswtClick(makeTableData[index]);
|
||||
}
|
||||
},
|
||||
[makeTableData, handleRswtClick]
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
<Table variant="secondary">
|
||||
<TableHeader className="font-bold">
|
||||
{headMakeprfmnc(rswtChkgdn?.rswtChkHeadList, rswtChkgdn?.rswtHeadNm)}
|
||||
</TableHeader>
|
||||
|
||||
<TableBody>
|
||||
{chRowspanTable(
|
||||
makeTableData,
|
||||
rswtChkgdn.rswtChkHeadList,
|
||||
handleChange,
|
||||
toggleSelection,
|
||||
selectedIds,
|
||||
handleCellClick
|
||||
)}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user