From 2e4ce5c265eaa57034189d14f692d2757c0c2428 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?junh=5Feee=28=EC=9D=B4=EC=A4=80=ED=9D=AC=29?= Date: Thu, 25 Aug 2022 16:34:59 +0900 Subject: [PATCH] =?UTF-8?q?=EB=B9=84=ED=96=89=EA=B3=84=ED=9A=8D=EC=84=9C?= =?UTF-8?q?=20-=20=EB=B9=84=ED=96=89=20=EC=8B=9C=EC=9E=91=20=EB=B0=8F=20?= =?UTF-8?q?=EC=A2=85=EB=A3=8C=20=EA=B3=84=ED=9A=8D=EC=84=9C=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=20=EB=B6=88=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../basis/flight/plan/FlightPlanForm.js | 189 +++++++++++++----- 1 file changed, 138 insertions(+), 51 deletions(-) diff --git a/src/components/basis/flight/plan/FlightPlanForm.js b/src/components/basis/flight/plan/FlightPlanForm.js index 33c3d05..adbd92a 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} : {} } > 삭제