diff --git a/src/components/basis/flight/plan/FlightPlanForm.js b/src/components/basis/flight/plan/FlightPlanForm.js index 33c3d051..adbd92ad 100644 --- a/src/components/basis/flight/plan/FlightPlanForm.js +++ b/src/components/basis/flight/plan/FlightPlanForm.js @@ -1,4 +1,4 @@ -import React, { useEffect } from 'react'; +import React, { useEffect, useState } from 'react'; import { Card, CardBody, @@ -24,6 +24,34 @@ import { useDispatch, useSelector } from 'react-redux'; const FlightPlanForm = ({data, handleModal, handleChange, handleSave, handleDelete, modal, handleDeleteArray }) => { const {areaList, pilotList, arcrftList} = data; + const flightState = useSelector(state => state.flightState); + const { detail } = flightState; + + const [date ,setDate] = useState(); + const [isBigCurrent, setIsBigCurrent] = useState(); + + useEffect(() => { + if(detail.createDt) { + setDate(detail.schFltStDt); + } + }, [detail]) + + useEffect(() => { + setDate(''); + }, []) + + useEffect(() => { + if(date) { + let cTime = new Date(); + let pTime = new Date(date) + if(cTime > pTime) { + setIsBigCurrent(true); + } else { + setIsBigCurrent(false); + } + } + }, [date]) + return ( @@ -69,6 +97,7 @@ const FlightPlanForm = ({data, handleModal, handleChange, handleSave, handleDele bsSize='sm' placeholder='' + { ...(isBigCurrent ? {readOnly:true} : {}) } /> @@ -84,7 +113,7 @@ const FlightPlanForm = ({data, handleModal, handleChange, handleSave, handleDele id='clncd' name='clncd' // defaultValue={data.clncd} - value={data.clncd || '+81'} + value={data.clncd || '+82'} bsSize='sm' placeholder='+82' onChange={(e) => { @@ -115,6 +144,7 @@ const FlightPlanForm = ({data, handleModal, handleChange, handleSave, handleDele }) }} placeholder='010-0000-0000' + { ...(isBigCurrent ? {readOnly:true} : {}) } /> @@ -140,6 +170,7 @@ const FlightPlanForm = ({data, handleModal, handleChange, handleSave, handleDele }} // innerRef={props.data} placeholder='' + { ...(isBigCurrent ? {readOnly:true} : {}) } /> @@ -157,24 +188,43 @@ const FlightPlanForm = ({data, handleModal, handleChange, handleSave, handleDele - { - const value = moment(date[0]).format('YYYY-MM-DD HH:mm:ss') || ''; - handleChange({ - type: 'plan', - name: 'schFltStDt', - value - }) - }} - placeholder='비행 시작일자 선택(클릭)'/> - + { + (isBigCurrent) ? + ( + + ) + : + ( + { + const value = moment(date[0]).format('YYYY-MM-DD HH:mm:ss') || ''; + handleChange({ + type: 'plan', + name: 'schFltStDt', + value + }) + }} + placeholder='비행 시작일자 선택(클릭)' + {...{options:{minDate: "today"}}} + /> + ) + } @@ -182,23 +232,43 @@ const FlightPlanForm = ({data, handleModal, handleChange, handleSave, handleDele - { - const value = moment(date[0]).format('YYYY-MM-DD HH:mm:ss') || ''; - handleChange({ - type: 'plan', - name: 'schFltEndDt', - value - }) - }} - placeholder='비행 종료일자 선택(클릭)'/> - + { + (isBigCurrent) ? + ( + + ) + : + ( + { + const value = moment(date[0]).format('YYYY-MM-DD HH:mm:ss') || ''; + handleChange({ + type: 'plan', + name: 'schFltEndDt', + value + }) + }} + placeholder='비행 종료일자 선택(클릭)' + {...{options:{minDate: "today"}}} + /> + ) + } @@ -207,7 +277,8 @@ const FlightPlanForm = ({data, handleModal, handleChange, handleSave, handleDele *비행 목적 {/* TODO CDNOT 코드연동 필요 */} - - - - - - - + { isBigCurrent ? + <> + : + <> + + + + + + + + + } @@ -246,9 +324,10 @@ const FlightPlanForm = ({data, handleModal, handleChange, handleSave, handleDele

비행 구역 정보

{ + onClick={(e) => { handleModal({target: 'area', isOpen: true}) - }} + }} + {...(isBigCurrent)? {disabled:true} : {} } > 비행 구역 설정 @@ -268,6 +347,7 @@ const FlightPlanForm = ({data, handleModal, handleChange, handleSave, handleDele onClick={(e) => { handleModal({target: 'pilot', isOpen: true}) }} + {...(isBigCurrent)? {disabled:true} : {} } > 조종사 조회 @@ -278,7 +358,8 @@ const FlightPlanForm = ({data, handleModal, handleChange, handleSave, handleDele index={i} data={item} handleChange={handleChange} - handleDeleteArray ={handleDeleteArray}/>) + handleDeleteArray ={handleDeleteArray} + isBigCurrent={isBigCurrent}/>) : } @@ -290,6 +371,7 @@ const FlightPlanForm = ({data, handleModal, handleChange, handleSave, handleDele onClick={(e) => { handleModal({target: 'arcrft', isOpen: true}); }} + {...(isBigCurrent)? {disabled:true} : {} } > 기체 조회 @@ -300,7 +382,8 @@ const FlightPlanForm = ({data, handleModal, handleChange, handleSave, handleDele index={i} data={item} handleChange={handleChange} - handleDeleteArray ={handleDeleteArray}/>) + handleDeleteArray ={handleDeleteArray} + isBigCurrent={isBigCurrent}/>) : } @@ -312,6 +395,7 @@ const FlightPlanForm = ({data, handleModal, handleChange, handleSave, handleDele color='primary' size='sm' onClick={handleSave} + {...(isBigCurrent)? {disabled:true} : {} } > 저장 @@ -319,6 +403,7 @@ const FlightPlanForm = ({data, handleModal, handleChange, handleSave, handleDele color='danger' size='sm' onClick={handleDelete} + {...(isBigCurrent)? {disabled:true} : {} } > 삭제 @@ -517,7 +602,7 @@ const AreaForm = ({data, handleChange, index}) => {
) } -const PilotForm = ({data, handleChange, index, handleDeleteArray}) => { +const PilotForm = ({data, handleChange, index, handleDeleteArray, isBigCurrent}) => { return (
@@ -634,6 +719,7 @@ const PilotForm = ({data, handleChange, index, handleDeleteArray}) => { handleDeleteArray({ type: 'pilot', index }) } outline + {...(isBigCurrent)? {disabled:true} : {} } > 삭제 @@ -650,7 +736,7 @@ const PilotForm = ({data, handleChange, index, handleDeleteArray}) => { } -const ArcrftForm = ({data, handleChange, index, handleDeleteArray}) => { +const ArcrftForm = ({data, handleChange, index, handleDeleteArray, isBigCurrent}) => { return (
@@ -791,6 +877,7 @@ const ArcrftForm = ({data, handleChange, index, handleDeleteArray}) => { handleDeleteArray({ type: 'arcrft', index }) } outline + {...(isBigCurrent)? {disabled:true} : {} } > 삭제