diff --git a/apps/sn/app/components/verticalTable.tsx b/apps/sn/app/components/verticalTable.tsx index ee27224ac..b792f3426 100644 --- a/apps/sn/app/components/verticalTable.tsx +++ b/apps/sn/app/components/verticalTable.tsx @@ -39,15 +39,15 @@ export function VerticalTable({ }: UiTableProps) { const [cur, setCur] = useState(1); const [formData, setFormData] = useState<{ [key: string]: string | number | boolean }>({}); - useEffect(() => { if (resetPageNo) { setCur(1); onPageChange(1); } }, [onPageChange, resetPageNo]); - + useEffect(() => { + console.log('data',tableData) if (tableData.length > 0 && tableData[0]) { setFormData(tableData[0] as { [key: string]: string | number | boolean }); } diff --git a/apps/sn/app/map/featureClickEventPopup.tsx b/apps/sn/app/map/featureClickEventPopup.tsx index f30d4cd78..545bc1697 100644 --- a/apps/sn/app/map/featureClickEventPopup.tsx +++ b/apps/sn/app/map/featureClickEventPopup.tsx @@ -2,80 +2,7 @@ import { VerticalTable } from "@/components/verticalTable"; import { Button, Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@common/components/ui"; import { useState } from "react"; -const RxTableColumn = [ - { id: 'FTR_CDE', title: '지형지물부호' }, - { id: 'FTR_IDN', title: '관리번호' }, - { id: 'HJD_CDE', title: '행정읍면동코드' }, - { id: 'SHT_NUM', title: '도엽번호' }, - { id: 'MNG_CDE', title: '관리기관코드' }, - { id: 'IST_YMD', title: '설치일자' }, - { id: 'SBA_CDE', title: '하수관용도' }, - { id: 'MOP_CDE', title: '관재질' }, - { id: 'LIT_CDE', title: '규모' }, - { id: 'FOR_CDE', title: '시설물형태' }, - { id: 'STD_DIP', title: '관경' }, - { id: 'STD_HOL', title: '가로길이' }, - { id: 'STD_VEL', title: '세로길이' }, - { id: 'BYC_LEN', title: '연장' }, - { id: 'BEG_DEP', title: '시점깊이' }, - { id: 'END_DEP', title: '종점깊이' }, - { id: 'SBK_HSL', title: '시점관저고' }, - { id: 'SBL_HSL', title: '종점관저고' }, - { id: 'PIP_SLP', title: '평균구배' }, - { id: 'SPH_LIN', title: '차선통로수' }, - { id: 'BST_ARA', title: '우수배수면적' }, - { id: 'DRT_ARA', title: '오수배수면적' }, - { id: 'SBQ_SPD', title: '우천시유속' }, - { id: 'SBR_SPD', title: '청천시유속' }, - { id: 'CNT_NUM', title: '공사번호' }, - { id: 'BOM_CDE', title: '시점맨홀지형지물부호' }, - { id: 'BOM_IDN', title: '시점맨홀관리번호' }, - { id: 'EOM_CDE', title: '중점맨홀지형지물부호' }, - { id: 'EOM_IDN', title: '중점맨홀관리번호' }, - { id: 'SYS_CHK', title: '대장초기화여부' }, - { id: 'PIP_LBL', title: '관라벨' }, - { id: 'IQT_CDE', title: '탐사구분' }, - { id: 'ORG_IDN', title: '기관관리번호' }, - { id: 'SRV_CHK', title: '인입관 유무' } -]; -const tableData = [ - { - FTR_CDE: "001", - FTR_IDN: "관리번호001", - HJD_CDE: "행정코드001", - SHT_NUM: "도엽번호001", - MNG_CDE: "관리기관001", - IST_YMD: "2025-04-16", - SBA_CDE: "하수관용도001", - MOP_CDE: "관재질001", - LIT_CDE: "규모001", - FOR_CDE: "시설물형태001", - STD_DIP: "300mm", - STD_HOL: "500mm", - STD_VEL: "1.2m/s", - BYC_LEN: "100m", - BEG_DEP: "1.5m", - END_DEP: "2.0m", - SBK_HSL: "50m", - SBL_HSL: "48m", - PIP_SLP: "2%", - SPH_LIN: "2개", - BST_ARA: "200㎡", - DRT_ARA: "150㎡", - SBQ_SPD: "3.5m/s", - SBR_SPD: "2.0m/s", - CNT_NUM: "공사번호001", - BOM_CDE: "맨홀지형지물부호001", - BOM_IDN: "맨홀관리번호001", - EOM_CDE: "중점맨홀지형지물부호001", - EOM_IDN: "중점맨홀관리번호001", - SYS_CHK: "초기화여부001", - PIP_LBL: "관라벨001", - IQT_CDE: "탐사구분001", - ORG_IDN: "기관관리번호001", - SRV_CHK: "인입관 유무001", - }, -]; +import { CommonTableColumn } from "./table"; const inputColumn = [ { id: "title", title: "설치주제", type: "select", options: ["BTL", "재정사업"] }, { id: "guyeok", title: "처리구역", type: "select", options: ["구역1", "구역2"] }, @@ -86,7 +13,7 @@ const inputColumn = [ { id: "place", title: "매설위치", type: "select", options: ["도로", "하상"] }, ]; -const FeatureClickEventPopup = ({ onClose }: { onClose: () => void }) => { +const FeatureClickEventPopup = ({ onClose, featureData }: { onClose: () => void, featureData:any }) => { // TODO: 런타임 에러 해결 필요 const [repairData, setRepairData] = useState([ { year: "2025", type: "개대체" }, @@ -119,7 +46,18 @@ const FeatureClickEventPopup = ({ onClose }: { onClose: () => void }) => { updateData(inspectionData, setInspectionData); } }; - + function transformFeatureDataToArray(featureData: any, keys: string[]) { + // 필요한 키만 추출하여 새로운 객체 생성 + const transformedData = keys.reduce((acc, key) => { + acc[key] = featureData[key] !== undefined ? featureData[key] : "N/A"; // 값이 없으면 "N/A"로 처리 + return acc; + }, {} as Record); + + // 배열로 감싸서 반환 + return [transformedData]; + } + const keys = CommonTableColumn.map((column) => column.id); + const transformedFeatureData = transformFeatureDataToArray(featureData, keys); const renderSection = (title: string, data: { year: string; type: string }[], sectionKey: string) => (
{/* 섹션 제목 */} @@ -170,7 +108,7 @@ const FeatureClickEventPopup = ({ onClose }: { onClose: () => void }) => {
- new GisApp.core({ targetId: mapRef.current }), []); //const [treeData, setTreeData] = useState([]); const checkedLayerIds = useRef([]); let gisMap = null; const closePopup = () => { setIsOpen(false); // 팝업 닫기 + setFeatureData(null) }; + const handleFeatureSelect = (data) => { + console.log('check',data) + setFeatureData(data); // 선택된 피처 데이터 저장 + setIsOpen(true); // 팝업 열기 + }; + useEffect(() => { if (!mapRef.current) return; @@ -101,7 +109,7 @@ function Gis({ treeData = [], isSearch = false }) { //setTreeData(data); const layerItems = getLayerItems(layerCode); - //setEditLayerItems(prev => [...layerItems]); + //setEditLayerItems(prev => [...layerItems]) }, [treeData]); const getLayerItems= (layerCode) => { @@ -135,8 +143,10 @@ function Gis({ treeData = [], isSearch = false }) {
- {isOpen && ( + + {isOpen && featureData && ( )} @@ -144,7 +154,6 @@ function Gis({ treeData = [], isSearch = false }) { -
diff --git a/packages/common/business_components/src/ui/map/GisContent.js b/packages/common/business_components/src/ui/map/GisContent.js index e58efcaad..686a3ae70 100644 --- a/packages/common/business_components/src/ui/map/GisContent.js +++ b/packages/common/business_components/src/ui/map/GisContent.js @@ -8,7 +8,7 @@ import './lib/css/gis.edit.css'; import MapToggleBtn from './MapToggleBtn'; import GisEdit from './GisEdit'; -export default function GisContent({ edit = false }) { +export default function GisContent({ edit = false,onFeatureSelect }) { const { gisMap, gisCore } = useGisContext(); const [visibleComponents, setVisibleComponents] = useState({}); const addressResultLayer = useRef(null); @@ -54,7 +54,7 @@ export default function GisContent({ edit = false }) { {/* */} {/* { */} {/* */} - + {/* {edit && } */} ); diff --git a/packages/common/business_components/src/ui/map/GisSelect.js b/packages/common/business_components/src/ui/map/GisSelect.js index ae4e15966..3b430fa02 100644 --- a/packages/common/business_components/src/ui/map/GisSelect.js +++ b/packages/common/business_components/src/ui/map/GisSelect.js @@ -3,7 +3,7 @@ import GisApp from './lib/gis.core'; import GisOlSelect from './lib/gis.select'; import { useContext } from 'react'; import { GisContext } from './Gis'; -export default React.memo(function GisSelect() { +export default React.memo(function GisSelect({ onFeatureSelect }) { const { gisMap } = useContext(GisContext); const select = new GisOlSelect(gisMap); GisApp.Module.select = select; @@ -13,6 +13,10 @@ export default React.memo(function GisSelect() { select.getSelectedInfo(function (features) { //clickFeature(features[0]); + if(features.length > 0) { + const layer = features[0]; + onFeatureSelect(layer.getProperties()); //피쳐 속성데이터 상위컴포넌트로 전달 + } }); return ( <>