From 4005975317015350add8d610eae4d1dc35bb52c7 Mon Sep 17 00:00:00 2001 From: hagjoon Date: Thu, 18 Aug 2022 14:19:55 +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=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95=20-=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../basis/flight/plan/FlightPlanForm.js | 15 +-- .../flight/plan/FlightPlanDetailContainer.js | 108 ++++++++++++------ 2 files changed, 81 insertions(+), 42 deletions(-) diff --git a/src/components/basis/flight/plan/FlightPlanForm.js b/src/components/basis/flight/plan/FlightPlanForm.js index 3487aa3..8cc21bd 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 574d9fc..29077c0 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; }