From 27da351ca5f19e53f14915f5bcc00457f562ca43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?kimjh=28=EA=B9=80=EC=9E=A5=ED=98=84=29?= Date: Thu, 22 Sep 2022 15:47:17 +0900 Subject: [PATCH] =?UTF-8?q?=EB=B9=84=ED=96=89=EC=9D=B4=EB=A0=A5=ED=98=84?= =?UTF-8?q?=ED=99=A9=20=EA=B7=B8=EB=A3=B9=20=EC=84=A0=ED=83=9D=EC=8B=9C=20?= =?UTF-8?q?=EB=B9=84=ED=96=89=EC=9D=B4=EB=A0=A5=20=ED=98=84=ED=99=A9=20?= =?UTF-8?q?=EC=B4=88=EA=B8=B0=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../history/AnalysisHistoryContainer.js | 148 +++++++++--------- .../history/actions/analysisHistoryAction.ts | 7 +- .../history/reducers/analysisHitoryReducer.ts | 6 + 3 files changed, 85 insertions(+), 76 deletions(-) diff --git a/src/containers/analysis/history/AnalysisHistoryContainer.js b/src/containers/analysis/history/AnalysisHistoryContainer.js index a0f656e..7c9263c 100644 --- a/src/containers/analysis/history/AnalysisHistoryContainer.js +++ b/src/containers/analysis/history/AnalysisHistoryContainer.js @@ -8,12 +8,19 @@ import { CustomMainLayout } from '../../../components/layout/CustomMainLayout'; import * as Actions from '../../../modules/analysis/history/actions/analysisHistoryAction'; import FlightPlanGroupGrid from '../../../components/basis/flight/plan/FlightPlanGroupGrid'; import { JOIN_LIST } from '../../../modules/basis/group/actions/basisGroupAction'; -import { Col, Row, Button, Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap'; +import { + Col, + Row, + Button, + Modal, + ModalHeader, + ModalBody, + ModalFooter +} from 'reactstrap'; import * as FlightAction from '../../../modules/basis/flight/actions/basisFlightAction'; import { useHistory } from 'react-router-dom'; import { MessageErrorModal } from '../../../components/message/MessageErrorModal'; - export const AnalysisHistoryContainer = props => { const { data, count, searchParams } = useSelector( state => state.analysisHistoryState @@ -23,12 +30,15 @@ export const AnalysisHistoryContainer = props => { endDate: moment().subtract(0, 'day').format('YYYY-MM-DD'), // stDate: moment().set({ 'date': 1, 'h': 0, 'm': 0, 's': 0 }).format('YYYY-MM-DD HH:mm:ss'), // endDate: moment().set({ 'h': 23, 'm': 59, 's': 59 }).format('YYYY-MM-DD HH:mm:ss'), - groupId: '', - + groupId: '' }; const [searchData, setSearchData] = useState(initSearchData); - const { list: aprvList, aprvProc, selectGroup } = useSelector(state => state.flightState); + const { + list: aprvList, + aprvProc, + selectGroup + } = useSelector(state => state.flightState); const { joinList, joinListCount } = useSelector(state => state.groupState); const { user } = useSelector(state => state.authState, shallowEqual); @@ -42,6 +52,42 @@ export const AnalysisHistoryContainer = props => { color: '' }); + useEffect(() => { + if (aprvProc && aprvProc.result > 0) { + handleSearch(searchData); + } + }, [aprvProc]); + + useEffect(() => { + if (user?.cstmrSno) { + dispatch( + JOIN_LIST.request({ + cstmrSno: user?.cstmrSno + }) + ); + } + }, [user]); + + useEffect(() => { + setParams({ + ...params, + stDate: '', + endDate: '', + search1: '', + groupId: searchData.groupId + }); + }, [searchData.groupId]); + + useEffect(() => { + handlerGroupCancel(); + }, []); + + const onKeyPress = e => { + if (e.key == 'Enter') { + handlerSearch(); + } + }; + const handleGroupSelect = ({ groupId }) => { // 권한 상관 없이 모두 조회 가능 const param = searchData; @@ -54,47 +100,33 @@ export const AnalysisHistoryContainer = props => { sessionStorage.setItem('groupId', groupId); sessionStorage.setItem('cstmrSno', user.cstmrSno); - setIsClick(0) + setIsClick(0); setSearchData(prevState => { return { ...prevState, // cstmrSno: user.cstmrSno, groupId: groupId - } + }; }); - //dispatch(Actions.list.request({ searchParams: param })); - } + dispatch(Actions.LIST_INITAL()); + }; const handlerGroupCancel = () => { - dispatch(FlightAction.FLIGHT_PLAN_GROUP_SELECT({ cstmrSno: 0, groupId: '', groupNm: '', endDate: '', stDate: '' })); - setIsClick(0) - - } - - - - useEffect(() => { - if (aprvProc && aprvProc.result > 0) { - handleSearch(searchData); - } - }, [aprvProc]) - - useEffect(() => { - if (user?.cstmrSno) { - dispatch( - JOIN_LIST.request({ - cstmrSno: user?.cstmrSno - }) - ); - } - }, [user]) - + dispatch( + FlightAction.FLIGHT_PLAN_GROUP_SELECT({ + cstmrSno: 0, + groupId: '', + groupNm: '', + endDate: '', + stDate: '' + }) + ); + setIsClick(0); + }; const dispatch = useDispatch(); const titleName = '비행이력 현황'; - - const excelHeaders = [ { label: '일자', key: 'cntrlStDt' }, { label: '식별번호', key: 'idntfNum' }, @@ -207,30 +239,7 @@ export const AnalysisHistoryContainer = props => { endDate: moment().subtract(-1, 'day').format('YYYY-MM-DD'), search1: '', groupId: searchData.groupId - }); - console.log(searchData.groupId); - - useEffect(() => { - setParams({ - ...params, - stDate: '', - endDate: '', - search1: '', - groupId: searchData.groupId - }); - }, [searchData.groupId]); - - - useEffect(() => { - if (data) return; - }, [searchParams]); - - const onKeyPress = e => { - if (e.key == 'Enter') { - handlerSearch(); - } - }; // useEffect(() => { }, [params]); @@ -241,18 +250,15 @@ export const AnalysisHistoryContainer = props => { title: '필수값 입력 오류', desc: '올바른 일자를 입력해 주세요.', color: 'modal-danger' - }) - } - else if (!params.groupId) { + }); + } else if (!params.groupId) { setModal({ isOpen: true, title: '필수값 입력 오류', desc: '그룹 선택 해주세요.', color: 'modal-danger' - }) - } - else - dispatch(Actions.list.request({ searchParams: params })); + }); + } else dispatch(Actions.list.request({ searchParams: params })); }; const handlerInput = (type, val) => { @@ -264,9 +270,9 @@ export const AnalysisHistoryContainer = props => { setParams({ ...params, stDate: moment(val[0]).format('YYYY-MM-DD'), - endDate: moment(val[1]).format('YYYY-MM-DD'), + endDate: moment(val[1]).format('YYYY-MM-DD') }); - setIsClick(-1) + setIsClick(-1); } } }; @@ -275,7 +281,6 @@ export const AnalysisHistoryContainer = props => { setIsClick(val); }; return ( -
@@ -303,13 +308,11 @@ export const AnalysisHistoryContainer = props => { searchData={searchData} /> - ) : (
나의 그룹 목록에서 상세보기를 클릭하세요.
)} - {selectGroup.cstmrSno !== 0 ? ( @@ -321,15 +324,11 @@ export const AnalysisHistoryContainer = props => { excelHeaders={excelHeaders} count={count} pagination={true} - /> - ) : ( -
-
+
)} -
@@ -358,6 +357,5 @@ export const AnalysisHistoryContainer = props => {
- ); }; diff --git a/src/modules/analysis/history/actions/analysisHistoryAction.ts b/src/modules/analysis/history/actions/analysisHistoryAction.ts index 921616e..66532f2 100644 --- a/src/modules/analysis/history/actions/analysisHistoryAction.ts +++ b/src/modules/analysis/history/actions/analysisHistoryAction.ts @@ -20,6 +20,8 @@ const DETAIL_FAILURE = 'anls/hstry/DETAIL_FAILURE'; const DISPATCH_SEARCH = 'amls/hstry/DISPATCH_SEARCH'; +const LIST_INIT = 'anls/hstry/LIST_INIT'; + export const dispatchSearch = createAction(DISPATCH_SEARCH)<{ searchParams: string }>(); @@ -41,11 +43,14 @@ export const detail = createAsyncAction( DETAIL_FAILURE )(); +export const LIST_INITAL = createAction(LIST_INIT)(); + const actions = { list, detail, log, - dispatchSearch + dispatchSearch, + LIST_INITAL }; export type AnalysisHistoryAction = ActionType; diff --git a/src/modules/analysis/history/reducers/analysisHitoryReducer.ts b/src/modules/analysis/history/reducers/analysisHitoryReducer.ts index 53d0e82..f71d0e8 100644 --- a/src/modules/analysis/history/reducers/analysisHitoryReducer.ts +++ b/src/modules/analysis/history/reducers/analysisHitoryReducer.ts @@ -44,4 +44,10 @@ export const analysisHistoryReducer = createReducer< draft.log = log; }) + ) + .handleAction(Actions.LIST_INITAL, (state, action) => + produce(state, draft => { + draft.data = initResponseAnalysisHistoryData.data; + draft.count = initResponseAnalysisHistoryData.count; + }) );