diff --git a/src/components/flight/ControlApprovalsTable.js b/src/components/flight/ControlApprovalsTable.js
index 33877679..26d34167 100644
--- a/src/components/flight/ControlApprovalsTable.js
+++ b/src/components/flight/ControlApprovalsTable.js
@@ -44,6 +44,7 @@ export default function ControlApprovalsTable(props) {
const [form] = Form.useForm();
+ // 체크박스 선택
const [checkList, setCheckList] = useState([]);
// 수정 키 확인
@@ -103,7 +104,6 @@ export default function ControlApprovalsTable(props) {
const row = await form.validateFields();
const index = { ...row, planAreaSno: selectedRowKey };
- console.log('recordrecord>>', row);
const updateRes = await dispatch(
updateLaancAprv([
{
@@ -516,7 +516,13 @@ export default function ControlApprovalsTable(props) {
}
},
{
- title: <>확인>,
+ title: (
+ <>
+ 확인
+
+ 결과
+ >
+ ),
dataIndex: 'areaList',
align: 'center',
width: '130px',
@@ -526,10 +532,16 @@ export default function ControlApprovalsTable(props) {
'검토불필요'
) : areaList[0].reviewedType === 'R' ? (
'검토완료'
- ) : areaList[0].reviewedType === 'C' ? (
- '검토취소'
- ) : (
+ ) : areaList[0].reviewedType === 'W' ? (
'검토대기'
+ ) : (
+
)
) : (
<>->
@@ -537,6 +549,15 @@ export default function ControlApprovalsTable(props) {
}
];
+ const handleIsModal = record => {
+ dispatch(
+ openModal({
+ header: '재검토 사유',
+ body: record,
+ type: 'review'
+ })
+ );
+ };
// 확장된 테이블 데이터
const expandedRowRender = record => {
const childColumns = [
@@ -766,14 +787,22 @@ export default function ControlApprovalsTable(props) {
dataIndex: 'reviewedType',
align: 'center',
width: '130px',
- render: text => {
- return text === 'U'
- ? '검토불필요'
- : text === 'R'
- ? '검토완료'
- : text === 'C'
- ? '검토취소'
- : '검토대기';
+ render: (text, record) => {
+ return text === 'U' ? (
+ '검토불필요'
+ ) : text === 'R' ? (
+ '검토완료'
+ ) : text === 'W' ? (
+ '검토대기'
+ ) : (
+
+ );
}
}
];
diff --git a/src/components/flight/OperationApprovalsTable.js b/src/components/flight/OperationApprovalsTable.js
index 804dfe10..ba34de7b 100644
--- a/src/components/flight/OperationApprovalsTable.js
+++ b/src/components/flight/OperationApprovalsTable.js
@@ -46,6 +46,9 @@ export default function OperationApprovalsTable(props) {
const [form] = Form.useForm();
+ // 체크박스 선택
+ const [checkList, setCheckList] = useState([]);
+
// 수정 키 확인
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}
pagination={false}
components={{
@@ -858,13 +867,13 @@ export default function OperationApprovalsTable(props) {
});
// 단순 메시지 표출 모달
- const handlerErrorModal = (header, body) => {
+ const handlerErrorModal = (header, body, isRefresh) => {
dispatch(
openModal({
header: header,
body: body,
isHistoryBack: false,
- isRefresh: true
+ isRefresh: isRefresh
})
);
};
@@ -916,10 +925,10 @@ export default function OperationApprovalsTable(props) {
})
);
} else {
- handlerErrorModal(ERROR_TITLE, ERROR_MESSAGE);
+ handlerErrorModal(ERROR_TITLE, ERROR_MESSAGE, true);
}
} catch (errInfo) {
- handlerErrorModal(ERROR_TITLE, ERROR_MESSAGE);
+ handlerErrorModal(ERROR_TITLE, ERROR_MESSAGE, true);
}
};
@@ -1043,6 +1052,151 @@ export default function OperationApprovalsTable(props) {
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 (