Browse Source

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

master
sanguu516 2 months ago
parent
commit
eb1cd51e74
  1. 186
      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

186
src/components/flight/ControlApprovalsTable.js

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

20
src/components/flight/NewFlightApprovalsReport.js

@ -72,16 +72,6 @@ export default function NewFlightApprovalsReport(props) {
onKeyPress={handleKeyDown}
/>
</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 className='layer-content'>
<div className='layer-ti'>
@ -118,6 +108,16 @@ export default function NewFlightApprovalsReport(props) {
))}
</CustomInput>
</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'>
<Button
color='primary'

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

@ -11,7 +11,8 @@ import {
getWeatherData,
AreaBufferList,
flightScheduleList,
getLaancAprvList
getLaancAprvList,
updateLaancAprvReview
} from './laancThunk';
import {
IBasFlightScheduleListRs,
@ -412,6 +413,12 @@ const laancSlice = createSlice({
state.laancAprvList = action.payload as ILaancAprvListRs[];
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;
addr2: string;
addr3: string;
reviewedType: string;
limitZoneNm: string;
limitZoneCd: string;
reqRadius: number;
allowRadius: number;
areaList: {
planAreaSno: number;
planSno: number;
reviewedType: string;
limitZoneNm: string;
limitZoneCd: string;
reqRadius: number;
allowRadius: number;
zoneNo: string;
bufferZone: number;
purpose: string;
@ -687,3 +697,8 @@ export interface ILaancAprvUpdateRq {
era: string;
rm: string;
}
export interface ILaancApprovalReviewdRq {
planAreaSnoList: [];
reviewedType: string;
}

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

@ -17,7 +17,8 @@ import {
IBasFlightScheduleListRs,
ILaancAprvListRs,
ILaancAprvListRq,
ILaancAprvUpdateRq
ILaancAprvUpdateRq,
ILaancApprovalReviewdRq
} from './laancState';
import { createAsyncThunk } from '@reduxjs/toolkit';
import { openModal } from '../comn/message/messageSlice';
@ -287,6 +288,7 @@ export const getLaancAprvList = createAsyncThunk(
era: item.areaList[0].era,
dtl: item.areaList[0].dtl,
planAreaSno: item.areaList[0].planAreaSno,
fltElevMax:
!item.areaList[0].fltElevMax &&
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')),
layout: 'BlankLayout',
meta: {

Loading…
Cancel
Save