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>
</Col>
{index !== 0 ?
<Col className='count-del-btn' xs={12} md={2} xl={2} >
<Button.Ripple
color='danger'
className='text-nowrap px-1'
onClick={() =>
handleDeleteArray({ type: 'pilot', index })
handleDeleteArray({ type: 'pilot'})
}
outline
>
@ -660,9 +660,6 @@ const PilotForm = ({data, handleChange, index, handleDeleteArray}) => {
<span>삭제</span>
</Button.Ripple>
</Col>
:
null
}
</Row>
</div>)
}
@ -775,7 +772,7 @@ const ArcrftForm = ({data, handleChange, index, handleDeleteArray}) => {
/>
</FormGroup>
</Col>
{index !== 0 ?
<Col className='count-del-btn' xs={12} md={2} xl={2} >
<Button.Ripple
color='danger'
@ -789,9 +786,7 @@ const ArcrftForm = ({data, handleChange, index, handleDeleteArray}) => {
<span>삭제</span>
</Button.Ripple>
</Col>
:
null
}
</Row>
</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 {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 = {
@ -40,6 +41,7 @@ const FlightPlanDetailContainer = () => {
if(pilotSelect !== undefined) {
const pilotList = detailData.pilotList.concat();
const pilot = Object.assign({}, initFlightBas['pilot']);
console.log(pilotSelect);
pilot.cstmrSno = pilotSelect.cstmrSno;
pilot.groupNm = pilotSelect.groupNm;
@ -48,14 +50,28 @@ const FlightPlanDetailContainer = () => {
pilot.memberName = pilotSelect.memberName;
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) => {
console.log(pilotList);
if(p.cstmrSno === 0) {
pilotList[i] = pilot
} else {
if(i === pilotList.length-1) {
return pilotList.push(pilot);
}
}
});
setDetailData(prevState => {
@ -65,6 +81,7 @@ const FlightPlanDetailContainer = () => {
}
})
}
}
}, [pilotSelect])
@ -82,15 +99,27 @@ const FlightPlanDetailContainer = () => {
arcrft.idntfNum = arcrftSelect.idntfNum;
arcrft.ownerNm = arcrftSelect.ownerNm;
arcrftList.forEach((p, i) => {
if(p.arcrftSno === 0) {
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 {
if(i === arcrftList.length-1) {
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);
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;
}

Loading…
Cancel
Save