Browse Source

조종사 검색기능 추가

feature/auth
qkr7828(박재우) 2 years ago
parent
commit
d7ddc505eb
  1. 12
      src/components/basis/flight/plan/FlightPlanPilot.js
  2. 36
      src/containers/basis/flight/plan/FlightPlanPilotContainer.js

12
src/components/basis/flight/plan/FlightPlanPilot.js

@ -3,7 +3,7 @@ import {Button, Card, CardBody, Col, CustomInput, Row, FormGroup, Input, Label}
import {Search} from 'react-feather'; import {Search} from 'react-feather';
import {GridDatabase} from '../../../crud/grid/GridDatatable'; import {GridDatabase} from '../../../crud/grid/GridDatatable';
const FlightPlanPilot = ({ pilotList, handleSelectPilot }) => { const FlightPlanPilot = ({ pilotList, handleSelectPilot, returnPilot, onClickEvent, setInputVal }) => {
const columns = [ const columns = [
{id: 'groupNm', name: '그룹 명', cell: row => (<div>{row.groupNm}</div>)}, {id: 'groupNm', name: '그룹 명', cell: row => (<div>{row.groupNm}</div>)},
{id: 'memberName', name: '성명', cell: row => (<div>{row.memberName}</div>)}, {id: 'memberName', name: '성명', cell: row => (<div>{row.memberName}</div>)},
@ -33,7 +33,7 @@ const FlightPlanPilot = ({ pilotList, handleSelectPilot }) => {
<Button.Ripple <Button.Ripple
color='primary' color='primary'
size='sm' size='sm'
// onClick={handleClickSearch} onClick={onClickEvent}
> >
<Search size={16}/> <Search size={16}/>
검색 검색
@ -57,7 +57,7 @@ const FlightPlanPilot = ({ pilotList, handleSelectPilot }) => {
id='memberName' id='memberName'
name='memberName' name='memberName'
// value={props.params.groupNm} // value={props.params.groupNm}
// onChange={props.handlerInput} onChange={(e) => {setInputVal(e.target.value)}}
bsSize='sm' bsSize='sm'
// onKeyPress={props.onKeyPress} // onKeyPress={props.onKeyPress}
placeholder='성명을 입력하세요' placeholder='성명을 입력하세요'
@ -82,7 +82,7 @@ const FlightPlanPilot = ({ pilotList, handleSelectPilot }) => {
<div className='cont-ti d-flex justify-content-between align-items-sm-center align-items-start flex-sm-row'> <div className='cont-ti d-flex justify-content-between align-items-sm-center align-items-start flex-sm-row'>
<div> <div>
<h4>조종사 목록</h4> <h4>조종사 목록</h4>
<span className='search-case'>검색결과 {!!pilotList ? pilotList.length : 0}</span> <span className='search-case'>검색결과 {!!returnPilot ? [returnPilot].length : 0}</span>
</div> </div>
<div className='d-flex align-items-center'></div> <div className='d-flex align-items-center'></div>
</div> </div>
@ -90,8 +90,8 @@ const FlightPlanPilot = ({ pilotList, handleSelectPilot }) => {
<Card> <Card>
<div className='invoice-list-dataTable'> <div className='invoice-list-dataTable'>
<GridDatabase <GridDatabase
data={pilotList} data={[returnPilot]}
count={pilotList ? pilotList.length : 0} count={returnPilot ? [returnPilot].length : 0}
columns={columns} columns={columns}
// pagination={props.pagination} // pagination={props.pagination}
/> />

36
src/containers/basis/flight/plan/FlightPlanPilotContainer.js

@ -6,6 +6,8 @@ import FlightPlanPilot from '../../../../components/basis/flight/plan/FlightPlan
const FlightPlanPilotContainer = ({handleModal, type}) => { const FlightPlanPilotContainer = ({handleModal, type}) => {
const dispatch = useDispatch(); const dispatch = useDispatch();
const { pilotList, selectGroup } = useSelector(state => state.flightState); const { pilotList, selectGroup } = useSelector(state => state.flightState);
const [returnPilot, setReturnPilot] = useState('');
const [inputVal , setInputVal] = useState('');
/* 조종사 조회 */ /* 조종사 조회 */
@ -19,7 +21,7 @@ const FlightPlanPilotContainer = ({handleModal, type}) => {
/* 조종사 선택 */ /* 조종사 선택 */
const handleSelectPilot = (cstmrSno) => { const handleSelectPilot = (cstmrSno) => {
handleModal({target: 'poilot', isOpen: false}); handleModal({target: 'pilot', isOpen: false});
const pilot = pilotList.find(pilot => { const pilot = pilotList.find(pilot => {
return pilot.cstmrSno === cstmrSno; return pilot.cstmrSno === cstmrSno;
@ -32,11 +34,41 @@ const FlightPlanPilotContainer = ({handleModal, type}) => {
handleSearch(); handleSearch();
}, []) }, [])
useEffect(()=> {
console.log('goToHome')
if(pilotList) {
onTest();
}
},[pilotList])
const onClickEvent= (e)=> {
setInputVal(e.target.value);
onTest();
}
const onTest = () => {
pilotList.filter((unit) =>{
if(inputVal==''){
setReturnPilot(unit)
}else if(unit.memberName.includes(inputVal)){
setReturnPilot(unit)
console.log("Filtered >>>>" , returnPilot)
}else if (inputVal != ''){
setReturnPilot('')
}
})
}
return ( return (
<FlightPlanPilot <FlightPlanPilot
pilotList = {pilotList}
handleSelectPilot={handleSelectPilot} handleSelectPilot={handleSelectPilot}
handleSearch={handleSearch}
onClickEvent={onClickEvent}
pilotList={pilotList}
returnPilot={returnPilot}
setInputVal={setInputVal}
/> />
) )
} }

Loading…
Cancel
Save