Browse Source

super 권한일 때 그룹명 검색조건 추가

pull/2/head
hhjk00 10 months ago
parent
commit
11f05f5bce
  1. 53
      src/components/statistics/StatisticsSearch.js
  2. 3
      src/components/statistics/StatisticsTotal.js
  3. 59
      src/containers/statistics/AbnormalSituationContainer.js
  4. 62
      src/containers/statistics/FlightContainer.js
  5. 62
      src/containers/statistics/FlightResultContainer.js

53
src/components/statistics/StatisticsSearch.js

@ -20,9 +20,11 @@ export default function StatisticsSearch({
dateLists,
categoryTypeOptions,
handlerBarTicks,
handlerTitleName,
handlerChartTitle,
handleChangeSearchType,
formatSeconds
formatSeconds,
user,
entireGroupList
}) {
const [total, setTotal] = useState([]);
const [top, setTop] = useState([]);
@ -271,6 +273,40 @@ export default function StatisticsSearch({
<CardBody className='pal-card-body'>
<div className='search-cont'>
<dl>
{user?.authId === 'SUPER' && (
<dt>
<div className='search-box'>
<div className='search-list-ti'>그룹명</div>
<div className='search-list'>
<div className='search-list-cont'>
<Row>
<Col className='list-input' md='4' sm='12'>
<CustomInput
inline
type='select'
id=''
bsSize='sm'
value={searchType.serviceType}
onChange={e =>
handleChangeSearchType(
'serviceType',
e.target.value
)
}
>
{entireGroupList?.map(i => (
<option key={i.groupId} value={i.groupNm}>
{i.groupNm}
</option>
))}
</CustomInput>
</Col>
</Row>
</div>
</div>
</div>
</dt>
)}
<dt>
<div className='search-box'>
<div className='search-list-ti'>검색조건</div>
@ -283,12 +319,13 @@ export default function StatisticsSearch({
type='select'
id=''
bsSize='sm'
onChange={e =>
value={searchType.category}
onChange={e => {
handleChangeSearchType(
'category',
e.target.value
)
}
);
}}
>
{Object.entries(categoryTypeOptions).map(
([value, label]) => (
@ -317,7 +354,7 @@ export default function StatisticsSearch({
<Card>
<CardHeader className='d-flex justify-content-between align-items-sm-center align-items-start flex-sm-row flex-column'>
<CardTitle tag='h4'>
{handlerTitleName(searchType.category)} 통계
{handlerChartTitle(searchType.category)} 통계
</CardTitle>
<div className='select-date-wrap'>
<Row>
@ -327,7 +364,7 @@ export default function StatisticsSearch({
type='select'
id=''
bsSize='sm'
value={searchType.type}
value={searchType.dateType}
onChange={e =>
handleChangeSearchType('dateType', e.target.value)
}
@ -427,7 +464,7 @@ export default function StatisticsSearch({
<Card>
<CardHeader className='d-flex justify-content-between align-items-sm-center align-items-start flex-sm-row flex-column'>
<CardTitle tag='h4'>
{handlerTitleName(searchType.category)} TOP5
{handlerChartTitle(searchType.category)} TOP5
</CardTitle>
</CardHeader>
<CardBody>

3
src/components/statistics/StatisticsTotal.js

@ -1,5 +1,6 @@
import { Col, Row } from 'reactstrap';
import { FcAlarmClock, FcWorkflow, FcBarChart } from 'react-icons/fc';
import { useEffect } from 'react';
export default function StatisticsTotal({
totalData,
@ -37,7 +38,7 @@ export default function StatisticsTotal({
<span>{renderIcon(idx)}</span>
<span>{totalTitle[idx]}</span>
</th>
<td colspan='2'>
<td colSpan='2'>
<span className='date'>기체명</span>
<span className='date-data'>{i.name}</span>
</td>

59
src/containers/statistics/AbnormalSituationContainer.js

@ -8,6 +8,7 @@ import StatisticsTotal from '../../components/statistics/StatisticsTotal';
export default function AbnormalSituationContainer() {
const dispatch = useDispatch();
const { abnormal, abnormalSearch } = useSelector(
state => state.statisticsState
);
@ -17,7 +18,7 @@ export default function AbnormalSituationContainer() {
const [searchType, setSearchType] = useState({
category: 'PLAN',
dateType: 'year',
serviceType: '',
serviceType: 'KAC',
year: new Date().getFullYear(),
month: new Date().getMonth() + 1,
day: new Date().getDate()
@ -35,30 +36,23 @@ export default function AbnormalSituationContainer() {
CRASH: '충돌위험'
};
// 사용자가 SUPER 권한일 경우 전체 그룹 조회
useEffect(() => {
if (user) {
user.authId === 'SUPER' &&
dispatch(GroupActions.ENTIRE_GROUP_LIST.request());
}
user?.authId === 'SUPER' &&
dispatch(GroupActions.ENTIRE_GROUP_LIST.request());
}, []);
// 사용자가 SUPER 권한일 경우 serviceType 파라미터 추가 - 상단 통계 데이터
useEffect(() => {
dispatch(
StcsActions.ABNORMAL_STCS.request({ serviceType: searchType.serviceType })
);
}, [searchType.serviceType]);
useEffect(() => {
const { year, month } = searchType;
const lastDay = new Date(year, month, 0).getDate();
const dayList = Array.from({ length: lastDay }, (_, index) => index + 1);
const params =
user?.authId === 'SUPER' ? { serviceType: searchType.serviceType } : {};
setDateLists({ ...dateLists, day: dayList });
}, [searchType.month]);
dispatch(StcsActions.ABNORMAL_STCS.request(params));
}, [searchType.serviceType, user]);
// 사용자가 SUPER 권한일 경우 serviceType 파라미터 추가 - 하단 그래프 데이터
useEffect(() => {
const { category, dateType, serviceType, year, month, day } = searchType;
const dateMapping = {
month: year,
day: `${year}-${month}`,
@ -66,15 +60,22 @@ export default function AbnormalSituationContainer() {
};
const date = dateMapping[dateType] || '';
dispatch(
StcsActions.ABNORMAL_STCS_SEARCH.request({
cate: category,
date,
type: dateType,
serviceType
})
);
}, [searchType]);
const params =
user?.authId === 'SUPER'
? { cate: category, date, type: dateType, serviceType }
: { cate: category, date, type: dateType };
dispatch(StcsActions.ABNORMAL_STCS_SEARCH.request(params));
}, [searchType, user]);
// 해당 월에 맞는 요일 표출
useEffect(() => {
const { year, month } = searchType;
const lastDay = new Date(year, month, 0).getDate();
const dayList = Array.from({ length: lastDay }, (_, index) => index + 1);
setDateLists({ ...dateLists, day: dayList });
}, [searchType.month]);
// 검색조건 handler
const handleChangeSearchType = useCallback(
@ -88,7 +89,7 @@ export default function AbnormalSituationContainer() {
);
// 그래프 타이틀 handler
const handlerTitleName = category => {
const handlerChartTitle = category => {
return categoryTypeOptions[category];
};
@ -138,10 +139,12 @@ export default function AbnormalSituationContainer() {
<StatisticsSearch
searchData={abnormalSearch}
searchType={searchType}
user={user}
entireGroupList={entireGroupList}
categoryTypeOptions={categoryTypeOptions}
dateLists={dateLists}
handlerBarTicks={handlerBarTicks}
handlerTitleName={handlerTitleName}
handlerChartTitle={handlerChartTitle}
handleChangeSearchType={handleChangeSearchType}
/>
</div>

62
src/containers/statistics/FlightContainer.js

@ -8,6 +8,7 @@ import StatisticsSearch from '../../components/statistics/StatisticsSearch';
export default function FlightContainer() {
const dispatch = useDispatch();
const { flight, flightSearch } = useSelector(state => state.statisticsState);
const { user } = useSelector(state => state.authState);
const { entireGroupList } = useSelector(state => state.groupState);
@ -15,7 +16,7 @@ export default function FlightContainer() {
const [searchType, setSearchType] = useState({
category: 'TIME',
dateType: 'year',
serviceType: '',
serviceType: 'KAC',
year: new Date().getFullYear(),
month: new Date().getMonth() + 1,
day: new Date().getDate()
@ -33,31 +34,23 @@ export default function FlightContainer() {
FLT_COUNT: '비행 횟수'
};
// 사용자가 SUPER 권한일 경우 전체 그룹 조회
useEffect(() => {
if (user) {
user.authId === 'SUPER' &&
dispatch(GroupActions.ENTIRE_GROUP_LIST.request());
}
}, []);
user?.authId === 'SUPER' &&
dispatch(GroupActions.ENTIRE_GROUP_LIST.request());
}, [user]);
// 사용자가 SUPER 권한일 경우 serviceType 파라미터 추가 - 상단 통계 데이터
useEffect(() => {
dispatch(
StcsActions.FLIGHT_STCS.request({ serviceType: searchType.serviceType })
);
}, [searchType.serviceType]);
const params =
user?.authId === 'SUPER' ? { serviceType: searchType.serviceType } : {};
// 해당 월에 맞는 요일 표출
useEffect(() => {
const { year, month } = searchType;
const lastDay = new Date(year, Number(month), 0).getDate();
const dayList = Array.from({ length: lastDay }, (_, index) => index + 1);
setDateLists({ ...dateLists, day: dayList });
}, [searchType.month]);
dispatch(StcsActions.FLIGHT_STCS.request(params));
}, [searchType.serviceType, user]);
// 사용자가 SUPER 권한일 경우 serviceType 파라미터 추가 - 하단 그래프 데이터
useEffect(() => {
const { category, dateType, serviceType, year, month, day } = searchType;
const dateMapping = {
month: year,
day: `${year}-${month}`,
@ -65,15 +58,22 @@ export default function FlightContainer() {
};
const date = dateMapping[dateType] || '';
dispatch(
StcsActions.FLIGHT_STCS_SEARCH.request({
cate: category,
date,
type: dateType,
serviceType
})
);
}, [searchType]);
const params =
user?.authId === 'SUPER'
? { cate: category, date, type: dateType, serviceType }
: { cate: category, date, type: dateType };
dispatch(StcsActions.FLIGHT_STCS_SEARCH.request(params));
}, [searchType, user]);
// 해당 월에 맞는 요일 표출
useEffect(() => {
const { year, month } = searchType;
const lastDay = new Date(year, Number(month), 0).getDate();
const dayList = Array.from({ length: lastDay }, (_, index) => index + 1);
setDateLists({ ...dateLists, day: dayList });
}, [searchType.month]);
// 검색조건 handler
const handleChangeSearchType = useCallback(
@ -87,7 +87,7 @@ export default function FlightContainer() {
);
// 그래프 타이틀 handler
const handlerTitleName = category => {
const handlerChartTitle = category => {
return categoryTypeOptions[category];
};
@ -199,11 +199,13 @@ export default function FlightContainer() {
<StatisticsSearch
searchData={flightSearch}
searchType={searchType}
user={user}
entireGroupList={entireGroupList}
categoryTypeOptions={categoryTypeOptions}
dateLists={dateLists}
formatSeconds={formatSeconds}
handlerBarTicks={handlerBarTicks}
handlerTitleName={handlerTitleName}
handlerChartTitle={handlerChartTitle}
handleChangeSearchType={handleChangeSearchType}
/>
</div>

62
src/containers/statistics/FlightResultContainer.js

@ -8,6 +8,7 @@ import StatisticsSearch from '../../components/statistics/StatisticsSearch';
export default function ResultContainer() {
const dispatch = useDispatch();
const { result, resultSearch } = useSelector(state => state.statisticsState);
const { user } = useSelector(state => state.authState);
const { entireGroupList } = useSelector(state => state.groupState);
@ -15,7 +16,7 @@ export default function ResultContainer() {
const [searchType, setSearchType] = useState({
category: 'FLT_RESULT',
dateType: 'year',
serviceType: '',
serviceType: 'KAC',
year: new Date().getFullYear(),
month: new Date().getMonth() + 1,
day: new Date().getDate()
@ -33,31 +34,23 @@ export default function ResultContainer() {
FLT_PLAN_APRVN: '비행 승인'
};
// 사용자가 SUPER 권한일 경우 전체 그룹 조회
useEffect(() => {
if (user) {
user.authId === 'SUPER' &&
dispatch(GroupActions.ENTIRE_GROUP_LIST.request());
}
}, []);
user?.authId === 'SUPER' &&
dispatch(GroupActions.ENTIRE_GROUP_LIST.request());
}, [user]);
// 사용자가 SUPER 권한일 경우 serviceType 파라미터 추가 - 상단 통계 데이터
useEffect(() => {
dispatch(
StcsActions.RESULT_STCS.request({ serviceType: searchType.serviceType })
);
}, [searchType.serviceType]);
const params =
user?.authId === 'SUPER' ? { serviceType: searchType.serviceType } : {};
// 해당 월에 맞는 요일 표출
useEffect(() => {
const { year, month } = searchType;
const lastDay = new Date(year, Number(month), 0).getDate();
const dayList = Array.from({ length: lastDay }, (_, index) => index + 1);
setDateLists({ ...dateLists, day: dayList });
}, [searchType.month]);
dispatch(StcsActions.RESULT_STCS.request(params));
}, [searchType.serviceType, user]);
// 사용자가 SUPER 권한일 경우 serviceType 파라미터 추가 - 하단 그래프 데이터
useEffect(() => {
const { category, dateType, serviceType, year, month, day } = searchType;
const dateMapping = {
month: year,
day: `${year}-${month}`,
@ -65,15 +58,22 @@ export default function ResultContainer() {
};
const date = dateMapping[dateType] || '';
dispatch(
StcsActions.RESULT_STCS_SEARCH.request({
cate: category,
date,
type: dateType,
serviceType
})
);
}, [searchType]);
const params =
user?.authId === 'SUPER'
? { cate: category, date, type: dateType, serviceType }
: { cate: category, date, type: dateType };
dispatch(StcsActions.RESULT_STCS_SEARCH.request(params));
}, [searchType, user]);
// 해당 월에 맞는 요일 표출
useEffect(() => {
const { year, month } = searchType;
const lastDay = new Date(year, Number(month), 0).getDate();
const dayList = Array.from({ length: lastDay }, (_, index) => index + 1);
setDateLists({ ...dateLists, day: dayList });
}, [searchType.month]);
// 검색조건 handler
const handleChangeSearchType = useCallback(
@ -87,7 +87,7 @@ export default function ResultContainer() {
);
// 그래프 타이틀 handler
const handlerTitleName = category => {
const handlerChartTitle = category => {
return categoryTypeOptions[category];
};
@ -137,10 +137,12 @@ export default function ResultContainer() {
<StatisticsSearch
searchData={resultSearch}
searchType={searchType}
user={user}
entireGroupList={entireGroupList}
categoryTypeOptions={categoryTypeOptions}
dateLists={dateLists}
handlerBarTicks={handlerBarTicks}
handlerTitleName={handlerTitleName}
handlerChartTitle={handlerChartTitle}
handleChangeSearchType={handleChangeSearchType}
/>
</div>

Loading…
Cancel
Save