diff --git a/src/components/basis/flight/plan/FlightPlanForm.js b/src/components/basis/flight/plan/FlightPlanForm.js index 3487aa3f..8cc21bd0 100644 --- a/src/components/basis/flight/plan/FlightPlanForm.js +++ b/src/components/basis/flight/plan/FlightPlanForm.js @@ -646,23 +646,20 @@ const PilotForm = ({data, handleChange, index, handleDeleteArray}) => { /> - {index !== 0 ? + - handleDeleteArray({ type: 'pilot', index }) + handleDeleteArray({ type: 'pilot'}) } outline > 삭제 - - : - null - } + ) } @@ -775,7 +772,7 @@ const ArcrftForm = ({data, handleChange, index, handleDeleteArray}) => { /> - {index !== 0 ? + { 삭제 - : - null - } + ) } diff --git a/src/containers/basis/flight/plan/FlightPlanDetailContainer.js b/src/containers/basis/flight/plan/FlightPlanDetailContainer.js index 574d9fc7..29077c0a 100644 --- a/src/containers/basis/flight/plan/FlightPlanDetailContainer.js +++ b/src/containers/basis/flight/plan/FlightPlanDetailContainer.js @@ -4,7 +4,8 @@ import {CustomDetailLayout} from '../../../../components/layout/CustomDetailLayo import {useHistory, useLocation, useParams} from 'react-router-dom'; import {useDispatch, useSelector} from 'react-redux'; import * as Actions from '../../../../modules/basis/flight/actions/basisFlightAction'; -import {initFlightBas} from '../../../../modules/basis/flight/models/basisFlightModel'; +import {initFlight, initFlightBas} from '../../../../modules/basis/flight/models/basisFlightModel'; +import { AiFillPropertySafety } from 'react-icons/ai'; const initModal = { @@ -39,7 +40,8 @@ const FlightPlanDetailContainer = () => { useEffect(() => { if(pilotSelect !== undefined) { const pilotList = detailData.pilotList.concat(); - const pilot = Object.assign({}, initFlightBas['pilot']); + const pilot = Object.assign({}, initFlightBas['pilot']); + console.log(pilotSelect); pilot.cstmrSno = pilotSelect.cstmrSno; pilot.groupNm = pilotSelect.groupNm; @@ -48,22 +50,37 @@ const FlightPlanDetailContainer = () => { pilot.memberName = pilotSelect.memberName; pilot.hpno = pilotSelect.hpno; - pilotList.forEach((p, i) => { - if(p.cstmrSno === 0) { - pilotList[i] = pilot - } else { - if(i === pilotList.length-1) { - return pilotList.push(pilot); + // 파일럿 중복 확인 + let checking = true + + pilotList.forEach(p => { + if(p.cstmrSno !== 0) { + if(p.cstmrSno === pilotSelect.cstmrSno) { + alert('중복'); + checking = false; + return false; } } - }); + }); - setDetailData(prevState => { - return { - ...prevState, - ['pilotList']: pilotList - } - }) + if(checking) { + pilotList.forEach((p, i) => { + console.log(pilotList); + if(p.cstmrSno === 0) { + pilotList[i] = pilot + } else { + + return pilotList.push(pilot); + } + }); + + setDetailData(prevState => { + return { + ...prevState, + ['pilotList']: pilotList + } + }) + } } }, [pilotSelect]) @@ -80,17 +97,29 @@ const FlightPlanDetailContainer = () => { arcrft.idntfTypeCd = arcrftSelect.idntfTypeCd; arcrft.arcrftTypeCd = arcrftSelect.arcrftTypeCd; arcrft.idntfNum = arcrftSelect.idntfNum; - arcrft.ownerNm = arcrftSelect.ownerNm; + arcrft.ownerNm = arcrftSelect.ownerNm; - arcrftList.forEach((p, i) => { - if(p.arcrftSno === 0) { - arcrftList[i] = arcrft - } else { - if(i === arcrftList.length-1) { - return arcrftList.push(arcrft); + let checking = true; + arcrftList.forEach(p => { + if(p.arcrftSno !== 0){ + if(p.arcrftSno === arcrftSelect.arcrftSno) { + alert('중복'); + checking = false; + return false; } } - }); + }); + + if(checking){ + arcrftList.forEach((p,i) => { + console.log('>>>>>>>>>>', arcrftList); + if(p.arcrftSno === 0){ + arcrftList[i] = arcrft + } else { + return arcrftList.push(arcrft); + } + }); + } setDetailData(prevState => { return { @@ -302,30 +331,45 @@ const FlightPlanDetailContainer = () => { setDetailData(prevState => { const arr = [...prevState[arrName]]; const deleteData = arr.splice(index, 1); - - return { - ...prevState, - [arrName]: arr - } + console.log(deleteData); + const id = initFlight.detail['pilotList'] + console.log(id); + if(arr.length > 0) { + debugger + return { + ...prevState, + [arrName]: arr + } + } + else { + debugger + return { + ...prevState, + [arrName]: id + } + } }) + break; case 'arcrft': setDetailData(prevState => { const arr = [...prevState[arrName]]; const deleteData = arr.splice(index, 1); - + console.log(deleteData); + const id = initFlight.detail['arcrftList'] if(arr.length > 0) { return { ...prevState, [arrName]: arr } - } else { + } + else{ return { ...prevState, - ['pilotList']: initFlightBas[arrName] + [arrName]: id } } - }) + break; default: break; }