From eb1cd51e7465373b4702092a3c7de44fdc5d76b2 Mon Sep 17 00:00:00 2001 From: sanguu516 Date: Tue, 16 Jul 2024 16:09:38 +0900 Subject: [PATCH] =?UTF-8?q?=EC=B2=B4=ED=81=AC=EB=B0=95=EC=8A=A4=20?= =?UTF-8?q?=EB=B9=84=ED=99=9C=EC=84=B1=ED=99=94=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EB=B0=8F=20=EA=B2=80=ED=86=A0=20=EC=88=98=EC=A0=95=20api=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 --- .../flight/ControlApprovalsTable.js | 194 +++++++++++------- .../flight/NewFlightApprovalsReport.js | 20 +- src/redux/features/laanc/laancSlice.ts | 9 +- src/redux/features/laanc/laancState.ts | 15 ++ src/redux/features/laanc/laancThunk.ts | 21 +- src/router/routes/index.js | 2 +- 6 files changed, 170 insertions(+), 91 deletions(-) diff --git a/src/components/flight/ControlApprovalsTable.js b/src/components/flight/ControlApprovalsTable.js index 36c1491e..c470bd49 100644 --- a/src/components/flight/ControlApprovalsTable.js +++ b/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) { ); } + }, + { + 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 (selected) { - newCheckList.push(...checkList, key); - } else { - newCheckList.push(...checkList.filter(k => k !== key)); + if (key.startsWith('parent_')) { + const childKeys = record.areaList + .filter(child => child.reviewedType !== 'R') + .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 함수 수정 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; + let newCheckList = [...checkList]; - if (key.startsWith('parent_')) { - const childKeys = record.areaList.map(child => { - // console.log('>>', checkList); - - 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); - } - }); - } + if (selected) { + newCheckList.push(key); + } else { + 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} diff --git a/src/components/flight/NewFlightApprovalsReport.js b/src/components/flight/NewFlightApprovalsReport.js index 0f0db085..9d63da5d 100644 --- a/src/components/flight/NewFlightApprovalsReport.js +++ b/src/components/flight/NewFlightApprovalsReport.js @@ -72,16 +72,6 @@ export default function NewFlightApprovalsReport(props) { onKeyPress={handleKeyDown} /> -
- props.setFilterId(e.target.value)} - onKeyPress={handleKeyDown} - /> -
@@ -118,6 +108,16 @@ export default function NewFlightApprovalsReport(props) { ))}
+
+ props.setFilterId(e.target.value)} + onKeyPress={handleKeyDown} + /> +