From 1b453cb8291f1c610040ee85c1270ad8bbbad15e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?dhji=28=EC=A7=80=EB=8C=80=ED=95=9C=29?= Date: Mon, 25 Jul 2022 02:29:44 +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=EB=AA=A9=EB=A1=9D=20=EC=A1=B0=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../basis/flight/plan/FlightPlanForm.js | 238 +++++++------ .../basis/flight/plan/FlightPlanGrid.js | 129 +++---- .../basis/flight/plan/FlightPlanSearch.js | 327 +++++++++--------- .../flight/plan/FlightPlanAreaContainer.js | 36 +- .../basis/flight/plan/FlightPlanContainer.js | 62 +++- .../flight/plan/FlightPlanDetailContainer.js | 183 +++++----- .../basis/flight/actions/basisFlightAction.ts | 124 ++++++- .../basis/flight/apis/basisFlightApi.ts | 65 +++- .../basis/flight/models/basisFlightModel.ts | 139 ++++++-- .../flight/reducers/basisFlightReducer.ts | 56 ++- .../basis/flight/sagas/basisFlightSaga.ts | 196 ++++++----- 11 files changed, 935 insertions(+), 620 deletions(-) diff --git a/src/components/basis/flight/plan/FlightPlanForm.js b/src/components/basis/flight/plan/FlightPlanForm.js index 540e389..2854de5 100644 --- a/src/components/basis/flight/plan/FlightPlanForm.js +++ b/src/components/basis/flight/plan/FlightPlanForm.js @@ -2,12 +2,12 @@ import React from 'react'; import { Card, CardBody, - Col, + Col, FormGroup, Input, Label, - Row, - Button + Row, + Button } from 'reactstrap'; import Flatpickr from 'react-flatpickr'; import '@styles/react/libs/flatpickr/flatpickr.scss'; @@ -20,7 +20,7 @@ const FlightPlanForm = (props) => { - + @@ -43,7 +43,7 @@ const FlightPlanForm = (props) => {

신청인 정보

- + @@ -53,7 +53,7 @@ const FlightPlanForm = (props) => { id='memberName' name='memberName' onChange={props.onChange} - size='sm' + size='sm' placeholder='' /> @@ -67,28 +67,26 @@ const FlightPlanForm = (props) => {
- + @@ -104,8 +102,8 @@ const FlightPlanForm = (props) => {
- - + + {/*
@@ -116,7 +114,7 @@ const FlightPlanForm = (props) => { type='text' id='applicantAddress' name='applicantAddress' - size='sm' + size='sm' // innerRef={props.data} placeholder='' /> @@ -129,12 +127,12 @@ const FlightPlanForm = (props) => { type='text' id='applicantAddress' name='applicantAddress' - size='sm' + size='sm' // innerRef={props.data} placeholder='' /> - +
*/} @@ -146,41 +144,57 @@ const FlightPlanForm = (props) => {
- + - - props.handlerInput(val) - } + onChange={(val) => { + console.log(val) + const data = {target: {}} + data.target.name = 'schFltStDt'; + data.target.value = val && val[0] && moment(val[0]).format('YYYY-MM-DD HH:mm:ss'); + props.onChange(data) + }} + // onChange={val => + // props.handlerInput(val) + // } // innerRef={props.data} - placeholder='비행 시작일자 선택(클릭)'/> - + placeholder='비행 시작일자 선택(클릭)'/> + - + - - props.handlerInput(val) - } + onChange={(val) => { + console.log(val) + const data = {target: {}} + data.target.name = 'schFltEndDt'; + data.target.value = val && val[0] && moment(val[0]).format('YYYY-MM-DD HH:mm:ss'); + props.onChange(data) + }} + // onChange={val => + // props.handlerInput(val) + // } // innerRef={props.data} - placeholder='비행 종료일자 선택(클릭)'/> - + placeholder='비행 종료일자 선택(클릭)'/> + @@ -194,7 +208,7 @@ const FlightPlanForm = (props) => { id='fltPurpose' size='sm' onChange={props.onChange} - // innerRef={props.data} + // innerRef={props.data} // className={classnames({ // 'is-invalid': props.errors.arcrftTypeCd // })} @@ -227,7 +241,7 @@ const FlightPlanForm = (props) => {
- + {/* */} - + {/* */} -
+

비행 구역 정보

- @@ -309,11 +323,11 @@ const FlightPlanForm = (props) => { @@ -326,26 +340,26 @@ const FlightPlanForm = (props) => {
- +
@@ -358,14 +372,14 @@ const FlightPlanForm = (props) => { - + - + - - + +

조종사 정보

- - 조종사 조회 + 조종사 조회
@@ -422,11 +436,11 @@ const FlightPlanForm = (props) => { @@ -438,11 +452,11 @@ const FlightPlanForm = (props) => { @@ -459,27 +473,27 @@ const FlightPlanForm = (props) => {
- + - +

기체 정보

- -  기체 조회  +  기체 조회 
@@ -519,11 +533,11 @@ const FlightPlanForm = (props) => { @@ -535,11 +549,11 @@ const FlightPlanForm = (props) => { @@ -555,14 +569,14 @@ const FlightPlanForm = (props) => { - + - +
- +
{ > 저장 - 삭제
- + - +
- +
@@ -615,4 +629,4 @@ const FlightPlanForm = (props) => { ) } -export default FlightPlanForm; \ No newline at end of file +export default FlightPlanForm; diff --git a/src/components/basis/flight/plan/FlightPlanGrid.js b/src/components/basis/flight/plan/FlightPlanGrid.js index 062c220..15fd608 100644 --- a/src/components/basis/flight/plan/FlightPlanGrid.js +++ b/src/components/basis/flight/plan/FlightPlanGrid.js @@ -1,66 +1,71 @@ import React from 'react'; -import { - Row, - Col, - Table, - Badge, - UncontrolledDropdown, - DropdownMenu, - DropdownItem, - DropdownToggle, - Card, - CardHeader, - CardBody, - CardTitle, - CardSubtitle, - ButtonGroup, - Button, - Input, - CustomInput, - FormGroup - } from 'reactstrap'; -import { GridDatabase } from '../../../crud/grid/GridDatatable'; +import {Button, Card, Col, Row} from 'reactstrap'; +import {GridDatabase} from '../../../crud/grid/GridDatatable'; +import {Redirect} from 'react-router-dom'; -const FlightPlanGrid = (props) => { - return ( -
- - -
-
- {/*

{"비행 계획"} 목록

*/} -

{"비행계획서 신청"} 목록

- 검색결과 총 0건 -
-
- - {/* 계획서 생성 */} - 비행계획서 신청 - -
-
-
- -
- - {/* 검색된 데이터가 없습니다. */} -
-
-
- -
-
- ) + +const FlightPlanGrid = ({movePage, planListData, handleMoveDetail}) => { + + const columns = [ + {id: 'planSno', name: '번호', cell: row => (
{row.planSno}
)}, + {id: 'fltPurpose', name: '비행목적', cell: row => (
{row.fltPurpose}
)}, + { + id: 'fltMethod', name: '비행방식', cell: row => { + const displayName = row.areaList && row.areaList.length > 0 && row.areaList[0].fltMethod || '-'; + return
{displayName}
+ } + }, + {id: 'schFltStDt', name: '출발일', cell: row => (
{row.schFltStDt}
)}, + {id: 'aprvlYn', name: '승인여부', cell: row => (
{row.aprvlYn}
)}, + { + id: 'moveDetail', name: '상세보기', cell: row => { + return { + handleMoveDetail(row.planSno)} + }>상세; + } + } + ]; + console.log(planListData, columns) + return ( +
+ + +
+
+ {/*

{"비행 계획"} 목록

*/} +

{"비행계획서 신청"} 목록

+ 검색결과 총 0건 +
+
+ + {/* 계획서 생성 */} + 비행계획서 신청 + +
+
+
+ +
+ + {/* 검색된 데이터가 없습니다. */} +
+
+
+ +
+
+ ) } -export default FlightPlanGrid; \ No newline at end of file +export default FlightPlanGrid; diff --git a/src/components/basis/flight/plan/FlightPlanSearch.js b/src/components/basis/flight/plan/FlightPlanSearch.js index 2bbcb88..c1ddd8b 100644 --- a/src/components/basis/flight/plan/FlightPlanSearch.js +++ b/src/components/basis/flight/plan/FlightPlanSearch.js @@ -1,174 +1,173 @@ -import React, { useEffect, useState } from 'react'; -import { - Row, - Col, - Table, - Badge, - UncontrolledDropdown, - DropdownMenu, - DropdownItem, - DropdownToggle, - Card, - CardHeader, - CardBody, - CardTitle, - CardSubtitle, - ButtonGroup, - Button, - Input, - CustomInput, - FormGroup - } from 'reactstrap'; -import { Calendar, Search } from 'react-feather'; +import React, {useState} from 'react'; +import {Button, Card, CardBody, Col, CustomInput, Row} from 'reactstrap'; +import {Search} from 'react-feather'; import Flatpickr from 'react-flatpickr'; +import moment from 'moment'; -const FlightPlanSearch = (props) => { +const FlightPlanSearch = ({searchData, onChangeSearchData}) => { - const [isCheck, setIsCheck] = useState({ - all: true, - yes: false, - no: false - }); - - useEffect(() => { - let aprvYn = ''; - - if (!isCheck.all) { - if (isCheck.yes) { - aprvYn = 'Y'; - } else if (isCheck.no) { - aprvYn = 'N'; - } else { - aprvYn = '-'; - } + const {schFltStDt, schFltEndDt, aprvlYn} = searchData; + const initCheckState = { + 'all': aprvlYn == 'A', + 'yes': (aprvlYn == 'Y' || aprvlYn == 'A'), + 'no': (aprvlYn == 'N' || aprvlYn == 'A'), } - - // props.setParams({ - // ...props.params, - // aprvYn: aprvYn - // }); - }, [isCheck]); - - return ( -
- - -
-
-

검색조건

-
-
- props.handlerSearch()} - > - - 검색 - -
-
- - -
-
-
-
-
신청일
-
-
- - -
- - props.handlerInput('searchDate', val) - } - onKeyPress={props.onKeyPress} - className='form-control flat-picker bg-transparent border-0 shadow-none' - /> -
- -
+ const [checkState, setCheckState] = useState(initCheckState); + const handleChangeInput = (dates, value, config) => { + if (dates.length === 2) { + const schFltStDt = moment(dates[0]).format('YYYY-MM-DD HH:mm:ss'); + const schFltEndDt = moment(dates[1]).set({'h': 23, 'm': 59, 's': 59}).format('YYYY-MM-DD HH:mm:ss'); + onChangeSearchData({schFltStDt, schFltEndDt}) + } + } + const handleChangeCheckbox = (e) => { + const {name, value, checked} = e.target; + let val; + switch (value) { + case 'A': + val = checked ? 'A' : ''; + onChangeSearchData({[name]: val}) + setCheckState({ + 'all': checked, + 'yes': checked, + 'no': checked + }) + break; + case 'Y': + if (checked && checkState.no) val = 'A' + else if (checked && !checkState.no) val = 'Y' + else if (!checked && checkState.no) val = 'N' + else if (!checked && !checkState.no) val = '' + onChangeSearchData({[name]: val}) + setCheckState(prevState => ({ + 'all': prevState.no && checked, + 'yes': checked, + 'no': prevState.no + })) + break; + case 'N': + if (checked && checkState.yes) val = 'A' + else if (checked && !checkState.yes) val = 'N' + else if (!checked && checkState.yes) val = 'Y' + else if (!checked && !checkState.yes) val = '' + onChangeSearchData({[name]: val}) + setCheckState(prevState => ({ + 'all': prevState.yes && checked, + 'yes': prevState.yes, + 'no': checked + })) + break; + default: + break; + } + } + return ( +
+ + +
+
+

검색조건

-
-
-
- -
-
-
승인여부
-
- {/*
- -
*/} -
- - setIsCheckBox({ - all: !isCheck.all, - yes: !isCheck.all, - no: !isCheck.all - }) - } - /> - - setIsCheckBox({ - all: false, - yes: !isCheck.yes - }) - } - /> - - setIsCheckBox({ - all: false, - no: !isCheck.no - }) - } - /> +
+ { + }} + > + + 검색 +
-
-
-
-
-
-
- - -
-
- ) + + +
+
+
+
+
신청일
+
+
+ + +
+ +
+ +
+
+
+
+
+ +
+
+
승인여부
+
+
+ + + +
+
+
+
+
+
+
+
+ + + + + ) } -export default FlightPlanSearch; \ No newline at end of file +export default FlightPlanSearch; diff --git a/src/containers/basis/flight/plan/FlightPlanAreaContainer.js b/src/containers/basis/flight/plan/FlightPlanAreaContainer.js index 39dc57e..33ef2bd 100644 --- a/src/containers/basis/flight/plan/FlightPlanAreaContainer.js +++ b/src/containers/basis/flight/plan/FlightPlanAreaContainer.js @@ -12,15 +12,15 @@ import { yupResolver } from '@hookform/resolvers/yup'; const FlightPlanAreaContainer = (props) => { const dispatch = useDispatch(); const history = useHistory(); - + const { areaList } = useSelector(state => state.flightState); const [airArea, setAirArea] = useState(null); - const validSchema = yup.object().shape({ + const validSchema = yup.object().shape({ }); const { register, getValues, setValue, errors, handleSubmit } = useForm({ - defaultValues: { + defaultValues: { coodinates: [], radius: '', altitude_m: '', @@ -34,42 +34,42 @@ const FlightPlanAreaContainer = (props) => { dispatch(Actions.AREA_LIST.request()); } - const createAirArea = async data => { - dispatch(Actions.FLIGHT_PLAN_AREA.request(data)); - - props.setModal({ ...props.modal, isOpen: !props.modal.isOpen }); - props.setOnSubmit(false); - } + // const createAirArea = async data => { + // dispatch(Actions.FLIGHT_AREA.request(data)); + // + // props.setModal({ ...props.modal, isOpen: !props.modal.isOpen }); + // props.setOnSubmit(false); + // } useEffect(() => { getAirAreaList(); }, []); - useEffect(() => { + useEffect(() => { setAirArea(areaList); - }, [areaList]) + }, [areaList]) - return ( + return ( {airArea != null ? ( - ) : null} + ) : null} - + + /> - - + + ) } -export default FlightPlanAreaContainer; \ No newline at end of file +export default FlightPlanAreaContainer; diff --git a/src/containers/basis/flight/plan/FlightPlanContainer.js b/src/containers/basis/flight/plan/FlightPlanContainer.js index 51f71b2..b530241 100644 --- a/src/containers/basis/flight/plan/FlightPlanContainer.js +++ b/src/containers/basis/flight/plan/FlightPlanContainer.js @@ -1,38 +1,66 @@ -import React, { useState } from 'react'; +import React, {useEffect, useState} from 'react'; import moment from 'moment'; -import { Link, useHistory } from 'react-router-dom'; +import {Link, Redirect, useHistory} from 'react-router-dom'; import FlightPlanGrid from '../../../../components/basis/flight/plan/FlightPlanGrid'; -import { CustomMainLayout } from '../../../../components/layout/CustomMainLayout'; +import {CustomMainLayout} from '../../../../components/layout/CustomMainLayout'; import FlightPlanSearch from '../../../../components/basis/flight/plan/FlightPlanSearch'; +import {useDispatch, useSelector} from 'react-redux'; +import * as FlightAction from '../../../../modules/basis/flight/actions/basisFlightAction'; +import {FlightPlanListRqData} from '../../../../modules/basis/flight/models/basisFlightModel'; -const FlightPlanContainer = () => { +const initSearchData = { + schFltStDt: moment().set({'h': 0, 'm': 0, 's': 0}).format('YYYY-MM-DD HH:mm:ss'), + schFltEndDt: moment().set({'h': 23, 'm': 59, 's': 59}).format('YYYY-MM-DD HH:mm:ss'), + aprvlYn: 'N', +} +const columns = [{}] +const FlightPlanContainer = () => { + const dispatch = useDispatch(); const history = useHistory(); + const [searchData, setSerchData] = useState(initSearchData); + const planListData = useSelector(state => state.flightState.list); - const moveFlightPlan = () => { + const moveFlightPlanDetailPage = () => { history.push('/basis/flight/plan/create'); }; - const [times, setTimes] = useState({ - stDate: moment().subtract(1, 'day').format('YYYY-MM-DD'), - endDate: moment().subtract(-1, 'day').format('YYYY-MM-DD'), - search1: '' - }) + useEffect(() => { + dispatch(FlightAction.FLIGHT_PLAN_LIST.request(searchData)) + }, []) // console.log(history, 'history') + console.log(searchData) + const handleChangeSearchData = (values) => { + setSerchData(prevState => ({ + ...prevState, + ...values + })) + } + // 비행계획서 저장 + const handleClickCreate = () => { + + }; + const handleMoveDetail = (id) => { + history.push(`/basis/flight/plan/detail/${id}`) + } return ( // - - + + ) } -export default FlightPlanContainer; \ No newline at end of file +export default FlightPlanContainer; diff --git a/src/containers/basis/flight/plan/FlightPlanDetailContainer.js b/src/containers/basis/flight/plan/FlightPlanDetailContainer.js index 3eb53db..c5f299b 100644 --- a/src/containers/basis/flight/plan/FlightPlanDetailContainer.js +++ b/src/containers/basis/flight/plan/FlightPlanDetailContainer.js @@ -1,137 +1,150 @@ import React, {useEffect, useState} from 'react'; import FlightPlanForm from '../../../../components/basis/flight/plan/FlightPlanForm'; -import { CustomDetailLayout } from '../../../../components/layout/CustomDetailLayout'; -import { FlightPlanAreaModal } from '../../../../components/basis/flight/plan/FlightPlanAreaModal'; +import {CustomDetailLayout} from '../../../../components/layout/CustomDetailLayout'; +import {FlightPlanAreaModal} from '../../../../components/basis/flight/plan/FlightPlanAreaModal'; import FlightPlanAreaContainer from './FlightPlanAreaContainer'; import {useHistory} from 'react-router-dom'; -import { useDispatch, useSelector } from 'react-redux'; +import {useDispatch, useSelector} from 'react-redux'; import * as yup from 'yup'; -import { yupResolver } from '@hookform/resolvers/yup'; +import {yupResolver} from '@hookform/resolvers/yup'; import * as Actions from '../../../../modules/basis/flight/actions/basisFlightAction'; -import { useForm } from 'react-hook-form'; +import {useForm} from 'react-hook-form'; import moment from 'moment'; -import { Save } from 'react-feather'; +import {Save} from 'react-feather'; + +const initFlightPlanData = { + id: '', + memberName: '', + clncd: '+82', + hpno: '', + email: '', + lonlat: '', + lonlat2: '', + lonlat3: '', + fltElev: '', + fltHight: '', + fltMethod: '', + groupNm: '', + pilotName: '', + pilotHpno: '', + pilotEmail: '', + aGroupNm: '', + arcrftModelNm: '', + arcrftTypeCd: '', + ownerNm: '', + createUserId: '', + updateUserId: '' +} const FlightPlanDetailContainer = props => { const dispatch = useDispatch(); const history = useHistory(); const [pageType, setPageType] = useState('create'); - const { flightPlanArea } = useSelector(state => state.flightState); - const [areaInfo, setAreaInfo] = useState(); + const {flightPlanArea} = useSelector(state => state.flightState); + const [areaInfo, setAreaInfo] = useState(); const [modal, setModal] = useState({ isOpen: false, - title: '', + title: '', }); - - const { listFlightP, flightCount, isRefreshFlight } = useSelector( + + const {listFlightP, flightCount, isRefreshFlight} = useSelector( state => state.flightState - ); - const [flightPlanData, setFlightPlanData] = useState({ - id:'', - memberName:'', - clncd: '+82', - hpno:'', - email:'', - lonlat:'', - lonlat2:'', - lonlat3:'', - fltElev:'', - fltHight:'', - fltMethod:'', - groupNm:'', - pilotName:'', - pilotHpno:'', - pilotEmail:'', - aGroupNm:'', - arcrftModelNm:'', - arcrftTypeCd:'', - ownerNm:'', - createUserId:'', - updateUserId:'' - }); + ); + const [flightPlanData, setFlightPlanData] = useState(initFlightPlanData); + 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) { - console.log(isRefreshFlight); - handlerSearch(); + console.log(isRefreshFlight); + handlerSearch(); } - }, [isRefreshFlight]); + }, [isRefreshFlight]); + const [flightPlanDataList, setFlightPlanDataList] = useState([]); + /* Form Validation Checking */ - const validSchema = yup.object().shape({ - }); + const validSchema = yup.object().shape({}); const {} = useForm({ - defaultValues: { + defaultValues: { coodinates: [], radius: '', altitude_m: '', altitude_ft: '', }, - resolver: yupResolver(validSchema) + resolver: yupResolver(validSchema) }) - + const saveFlightPlanArea = () => { console.log('비행 구역 설정 저장'); } useEffect(() => { if (props.id) { - handlerSearch(); - setPageType('update'); + handlerSearch(); + setPageType('update'); } // console.log(selectData); - }, []); - useEffect(() => { + }, []); + + useEffect(() => { let newArr = []; - + listFlightP?.map(item => { - newArr.push({ ...item }); + newArr.push({...item}); }); setFlightPlanDataList(listFlightP); - }, [listFlightP]); + }, [listFlightP]); + const openModal = () => { - setModal({ + setModal({ isOpen: true, - title: '비행 구역 설정', + title: '비행 구역 설정', }); } - const handlerCreate = async data => { - console.log('data>>>>>', data); - console.log('flightPlanData>>>',{flightPlanData, params}); - let saveArr = {flightPlanData, params}; + + const handlerCreate = e => { + // console.log('flightPlanData>>>', {flightPlanData, params}); + // let saveData = {flightPlanData, params}; + const saveData = {...flightPlanData}; dispatch( - Actions.FLIGHT_PLAN_CREATE.request({ - data: saveArr - }) + Actions.FLIGHT_PLAN_CREATE.request(saveData) ); - }; - 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 => { + }; + + // const handlerInput = (val) => { + // console.log('handler input : ', val) + // console.log('handler input : ', val[1]) + // console.log('handler input : ', val[0]) + // setParams({ + // ...params, + // schFltStDt: moment(val[1]).format('YYYY-MM-DD'), + // schFltEndDt: moment(val[0]).format('YYYY-MM-DD') + // }); + // }; + // console.log('params >>>>> ', params) + const onChange = (e) => { + const {name, value} = e.target; + setFlightPlanData((prevState) => ({ + ...prevState, + [name]: value, + })); + }; + + console.log('===> ', flightPlanData); + + const handlerDelete = async data => { // dispatch(Actions.IDNTF_DELETE.request(data.arcrftSno)); - }; + }; + useEffect(() => { setAreaInfo(flightPlanArea); }, [flightPlanArea]); - + return ( { areaInfo={areaInfo} params={params} handlerSave={ - pageType === 'create' ? handlerCreate : handlerUpdate + pageType === 'create' ? handlerCreate : handlerUpdate } onChange={onChange} handlerDelete={handlerDelete} - handlerInput={handlerInput} + // handlerInput={handlerInput} /> - + /> ) } -export default FlightPlanDetailContainer; \ No newline at end of file +export default FlightPlanDetailContainer; diff --git a/src/modules/basis/flight/actions/basisFlightAction.ts b/src/modules/basis/flight/actions/basisFlightAction.ts index 3bd70d9..9471fef 100644 --- a/src/modules/basis/flight/actions/basisFlightAction.ts +++ b/src/modules/basis/flight/actions/basisFlightAction.ts @@ -1,6 +1,12 @@ import { AxiosError } from 'axios'; import { createAsyncAction, ActionType} from 'typesafe-actions'; -import { FlightAreaData, FlightPlanArea, FlightPlanData } from '../models/basisFlightModel'; +import { + FlightAreaData, + FlightPlanArcrftDataList, + // FlightPlanArea, + FlightPlanData, + FlightPlanListRqData, FlightPlanPilotDataList +} from '../models/basisFlightModel'; // 공역 조회 @@ -9,13 +15,49 @@ const AREA_LIST_SUCCESS = 'basis/flight/area/LIST_SUCCESS'; const AREA_LIST_FAILURE = 'basis/flight/area/LIST_FAILURE'; // 비행 구역 설정 -const FLIGHT_PLAN_AREA_REQUEST = 'basis/flight/plan/area/LIST_REQUEST'; -const FLIGHT_PLAN_AREA_SUCCESS = 'basis/flight/plan/area/LIST_SUCCESS'; -const FLIGHT_PLAN_AREA_FAILURE = 'basis/flight/plan/area/LIST_FAILURE'; +// const FLIGHT_PLAN_AREA_REQUEST = 'basis/flight/plan/area/LIST_REQUEST'; +// const FLIGHT_PLAN_AREA_SUCCESS = 'basis/flight/plan/area/LIST_SUCCESS'; +// const FLIGHT_PLAN_AREA_FAILURE = 'basis/flight/plan/area/LIST_FAILURE'; + +// 목록 +const FLIGHT_PLAN_LIST_REQUEST = 'basis/flight/plan/list/LIST_REQUEST'; +const FLIGHT_PLAN_LIST_SUCCESS = 'basis/flight/plan/list/LIST_SUCCESS'; +const FLIGHT_PLAN_LIST_FAILURE = 'basis/flight/plan/list/LIST_FAILURE'; + +// 상세 +const FLIGHT_PLAN_DETAIL_REQUEST = 'basis/flight/plan/detail/DETAIL_REQUEST'; +const FLIGHT_PLAN_DETAIL_SUCCESS = 'basis/flight/plan/detail/DETAIL_SUCCESS'; +const FLIGHT_PLAN_DETAIL_FAILURE = 'basis/flight/plan/detail/DETAIL_FAILURE'; + +// 생성 +const FLIGHT_PLAN_CREATE_REQUEST = 'basis/flight/plan/create/CREATE_REQUEST'; +const FLIGHT_PLAN_CREATE_SUCCESS = 'basis/flight/plan/create/CREATE_SUCCESS'; +const FLIGHT_PLAN_CREATE_FAILURE = 'basis/flight/plan/create/CREATE_FAILURE'; + +// 수정 +const FLIGHT_PLAN_UPDATE_REQUEST = 'basis/flight/plan/update/UPDATE_REQUEST'; +const FLIGHT_PLAN_UPDATE_SUCCESS = 'basis/flight/plan/update/UPDATE_SUCCESS'; +const FLIGHT_PLAN_UPDATE_FAILURE = 'basis/flight/plan/update/UPDATE_FAILURE'; + +// 삭제 +const FLIGHT_PLAN_DELETE_REQUEST = 'basis/flight/plan/delete/DELETE_REQUEST'; +const FLIGHT_PLAN_DELETE_SUCCESS = 'basis/flight/plan/delete/DELETE_SUCCESS'; +const FLIGHT_PLAN_DELETE_FAILURE = 'basis/flight/plan/delete/DELETE_FAILURE'; + +// 조종사 조회 +const FLIGHT_PLAN_PILOT_LIST_REQUEST = 'basis/flight/plan/pilot_list/PILOT_LIST_REQUEST'; +const FLIGHT_PLAN_PILOT_LIST_SUCCESS = 'basis/flight/plan/pilot_list/PILOT_LIST_SUCCESS'; +const FLIGHT_PLAN_PILOT_LIST_FAILURE = 'basis/flight/plan/pilot_list/PILOT_LIST_FAILURE'; + +// 기체 조회 +const FLIGHT_PLAN_ARCRFT_LIST_REQUEST = 'basis/flight/plan/arcrft_list/ARCRFT_LIST_REQUEST'; +const FLIGHT_PLAN_ARCRFT_LIST_SUCCESS = 'basis/flight/plan/arcrft_list/ARCRFT_LIST_SUCCESS'; +const FLIGHT_PLAN_ARCRFT_LIST_FAILURE = 'basis/flight/plan/arcrft_list/ARCRFT_LIST_FAILURE'; + + + + -const FLIGHT_PLAN_CREATE_REQUEST = 'basis/flight/plan/area/LIST_CREATE_REQUEST'; -const FLIGHT_PLAN_CREATE_SUCCESS = 'basis/flight/plan/area/LIST_CREATE_SUCCESS'; -const FLIGHT_PLAN_CREATE_FAILURE = 'basis/flight/plan/area/LIST_CREATE_FAILURE'; export const AREA_LIST = createAsyncAction( AREA_LIST_REQUEST, @@ -23,22 +65,72 @@ export const AREA_LIST = createAsyncAction( AREA_LIST_FAILURE )(); -export const FLIGHT_PLAN_AREA = createAsyncAction( - FLIGHT_PLAN_AREA_REQUEST, - FLIGHT_PLAN_AREA_SUCCESS, - FLIGHT_PLAN_AREA_FAILURE -)(); +// export const FLIGHT_PLAN_AREA = createAsyncAction( +// FLIGHT_PLAN_AREA_REQUEST, +// FLIGHT_PLAN_AREA_SUCCESS, +// FLIGHT_PLAN_AREA_FAILURE +// )(); + +// 목록 +export const FLIGHT_PLAN_LIST = createAsyncAction( + FLIGHT_PLAN_LIST_REQUEST, + FLIGHT_PLAN_LIST_SUCCESS, + FLIGHT_PLAN_LIST_FAILURE +)(); +// 상세 +export const FLIGHT_PLAN_DETAIL = createAsyncAction( + FLIGHT_PLAN_DETAIL_REQUEST, + FLIGHT_PLAN_DETAIL_SUCCESS, + FLIGHT_PLAN_DETAIL_FAILURE +)(); + +// 생성 export const FLIGHT_PLAN_CREATE = createAsyncAction( FLIGHT_PLAN_CREATE_REQUEST, FLIGHT_PLAN_CREATE_SUCCESS, FLIGHT_PLAN_CREATE_FAILURE -)(); +)(); + +// 수정 +export const FLIGHT_PLAN_UPDATE = createAsyncAction( + FLIGHT_PLAN_UPDATE_REQUEST, + FLIGHT_PLAN_UPDATE_SUCCESS, + FLIGHT_PLAN_UPDATE_FAILURE +)(); + +// 삭제 +export const FLIGHT_PLAN_DELETE = createAsyncAction( + FLIGHT_PLAN_DELETE_REQUEST, + FLIGHT_PLAN_DELETE_SUCCESS, + FLIGHT_PLAN_DELETE_FAILURE +)(); + +// 조종사 목록 +export const FLIGHT_PLAN_PILOT_LIST = createAsyncAction( + FLIGHT_PLAN_PILOT_LIST_REQUEST, + FLIGHT_PLAN_PILOT_LIST_SUCCESS, + FLIGHT_PLAN_PILOT_LIST_FAILURE +)(); + +// 기체 목록 +export const FLIGHT_PLAN_ARCRFT_LIST = createAsyncAction( + FLIGHT_PLAN_ARCRFT_LIST_REQUEST, + FLIGHT_PLAN_ARCRFT_LIST_SUCCESS, + FLIGHT_PLAN_ARCRFT_LIST_FAILURE +)(); + const actions = { AREA_LIST, - FLIGHT_PLAN_AREA, - FLIGHT_PLAN_CREATE + // FLIGHT_PLAN_AREA, + FLIGHT_PLAN_LIST, + FLIGHT_PLAN_DETAIL, + FLIGHT_PLAN_CREATE, + FLIGHT_PLAN_UPDATE, + FLIGHT_PLAN_DELETE, + FLIGHT_PLAN_PILOT_LIST, + FLIGHT_PLAN_ARCRFT_LIST }; -export type FlightAction = ActionType; \ No newline at end of file +export type FlightAction = ActionType; diff --git a/src/modules/basis/flight/apis/basisFlightApi.ts b/src/modules/basis/flight/apis/basisFlightApi.ts index 14b1ad6..8c93f50 100644 --- a/src/modules/basis/flight/apis/basisFlightApi.ts +++ b/src/modules/basis/flight/apis/basisFlightApi.ts @@ -1,18 +1,57 @@ import axios from '../../../utils/customAxiosUtil'; import qs from 'qs'; -import { FlightPlanData } from '../models/basisFlightModel'; +import { FlightPlanData, FlightPlanListRqData } from '../models/basisFlightModel'; export const flightPlanAPI = { - area: async () => { - 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 + area: async () => { + const res = await axios.get(`api/bas/flight/area`); + return res; + }, + list: async (data: FlightPlanListRqData) => { + const queryString = qs.stringify(data, { + addQueryPrefix: true, + arrayFormat: 'repeat' + }); + console.log('>>> rq : ', queryString) + const res = await axios.get(`api/bas/flight/plan/list${queryString}`); + console.log('>>> rs : ', res); + return res; + }, + detail: async (planSno: number) => { + console.log('>>> rq : ', planSno) + const res = await axios.get(`api/bas/flight/plan/detail/${planSno}`); + console.log('>>> rs : ', res); + return res; + }, + create: async (data: FlightPlanData) => { + console.log('>>> rq : ', data) + const res = await axios.post(`api/bas/flight/paln/create`, data); + console.log('>>> rs : ', res); + return res; + }, + update: async (data: FlightPlanData) => { + console.log('>>> rq : ', data) + const res = await axios.put(`api/bas/flight/plan/update`, data); + console.log('>>> rs : ', res); + return res; + }, + delete: async (planSno: number) => { + console.log('>>> rq : ', planSno) + const res = await axios.get(`api/bas/flight/plan/delete/${planSno}`); + console.log('>>> rs : ', res); + return res; + }, + listPilot: async (groupId: number) => { + console.log('>>> rq : ', groupId) + const res = await axios.get(`api/bas/flight/plan/pilot/${groupId}`); + console.log('>>> rs : ', res); + return res; + }, + listArcrft: async (groupId: number) => { + console.log('>>> rq : ', groupId) + const res = await axios.get(`api/bas/flight/plan/arcrft/${groupId}`); + console.log('>>> rs : ', res); + return res; + } +} diff --git a/src/modules/basis/flight/models/basisFlightModel.ts b/src/modules/basis/flight/models/basisFlightModel.ts index 6afe7a4..d25a98c 100644 --- a/src/modules/basis/flight/models/basisFlightModel.ts +++ b/src/modules/basis/flight/models/basisFlightModel.ts @@ -1,49 +1,116 @@ +import { date } from "yup"; + export interface FlightState { - areaList: FlightAreaData | undefined - flightPlanArea: FlightPlanArea | undefined - flightPlanData: FlightPlanData | undefined + areaList: FlightAreaData | undefined + flightPlanArea: FlightPlanArea | undefined + list: [FlightPlanData] | undefined + detail: FlightPlanData | undefined + pilotList: FlightPlanPilotDataList | undefined + arcrftList: FlightPlanArcrftDataList | undefined } export interface FlightAreaData { - areaList: [] + areaList: [] } export interface FlightPlanArea { - address : '', - coordinates : '', - redius : '', - altitude_m : '', - altitude_ft : '', + address: '', + coordinates: '', + redius: '', + altitude_m: '', + altitude_ft: '', } export interface FlightPlanData { - 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; + planArcrftSno: number, + planSno: number, + arcrftSno: number, + idntfNum: string, + groupNm: string, + prdctNum: string, + arcrftTypeCd: string, + arcrftModelNm: string, + prdctCmpnNm: string, + prdctDate: Date; + arcrftLngth: number, + arcrftWdth: number, + arcrftHght: number, + arcrftWght: number, + wghtTypeCd: string, + imageUrl: string, + takeoffWght: number; + useYn: string, + cameraYn: string, + insrncYn: string, + ownerNm: string, + createUserId: string, + createDt: Date, + updateUserId: string, + updateDt: Date, + areaList: FlightPlanAreaDataList, + pilotList: FlightPlanPilotDataList, + arcrftList: FlightPlanArcrftDataList, + docState: string, +} + +export interface FlightPlanAreaData { + planAreaSno: number, + planSno: number, + areaType: string, + fltMethod: string, + bufferZone: number, + fltElev: string, + createUserId: string, + createDt: Date, + updateUserId: string, + updateDt: Date, + coordList: FlightPlanAreaCoordData + docState: string, +} + +export interface FlightPlanAreaDataList extends Array {}; + +export interface FlightPlanAreaCoordData { + planAreaCoordSno: number, + planAreaSno: number, + lat: number, + lon: number, + createUserId: string, + createDt: Date, + docState: string +} + +export interface FlightPlanAreaCoordData extends Array {}; + +export interface FlightPlanPilotData { + } +export interface FlightPlanPilotDataList extends Array {}; + +export interface FlightPlanArcrftData { + +} + +export interface FlightPlanArcrftDataList extends Array {}; + +// rq +export interface FlightPlanListRqData { + schFltStDt: Date, + schFltEndDt: Date, + aprvlYn: string +} +export interface FlightPlanAprovRqData { + planSnoList: [number], + aprvlYn: string +} + + export const initFlight = { - areaList: undefined, - flightPlanArea: undefined, - flightPlanData: undefined -}; \ No newline at end of file + areaList: undefined, + flightPlanArea: undefined, + list: undefined, + detail: undefined, + pilotList: undefined, + arcrftList: undefined +}; diff --git a/src/modules/basis/flight/reducers/basisFlightReducer.ts b/src/modules/basis/flight/reducers/basisFlightReducer.ts index bfaa0e7..10bd0c5 100644 --- a/src/modules/basis/flight/reducers/basisFlightReducer.ts +++ b/src/modules/basis/flight/reducers/basisFlightReducer.ts @@ -6,22 +6,48 @@ import { FlightState, initFlight } from '../models/basisFlightModel'; import { any } from 'prop-types'; -export const flightReducer = createReducer ( initFlight ) -.handleAction(Actions.AREA_LIST.success, (state, action) => +export const flightReducer = createReducer(initFlight) + .handleAction(Actions.AREA_LIST.success, (state, action) => produce(state, draft => { - const {data} = action.payload; - draft.areaList = data; + const {data} = action.payload; + draft.areaList = data; }) -) -.handleAction(Actions.FLIGHT_PLAN_AREA.request, (state, action) => - produce(state, draft => { - const data = action.payload; - draft.flightPlanArea = data; + ) + // .handleAction(Actions.FLIGHT_PLAN_AREA.request, (state, action) => + // produce(state, draft => { + // const data = action.payload; + // draft.flightPlanArea = data; + // }) + // ) + // 목록 + .handleAction(Actions.FLIGHT_PLAN_LIST.success, (state, action) => + produce(state, draft => { + console.log('list : ', state, action); + const data = action.payload; + draft.list = data; + }) + ) + // 상세 + .handleAction(Actions.FLIGHT_PLAN_DETAIL.success, (state, action) => + produce(state, draft => { + console.log('detail : ', state, action); + const data = action.payload; + draft.detail = data; }) -) -.handleAction(Actions.FLIGHT_PLAN_CREATE.request, (state, action) => - produce(state, draft => { - const data = action.payload; - draft.flightPlanData = data; + ) + // 조종사 조회 + .handleAction(Actions.FLIGHT_PLAN_PILOT_LIST.success, (state, action) => + produce(state, draft => { + console.log('pilot : ', state, action); + const data = action.payload; + draft.pilotList = data; + }) + ) + // 기체 조회 + .handleAction(Actions.FLIGHT_PLAN_ARCRFT_LIST.success, (state, action) => + produce(state, draft => { + console.log('arcrft : ', state, action); + const data = action.payload; + draft.arcrftList = 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 07ee998..7f51438 100644 --- a/src/modules/basis/flight/sagas/basisFlightSaga.ts +++ b/src/modules/basis/flight/sagas/basisFlightSaga.ts @@ -9,101 +9,133 @@ import { import * as MessageActions from '../../../comn/message/actions/comnMessageAction'; import * as Actions from '../actions/basisFlightAction'; import * as Apis from '../apis/basisFlightApi'; +import { FlightPlanData } from "../models/basisFlightModel"; function* listAreaSaga(action: ActionType) { - try { - const response = yield call(Apis.flightPlanAPI.area); + try { + const response = yield call(Apis.flightPlanAPI.area); - if(response.errorCode) { - yield put( - MessageActions.IS_ERROR({ - errorCode: response.errorCode, - errorMessage: response.errorMessage, - isHistoryBack: false, - isRefresh: false - }) - ); - return; - } - - yield put( - Actions.AREA_LIST.success({ - data: response - }) - ); - } catch (error: any) { - yield put( - Actions.AREA_LIST.failure(error) - ); + if (response.errorCode) { + yield put( + MessageActions.IS_ERROR({ + errorCode: response.errorCode, + errorMessage: response.errorMessage, + isHistoryBack: false, + isRefresh: false + }) + ); + return; } -} -function* createFlightPlanArea(action: ActionType) { - try { - const data = action.payload; + yield put( + Actions.AREA_LIST.success({ + data: response + }) + ); + } catch (error: any) { + yield put( + Actions.AREA_LIST.failure(error) + ); + } +} - yield put( - Actions.FLIGHT_PLAN_AREA.success({ - data: data - }) - ) +// function* createFlightPlanArea(action: ActionType) { +// try { +// const data = action.payload; +// +// yield put( +// Actions.FLIGHT_PLAN_AREA.success({ +// data: data +// }) +// ) +// +// } catch (error: any) { +// yield put( +// Actions.FLIGHT_PLAN_AREA.failure(error) +// ) +// } +// } - } catch (error: any) { - yield put( - Actions.FLIGHT_PLAN_AREA.failure(error) - ) - } -} -function* createFlightPlanData( - 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) { +function* listPlanSaga(action: ActionType) { + try { + const data = action.payload; + console.log(`listPlanSaga payload `, data) + const response = yield call(Apis.flightPlanAPI.list, data); + console.log('rs', response); + if (response.errorCode) { yield put( MessageActions.IS_ERROR({ - errorCode: ERROR_MESSAGE.code, - errorMessage: ERROR_MESSAGE.message, + errorCode: response.errorCode, + errorMessage: response.errorMessage, isHistoryBack: false, isRefresh: false }) ); - // yield put(Actions.GROUP_CREATE.failure(error)); + return; } + + yield put( + Actions.FLIGHT_PLAN_LIST.success(response.data) + ); + } catch (error: any) { + yield put( + Actions.FLIGHT_PLAN_LIST.failure(error) + ); } +} + +// function* createFlightPlanData( +// 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 + yield takeEvery(Actions.AREA_LIST.request, listAreaSaga); + // yield takeEvery(Actions.FLIGHT_PLAN_AREA.request, createFlightPlanArea); + yield takeEvery(Actions.FLIGHT_PLAN_LIST.request, listPlanSaga) + // yield takeEvery(Actions.FLIGHT_PLAN_CREATE.request, createFlightPlanData) +}