|
|
|
@ -1,10 +1,10 @@
|
|
|
|
|
import React, {useEffect, useState} from 'react'; |
|
|
|
|
import React, { useEffect, useState } from 'react'; |
|
|
|
|
import FlightPlanForm from '../../../../components/basis/flight/plan/FlightPlanForm'; |
|
|
|
|
import {CustomDetailLayout} from '../../../../components/layout/CustomDetailLayout'; |
|
|
|
|
import {useHistory, useLocation, useParams} from 'react-router-dom'; |
|
|
|
|
import {useDispatch, useSelector} from 'react-redux'; |
|
|
|
|
import { CustomDetailLayout } from '../../../../components/layout/CustomDetailLayout'; |
|
|
|
|
import { useHistory, useLocation, useParams } from 'react-router-dom'; |
|
|
|
|
import { useDispatch, useSelector } from 'react-redux'; |
|
|
|
|
import * as Actions from '../../../../modules/basis/flight/actions/basisFlightAction'; |
|
|
|
|
import {initFlight, initFlightBas} from '../../../../modules/basis/flight/models/basisFlightModel'; |
|
|
|
|
import { initFlight, initFlightBas } from '../../../../modules/basis/flight/models/basisFlightModel'; |
|
|
|
|
import { AiFillPropertySafety } from 'react-icons/ai'; |
|
|
|
|
import { ErrorModal } from '../../../../components/modal/ErrorModal'; |
|
|
|
|
import { CgArrowLeftR } from 'react-icons/cg'; |
|
|
|
@ -25,12 +25,12 @@ const FlightPlanDetailContainer = () => {
|
|
|
|
|
const { detail, pilotSelect, arcrftSelect, areaList, selectGroup } = flightState; |
|
|
|
|
const [modal, setModal] = useState(initModal); |
|
|
|
|
const [detailData, setDetailData] = useState(initFlightBas.initDetail); |
|
|
|
|
//모달 관련 설정
|
|
|
|
|
const [modal2, setModal2] = useState({ |
|
|
|
|
isOpen: false, |
|
|
|
|
title: '', |
|
|
|
|
desc: '' |
|
|
|
|
}); |
|
|
|
|
//모달 관련 설정
|
|
|
|
|
const [modal2, setModal2] = useState({ |
|
|
|
|
isOpen: false, |
|
|
|
|
title: '', |
|
|
|
|
desc: '' |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
if (Object.keys(urlParams).length === 0 && urlParams.constructor === Object) return; |
|
|
|
@ -46,7 +46,7 @@ const FlightPlanDetailContainer = () => {
|
|
|
|
|
}, [detail]) |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
if(pilotSelect !== undefined) {
|
|
|
|
|
if (pilotSelect !== undefined) { |
|
|
|
|
const pilotList = detailData.pilotList.concat(); |
|
|
|
|
const pilot = Object.assign({}, initFlightBas['pilot']); |
|
|
|
|
|
|
|
|
@ -62,24 +62,24 @@ const FlightPlanDetailContainer = () => {
|
|
|
|
|
let checking = true |
|
|
|
|
|
|
|
|
|
pilotList.forEach((p, i) => { |
|
|
|
|
if(p.cstmrSno === pilotSelect.cstmrSno) { |
|
|
|
|
if (p.cstmrSno === pilotSelect.cstmrSno) { |
|
|
|
|
setModal2({ |
|
|
|
|
isOpen: true, |
|
|
|
|
title: '중복값 입력 오류', |
|
|
|
|
desc: '이미 등록된 조종사 정보입니다.' |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
checking = false; |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(p.cstmrSno !== 0) { |
|
|
|
|
if(i === pilotList.length -1) pilotList.push(pilot);
|
|
|
|
|
if (p.cstmrSno !== 0) { |
|
|
|
|
if (i === pilotList.length - 1) pilotList.push(pilot); |
|
|
|
|
} else { |
|
|
|
|
pilotList[i] = pilot; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
if(checking) { |
|
|
|
|
if (checking) { |
|
|
|
|
setDetailData(prevState => { |
|
|
|
|
return { |
|
|
|
|
...prevState, |
|
|
|
@ -92,7 +92,7 @@ const FlightPlanDetailContainer = () => {
|
|
|
|
|
}, [pilotSelect]) |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
if(arcrftSelect !== undefined) { |
|
|
|
|
if (arcrftSelect !== undefined) { |
|
|
|
|
const arcrftList = detailData.arcrftList.concat(); |
|
|
|
|
const arcrft = Object.assign({}, initFlightBas['arcrft']); |
|
|
|
|
|
|
|
|
@ -108,25 +108,25 @@ const FlightPlanDetailContainer = () => {
|
|
|
|
|
|
|
|
|
|
let checking = true; |
|
|
|
|
|
|
|
|
|
arcrftList.forEach((p,i) => {
|
|
|
|
|
if(p.idntfNum === arcrftSelect.idntfNum) {
|
|
|
|
|
arcrftList.forEach((p, i) => { |
|
|
|
|
if (p.idntfNum === arcrftSelect.idntfNum) { |
|
|
|
|
setModal2({ |
|
|
|
|
isOpen: true, |
|
|
|
|
title: '중복값 입력 오류', |
|
|
|
|
desc: '이미 등록된 기체 정보입니다.' |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
checking = false; |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(p.idntfNum) { |
|
|
|
|
if(i === arcrftList.length -1) arcrftList.push(arcrft); |
|
|
|
|
if (p.idntfNum) { |
|
|
|
|
if (i === arcrftList.length - 1) arcrftList.push(arcrft); |
|
|
|
|
} else { |
|
|
|
|
arcrftList[i] = arcrft; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
if(checking) { |
|
|
|
|
if (checking) { |
|
|
|
|
setDetailData(prevState => { |
|
|
|
|
return { |
|
|
|
|
...prevState, |
|
|
|
@ -138,30 +138,30 @@ const FlightPlanDetailContainer = () => {
|
|
|
|
|
}, [arcrftSelect]) |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
if(areaList !== undefined) { |
|
|
|
|
if (areaList !== undefined) { |
|
|
|
|
const areas = detailData.areaList.concat(); |
|
|
|
|
|
|
|
|
|
const createAreaList = areas.map((area, i) => { |
|
|
|
|
const targetArea = areaList[i]; |
|
|
|
|
|
|
|
|
|
let targetCoordList = area.coordList; |
|
|
|
|
if(targetArea.coordList) { |
|
|
|
|
if (targetArea.coordList) { |
|
|
|
|
targetCoordList = targetArea.coordList.map((coord, j) => { |
|
|
|
|
return { |
|
|
|
|
...coord, |
|
|
|
|
planAreaSno : area.planAreaSno, |
|
|
|
|
planAreaCoordSno : 0 |
|
|
|
|
planAreaSno: area.planAreaSno, |
|
|
|
|
planAreaCoordSno: 0 |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
...area, |
|
|
|
|
areaType : targetArea.areaType, |
|
|
|
|
areaType: targetArea.areaType, |
|
|
|
|
bufferZone: targetArea.bufferZone ? targetArea.bufferZone : 0, |
|
|
|
|
fltElev : targetArea.fltElev ? targetArea.fltElev : 0, |
|
|
|
|
fltMethod : targetArea.fltMethod ? targetArea.fltMethod : '', |
|
|
|
|
coordList : targetCoordList |
|
|
|
|
fltElev: targetArea.fltElev ? targetArea.fltElev : 0, |
|
|
|
|
fltMethod: targetArea.fltMethod ? targetArea.fltMethod : '', |
|
|
|
|
coordList: targetCoordList |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
@ -183,8 +183,8 @@ const FlightPlanDetailContainer = () => {
|
|
|
|
|
}, [flightState]); |
|
|
|
|
|
|
|
|
|
const handleModal = (modal) => { |
|
|
|
|
if(modal.target === 'area' && modal.isOpen) {
|
|
|
|
|
if(detailData.areaList) {
|
|
|
|
|
if (modal.target === 'area' && modal.isOpen) { |
|
|
|
|
if (detailData.areaList) { |
|
|
|
|
dispatch(Actions.FLIGHT_PLAN_AREA_BUFFER_LIST.request(detailData.areaList)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -196,18 +196,18 @@ const FlightPlanDetailContainer = () => {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 변경감지
|
|
|
|
|
const handleChange = ({name, value, type, index, pIndex}) => { |
|
|
|
|
const handleChange = ({ name, value, type, index, pIndex }) => { |
|
|
|
|
const arrName = `${type}List`; |
|
|
|
|
switch (type) { |
|
|
|
|
case 'coord': |
|
|
|
|
// TODO 추후 삭제 필요 start
|
|
|
|
|
if(name == 'lonlat'){ |
|
|
|
|
if (name == 'lonlat') { |
|
|
|
|
const values = value.split("/"); |
|
|
|
|
let latValue = 1 |
|
|
|
|
let lonValue = 1 |
|
|
|
|
if(values.length == 1){ |
|
|
|
|
if (values.length == 1) { |
|
|
|
|
latValue = values[0].trim(); |
|
|
|
|
} else if(values.length == 2){ |
|
|
|
|
} else if (values.length == 2) { |
|
|
|
|
latValue = values[0].trim(); |
|
|
|
|
lonValue = values[1].trim(); |
|
|
|
|
} else { |
|
|
|
@ -215,10 +215,10 @@ const FlightPlanDetailContainer = () => {
|
|
|
|
|
} |
|
|
|
|
setDetailData(prevState => { |
|
|
|
|
const areaList = prevState.areaList.map((area, i) => { |
|
|
|
|
if(i !== pIndex) return {...area}; |
|
|
|
|
if (i !== pIndex) return { ...area }; |
|
|
|
|
|
|
|
|
|
const coordList = area.coordList.map((coord, j) => { |
|
|
|
|
if(j !== index) return {...coord}; |
|
|
|
|
if (j !== index) return { ...coord }; |
|
|
|
|
return { |
|
|
|
|
...coord, |
|
|
|
|
lat: latValue, |
|
|
|
@ -281,7 +281,7 @@ const FlightPlanDetailContainer = () => {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 추가
|
|
|
|
|
const handleAddArray = ({type, pIndex}) => { |
|
|
|
|
const handleAddArray = ({ type, pIndex }) => { |
|
|
|
|
const arrName = `${type}List`; |
|
|
|
|
switch (type) { |
|
|
|
|
case 'coord': |
|
|
|
@ -317,7 +317,7 @@ const FlightPlanDetailContainer = () => {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// 삭제
|
|
|
|
|
const handleDeleteArray = ({type, index, pIndex}) => { |
|
|
|
|
const handleDeleteArray = ({ type, index, pIndex }) => { |
|
|
|
|
const arrName = `${type}List`; |
|
|
|
|
switch (type) { |
|
|
|
|
case 'coord': |
|
|
|
@ -340,7 +340,7 @@ const FlightPlanDetailContainer = () => {
|
|
|
|
|
|
|
|
|
|
const id = initFlight.detail['pilotList'] |
|
|
|
|
|
|
|
|
|
if(arr.length > 0) {
|
|
|
|
|
if (arr.length > 0) { |
|
|
|
|
return { |
|
|
|
|
...prevState, |
|
|
|
|
[arrName]: arr |
|
|
|
@ -360,13 +360,13 @@ const FlightPlanDetailContainer = () => {
|
|
|
|
|
const deleteData = arr.splice(index, 1); |
|
|
|
|
|
|
|
|
|
const id = initFlight.detail['arcrftList'] |
|
|
|
|
if(arr.length > 0) { |
|
|
|
|
if (arr.length > 0) { |
|
|
|
|
return { |
|
|
|
|
...prevState, |
|
|
|
|
[arrName]: arr |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else{ |
|
|
|
|
else { |
|
|
|
|
return { |
|
|
|
|
...prevState, |
|
|
|
|
[arrName]: id |
|
|
|
@ -380,37 +380,43 @@ const FlightPlanDetailContainer = () => {
|
|
|
|
|
} |
|
|
|
|
// 저장
|
|
|
|
|
const handleSave = () => { |
|
|
|
|
const reg_email = /^([0-9a-zA-Z_\.-]+)@([0-9a-zA-Z_-]+)(\.[0-9a-zA-Z_-]+){1,2}$/; |
|
|
|
|
const check_num = /[0-9]/; |
|
|
|
|
const check_kor = |
|
|
|
|
/^[가-힣a-zA-Z0-9][^!@#$%^&*()+\=\[\]{};':"\\|,.<>\/?\s]*$/; |
|
|
|
|
|
|
|
|
|
if (!detailData.memberName) { |
|
|
|
|
if (!detailData.memberName) { |
|
|
|
|
setModal2({ |
|
|
|
|
isOpen: true, |
|
|
|
|
title: '필수값 입력 오류', |
|
|
|
|
desc: '이름을 입력해 주세요.' |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
else if (!detailData.hpno) { |
|
|
|
|
setModal2({ |
|
|
|
|
isOpen: true, |
|
|
|
|
title: '필수값 입력 오류', |
|
|
|
|
desc: '전화번호를 입력해 주세요.' |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
else if(!detailData.email){ |
|
|
|
|
|
|
|
|
|
else if (!detailData.email) { |
|
|
|
|
setModal2({ |
|
|
|
|
isOpen: true, |
|
|
|
|
title: '필수값 입력 오류', |
|
|
|
|
desc: '이메일을 입력해 주세요.' |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
else if(!detailData.fltPurpose){ |
|
|
|
|
else if (!detailData.fltPurpose) { |
|
|
|
|
setModal2({ |
|
|
|
|
isOpen:true, |
|
|
|
|
isOpen: true, |
|
|
|
|
title: '필수값 입력 오류', |
|
|
|
|
desc: '비행목적을 선택해 주세요.' |
|
|
|
|
}); |
|
|
|
@ -422,63 +428,86 @@ const FlightPlanDetailContainer = () => {
|
|
|
|
|
isOpen: true, |
|
|
|
|
title: '필수값 입력 오류', |
|
|
|
|
desc: '좌표를 선택해 주세요.' |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
else if (!detailData.areaList[0].fltElev) { |
|
|
|
|
setModal2({ |
|
|
|
|
isOpen: true, |
|
|
|
|
title: '필수값 입력 오류', |
|
|
|
|
desc: '반경/고도를 입력해 주세요.' |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
else if (!detailData.areaList[0].fltMethod) { |
|
|
|
|
setModal2({ |
|
|
|
|
isOpen: true, |
|
|
|
|
title: '필수값 입력 오류', |
|
|
|
|
desc: '비행방식를 입력해 주세요.' |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
else if (!detailData.pilotList[0].groupNm) { |
|
|
|
|
setModal2({ |
|
|
|
|
isOpen: true, |
|
|
|
|
title: '필수값 입력 오류', |
|
|
|
|
desc: '조종사를 선택해 주세요.' |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
else if (!detailData.arcrftList[0].groupNm) { |
|
|
|
|
setModal2({ |
|
|
|
|
isOpen: true, |
|
|
|
|
title: '필수값 입력 오류', |
|
|
|
|
desc: '기체를 선택해 주세요.' |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
else if (!check_kor.test(detailData.memberName)) { |
|
|
|
|
setModal2({ |
|
|
|
|
isOpen: true, |
|
|
|
|
title: '필수값 입력 오류', |
|
|
|
|
desc: '지원하지 않는 입력값 입니다.' |
|
|
|
|
}); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
else if (!check_num.test(detailData.hpno)) { |
|
|
|
|
setModal2({ |
|
|
|
|
isOpen: true, |
|
|
|
|
title: '필수값 입력 오류', |
|
|
|
|
desc: '연락처에 숫자만 입력해주세요.' |
|
|
|
|
}); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
if (!reg_email.test(detailData.email)) { |
|
|
|
|
setModal2({ |
|
|
|
|
isOpen: true, |
|
|
|
|
title: '필수값 입력 오류', |
|
|
|
|
desc: '이메일 형식을 다시 확인해 주세요.', |
|
|
|
|
}); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!detailData.planSno) { |
|
|
|
|
dispatch(Actions.FLIGHT_PLAN_CREATE.request(detailData)); |
|
|
|
|
} else { |
|
|
|
|
dispatch(Actions.FLIGHT_PLAN_UPDATE.request(detailData)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
dispatch(Actions.FLIGHT_PLAN_GROUP_SELECT( {cstmrSno: 0, groupId: '', groupNm: ''} )); |
|
|
|
|
dispatch(Actions.FLIGHT_PLAN_GROUP_SELECT({ cstmrSno: 0, groupId: '', groupNm: '' })); |
|
|
|
|
} |
|
|
|
|
// 삭제
|
|
|
|
|
const handleDelete = () => { |
|
|
|
|
if(!urlParams.planSno || urlParams.planSno){ |
|
|
|
|
if (!urlParams.planSno || urlParams.planSno) { |
|
|
|
|
|
|
|
|
|
dispatch(Actions.FLIGHT_PLAN_DELETE.request(urlParams.planSno)); |
|
|
|
|
dispatch(Actions.FLIGHT_PLAN_DELETE.request(urlParams.planSno)); |
|
|
|
|
} |
|
|
|
|
dispatch(Actions.FLIGHT_PLAN_GROUP_SELECT({ cstmrSno: 0, groupId: '', groupNm: '' })); |
|
|
|
|
} |
|
|
|
|
dispatch(Actions.FLIGHT_PLAN_GROUP_SELECT({cstmrSno: 0, groupId: '', groupNm: ''})); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
<CustomDetailLayout title={"비행 계획 신청서"}> |
|
|
|
@ -491,14 +520,14 @@ const FlightPlanDetailContainer = () => {
|
|
|
|
|
handleChange={handleChange} |
|
|
|
|
handleAddArray={handleAddArray} |
|
|
|
|
handleDeleteArray={handleDeleteArray} |
|
|
|
|
// handlerSave={
|
|
|
|
|
// pageType === 'create' ? handlerCreate : handlerUpdate
|
|
|
|
|
// }
|
|
|
|
|
// onChange={onChange}
|
|
|
|
|
// handlerDelete={handlerDelete}
|
|
|
|
|
// handlerInput={handlerInput}
|
|
|
|
|
// handlerSave={
|
|
|
|
|
// pageType === 'create' ? handlerCreate : handlerUpdate
|
|
|
|
|
// }
|
|
|
|
|
// onChange={onChange}
|
|
|
|
|
// handlerDelete={handlerDelete}
|
|
|
|
|
// handlerInput={handlerInput}
|
|
|
|
|
/> |
|
|
|
|
<ErrorModal modal={modal2} setModal={setModal2} /> |
|
|
|
|
<ErrorModal modal={modal2} setModal={setModal2} /> |
|
|
|
|
{/*<FlightPlanAreaModal*/} |
|
|
|
|
{/* modal={modal}*/} |
|
|
|
|
{/* save={saveFlightPlanArea}*/} |
|
|
|
|