78 lines
2.4 KiB
TypeScript
78 lines
2.4 KiB
TypeScript
import { useWrStore } from "@/app/store";
|
|
import { rainMapSize } from "@/app/store/map/rainMap";
|
|
import type { customHtdflBdst } from "@/app/store/ruseFcltMng/fcltReg/htdflReg";
|
|
import { tableData } from "@/components/lib/func/commom";
|
|
import { Title, UiTable } from "@common/business_components/ui";
|
|
import { HeadMakeColSpan } from "@common/business_components/ui/table/HeadMakeColSpan";
|
|
import { useEffect, useState } from "react";
|
|
|
|
export function HtdflFacility({
|
|
rtnFeature,
|
|
}: {
|
|
rtnFeature: (feature: any) => void;
|
|
}) {
|
|
const { code, htdfMap, htdfMapInit } = useWrStore((state) => state);
|
|
const { htdfMapCount, htdfMapRes, htdfSttHeadList, htdfSttNodeList } =
|
|
htdfMap;
|
|
const [htdflTable, setHtdflTable] = useState<customHtdflBdst[]>();
|
|
const [isReset, setIsReset] = useState(false);
|
|
|
|
const htdflCellClick = (index: number | undefined) => {
|
|
if (index !== undefined && htdflTable !== undefined) {
|
|
rtnFeature(htdflTable[index]);
|
|
|
|
}
|
|
};
|
|
|
|
useEffect(() => {
|
|
if (!htdfMap.isInit) {
|
|
htdfMapInit(1, rainMapSize, "0");
|
|
}
|
|
}, [htdfMap.isInit, htdfMapInit]);
|
|
|
|
useEffect(() => {
|
|
const data = tableData(htdfMapRes, { code });
|
|
const chData = data
|
|
.map((item: any) => ({
|
|
...item,
|
|
...item.reuseBuilding[0],
|
|
...item.reuseBuilding[0].htdflObj,
|
|
chBuildingYn: item.chgBuilding[0]?.bdstChgNm !== null ? "Y" : "N",
|
|
}))
|
|
.filter((item: any) => item.htdflObj !== undefined);
|
|
setHtdflTable(chData);
|
|
}, [code, htdfMapRes]);
|
|
|
|
return (
|
|
<>
|
|
<div style={{ overflowY: "auto" }}>
|
|
<div className="flex justify-between items-center">
|
|
<Title title="온배수시설 현황" />
|
|
{/* <div className="flex gap-2 mt-8">
|
|
<Button className={btnClass} color="primary" onClick={excelClick}>
|
|
엑셀다운로드
|
|
</Button>
|
|
</div> */}
|
|
</div>
|
|
<UiTable
|
|
headName={[]}
|
|
tableData={htdflTable || []}
|
|
headlist={htdfSttHeadList}
|
|
pageSize={rainMapSize}
|
|
total={htdfMapCount}
|
|
cellClick={(index: number | undefined) => {
|
|
htdflCellClick(index ?? undefined);
|
|
}}
|
|
onPageChange={(page) => {
|
|
htdfMapInit(page, rainMapSize, "0");
|
|
setIsReset(false);
|
|
}}
|
|
resetPageNo={isReset}
|
|
>
|
|
<HeadMakeColSpan upHeadList={htdfSttNodeList} />
|
|
</UiTable>
|
|
</div>
|
|
</>
|
|
);
|
|
}
|