From c6c9b62d2a5dfe640720faf3a8d72bd5284d42ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?junh=5Feee=28=EC=9D=B4=EC=A4=80=ED=9D=AC=29?= Date: Wed, 12 Oct 2022 17:32:52 +0900 Subject: [PATCH] =?UTF-8?q?=EA=B6=8C=ED=95=9C=EC=A0=95=EB=A6=AC=20-=20?= =?UTF-8?q?=EB=B9=84=ED=96=89=EA=B3=84=ED=9A=8D=EC=8A=B9=EC=9D=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../basis/flight/aprv/FlightPlanAprvGrid.js | 45 ++----- .../basis/flight/plan/FlightPlanGrid.js | 20 +-- .../flight/aprv/FlightPlanAprvContainer.js | 121 +++++++----------- .../flight/plan/FlightPlanDetailContainer.js | 27 ++-- 4 files changed, 80 insertions(+), 133 deletions(-) diff --git a/src/components/basis/flight/aprv/FlightPlanAprvGrid.js b/src/components/basis/flight/aprv/FlightPlanAprvGrid.js index 299490d7..4b99c3a7 100644 --- a/src/components/basis/flight/aprv/FlightPlanAprvGrid.js +++ b/src/components/basis/flight/aprv/FlightPlanAprvGrid.js @@ -7,50 +7,18 @@ import { useSelector } from 'react-redux'; const FlightPlanAprvGrid = ({ data, - // columns, handleChangeSelected, handleClickAprv, - joinList, - selectGroup, - handleChangeCheckbox, paginationPerPage, pagination, paginationRowsPerPageOptions, handlerPageChange, - total + total, + isMyGroup }) => { - const [aprvAuth, setAprvAuth] = useState(''); const { loading } = useSelector(state => state.loadingReducer); - useEffect(() => { - joinList.forEach(c => { - if (c.groupId === selectGroup.groupId) { - if (c.groupAuthCd === 'NORMAL') { - setAprvAuth(false); - } else if (c.groupAuthCd === 'MASTER' || c.groupAuthCd === 'LEADER') { - setAprvAuth(true); - } - } - }); - }, [selectGroup]); - const columns = [ - // { - // id: '', - // name: '', - // minWidth: '50px', - // cell: (row, i) => ( - // <> - // handleChangeCheckbox(e, row)} - // /> - // - // ) - // }, { id: 'planSno', name: '번호', @@ -87,7 +55,10 @@ const FlightPlanAprvGrid = ({ name: '상세보기', cell: row => { return ( - + 상세보기 ); @@ -109,7 +80,7 @@ const FlightPlanAprvGrid = ({ color='primary' size='sm' onClick={handleClickAprv('aprv')} - {...(aprvAuth ? {} : { disabled: true })} + {...(isMyGroup ? {} : { disabled: true })} > 승인 @@ -118,7 +89,7 @@ const FlightPlanAprvGrid = ({ size='sm' style={{ marginLeft: 10 }} onClick={handleClickAprv('notAprov')} - {...(aprvAuth ? {} : { disabled: true })} + {...(isMyGroup ? {} : { disabled: true })} > 미승인 diff --git a/src/components/basis/flight/plan/FlightPlanGrid.js b/src/components/basis/flight/plan/FlightPlanGrid.js index 0201ef0d..de51e862 100644 --- a/src/components/basis/flight/plan/FlightPlanGrid.js +++ b/src/components/basis/flight/plan/FlightPlanGrid.js @@ -46,21 +46,13 @@ const FlightPlanGrid = ({ id: 'moveDetail', name: '상세보기', cell: row => { - // let mine = false; - // if (user.authId === 'SUPER') { - // mine = true; - // } else if (user.authId === 'ADMIN' || user.authId === 'USER') { - // if (row.createUserId === user.userId) { - // mine = true; - // } - // } - return ( - <> - - 상세보기 - - + + 상세보기 + ); } } diff --git a/src/containers/basis/flight/aprv/FlightPlanAprvContainer.js b/src/containers/basis/flight/aprv/FlightPlanAprvContainer.js index d47a2e55..398450cc 100644 --- a/src/containers/basis/flight/aprv/FlightPlanAprvContainer.js +++ b/src/containers/basis/flight/aprv/FlightPlanAprvContainer.js @@ -28,7 +28,6 @@ const initSearchData = { const FlightPlanAprvContainer = () => { const dispatch = useDispatch(); - const history = useHistory(); const [searchData, setSearchData] = useState(initSearchData); const [selPlanSnoList, setSelPlanSnoList] = useState([]); const { @@ -47,10 +46,14 @@ const FlightPlanAprvContainer = () => { desc: '', color: '' }); + + //승인/미승인버튼 활성/비활성 제어 + const [isMyGroup, setIsMyGroup] = useState(); + const columns = [ { // id: 'groupNm', - name: '그룹 명', + name: '그룹명', selector: row => row.groupNm, minWidth: '102px', sortable: true, @@ -104,7 +107,8 @@ const FlightPlanAprvContainer = () => { handleGroupSelect({ groupId: row?.groupId, groupNm: row?.groupNm, - groupAuthCd: row?.groupAuthCd + groupAuthCd: row?.groupAuthCd, + myGroupAuthCd: row?.myGroupAuthCd }); }} > @@ -115,47 +119,51 @@ const FlightPlanAprvContainer = () => { } ]; - const handleGroupSelect = ({ groupId, groupNm, groupAuthCd }) => { + const handleGroupSelect = ({ + groupId, + groupNm, + groupAuthCd, + myGroupAuthCd + }) => { const param = searchData; - param.cstmrSno = user.cstmrSno; param.groupId = groupId; - // if (groupAuthCd === 'CREATER' || groupAuthCd === 'ADMIN') { - if ( - groupAuthCd === 'MASTER' || - groupAuthCd === 'LEADER' || - user.authId === 'SUPER' || - user.authId === 'ADMIN' - ) { - 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); + dispatch( + FlightAction.FLIGHT_PLAN_GROUP_SELECT({ + cstmrSno: user.cstmrSno, + groupId: groupId, + groupNm: groupNm + }) + ); - setSearchData(prevState => { - return { - ...prevState, - cstmrSno: user.cstmrSno, - groupId: groupId - }; - }); - dispatch(FlightAction.FLIGHT_APRV_LIST.request({ ...param, page: 1 })); - } else { - setModal({ - isOpen: true, - title: '권한 확인', - desc: '승인정보 확인을 위해서는 운영자 권한이 필요합니다. 운영자에게 권한을 부여받고 다시 시도해 주세요.', - color: 'info' - }); - return; + // 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_APRV_LIST.request({ ...param, page: 1 })); + + //승인/미승인버튼 활성/비활성 제어 + let my = false; + if (user.authId === 'SUPER') { + my = true; + } else if (user.authId === 'ADMIN') { + if (myGroupAuthCd) { + my = true; + } + } else if (user.authId === 'USER') { + if (groupAuthCd) { + my = true; + } } + setIsMyGroup(my); }; const handlerGroupCancel = () => { @@ -252,39 +260,9 @@ const FlightPlanAprvContainer = () => { return ( - {/*
*/} -
+
- {/* - - - - - */} - {/* - - */} - {/* */} - {user ? ( <> { handlerPageChange={onChangePage} data={aprvList} handleClickAprv={handleClickAprv} - // joinList={joinList} {...(user?.authId === 'SUPER' || user?.authId === 'ADMIN' ? { joinList: groupList } : { joinList: joinList })} @@ -329,11 +306,11 @@ const FlightPlanAprvContainer = () => { paginationPerPage={10} paginationRowsPerPageOptions={[10, 20, 30, 40]} total={total} - // handleChangeCheckbox={handleChangeCheckbox} + isMyGroup={isMyGroup} + // handleChangeCheckbox={handleChangeCheckbox} /> ) : ( - //
그룹 목록에서 상세보기를 클릭하세요.
diff --git a/src/containers/basis/flight/plan/FlightPlanDetailContainer.js b/src/containers/basis/flight/plan/FlightPlanDetailContainer.js index 24b8c614..54492c12 100644 --- a/src/containers/basis/flight/plan/FlightPlanDetailContainer.js +++ b/src/containers/basis/flight/plan/FlightPlanDetailContainer.js @@ -8,9 +8,8 @@ import { initFlight, initFlightBas } from '../../../../modules/basis/flight/models/basisFlightModel'; -import { AiFillPropertySafety } from 'react-icons/ai'; import { ErrorModal } from '../../../../components/modal/ErrorModal'; -import { CgArrowLeftR } from 'react-icons/cg'; +import qs from 'qs'; const initModal = { area: false, @@ -18,9 +17,10 @@ const initModal = { arcrft: false }; -const FlightPlanDetailContainer = () => { +const FlightPlanDetailContainer = props => { const dispatch = useDispatch(); const urlParams = useParams(); + const { search } = useLocation(); const { user } = useSelector(state => state.authState); const flightState = useSelector(state => state.flightState); const { detail, pilotSelect, arcrftSelect, areaList, selectGroup } = @@ -52,7 +52,10 @@ const FlightPlanDetailContainer = () => { } }, [date]); - //본인이 등록한 기체가 아니면 true + //목록에서 넘어오는지 승인에서 넘어오는지 체크 + const { type } = qs.parse(search, { ignoreQueryPrefix: true }); + + //본인이 등록한 기체가 아니거나 승인에서 넘어오면 true const [isDisabled, setIsDisabled] = useState(false); useEffect(() => { @@ -71,14 +74,18 @@ const FlightPlanDetailContainer = () => { groupId: sessionStorage.getItem('groupId') }); - if (user?.authId === 'ADMIN' || user?.authId === 'USER') { - if (detail?.createUserId !== '') { - if (detail?.createUserId != user.userId) { - setIsDisabled(true); - } else { - setIsDisabled(false); + if (type === 'plan') { + if (user?.authId === 'ADMIN' || user?.authId === 'USER') { + if (detail?.createUserId !== '') { + if (detail?.createUserId != user.userId) { + setIsDisabled(true); + } else { + setIsDisabled(false); + } } } + } else if (type === 'aprv') { + setIsDisabled(true); } }, [detail]);