diff --git a/src/containers/basis/flight/aprv/FlightPlanAprvContainer_bdf.js b/src/containers/basis/flight/aprv/FlightPlanAprvContainer_bdf.js new file mode 100644 index 00000000..fef28aab --- /dev/null +++ b/src/containers/basis/flight/aprv/FlightPlanAprvContainer_bdf.js @@ -0,0 +1,178 @@ +import React, {useEffect, useState} from 'react'; +import {Col, Row, Button} from 'reactstrap'; +import {CustomMainLayout} from '../../../../components/layout/CustomMainLayout'; +import moment from 'moment/moment'; +import FlightPlanAprvSearch from '../../../../components/basis/flight/aprv/FlightPlanAprvSearch'; +import FlightPlanAprvGrid from '../../../../components/basis/flight/aprv/FlightPlanAprvGrid'; +import FlightPlanGrid from '../../../../components/basis/flight/plan/FlightPlanGrid'; +import {useDispatch, useSelector, shallowEqual} from 'react-redux'; +import * as FlightAction from '../../../../modules/basis/flight/actions/basisFlightAction'; +import {useHistory} from 'react-router-dom'; +import FlightPlanGroupGrid from '../../../../components/basis/flight/plan/FlightPlanGroupGrid'; +import { JOIN_LIST } from '../../../../modules/basis/group/actions/basisGroupAction'; + +const initSearchData = { + schFltStDt: moment().set({'date': 1, 'h': 0, 'm': 0, 's': 0}).format('YYYY-MM-DD HH:mm:ss'), + schFltEndDt: moment().set({'h': 23, 'm': 59, 's': 59}).format('YYYY-MM-DD HH:mm:ss'), + aprvlYn: 'N', + groupId: '', + cstmrSno: 0, +}; + + +const FlightPlanAprvContainer_Df = () => { + const dispatch = useDispatch(); + const history = useHistory(); + const [searchData, setSearchData] = useState(initSearchData); + const [selPlanSnoList, setSelPlanSnoList] = useState([]); + const {list: aprvList, aprvProc, selectGroup} = useSelector(state => state.flightState); + const { joinList, joinListCount } = useSelector(state => state.groupState); + const { user } = useSelector(state => state.authState, shallowEqual); + + + const handleGroupSelect = ({ groupId, groupNm, groupAuthCd }) => { + // 권한 상관 없이 모두 조회 가능 + const param = searchData; + + param.cstmrSno = user.cstmrSno; + param.groupId = groupId; + + dispatch(FlightAction.FLIGHT_PLAN_GROUP_SELECT( {cstmrSno: user.cstmrSno, groupId: groupId, groupNm: groupNm} )); + + // groupId sessionStorage에 보관 (1 브라우저 1 tab에만 유효) + sessionStorage.setItem('groupId', groupId); + sessionStorage.setItem('cstmrSno', user.cstmrSno); + + setSearchData(prevState => { + return { + ...prevState, + cstmrSno: user.cstmrSno, + groupId: groupId + } + }); + + dispatch(FlightAction.FLIGHT_PLAN_LIST.request(param)); + } + + const handlerGroupCancel = () => { + dispatch(FlightAction.FLIGHT_PLAN_GROUP_SELECT( {cstmrSno: 0, groupId: '', groupNm: ''} )); + } + + + const handleMoveDetail = (id) => { + history.push(`/basis/flight/plan/detail/${id}`) + } + + const columns = [ + {id: 'planSno', name: '번호', cell: (row, i) => (
{i + 1}
)}, + {id: 'fltPurpose', name: '비행목적', cell: row => (
{row.fltPurpose}
)}, + { + id: 'fltMethod', name: '비행방식', cell: row => { + const displayName = row.areaList && row.areaList.length > 0 && row.areaList[0].fltMethod || '-'; + return
{displayName}
+ } + }, + {id: 'schFltStDt', name: '출발일', cell: row => (
{row.schFltStDt}
)}, + {id: 'aprvlYn', name: '승인여부', cell: row => (
{row.aprvlYn}
)}, + { + id: 'moveDetail', name: '상세보기', cell: row => { + return { + handleMoveDetail(row.planSno)} + }>상세; + } + } + ]; + + // 최초 비행계획서 목록 조회 + useEffect(() => { + handleSearch(searchData); + }, []) + + useEffect(() => { + if (user?.cstmrSno) { + dispatch( + JOIN_LIST.request({ + cstmrSno: user?.cstmrSno + }) + ); + } + }, [user]) + + useEffect(() => { + console.log(aprvProc) + if (aprvProc && aprvProc.result > 0) { + handleSearch(searchData); + } + }, [aprvProc]) + + + const handleSearch = (data) => { + dispatch(FlightAction.FLIGHT_APRV_LIST.request(data)); + } + const handleChangeSearchData = (values) => { + setSearchData(prevState => ({ + ...prevState, + ...values + })) + } + const handleChangeSelected = ({selectedRows}) => { + setSelPlanSnoList(selectedRows.map(item => item.planSno)) + } + const handleClickAprv = (type) => (e) => { + // notAprov, aprv + // console.log(type, selPlanSnoList, e) + if (!selPlanSnoList || selPlanSnoList.length < 1) { + alert('비행계획서를 선택해주세요.'); + return; + } + ; + const sendData = { + planSnoList: [...selPlanSnoList], + aprvlYn: type === 'aprv' ? 'Y' : 'N' + } + dispatch(FlightAction.FLIGHT_APRV_PROC.request(sendData)); + } + + return ( + +
+ + + + + + {selectGroup.cstmrSno !==0 ? ( + <> + + + + ) : ( +
+ 나의 그룹 목록에서 상세보기를 클릭하세요. +
+ )} + +
+
+
+ ) +} + +export default FlightPlanAprvContainer_Df;