From 4c41fc5203b262dfd17651cd7509f6dc8c8e2cc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?qkr7828=28=EB=B0=95=EC=9E=AC=EC=9A=B0=29?= Date: Tue, 19 Jul 2022 09:46:26 +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=ED=8F=BC=20+=20api=EC=9E=91=EC=97=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../basis/flight/plan/FlightPlanForm.js | 128 +++++++++++------- .../flight/plan/FlightPlanDetailContainer.js | 53 ++++++-- .../basis/flight/apis/basisFlightApi.ts | 11 +- .../basis/flight/models/basisFlightModel.ts | 33 +++-- .../flight/reducers/basisFlightReducer.ts | 6 + .../basis/flight/sagas/basisFlightSaga.ts | 50 ++++++- 6 files changed, 212 insertions(+), 69 deletions(-) diff --git a/src/components/basis/flight/plan/FlightPlanForm.js b/src/components/basis/flight/plan/FlightPlanForm.js index 77ad37c..540e389 100644 --- a/src/components/basis/flight/plan/FlightPlanForm.js +++ b/src/components/basis/flight/plan/FlightPlanForm.js @@ -11,6 +11,8 @@ import { } from 'reactstrap'; import Flatpickr from 'react-flatpickr'; import '@styles/react/libs/flatpickr/flatpickr.scss'; +import moment from 'moment'; + const FlightPlanForm = (props) => { @@ -48,12 +50,10 @@ const FlightPlanForm = (props) => { @@ -69,7 +69,9 @@ const FlightPlanForm = (props) => { id='clncd' name='clncd' size='sm' - placeholder='+82' + placeholder='+82' + value='+82' + readOnly /> @@ -79,6 +81,7 @@ const FlightPlanForm = (props) => { id='hpno' name='hpno' size='sm' + onChange={props.onChange} placeholder='010-0000-0000' @@ -94,6 +97,7 @@ const FlightPlanForm = (props) => { id='email' name='email' size='sm' + onChange={props.onChange} // innerRef={props.data} placeholder='' /> @@ -151,6 +155,10 @@ const FlightPlanForm = (props) => { type='text' id='schFltStDt' name='schFltStDt' + value={props.schFltStDt} + onChange={val => + props.handlerInput(val) + } // innerRef={props.data} placeholder='비행 시작일자 선택(클릭)'/> @@ -159,13 +167,17 @@ const FlightPlanForm = (props) => { + props.handlerInput(val) + } // innerRef={props.data} placeholder='비행 종료일자 선택(클릭)'/> @@ -181,12 +193,19 @@ const FlightPlanForm = (props) => { name='fltPurpose' id='fltPurpose' size='sm' + onChange={props.onChange} // innerRef={props.data} // className={classnames({ // 'is-invalid': props.errors.arcrftTypeCd // })} > + + + + + + {/* CDNOT 코드연동 필요 */} {/* {ARCTFT_TYPE_CD.map(item => { return ( @@ -289,11 +308,12 @@ const FlightPlanForm = (props) => { @@ -308,18 +328,20 @@ const FlightPlanForm = (props) => { id='fltElev' name='fltElev' size='sm' - placeholder='반경' - readOnly + placeholder='반경' + onChange={props.onChange} + />
@@ -335,11 +357,12 @@ const FlightPlanForm = (props) => { @@ -354,7 +377,8 @@ const FlightPlanForm = (props) => { name='fltMethod' size='sm' placeholder='' - readOnly + onChange={props.onChange} + /> @@ -365,11 +389,12 @@ const FlightPlanForm = (props) => { @@ -399,8 +424,9 @@ const FlightPlanForm = (props) => { id='groupNm' name='groupNm' size='sm' - placeholder='' - readOnly + placeholder='' + onChange={props.onChange} + /> @@ -411,11 +437,12 @@ const FlightPlanForm = (props) => { @@ -434,18 +461,20 @@ const FlightPlanForm = (props) => { id='clncd' name='clncd' size='sm' - placeholder='+82' - readOnly + placeholder='+82' + onChange={props.onChange} + />
@@ -458,11 +487,12 @@ const FlightPlanForm = (props) => { @@ -488,11 +518,12 @@ const FlightPlanForm = (props) => { @@ -507,7 +538,8 @@ const FlightPlanForm = (props) => { name='arcrftModelNm' size='sm' placeholder='' - readOnly + onChange={props.onChange} + /> @@ -526,7 +558,8 @@ const FlightPlanForm = (props) => { name='arcrftTypeCd' size='sm' placeholder='' - readOnly + onChange={props.onChange} + /> @@ -541,7 +574,8 @@ const FlightPlanForm = (props) => { name='ownerNm' size='sm' placeholder='' - readOnly + onChange={props.onChange} + /> diff --git a/src/containers/basis/flight/plan/FlightPlanDetailContainer.js b/src/containers/basis/flight/plan/FlightPlanDetailContainer.js index 24e4be2..3eb53db 100644 --- a/src/containers/basis/flight/plan/FlightPlanDetailContainer.js +++ b/src/containers/basis/flight/plan/FlightPlanDetailContainer.js @@ -9,6 +9,8 @@ import * as yup from 'yup'; import { yupResolver } from '@hookform/resolvers/yup'; import * as Actions from '../../../../modules/basis/flight/actions/basisFlightAction'; import { useForm } from 'react-hook-form'; +import moment from 'moment'; +import { Save } from 'react-feather'; const FlightPlanDetailContainer = props => { const dispatch = useDispatch(); @@ -20,20 +22,38 @@ const FlightPlanDetailContainer = props => { isOpen: false, title: '', }); + const { listFlightP, flightCount, isRefreshFlight } = useSelector( state => state.flightState ); const [flightPlanData, setFlightPlanData] = useState({ - id: '', - memberName: '', - clncd: '', - hpno: '', + id:'', + memberName:'', + clncd: '+82', + hpno:'', email:'', - createDt: '', - createUserId: '', - updateUserId: '', - updateDt: '' + lonlat:'', + lonlat2:'', + lonlat3:'', + fltElev:'', + fltHight:'', + fltMethod:'', + groupNm:'', + pilotName:'', + pilotHpno:'', + pilotEmail:'', + aGroupNm:'', + arcrftModelNm:'', + arcrftTypeCd:'', + ownerNm:'', + createUserId:'', + updateUserId:'' }); + const [params, setParams] = useState({ + schFltStDt: moment().subtract(1, 'day').format('YYYY-MM-DD'), + schFltEndDt: moment().subtract(-1, 'day').format('YYYY-MM-DD'), + search1: '' + }); useEffect(() => { console.log('isRefreshFlight>>>>', isRefreshFlight); if (isRefreshFlight) { @@ -81,21 +101,30 @@ const FlightPlanDetailContainer = props => { } const handlerCreate = async data => { console.log('data>>>>>', data); - console.log('flightPlanData>>>',flightPlanData); - let saveArr = flightPlanData; + console.log('flightPlanData>>>',{flightPlanData, params}); + let saveArr = {flightPlanData, params}; dispatch( Actions.FLIGHT_PLAN_CREATE.request({ data: saveArr }) ); }; + const handlerInput = (val) => { + setParams({ + ...params, + schFltStDt: moment(val[1]).format('YYYY-MM-DD'), + schFltEndDt: moment(val[0]).format('YYYY-MM-DD') + }); + }; const onChange = (e) => { + setFlightPlanData({ ...flightPlanData, [e.target.name]: e.target.value, }); }; - + + const handlerDelete = async data => { // dispatch(Actions.IDNTF_DELETE.request(data.arcrftSno)); }; @@ -109,11 +138,13 @@ const FlightPlanDetailContainer = props => { data={flightPlanData} openModal={openModal} areaInfo={areaInfo} + params={params} handlerSave={ pageType === 'create' ? handlerCreate : handlerUpdate } onChange={onChange} handlerDelete={handlerDelete} + handlerInput={handlerInput} /> { return await axios.get(`api/bas/flight/area`); - } + }, + Create: async (data: FlightPlanData) => { + console.log(data); + + const res = await axios.post('api/bas/flight/create', data); + console.log('res>>>>', res); + + return res; + } } \ No newline at end of file diff --git a/src/modules/basis/flight/models/basisFlightModel.ts b/src/modules/basis/flight/models/basisFlightModel.ts index e080053..6afe7a4 100644 --- a/src/modules/basis/flight/models/basisFlightModel.ts +++ b/src/modules/basis/flight/models/basisFlightModel.ts @@ -1,6 +1,7 @@ export interface FlightState { areaList: FlightAreaData | undefined flightPlanArea: FlightPlanArea | undefined + flightPlanData: FlightPlanData | undefined } export interface FlightAreaData { @@ -16,15 +17,29 @@ export interface FlightPlanArea { } export interface FlightPlanData { - id: '', - memberName: '', - clncd: '', - hpno: '', - email:'', - createDt: '', - createUserId: '', - updateUserId: '', - updateDt: '' + id:string; + memberName:string; + clncd:string; + hpno:string; + email:string; + lonlat:string; + lonlat2:string; + lonlat3:string; + fltElev:string; + fltHight:string; + fltMethod:string; + groupNm:string; + pilotName:string; + pilotHpno:string; + pilotEmail:string; + aGroupNm:string; + arcrftModelNm:string; + arcrftTypeCd:string; + ownerNm:string; + createUserId:string; + updateUserId:string; + schFltStDt:Date; + schFltEndDt:Date; } export const initFlight = { diff --git a/src/modules/basis/flight/reducers/basisFlightReducer.ts b/src/modules/basis/flight/reducers/basisFlightReducer.ts index 708445a..bfaa0e7 100644 --- a/src/modules/basis/flight/reducers/basisFlightReducer.ts +++ b/src/modules/basis/flight/reducers/basisFlightReducer.ts @@ -18,4 +18,10 @@ export const flightReducer = createReducer ( const data = action.payload; draft.flightPlanArea = data; }) +) +.handleAction(Actions.FLIGHT_PLAN_CREATE.request, (state, action) => + produce(state, draft => { + const data = action.payload; + draft.flightPlanData = data; + }) ) \ No newline at end of file diff --git a/src/modules/basis/flight/sagas/basisFlightSaga.ts b/src/modules/basis/flight/sagas/basisFlightSaga.ts index 82362ef..07ee998 100644 --- a/src/modules/basis/flight/sagas/basisFlightSaga.ts +++ b/src/modules/basis/flight/sagas/basisFlightSaga.ts @@ -54,8 +54,56 @@ function* createFlightPlanArea(action: ActionType + ) { + try { + const detail = action.payload; + + console.log('detail>>>:', detail); + const res = yield call(Apis.flightPlanAPI.Create, detail); + console.log(res); + const { data } = res; + console.log('data:>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>', data.result); + if (data.result) { + yield put( + MessageActions.IS_MESSAGE({ + messageCode: SAVE_MESSAGE.code, + message: SAVE_MESSAGE.message, + isHistoryBack: false, + isRefresh: false + }) + ); + yield put(Actions.FLIGHT_PLAN_CREATE.success(data)); + } else { + console.log('errorCode >>> ', data.errorCode); + if (data.errorCode === 'DT002') { + yield put( + MessageActions.IS_ERROR({ + errorCode: DUPLATE_MESSAGE.code, + errorMessage: '식별번호가 ' + DUPLATE_MESSAGE.message, + isHistoryBack: false, + isRefresh: false + }) + ); + } else { + throw Error; + } + } + } catch (error) { + yield put( + MessageActions.IS_ERROR({ + errorCode: ERROR_MESSAGE.code, + errorMessage: ERROR_MESSAGE.message, + isHistoryBack: false, + isRefresh: false + }) + ); + // yield put(Actions.GROUP_CREATE.failure(error)); + } + } export function* flightSaga() { yield takeEvery(Actions.AREA_LIST.request, listAreaSaga); yield takeEvery(Actions.FLIGHT_PLAN_AREA.request, createFlightPlanArea); + yield takeEvery(Actions.FLIGHT_PLAN_CREATE.request, createFlightPlanData) } \ No newline at end of file