diff --git a/src/components/basis/flight/plan/FlightPlanArcrft.js b/src/components/basis/flight/plan/FlightPlanArcrft.js index 7cf45df..d76a066 100644 --- a/src/components/basis/flight/plan/FlightPlanArcrft.js +++ b/src/components/basis/flight/plan/FlightPlanArcrft.js @@ -13,7 +13,7 @@ const FlightPlanArcrft = ({ arcrftList, handleSelectArcrft, onClickEvent, name, { id: 'selectPilot', name: '선택', cell: row => { return { - handleSelectArcrft(row.arcrftSno) + handleSelectArcrft(row.idntfNum) } }>선택; } diff --git a/src/containers/basis/flight/plan/FlightPlanArcrftContainer.js b/src/containers/basis/flight/plan/FlightPlanArcrftContainer.js index 49ffde7..df658a2 100644 --- a/src/containers/basis/flight/plan/FlightPlanArcrftContainer.js +++ b/src/containers/basis/flight/plan/FlightPlanArcrftContainer.js @@ -20,11 +20,11 @@ const FlightPlanArcrftContainer = ({handleModal, type}) => { } /* 기체 선택 */ - const handleSelectArcrft = (arcrftSno) => { + const handleSelectArcrft = (idntfNum) => { handleModal({target: 'arcrft', isOpen: false}); const arcrft = arcrftList.find(arcrft => { - return arcrft.arcrftSno === arcrftSno; + return arcrft.idntfNum === idntfNum; }); /* 기체 정보 Redux 저장 */ dispatch(Actions.ARCRFT_SELECT(arcrft)); diff --git a/src/containers/basis/flight/plan/FlightPlanDetailContainer.js b/src/containers/basis/flight/plan/FlightPlanDetailContainer.js index e4c8bd3..ba81175 100644 --- a/src/containers/basis/flight/plan/FlightPlanDetailContainer.js +++ b/src/containers/basis/flight/plan/FlightPlanDetailContainer.js @@ -40,9 +40,9 @@ const FlightPlanDetailContainer = () => { useEffect(() => { if(pilotSelect !== undefined) { const pilotList = detailData.pilotList.concat(); - const pilot = Object.assign({}, initFlightBas['pilot']); - console.log(pilotSelect); + const pilot = Object.assign({}, initFlightBas['pilot']); + pilot.planSno = detailData.planSno; pilot.cstmrSno = pilotSelect.cstmrSno; pilot.groupNm = pilotSelect.groupNm; pilot.clncd = pilotSelect.clncd; @@ -53,32 +53,27 @@ const FlightPlanDetailContainer = () => { // 파일럿 중복 확인 let checking = true - pilotList.forEach(p => { - if(p.cstmrSno !== 0) { - if(p.cstmrSno === pilotSelect.cstmrSno) { - alert('중복'); - checking = false; - return false; - } + pilotList.forEach((p, i) => { + if(p.cstmrSno === pilotSelect.cstmrSno) { + alert('이미 등록된 조종사입니다.'); + checking = false; + return false; } + + if(p.cstmrSno !== 0) { + if(i === pilotList.length -1) pilotList.push(pilot); + } else { + pilotList[i] = pilot; + } }); if(checking) { - pilotList.forEach((p, i) => { - console.log(pilotList); - if(p.cstmrSno === 0) { - pilotList[i] = pilot - } else if(i == 0){ - return pilotList.push(pilot); - } - }); - setDetailData(prevState => { return { ...prevState, ['pilotList']: pilotList } - }) + }); } } @@ -87,8 +82,9 @@ const FlightPlanDetailContainer = () => { useEffect(() => { if(arcrftSelect !== undefined) { const arcrftList = detailData.arcrftList.concat(); - const arcrft = Object.assign({}, initFlightBas['arcrft']); + const arcrft = Object.assign({}, initFlightBas['arcrft']); + arcrft.planSno = detailData.planSno; arcrft.arcrftSno = arcrftSelect.arcrftSno; arcrft.groupId = arcrftSelect.groupId; arcrft.groupNm = arcrftSelect.groupNm; @@ -98,35 +94,30 @@ const FlightPlanDetailContainer = () => { arcrft.idntfNum = arcrftSelect.idntfNum; arcrft.ownerNm = arcrftSelect.ownerNm; - let checking = true; - arcrftList.forEach(p => { - if(p.arcrftSno !== 0){ - if(p.arcrftSno === arcrftSelect.arcrftSno) { - alert('중복'); - checking = false; - return false; - } - } - console.log(p); - }); + let checking = true; - if(checking){ - arcrftList.forEach((p,i) => { - console.log('>>>>>>>>>>', arcrftList); - if(p.arcrftSno === 0){ - arcrftList[i] = arcrft - } else if(i == 0){ - return arcrftList.push(arcrft); - } - }); - } + arcrftList.forEach((p,i) => { + if(p.idntfNum === arcrftSelect.idntfNum) { + alert('이미 등록된 기체 식별번호입니다.'); + checking = false; + return false; + } + + if(p.idntfNum) { + if(i === arcrftList.length -1) arcrftList.push(arcrft); + } else { + arcrftList[i] = arcrft; + } + }); - setDetailData(prevState => { - return { - ...prevState, - ['arcrftList']: arcrftList - } - }) + if(checking) { + setDetailData(prevState => { + return { + ...prevState, + ['arcrftList']: arcrftList + } + }) + } } }, [arcrftSelect]) @@ -331,11 +322,10 @@ const FlightPlanDetailContainer = () => { setDetailData(prevState => { const arr = [...prevState[arrName]]; const deleteData = arr.splice(index, 1); - console.log(deleteData); + const id = initFlight.detail['pilotList'] - console.log(id); - if(arr.length > 0) { - debugger + + if(arr.length > 0) { return { ...prevState, [arrName]: arr @@ -353,8 +343,8 @@ const FlightPlanDetailContainer = () => { setDetailData(prevState => { const arr = [...prevState[arrName]]; const deleteData = arr.splice(index, 1); - console.log(deleteData); - const id = initFlight.detail['arcrftList'] + + const id = initFlight.detail['arcrftList'] if(arr.length > 0) { return { ...prevState,