Browse Source

비행계획서 버그 수정 - 삭제

feature/auth
이학준 2 years ago
parent
commit
4005975317
  1. 13
      src/components/basis/flight/plan/FlightPlanForm.js
  2. 68
      src/containers/basis/flight/plan/FlightPlanDetailContainer.js

13
src/components/basis/flight/plan/FlightPlanForm.js

@ -646,13 +646,13 @@ const PilotForm = ({data, handleChange, index, handleDeleteArray}) => {
/> />
</FormGroup> </FormGroup>
</Col> </Col>
{index !== 0 ?
<Col className='count-del-btn' xs={12} md={2} xl={2} > <Col className='count-del-btn' xs={12} md={2} xl={2} >
<Button.Ripple <Button.Ripple
color='danger' color='danger'
className='text-nowrap px-1' className='text-nowrap px-1'
onClick={() => onClick={() =>
handleDeleteArray({ type: 'pilot', index }) handleDeleteArray({ type: 'pilot'})
} }
outline outline
> >
@ -660,9 +660,6 @@ const PilotForm = ({data, handleChange, index, handleDeleteArray}) => {
<span>삭제</span> <span>삭제</span>
</Button.Ripple> </Button.Ripple>
</Col> </Col>
:
null
}
</Row> </Row>
</div>) </div>)
} }
@ -775,7 +772,7 @@ const ArcrftForm = ({data, handleChange, index, handleDeleteArray}) => {
/> />
</FormGroup> </FormGroup>
</Col> </Col>
{index !== 0 ?
<Col className='count-del-btn' xs={12} md={2} xl={2} > <Col className='count-del-btn' xs={12} md={2} xl={2} >
<Button.Ripple <Button.Ripple
color='danger' color='danger'
@ -789,9 +786,7 @@ const ArcrftForm = ({data, handleChange, index, handleDeleteArray}) => {
<span>삭제</span> <span>삭제</span>
</Button.Ripple> </Button.Ripple>
</Col> </Col>
:
null
}
</Row> </Row>
</div>) </div>)
} }

68
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 {useHistory, useLocation, useParams} from 'react-router-dom';
import {useDispatch, useSelector} from 'react-redux'; import {useDispatch, useSelector} from 'react-redux';
import * as Actions from '../../../../modules/basis/flight/actions/basisFlightAction'; 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 = { const initModal = {
@ -40,6 +41,7 @@ const FlightPlanDetailContainer = () => {
if(pilotSelect !== undefined) { if(pilotSelect !== undefined) {
const pilotList = detailData.pilotList.concat(); 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.cstmrSno = pilotSelect.cstmrSno;
pilot.groupNm = pilotSelect.groupNm; pilot.groupNm = pilotSelect.groupNm;
@ -48,14 +50,28 @@ const FlightPlanDetailContainer = () => {
pilot.memberName = pilotSelect.memberName; pilot.memberName = pilotSelect.memberName;
pilot.hpno = pilotSelect.hpno; pilot.hpno = pilotSelect.hpno;
// 파일럿 중복 확인
let checking = true
pilotList.forEach(p => {
if(p.cstmrSno !== 0) {
if(p.cstmrSno === pilotSelect.cstmrSno) {
alert('중복');
checking = false;
return false;
}
}
});
if(checking) {
pilotList.forEach((p, i) => { pilotList.forEach((p, i) => {
console.log(pilotList);
if(p.cstmrSno === 0) { if(p.cstmrSno === 0) {
pilotList[i] = pilot pilotList[i] = pilot
} else { } else {
if(i === pilotList.length-1) {
return pilotList.push(pilot); return pilotList.push(pilot);
} }
}
}); });
setDetailData(prevState => { setDetailData(prevState => {
@ -65,6 +81,7 @@ const FlightPlanDetailContainer = () => {
} }
}) })
} }
}
}, [pilotSelect]) }, [pilotSelect])
@ -82,15 +99,27 @@ const FlightPlanDetailContainer = () => {
arcrft.idntfNum = arcrftSelect.idntfNum; arcrft.idntfNum = arcrftSelect.idntfNum;
arcrft.ownerNm = arcrftSelect.ownerNm; arcrft.ownerNm = arcrftSelect.ownerNm;
arcrftList.forEach((p, i) => { let checking = true;
if(p.arcrftSno === 0) { 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 arcrftList[i] = arcrft
} else { } else {
if(i === arcrftList.length-1) {
return arcrftList.push(arcrft); return arcrftList.push(arcrft);
} }
}
}); });
}
setDetailData(prevState => { setDetailData(prevState => {
return { return {
@ -302,30 +331,45 @@ const FlightPlanDetailContainer = () => {
setDetailData(prevState => { setDetailData(prevState => {
const arr = [...prevState[arrName]]; const arr = [...prevState[arrName]];
const deleteData = arr.splice(index, 1); const deleteData = arr.splice(index, 1);
console.log(deleteData);
const id = initFlight.detail['pilotList']
console.log(id);
if(arr.length > 0) {
debugger
return { return {
...prevState, ...prevState,
[arrName]: arr [arrName]: arr
} }
}
else {
debugger
return {
...prevState,
[arrName]: id
}
}
}) })
break;
case 'arcrft': case 'arcrft':
setDetailData(prevState => { setDetailData(prevState => {
const arr = [...prevState[arrName]]; const arr = [...prevState[arrName]];
const deleteData = arr.splice(index, 1); const deleteData = arr.splice(index, 1);
console.log(deleteData);
const id = initFlight.detail['arcrftList']
if(arr.length > 0) { if(arr.length > 0) {
return { return {
...prevState, ...prevState,
[arrName]: arr [arrName]: arr
} }
} else { }
else{
return { return {
...prevState, ...prevState,
['pilotList']: initFlightBas[arrName] [arrName]: id
} }
} }
}) })
break;
default: default:
break; break;
} }

Loading…
Cancel
Save