100 lines
3.4 KiB
TypeScript
100 lines
3.4 KiB
TypeScript
'use client'
|
|
import { VerticalTable } from '@/components/ui/verticalTable';
|
|
import React, { useState, useEffect } from 'react'
|
|
import InputSection from '../InputSection';
|
|
import { handleInputChange } from '../common';
|
|
|
|
// 하수관로
|
|
const inputColumn = [
|
|
{ id: "instlMbdyCd", title: "설치주제", type: "select", options: ["BTL", "재정사업"] },
|
|
{ id: "swtrmtZoneCd", title: "처리구역", type: "input" },
|
|
{ id: "mltvZoneNm", title: "배수구역", type: "input" },
|
|
{ id: "mltvDtdvNm", title: "배수분구", type: "input" },
|
|
{ id: "lineCd", title: "지선/간선", type: "select", options: ["지선", "간선"] },
|
|
{ id: "floCd", title: "흐름방식", type: "select", options: ["자연유하", "압송"] },
|
|
{ id: "layCd", title: "매설위치", type: "select", options: ["도로", "하상"] },
|
|
];
|
|
|
|
const MsSwagePpl = ({ featureData, onSaveClick }: { featureData: any, onSaveClick?: () => void }) => {
|
|
const [repairData, setRepairData] = useState([
|
|
{ year: "2025", type: "개대체" },
|
|
{ year: "2025", type: "보수" },
|
|
]);
|
|
const [cleaningData, setCleaningData] = useState([
|
|
{ year: "2025", type: "청소" },
|
|
{ year: "2025", type: "준설" },
|
|
]);
|
|
const [inspectionData, setInspectionData] = useState([
|
|
{ year: "2025", type: "관로기술진단" },
|
|
{ year: "2025", type: "관로기술진단" },
|
|
]);
|
|
const dataMap = {
|
|
repair: { data: repairData, setData: setRepairData },
|
|
cleaning: { data: cleaningData, setData: setCleaningData },
|
|
inspection: { data: inspectionData, setData: setInspectionData },
|
|
};
|
|
|
|
const [formData, setFormData] = useState<any>({});
|
|
|
|
// featureData가 변경될 때 formData 초기화
|
|
useEffect(() => {
|
|
if (featureData) {
|
|
setFormData(featureData);
|
|
}
|
|
}, [featureData]);
|
|
|
|
// 폼 데이터가 변경될 때 호출될 핸들러
|
|
const handleFormDataChange = (newFormData: any) => {
|
|
setFormData(newFormData);
|
|
};
|
|
|
|
// 저장 버튼 클릭 시 최신 formData를 부모에게 전달
|
|
const handleSaveClick = () => {
|
|
if (onSaveClick) {
|
|
// 저장 전에 formData를 부모 컴포넌트의 handleSaveClick에 전달
|
|
onSaveClick();
|
|
}
|
|
};
|
|
|
|
|
|
return (
|
|
<>
|
|
<VerticalTable
|
|
headName='자체 입력정보'
|
|
tableData={featureData ? [formData] : []}
|
|
headlist={inputColumn}
|
|
pageSize={20}
|
|
total={0}
|
|
children={undefined}
|
|
cellClick={undefined}
|
|
isEditable={true}
|
|
onPageChange={function (page: number): void {
|
|
throw new Error("Function not implemented.");
|
|
}}
|
|
showSaveButton={true}
|
|
onSaveClick={handleSaveClick}
|
|
onFormDataChange={handleFormDataChange} // 폼 데이터 변경 콜백 추가
|
|
/>
|
|
<InputSection
|
|
title="보수 및 갱신"
|
|
data={repairData}
|
|
sectionKey="repair"
|
|
onInputChange={(section, index, field, value) => handleInputChange(section, index, field, value, dataMap)}
|
|
/>
|
|
<InputSection
|
|
title="청소 및 준설"
|
|
data={cleaningData}
|
|
sectionKey="cleaning"
|
|
onInputChange={(section, index, field, value) => handleInputChange(section, index, field, value, dataMap)}
|
|
/>
|
|
<InputSection
|
|
title="점검 및 진단"
|
|
data={inspectionData}
|
|
sectionKey="inspection"
|
|
onInputChange={(section, index, field, value) => handleInputChange(section, index, field, value, dataMap)}
|
|
/>
|
|
</>
|
|
)
|
|
}
|
|
|
|
export default MsSwagePpl |