From 6b41302ec88a6fb77a7b4c867748743f7cf53b2c Mon Sep 17 00:00:00 2001 From: sanguu Date: Tue, 4 Oct 2022 18:41:32 +0900 Subject: [PATCH] =?UTF-8?q?=EA=B7=B8=EB=A3=B9=EA=B4=80=EB=A6=AC-=EC=8A=B9?= =?UTF-8?q?=EC=9D=B8=EA=B4=80=EB=A6=AC(=EA=B7=B8=EB=A3=B9=EB=B3=84=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20=EA=B0=80=EB=8A=A5=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../basis/group/BasisGroupApprovalSearch.js | 54 ++-- .../group/BasisGroupApprovalContainer.js | 247 +++++++++++++++--- .../basis/group/actions/basisGroupAction.ts | 12 +- .../basis/group/models/basisGroupModel.ts | 10 +- .../basis/group/reducers/basisGroupReducer.ts | 7 + 5 files changed, 259 insertions(+), 71 deletions(-) diff --git a/src/components/basis/group/BasisGroupApprovalSearch.js b/src/components/basis/group/BasisGroupApprovalSearch.js index 84a5d0f..23a7a17 100644 --- a/src/components/basis/group/BasisGroupApprovalSearch.js +++ b/src/components/basis/group/BasisGroupApprovalSearch.js @@ -49,7 +49,7 @@ export const BasisGroupApprovalSearch = props => { // aprvYn: aprvYn // }); // }, [isCheckBox]); - let aprvYn='N'; + let aprvYn = 'A'; const initCheckState = { 'all': aprvYn == 'A', 'yes': (aprvYn == 'Y' || aprvYn == 'A'), @@ -58,10 +58,10 @@ export const BasisGroupApprovalSearch = props => { const [checkState, setCheckState] = useState(initCheckState); const handleChangeCheckbox = (e) => { - const {name, value, checked} = e.target; + const { name, value, checked } = e.target; let val; - switch(value) { - case 'A' : + switch (value) { + case 'A': val = checked ? '' : '-'; props.setParams({ ...props.params, @@ -143,7 +143,7 @@ export const BasisGroupApprovalSearch = props => { type='text' id='groupNm' name='groupNm' - value={props.params.groupNm ||''} + value={props.params.groupNm || ''} onChange={props.handlerInput} bsSize='sm' onKeyPress={props.onKeyPress} @@ -200,14 +200,14 @@ export const BasisGroupApprovalSearch = props => { value='A' checked={checkState.all} onChange={handleChangeCheckbox} - // defaultChecked={isCheckBox.all} - // onClick={() => - // setIsCheckBox({ - // all: !isCheckBox.all, - // yes: !isCheckBox.all, - // no: !isCheckBox.all - // }) - // } + // defaultChecked={isCheckBox.all} + // onClick={() => + // setIsCheckBox({ + // all: !isCheckBox.all, + // yes: !isCheckBox.all, + // no: !isCheckBox.all + // }) + // } /> { value='Y' checked={checkState.yes} onChange={handleChangeCheckbox} - // defaultChecked={isCheckBox.yes || isCheckBox.all} - // onClick={() => - // setIsCheckBox({ - // all: false, - // yes: !isCheckBox.yes - // }) - // } + // defaultChecked={isCheckBox.yes || isCheckBox.all} + // onClick={() => + // setIsCheckBox({ + // all: false, + // yes: !isCheckBox.yes + // }) + // } /> { value='N' checked={checkState.no} onChange={handleChangeCheckbox} - // defaultChecked={isCheckBox.no || isCheckBox.all} - // onClick={() => - // setIsCheckBox({ - // all: false, - // no: !isCheckBox.no - // }) - // } + // defaultChecked={isCheckBox.no || isCheckBox.all} + // onClick={() => + // setIsCheckBox({ + // all: false, + // no: !isCheckBox.no + // }) + // } /> diff --git a/src/containers/basis/group/BasisGroupApprovalContainer.js b/src/containers/basis/group/BasisGroupApprovalContainer.js index 42c3dcc..094de4d 100644 --- a/src/containers/basis/group/BasisGroupApprovalContainer.js +++ b/src/containers/basis/group/BasisGroupApprovalContainer.js @@ -1,27 +1,183 @@ import { useEffect, useState } from 'react'; import { useDispatch, useSelector } from 'react-redux'; -import { useHistory } from 'react-router-dom'; -import { Button } from 'reactstrap'; +import { Button, Col, Row } from 'reactstrap'; import { BasisGroupApprovalGrid } from '../../../components/basis/group/BasisGroupApprovalGrid'; import { BasisGroupApprovalSearch } from '../../../components/basis/group/BasisGroupApprovalSearch'; import { CustomMainLayout } from '../../../components/layout/CustomMainLayout'; import { ConfirmModal } from '../../../components/modal/ConfirmModal'; import * as Actions from '../../../modules/basis/group/actions/basisGroupAction'; +import * as GroupActions from '../../../modules/basis/group/actions/basisGroupAction'; +import { BasisGroupDronGrid } from '../../../components/basis/dron/BasisGroupDronGrid'; export const BasisGroupApprovalContainer = props => { const { aprvList, aprvCount } = useSelector(state => state.groupState); const { user } = useSelector(state => state.authState); + const { joinList, joinListCount } = useSelector(state => state.groupState); + const { selectData } = useSelector(state => state.groupState); const dispatch = useDispatch(); - const history = useHistory(); - const titleName = '승인관리'; - const [params, setParams] = useState({ - cstmrSno: user?.cstmrSno + cstmrSno: user?.cstmrSno, + aprvYn: '', }); + const column = [ + { + name: '그룹명', + selector: 'groupNm', + minWidth: '102px', + sortable: true, + cell: row => { + return row?.groupNm; + // return selectData; + } + }, + { + name: '그룹 코드', + selector: 'groupId', + minWidth: '102px', + sortable: true, + cell: row => { + return row?.groupId; + } + }, + + { + name: '', + // selector: 'cntrlStDate', + // width: '100px', + sortable: true, + cell: row => { + return selectData?.groupId === row?.groupId ? ( + handlerCancel()} + > + 선택취소 + + ) : ( + + handlerDetail( + row?.groupId, + row?.groupNm, + row?.groupAuthCd, + row?.aprvlYn, + ) + } + > + 상세보기 + + ); + } + } + ]; + const handlerDetail = (groupId, groupNm) => { + // 권한 상관 없이 모두 조회 가능 + // param.cstmrSno = user.cstmrSno; + dispatch(Actions.SELECT({ groupId: groupId, groupNm: groupNm })); + if (user?.cstmrSno) { + setParams({ + ...params, + cstmrSno: user?.cstmrSno, + aprvYn: '', + groupId: groupId + }); + + dispatch( + Actions.APPROVAL_LIST.request({ + searchParams: { cstmrSno: user?.cstmrSno, aprvYn: '', groupId: groupId } + + }) + + ); + } + }; + + const handlerCancel = () => { + dispatch(Actions.SELECT()); + + setParams({ + ...params, + groupId: '', + groupNm: '' + }); + }; + + useEffect(() => { + if (user?.cstmrSno) { + setParams({ + ...params, + cstmrSno: user?.cstmrSno, + groupId: selectData?.groupId, + aprvYn: 'A' + }); + dispatch( + GroupActions.JOIN_LIST.request({ + cstmrSno: user?.cstmrSno, + groupId: selectData?.groupId + }) + ); + } + }, [user]); + const dronColumns = [ + { + name: '모델명', + selector: 'arcrftModelNm', + minWidth: '102px', + sortable: true, + cell: row => { + return row?.arcrftModelNm; + } + }, + { + name: '종류', + selector: 'arcrftTypeCd', + minWidth: '102px', + sortable: true, + cell: row => { + return GET_ARCTFT_TYPE_CD(row?.arcrftTypeCd); + } + }, + { + name: '제작사', + selector: 'prdctCmpnNm', + minWidth: '102px', + sortable: true, + cell: row => { + return row?.prdctCmpnNm; + } + }, + { + name: '수정일자', + selector: 'updateDt', + minWidth: '102px', + sortable: true, + cell: row => { + return moment(row?.updateDt).format('MM-DD HH:mm'); + } + }, + { + name: '상세보기', + // selector: 'cntrlStDate', + // minWidth: '102px', + sortable: true, + cell: row => { + return ( + + 상세보기 + + ); + } + } + ]; const [saveData, setSaveData] = useState({ cstmrGroupSno: '', // aprvlYn: 'N', //가입은 USER 로만 @@ -127,26 +283,10 @@ export const BasisGroupApprovalContainer = props => { } ]; - useEffect(() => { - if (user?.cstmrSno) { - setParams({ - ...params, - cstmrSno: user?.cstmrSno, - aprvYn: 'N' - }); - - dispatch( - Actions.APPROVAL_LIST.request({ - searchParams: { cstmrSno: user?.cstmrSno, aprvYn: 'N' } - // searchParams: params - }) - ); - } - }, [user]); const onKeyPress = e => { if (e.key == 'Enter') { - handlerSearch(); + // handlerSearch(); } }; @@ -195,25 +335,52 @@ export const BasisGroupApprovalContainer = props => { [name]: value }); }; - return ( - - - - +
+ + + + + + {!selectData ? ( +
+ 그룹 목록에서 상세보기를 클릭하세요. +
+ ) : ( + + )} + + {!selectData ? ( + <> +
+
+ + ) : ( + + )} + + +
+
(); +export const SELECT = createAction(SELECT_GROUP)(); + const actions = { MY_LIST, JOIN_LIST, @@ -225,7 +231,9 @@ const actions = { USER_UPDATE, USER_DELEGATE, GROUP_MYLIST, - GROUP_MAIN_LIST + GROUP_MAIN_LIST, + SELECT }; + export type GroupAction = ActionType; diff --git a/src/modules/basis/group/models/basisGroupModel.ts b/src/modules/basis/group/models/basisGroupModel.ts index 2c417f6..f17f2c0 100644 --- a/src/modules/basis/group/models/basisGroupModel.ts +++ b/src/modules/basis/group/models/basisGroupModel.ts @@ -18,6 +18,8 @@ export interface GroupState { newGroupId: String | ''; searchParams: string | ''; error: ErrorModel | undefined; + selectData: SelectData | undefined; + } export interface GroupSearchData { @@ -33,7 +35,10 @@ export interface GroupData { createDt: Date; updateDt: Date; } - +export interface SelectData { + groupId: string; + groupNm: string; +} export interface JoinGroupData { cstmrGroupSno: number; groupId: string; @@ -111,5 +116,6 @@ export const initGroup = { groupId: '', newGroupId: '', searchParams: '', - error: undefined + error: undefined, + selectData: undefined }; diff --git a/src/modules/basis/group/reducers/basisGroupReducer.ts b/src/modules/basis/group/reducers/basisGroupReducer.ts index 8dfdbcb..bde31a4 100644 --- a/src/modules/basis/group/reducers/basisGroupReducer.ts +++ b/src/modules/basis/group/reducers/basisGroupReducer.ts @@ -45,6 +45,7 @@ export const groupReducer = createReducer( draft.mainListCount = count; }) ) + .handleAction(Actions.GROUP_MYLIST.success, (state, action) => produce(state, draft => { const { data, count } = action.payload; @@ -96,4 +97,10 @@ export const groupReducer = createReducer( draft.userList = data; draft.userCount = count; }) + ) + .handleAction(Actions.SELECT, (state, action) => + produce(state, draft => { + const selectData = action.payload; + draft.selectData = selectData; + }) );