Browse Source

운항과 페이지 체크박스 기능 추가

master
sanguu516 2 months ago
parent
commit
a864679e95
  1. 55
      src/components/flight/ControlApprovalsTable.js
  2. 175
      src/components/flight/OperationApprovalsTable.js

55
src/components/flight/ControlApprovalsTable.js

@ -44,6 +44,7 @@ export default function ControlApprovalsTable(props) {
const [form] = Form.useForm(); const [form] = Form.useForm();
// 체크박스 선택
const [checkList, setCheckList] = useState([]); const [checkList, setCheckList] = useState([]);
// 수정 키 확인 // 수정 키 확인
@ -103,7 +104,6 @@ export default function ControlApprovalsTable(props) {
const row = await form.validateFields(); const row = await form.validateFields();
const index = { ...row, planAreaSno: selectedRowKey }; const index = { ...row, planAreaSno: selectedRowKey };
console.log('recordrecord>>', row);
const updateRes = await dispatch( const updateRes = await dispatch(
updateLaancAprv([ updateLaancAprv([
{ {
@ -516,7 +516,13 @@ export default function ControlApprovalsTable(props) {
} }
}, },
{ {
title: <>확인</>, title: (
<>
확인
<br />
결과
</>
),
dataIndex: 'areaList', dataIndex: 'areaList',
align: 'center', align: 'center',
width: '130px', width: '130px',
@ -526,10 +532,16 @@ export default function ControlApprovalsTable(props) {
'검토불필요' '검토불필요'
) : areaList[0].reviewedType === 'R' ? ( ) : areaList[0].reviewedType === 'R' ? (
'검토완료' '검토완료'
) : areaList[0].reviewedType === 'C' ? ( ) : areaList[0].reviewedType === 'W' ? (
'검토취소'
) : (
'검토대기' '검토대기'
) : (
<Button color='flat-dark' onClick={() => handleIsModal(record)}>
<>
재검토
<br />
사유보기
</>
</Button>
) )
) : ( ) : (
<>-</> <>-</>
@ -537,6 +549,15 @@ export default function ControlApprovalsTable(props) {
} }
]; ];
const handleIsModal = record => {
dispatch(
openModal({
header: '재검토 사유',
body: record,
type: 'review'
})
);
};
// 확장된 테이블 데이터 // 확장된 테이블 데이터
const expandedRowRender = record => { const expandedRowRender = record => {
const childColumns = [ const childColumns = [
@ -766,14 +787,22 @@ export default function ControlApprovalsTable(props) {
dataIndex: 'reviewedType', dataIndex: 'reviewedType',
align: 'center', align: 'center',
width: '130px', width: '130px',
render: text => { render: (text, record) => {
return text === 'U' return text === 'U' ? (
? '검토불필요' '검토불필요'
: text === 'R' ) : text === 'R' ? (
? '검토완료' '검토완료'
: text === 'C' ) : text === 'W' ? (
? '검토취소' '검토대기'
: '검토대기'; ) : (
<Button color='flat-dark' onClick={() => handleIsModal(record)}>
<>
재검토
<br />
사유보기
</>
</Button>
);
} }
} }
]; ];

175
src/components/flight/OperationApprovalsTable.js

@ -46,6 +46,9 @@ export default function OperationApprovalsTable(props) {
const [form] = Form.useForm(); const [form] = Form.useForm();
// 체크박스 선택
const [checkList, setCheckList] = useState([]);
// 수정 키 확인 // 수정 키 확인
const isEditing = record => record.key === editingKey; const isEditing = record => record.key === editingKey;
@ -805,6 +808,12 @@ export default function OperationApprovalsTable(props) {
}) })
}; };
})} })}
rowSelection={{
...childRowSelection,
selectedRowKeys: checkList.filter(key =>
key.startsWith(`child_${record.planSno}_`)
)
}}
dataSource={data} dataSource={data}
pagination={false} pagination={false}
components={{ components={{
@ -858,13 +867,13 @@ export default function OperationApprovalsTable(props) {
}); });
// 단순 메시지 표출 모달 // 단순 메시지 표출 모달
const handlerErrorModal = (header, body) => { const handlerErrorModal = (header, body, isRefresh) => {
dispatch( dispatch(
openModal({ openModal({
header: header, header: header,
body: body, body: body,
isHistoryBack: false, isHistoryBack: false,
isRefresh: true isRefresh: isRefresh
}) })
); );
}; };
@ -916,10 +925,10 @@ export default function OperationApprovalsTable(props) {
}) })
); );
} else { } else {
handlerErrorModal(ERROR_TITLE, ERROR_MESSAGE); handlerErrorModal(ERROR_TITLE, ERROR_MESSAGE, true);
} }
} catch (errInfo) { } catch (errInfo) {
handlerErrorModal(ERROR_TITLE, ERROR_MESSAGE); handlerErrorModal(ERROR_TITLE, ERROR_MESSAGE, true);
} }
}; };
@ -1043,6 +1052,151 @@ export default function OperationApprovalsTable(props) {
setIsModal(!ismodal); setIsModal(!ismodal);
// } // }
}; };
// 부모 체크박스
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, nativeEvent) => {
let newCheckList = [...checkList]; // const를 let으로 변경
const key = record.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 selectableChildren = parent.areaList.filter(
child => child.reviewedType !== 'R'
);
const childKeys = selectableChildren.map(
child => `child_${parent.planSno}_${child.planAreaSno}`
);
const allSelectableChildrenChecked = childKeys.every(key =>
newList.includes(key)
);
const someSelectableChildrenChecked = childKeys.some(key =>
newList.includes(key)
);
if (allSelectableChildrenChecked && selectableChildren.length > 0) {
if (!newList.includes(parentKey)) {
newList.push(parentKey);
}
} else if (!someSelectableChildrenChecked) {
const index = newList.indexOf(parentKey);
if (index > -1) {
newList.splice(index, 1);
}
}
});
setCheckList(newList);
};
// 자식 테이블 체크박스
const childRowSelection = {
selectedRowKeys: checkList.filter(key => key.startsWith('child_')),
getCheckboxProps: record => ({
disabled: record.reviewedType !== 'R',
name: record.key
}),
onSelect: (record, selected, selectedRows) => {
const key = record.key;
let newCheckList = [...checkList];
if (selected) {
newCheckList.push(key);
} else {
newCheckList = newCheckList.filter(k => k !== key);
}
updateCheckList(newCheckList);
}
};
// 체크박스 업데이트 함수
const handleCheckbox = async () => {
if (checkList.length === 0) {
return handlerErrorModal(
'재검토 요청 실패',
'재검토 항목을 선택해주세요.',
false
);
}
// try {
// const planAreaSnoList = [
// ...new Set(
// checkList
// .filter(item => item.startsWith('child_')) // 'child_'로 시작하는 항목 필터링
// .map(item => item.split('_').pop()) // 마지막 언더바 이후의 숫자 추출
// )
// ];
// dispatch(
// updateLaancAprvReview({ planAreaSnoList, reviewedType: 'R' })
// ).then(() => {
// dispatch(
// getLaancAprvList({
// searchStDt: props.startDate,
// searchEndDt: props.endDate
// })
// );
// });
// setCheckList([]);
// } catch (error) {
// return handlerErrorModal(
// '재검토 요청 실패',
// '재검토 요청을 실패하였습니다. 다시 시도해주세요.',
// false
// );
// }
};
return ( return (
<div className='layer-content'> <div className='layer-content'>
@ -1073,6 +1227,11 @@ export default function OperationApprovalsTable(props) {
</span> </span>
</div> </div>
<div className='download'>
<Button color='primary' size='sm' onClick={handleCheckbox}>
재검토 요청
</Button>
</div>
</div> </div>
<div className='search-case-list'> <div className='search-case-list'>
<div> <div>
@ -1110,10 +1269,7 @@ export default function OperationApprovalsTable(props) {
}} }}
dataSource={laancAprvList.map((item, index) => ({ dataSource={laancAprvList.map((item, index) => ({
...item, ...item,
key: key: `parent_${item.planSno}`
item.areaList.length >= 1
? `${item.planAreaSno}-${index}`
: `${item.planAreaSno}`
}))} }))}
columns={mergedColumns} columns={mergedColumns}
rowClassName={record => { rowClassName={record => {
@ -1165,6 +1321,9 @@ export default function OperationApprovalsTable(props) {
} }
} }
})} })}
rowSelection={{
...rowSelection
}}
loading={laancAprvLoading} loading={laancAprvLoading}
expandable={{ expandable={{
expandedRowRender, expandedRowRender,

Loading…
Cancel
Save