Browse Source

체크박스 비활성화 기능 및 검토 수정 api 추가

master
sanguu516 2 months ago
parent
commit
eb1cd51e74
  1. 194
      src/components/flight/ControlApprovalsTable.js
  2. 20
      src/components/flight/NewFlightApprovalsReport.js
  3. 9
      src/redux/features/laanc/laancSlice.ts
  4. 15
      src/redux/features/laanc/laancState.ts
  5. 21
      src/redux/features/laanc/laancThunk.ts
  6. 2
      src/router/routes/index.js

194
src/components/flight/ControlApprovalsTable.js

@ -9,7 +9,8 @@ import axios from 'axios';
import { getAccessToken } from '../../utility/authService/jwtTokenUtil'; import { getAccessToken } from '../../utility/authService/jwtTokenUtil';
import { import {
updateLaancAprv, updateLaancAprv,
getLaancAprvList getLaancAprvList,
updateLaancAprvReview
} from '@src/redux/features/laanc/laancThunk'; } from '@src/redux/features/laanc/laancThunk';
import { ERROR_MESSAGE, ERROR_TITLE } from '@src/configs/msgConst'; import { ERROR_MESSAGE, ERROR_TITLE } from '@src/configs/msgConst';
import { CgKey } from 'react-icons/cg'; import { CgKey } from 'react-icons/cg';
@ -248,13 +249,7 @@ export default function ControlApprovalsTable(props) {
width: '100px', width: '100px',
align: 'center', align: 'center',
render: areaList => { render: areaList => {
return areaList.length <= 1 return areaList.length <= 1 ? areaList[0].limitZoneNm : '-';
? areaList[0].fltElevMax === 120
? '원추'
: areaList[0].fltElevMax > 45 && areaList[0].fltElevMax < 100
? '수평'
: '-'
: '-';
} }
}, },
{ {
@ -394,7 +389,7 @@ export default function ControlApprovalsTable(props) {
), ),
dataIndex: 'areaList', dataIndex: 'areaList',
align: 'center', align: 'center',
width: '120px', width: '140px',
render: areaList => { render: areaList => {
const approvalCounts = areaList.reduce( const approvalCounts = areaList.reduce(
(counts, item) => { (counts, item) => {
@ -497,6 +492,24 @@ export default function ControlApprovalsTable(props) {
<>-</> <>-</>
); );
} }
},
{
title: <>확인</>,
dataIndex: 'areaList',
align: 'center',
width: '130px',
render: (areaList, record) =>
areaList.length <= 1 ? (
areaList[0].reviewedType === 'R' ? (
'검토완료'
) : areaList[0].reviewedType === 'W' ? (
'검토대기'
) : (
'검토취소'
)
) : (
<>-</>
)
} }
]; ];
@ -563,17 +576,11 @@ export default function ControlApprovalsTable(props) {
}, },
{ {
dataIndex: 'fltElevMax', dataIndex: 'limitZoneNm',
align: 'center', align: 'center',
width: '100px', width: '100px',
render: text => { render: text => {
return text return text ? text : <>-</>;
? text === 120
? '원추'
: text > 45 && text < 100
? '수평'
: '-'
: '-';
} }
}, },
@ -650,7 +657,7 @@ export default function ControlApprovalsTable(props) {
{ {
dataIndex: 'approvalCd', dataIndex: 'approvalCd',
align: 'center', align: 'center',
width: '120px', width: '140px',
render: text => ( render: text => (
<> <>
{text === 'U' {text === 'U'
@ -700,6 +707,18 @@ export default function ControlApprovalsTable(props) {
</Button> </Button>
); );
} }
},
{
dataIndex: 'reviewedType',
align: 'center',
width: '130px',
render: text => {
return text === 'R'
? '검토완료'
: text === 'W'
? '검토대기'
: '검토취소';
}
} }
]; ];
@ -720,6 +739,7 @@ export default function ControlApprovalsTable(props) {
era: item.era, era: item.era,
fltElevMax: item.fltElevMax, fltElevMax: item.fltElevMax,
purpose: item.purpose, purpose: item.purpose,
reviewedType: item.reviewedType,
applyNm: item.applyNm, applyNm: item.applyNm,
dtl: item.dtl, dtl: item.dtl,
approvalCd: item.approvalCd, approvalCd: item.approvalCd,
@ -920,12 +940,12 @@ export default function ControlApprovalsTable(props) {
try { try {
const fileDetails = { const fileDetails = {
pdf: { pdf: {
url: `${HOST}api/bas/dos/plan/download/pdf?searchStDt=${ url: `${HOST}api/bas/dos/plan/download/han-com?searchStDt=${
props.startDate props.startDate
}&searchEndDt=${props.endDate}&selectZone=${props.filterArea}${ }&searchEndDt=${props.endDate}&selectZone=${props.filterArea}${
props.filterId ? '&approvalCd=${props.filterId}' : '' props.filterId ? '&approvalCd=${props.filterId}' : ''
}`, }`,
name: '비행승인 관련 검토결과.pdf' name: '비행승인 관련 검토결과.hwp'
}, },
excel: { excel: {
url: `${HOST}api/bas/dos/plan/download/excel?searchStDt=${ url: `${HOST}api/bas/dos/plan/download/excel?searchStDt=${
@ -980,44 +1000,84 @@ export default function ControlApprovalsTable(props) {
} }
}; };
// 자식 테이블 체크박스 // 부모 체크박스
const childRowSelection = { const rowSelection = {
selectedRowKeys: checkList.filter(key => key.startsWith('child_')), selectedRowKeys: checkList,
onChange: (selectedRowKeys, selectedRows, info) => { getCheckboxProps: record => {
const newCheckList = checkList.filter(key => !key.startsWith('child_')); const allChildrenReviewed = record.areaList.every(
// console.log('>>>>', selectedRowKeys); child => child.reviewedType === 'R'
);
return {
disabled: allChildrenReviewed,
name: record.key
};
}, },
onSelect: (record, selected, selectedRows) => { onSelect: (record, selected, selectedRows, nativeEvent) => {
let newCheckList = [...checkList]; // const를 let으로 변경
const key = record.key; const key = record.key;
const newCheckList = [];
if (selected) { if (key.startsWith('parent_')) {
newCheckList.push(...checkList, key); const childKeys = record.areaList
} else { .filter(child => child.reviewedType !== 'R')
newCheckList.push(...checkList.filter(k => k !== key)); .map(child => `child_${record.planSno}_${child.planAreaSno}`);
if (selected) {
newCheckList.push(key, ...childKeys);
} else {
newCheckList = newCheckList.filter(
k => k !== key && !childKeys.includes(k)
);
}
} }
updateCheckList(newCheckList);
},
onSelectAll: (selected, selectedRows, changeRows) => {
const newCheckList = selected
? laancAprvList.flatMap(parent => {
const parentKey = `parent_${parent.planSno}`;
const selectableChildren = parent.areaList.filter(
child => child.reviewedType !== 'R'
);
const childKeys = selectableChildren.map(
child => `child_${parent.planSno}_${child.planAreaSno}`
);
return selectableChildren.length > 0
? [parentKey, ...childKeys]
: [];
})
: [];
updateCheckList(newCheckList); updateCheckList(newCheckList);
} }
}; };
// 체크박스 업데이트 // updateCheckList 함수 수정
const updateCheckList = list => { const updateCheckList = list => {
const newList = [...list]; const newList = [...list];
// 부모 키 업데이트 // 부모 키 업데이트
laancAprvList.forEach(parent => { laancAprvList.forEach(parent => {
const parentKey = `parent_${parent.planSno}`; const parentKey = `parent_${parent.planSno}`;
const childKeys = parent.areaList.map( const selectableChildren = parent.areaList.filter(
child => child.reviewedType !== 'R'
);
const childKeys = selectableChildren.map(
child => `child_${parent.planSno}_${child.planAreaSno}` child => `child_${parent.planSno}_${child.planAreaSno}`
); );
const allChildrenChecked = childKeys.every(key => newList.includes(key)); const allSelectableChildrenChecked = childKeys.every(key =>
const someChildrenChecked = childKeys.some(key => newList.includes(key)); newList.includes(key)
);
const someSelectableChildrenChecked = childKeys.some(key =>
newList.includes(key)
);
if (allChildrenChecked) { if (allSelectableChildrenChecked && selectableChildren.length > 0) {
if (!newList.includes(parentKey)) { if (!newList.includes(parentKey)) {
newList.push(parentKey); newList.push(parentKey);
} }
} else if (!someChildrenChecked) { } else if (!someSelectableChildrenChecked) {
const index = newList.indexOf(parentKey); const index = newList.indexOf(parentKey);
if (index > -1) { if (index > -1) {
newList.splice(index, 1); newList.splice(index, 1);
@ -1028,48 +1088,26 @@ export default function ControlApprovalsTable(props) {
setCheckList(newList); setCheckList(newList);
}; };
// 부모 체크박스 console.log('check>>', checkList);
const rowSelection = { // 자식 테이블 체크박스
selectedRowKeys: checkList, const childRowSelection = {
onSelect: (record, selected, selectedRows, nativeEvent) => { selectedRowKeys: checkList.filter(key => key.startsWith('child_')),
const newCheckList = [...checkList]; getCheckboxProps: record => ({
disabled: record.reviewedType === 'R',
name: record.key
}),
onChange: (selectedRowKeys, selectedRows, info) => {
// 기존 코드 유지
},
onSelect: (record, selected, selectedRows) => {
const key = record.key; const key = record.key;
let newCheckList = [...checkList];
if (key.startsWith('parent_')) { if (selected) {
const childKeys = record.areaList.map(child => { newCheckList.push(key);
// console.log('>>', checkList); } else {
newCheckList = newCheckList.filter(k => k !== key);
return `child_${record.planSno}_${child.planAreaSno}`;
});
if (selected) {
newCheckList.push(key, ...childKeys);
} else {
const index = newCheckList.indexOf(key);
if (index > -1) {
newCheckList.splice(index, 1);
}
childKeys.forEach(childKey => {
const childIndex = newCheckList.indexOf(childKey);
if (childIndex > -1) {
newCheckList.splice(childIndex, 1);
}
});
}
} }
updateCheckList(newCheckList);
},
onSelectAll: (selected, selectedRows, changeRows) => {
const newCheckList = selected
? laancAprvList.flatMap(parent => [
`parent_${parent.planSno}`,
...parent.areaList.map(
child => `child_${parent.planSno}_${child.planAreaSno}`
)
])
: [];
updateCheckList(newCheckList); updateCheckList(newCheckList);
} }
}; };
@ -1201,7 +1239,7 @@ export default function ControlApprovalsTable(props) {
rowExpandable: record => record?.areaList?.length > 1 rowExpandable: record => record?.areaList?.length > 1
}} }}
scroll={{ scroll={{
x: 1500 x: 1600
}} }}
rowHoverable={false} rowHoverable={false}
expandIconColumnIndex={-1} expandIconColumnIndex={-1}

20
src/components/flight/NewFlightApprovalsReport.js

@ -72,16 +72,6 @@ export default function NewFlightApprovalsReport(props) {
onKeyPress={handleKeyDown} onKeyPress={handleKeyDown}
/> />
</div> </div>
<div className='list-input'>
<Input
type='text'
bsSize='sm'
placeholder='주소를 입력해주세요.'
value={props.filterId}
onChange={e => props.setFilterId(e.target.value)}
onKeyPress={handleKeyDown}
/>
</div>
</div> </div>
<div className='layer-content'> <div className='layer-content'>
<div className='layer-ti'> <div className='layer-ti'>
@ -118,6 +108,16 @@ export default function NewFlightApprovalsReport(props) {
))} ))}
</CustomInput> </CustomInput>
</div> </div>
<div className='list-input'>
<Input
type='text'
bsSize='sm'
placeholder='주소를 입력해주세요.'
value={props.filterId}
onChange={e => props.setFilterId(e.target.value)}
onKeyPress={handleKeyDown}
/>
</div>
<div className='list-input list-input-btn'> <div className='list-input list-input-btn'>
<Button <Button
color='primary' color='primary'

9
src/redux/features/laanc/laancSlice.ts

@ -11,7 +11,8 @@ import {
getWeatherData, getWeatherData,
AreaBufferList, AreaBufferList,
flightScheduleList, flightScheduleList,
getLaancAprvList getLaancAprvList,
updateLaancAprvReview
} from './laancThunk'; } from './laancThunk';
import { import {
IBasFlightScheduleListRs, IBasFlightScheduleListRs,
@ -412,6 +413,12 @@ const laancSlice = createSlice({
state.laancAprvList = action.payload as ILaancAprvListRs[]; state.laancAprvList = action.payload as ILaancAprvListRs[];
state.laancAprvLoading = false; state.laancAprvLoading = false;
}); });
builder.addCase(updateLaancAprvReview.pending, (state, action) => {
state.laancAprvLoading = true;
});
builder.addCase(updateLaancAprvReview.fulfilled, (state, action) => {
state.laancAprvLoading = false;
});
} }
}); });

15
src/redux/features/laanc/laancState.ts

@ -651,9 +651,19 @@ export interface ILaancAprvListRs {
addr1: string; addr1: string;
addr2: string; addr2: string;
addr3: string; addr3: string;
reviewedType: string;
limitZoneNm: string;
limitZoneCd: string;
reqRadius: number;
allowRadius: number;
areaList: { areaList: {
planAreaSno: number; planAreaSno: number;
planSno: number; planSno: number;
reviewedType: string;
limitZoneNm: string;
limitZoneCd: string;
reqRadius: number;
allowRadius: number;
zoneNo: string; zoneNo: string;
bufferZone: number; bufferZone: number;
purpose: string; purpose: string;
@ -687,3 +697,8 @@ export interface ILaancAprvUpdateRq {
era: string; era: string;
rm: string; rm: string;
} }
export interface ILaancApprovalReviewdRq {
planAreaSnoList: [];
reviewedType: string;
}

21
src/redux/features/laanc/laancThunk.ts

@ -17,7 +17,8 @@ import {
IBasFlightScheduleListRs, IBasFlightScheduleListRs,
ILaancAprvListRs, ILaancAprvListRs,
ILaancAprvListRq, ILaancAprvListRq,
ILaancAprvUpdateRq ILaancAprvUpdateRq,
ILaancApprovalReviewdRq
} from './laancState'; } from './laancState';
import { createAsyncThunk } from '@reduxjs/toolkit'; import { createAsyncThunk } from '@reduxjs/toolkit';
import { openModal } from '../comn/message/messageSlice'; import { openModal } from '../comn/message/messageSlice';
@ -287,6 +288,7 @@ export const getLaancAprvList = createAsyncThunk(
era: item.areaList[0].era, era: item.areaList[0].era,
dtl: item.areaList[0].dtl, dtl: item.areaList[0].dtl,
planAreaSno: item.areaList[0].planAreaSno, planAreaSno: item.areaList[0].planAreaSno,
fltElevMax: fltElevMax:
!item.areaList[0].fltElevMax && !item.areaList[0].fltElevMax &&
item.areaList[0].approvalCd === 'U' item.areaList[0].approvalCd === 'U'
@ -343,3 +345,20 @@ export const updateLaancAprv = createAsyncThunk(
} }
} }
); );
// 검토 수정 API
export const updateLaancAprvReview = createAsyncThunk(
'laanc/updateLaancAprvReview',
async (rq: ILaancApprovalReviewdRq, thunkAPI) => {
try {
const data: { any } = await axios.patch(`api/dos/plan/reviewed`, rq);
console.log('>>', data);
return data;
} catch (error) {
openModal({
header: ERROR_TITLE,
body: ERROR_MESSAGE
});
}
}
);

2
src/router/routes/index.js

@ -255,7 +255,7 @@ const GimpoControlRoutes = [
} }
}, },
{ {
path: 'control/rightMenu', path: '/control/rightMenu',
component: lazy(() => import('../../views/controlMenuView')), component: lazy(() => import('../../views/controlMenuView')),
layout: 'BlankLayout', layout: 'BlankLayout',
meta: { meta: {

Loading…
Cancel
Save