From 239b42dd4af9dbfec0599cb53ada4fabc60d7e0b Mon Sep 17 00:00:00 2001 From: sanguu516 Date: Tue, 23 Jul 2024 11:34:50 +0900 Subject: [PATCH] =?UTF-8?q?=EC=9A=B4=ED=95=AD=EA=B3=BC=20=EB=8B=A4?= =?UTF-8?q?=EC=9A=B4=EB=A1=9C=EB=93=9C=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../flight/ControlApprovalsTable.js | 4 +- .../flight/OperationApprovalsTable.js | 192 +++++------------- 2 files changed, 56 insertions(+), 140 deletions(-) diff --git a/src/components/flight/ControlApprovalsTable.js b/src/components/flight/ControlApprovalsTable.js index 03e30e78..49d47cff 100644 --- a/src/components/flight/ControlApprovalsTable.js +++ b/src/components/flight/ControlApprovalsTable.js @@ -1171,9 +1171,7 @@ export default function ControlApprovalsTable(props) { disabled: record.reviewedType === 'R', name: record.key }), - onChange: (selectedRowKeys, selectedRows, info) => { - // 기존 코드 유지 - }, + onSelect: (record, selected, selectedRows) => { const key = record.key; let newCheckList = [...checkList]; diff --git a/src/components/flight/OperationApprovalsTable.js b/src/components/flight/OperationApprovalsTable.js index a8d0bdd6..1738b29d 100644 --- a/src/components/flight/OperationApprovalsTable.js +++ b/src/components/flight/OperationApprovalsTable.js @@ -4,9 +4,6 @@ import { Button, Card } from '@component/ui'; import { openModal } from '@src/redux/features/comn/message/messageSlice'; import { FaAngleDown, FaAngleUp } from 'react-icons/fa'; import { Form, Input, Table, Typography } from 'antd'; -import { HOST } from '../../configs/constants'; -import axios from 'axios'; -import { getAccessToken } from '../../utility/authService/jwtTokenUtil'; import { updateLaancAprv, getLaancAprvList @@ -51,6 +48,7 @@ export default function OperationApprovalsTable(props) { // 유효성 기체 데이터 const [validData, setValidData] = useState(); + useEffect(() => { let approvalCdValue = { S: 0, F: 0, C: 0, U: 0 }; @@ -80,60 +78,6 @@ export default function OperationApprovalsTable(props) { } }, [laancAprvList]); - // 수정 이벤트 - const edit = record => { - form.setFieldsValue({ - planAreaSno: record.planAreaSno, - bufferZone: record.bufferZone, - fltElev: record.fltElev, - dtl: record.dtl, - era: record.era, - rm: record.rm, - ...record - }); - setEditingKey(record.key); - }; - - // 취소 이벤트 - const cancel = () => { - setEditingKey(''); - }; - - // 저장 이벤트 - const save = async (key, type) => { - try { - const row = await form.validateFields(); - const index = { ...row, planAreaSno: selectedRowKey }; - - const updateRes = await dispatch( - updateLaancAprv([ - { - planAreaSno: selectedRowKey, - bufferZone: row.bufferZone, - fltElev: row.fltElev, - dtl: row.dtl || '', - era: row.era || '', - rm: row.rm || '' - } - ]) - ); - - if (updateRes.meta.requestStatus === 'fulfilled') { - setEditingKey(''); - await dispatch( - getLaancAprvList({ - searchStDt: props.startDate, - searchEndDt: props.endDate - }) - ); - } else { - handlerErrorModal(ERROR_TITLE, ERROR_MESSAGE); - } - } catch (errInfo) { - handlerErrorModal(ERROR_TITLE, ERROR_MESSAGE); - } - }; - // 데이터 const columns = [ { @@ -922,6 +866,60 @@ export default function OperationApprovalsTable(props) { ); }; + // 수정 이벤트 + const edit = record => { + form.setFieldsValue({ + planAreaSno: record.planAreaSno, + bufferZone: record.bufferZone, + fltElev: record.fltElev, + dtl: record.dtl, + era: record.era, + rm: record.rm, + ...record + }); + setEditingKey(record.key); + }; + + // 취소 이벤트 + const cancel = () => { + setEditingKey(''); + }; + + // 저장 이벤트 + const save = async (key, type) => { + try { + const row = await form.validateFields(); + const index = { ...row, planAreaSno: selectedRowKey }; + + const updateRes = await dispatch( + updateLaancAprv([ + { + planAreaSno: selectedRowKey, + bufferZone: row.bufferZone, + fltElev: row.fltElev, + dtl: row.dtl || '', + era: row.era || '', + rm: row.rm || '' + } + ]) + ); + + if (updateRes.meta.requestStatus === 'fulfilled') { + setEditingKey(''); + await dispatch( + getLaancAprvList({ + searchStDt: props.startDate, + searchEndDt: props.endDate + }) + ); + } else { + handlerErrorModal(ERROR_TITLE, ERROR_MESSAGE); + } + } catch (errInfo) { + handlerErrorModal(ERROR_TITLE, ERROR_MESSAGE); + } + }; + // 모달 오픈 핸들러 const handlerOpenModal = (approval, fltElev, fltElevMax) => { if (approval === 'F') { @@ -1031,70 +1029,6 @@ export default function OperationApprovalsTable(props) { } }; - const handleFileDownload = async type => { - try { - const fileDetails = { - pdf: { - url: `${HOST}api/bas/dos/plan/download/pdf?searchStDt=${ - props.startDate - }&searchEndDt=${props.endDate}&selectZone=${props.filterArea}${ - props.filterId ? '&approvalCd=${props.filterId}' : '' - }`, - name: '비행승인 관련 검토결과.pdf' - }, - excel: { - url: `${HOST}api/bas/dos/plan/download/excel?searchStDt=${ - props.startDate - }&searchEndDt=${props.endDate}&selectZone=${props.filterArea}${ - props.filterId ? '&approvalCd=${props.filterId}' : '' - }`, - name: '비행승인 검토.xlsx' - } - }; - - if (!fileDetails[type]) { - throw new Error('Invalid file type specified.'); - } - - const { url: fileUrl, name: fileName } = fileDetails[type]; - const accessToken = await getAccessToken(); - - const res = await axios({ - url: fileUrl, - method: 'GET', - responseType: 'blob', - headers: { - 'Content-Type': 'application/json', - Authorization: `${accessToken}` // Bearer 추가 - } - }); - - if (!res.headers) { - throw new Error('No response headers.'); - } - - const contentType = - res.headers['content-type'] || 'application/octet-stream'; - - const blob = new Blob([res.data], { type: contentType }); - const downloadUrl = window.URL.createObjectURL(blob); - - const link = document.createElement('a'); - link.href = downloadUrl; - link.style.display = 'none'; - link.download = fileName; - - document.body.appendChild(link); - link.click(); - document.body.removeChild(link); - - window.URL.revokeObjectURL(downloadUrl); - } catch (error) { - console.error('File download failed:', error); - console.error(error.message); - } - }; - // 유효성 검사 모달창 const handleIsModal = record => { setValidData({ @@ -1136,22 +1070,6 @@ export default function OperationApprovalsTable(props) { 건 -
- - -