Browse Source

feat/테이블 Input 포커스 아웃 저장 처리

master
sanguu516 4 weeks ago
parent
commit
5ca6ad9034
  1. 201
      src/components/flight/OperationApprovalsTable.js
  2. 29
      src/containers/flight/OperationApprovalsContainer.js

201
src/components/flight/OperationApprovalsTable.js

@ -81,6 +81,49 @@ export default function OperationApprovalsTable(props) {
setCheckList([]); setCheckList([]);
}, [laancAprvList]); }, [laancAprvList]);
// input 수정 컴포넌트
const EditableCell = ({
editable,
children,
dataIndex,
record,
handleSave,
...restProps
}) => {
// 저장 이벤트
const save = async () => {
try {
const values = await form.validateFields();
const currentValue = form.getFieldValue(
`${record.planAreaSno}_${dataIndex}`
);
console.log('>>', record);
console.log('>>', currentValue);
handleSave({ ...record, ...values });
} catch (errInfo) {}
};
let childNode = children;
if (editable) {
childNode = (
<Form.Item
className='editable-input'
name={`${record.planAreaSno}_${dataIndex}`} // 고유한 이름 설정
initialValue={record[dataIndex]}
onClick={e => e.stopPropagation()} // 클릭 이벤트 전파 중지
>
<Input onPressEnter={save} onBlur={save} />
</Form.Item>
);
}
return <td {...restProps}>{childNode}</td>;
};
// 검토 상태 변경
const handlerReviewed = (value, type) => { const handlerReviewed = (value, type) => {
let text = ''; let text = '';
if (type === 'operation') { if (type === 'operation') {
@ -129,6 +172,7 @@ export default function OperationApprovalsTable(props) {
return text; return text;
} }
}; };
// 데이터 // 데이터
const columns = [ const columns = [
{ {
@ -476,63 +520,28 @@ export default function OperationApprovalsTable(props) {
if (!col.editable) { if (!col.editable) {
return col; return col;
} }
return { return {
...col, ...col,
onCell: record => ({ onCell: record => ({
record, record,
editable: col.editable, editable: col.editable,
dataIndex: col.dataIndex, dataIndex: col.dataIndex,
title: col.title title: col.title,
// handleSave handleSave
}) })
}; };
}); });
// 단순 메시지 표출 모달 const handleSave = async row => {
const handlerErrorModal = (header, body, isRefresh) => {
dispatch(
openModal({
header: header,
body: body,
isHistoryBack: false,
isRefresh: isRefresh
})
);
};
// 수정 이벤트
const edit = record => {
form.setFieldsValue({
planAreaSno: record.planAreaSno,
reqRadius: record.reqRadius,
fltElev: record.fltElev,
dtl: record.dtl,
era: record.era,
rm: record.rm,
reqRadius: record.reqRadius,
reqElev: record.reqElev,
...record
});
setEditingKey(record.key);
};
// 저장 이벤트
const save = async (key, type) => {
try { try {
const row = await form.validateFields();
const index = { ...row, planAreaSno: selectedRowKey };
const updateRes = await dispatch( const updateRes = await dispatch(
updateLaancAprv([ updateLaancAprv([
{ {
planAreaSno: selectedRowKey, planAreaSno: row.key,
reqRadius: row.reqRadius || '', reqRadius: row[`${row.key}_reqRadius`] || '',
fltElev: row.fltElev || '', fltElev: row[`${row.key}_fltElev`] || '',
dtl: row.dtl || '', reqElev: row[`${row.key}_reqElev`] || ''
era: row.era || '',
rm: row.rm || '',
reqRadius: row.reqRadius || '',
reqElev: row.reqElev || ''
} }
]) ])
); );
@ -551,6 +560,27 @@ export default function OperationApprovalsTable(props) {
} catch (errInfo) { } catch (errInfo) {
handlerErrorModal(ERROR_TITLE, ERROR_MESSAGE, true); handlerErrorModal(ERROR_TITLE, ERROR_MESSAGE, true);
} }
// const newData = [...tempDataSource];
// newData.map(item => {
// if (row.hasOwnProperty(item.planAreaSno)) {
// item.reviewedReason = row[item.planAreaSno];
// }
// });
// setTempDataSource(newData);
};
// 단순 메시지 표출 모달
const handlerErrorModal = (header, body, isRefresh) => {
dispatch(
openModal({
header: header,
body: body,
isHistoryBack: false,
isRefresh: isRefresh
})
);
}; };
// 모달 오픈 핸들러 // 모달 오픈 핸들러
@ -632,7 +662,11 @@ export default function OperationApprovalsTable(props) {
// 체크박스 분기 처리 // 체크박스 분기 처리
const handleCheckbox = async type => { const handleCheckbox = async type => {
if (checkList.length === 0) { if (checkList.length === 0) {
return handlerErrorModal('검토 실패', '검토 항목을 선택해주세요.', false); return handlerErrorModal(
'필수값 실패',
'검토 항목을 선택해주세요.',
false
);
} }
const res = laancAprvList.flatMap(item => const res = laancAprvList.flatMap(item =>
@ -640,12 +674,12 @@ export default function OperationApprovalsTable(props) {
checkList.includes(area.planAreaSno.toString()) checkList.includes(area.planAreaSno.toString())
) )
); );
console.log('>>', checkList);
// 검토 요청, 재 요청 조건 // 검토 요청, 재 요청 조건
const checkCondition = { const checkCondition = {
A: item => item.reviewedType !== 'R' && item.reviewedType !== 'C', A: item => item.reviewedType !== 'R' && item.reviewedType !== 'C',
Q: item => item.reviewedType !== 'W' Q: item => item.reviewedType !== 'W',
R: item => item.reviewedType !== 'U' && item.reviewedType !== 'W'
}; };
// 요청 실패 시 에러 메시지 // 요청 실패 시 에러 메시지
@ -654,7 +688,11 @@ export default function OperationApprovalsTable(props) {
'재 요청 요청 실패', '재 요청 요청 실패',
'검토결과 완료, 검토취소인 신청건만 재 요청이 가능합니다.' '검토결과 완료, 검토취소인 신청건만 재 요청이 가능합니다.'
], ],
Q: ['검토 요청 실패', '검토결과 대기인 신청건만 요청이 가능합니다.'] Q: ['검토 요청 실패', '검토결과 대기인 신청건만 요청이 가능합니다.'],
R: [
'검토 완료 실패',
'검토불필요, 검토대기인 신청건만 재 요청이 가능합니다.'
]
}; };
// 요청 성공 시 액션 핸들러 // 요청 성공 시 액션 핸들러
@ -666,7 +704,32 @@ export default function OperationApprovalsTable(props) {
Q: async () => { Q: async () => {
try { try {
await dispatch( await dispatch(
updateLaancAprvReview({ checkList, reviewedType: 'Q' }) updateLaancAprvReview({
planAreaSnoList: checkList,
reviewedType: 'Q'
})
);
props.handlerSearch(
props.filterId,
{ startDate: props.startDate, endDate: props.endDate },
props.filterArea
);
setCheckList([]);
} catch (error) {
return handlerErrorModal(
'검토 실패',
'검토를 요청을 실패하였습니다. 다시 시도해주세요.',
false
);
}
},
R: async () => {
try {
await dispatch(
updateLaancAprvReview({
planAreaSnoList: checkList,
reviewedType: 'R'
})
); );
props.handlerSearch( props.handlerSearch(
props.filterId, props.filterId,
@ -737,6 +800,9 @@ export default function OperationApprovalsTable(props) {
</span> </span>
</div> </div>
<div className='download'> <div className='download'>
<Button color='primary' size='sm' onClick={() => handleCheckbox('R')}>
검토 완료
</Button>
<Button color='primary' size='sm' onClick={() => handleCheckbox('Q')}> <Button color='primary' size='sm' onClick={() => handleCheckbox('Q')}>
검토 요청 검토 요청
</Button> </Button>
@ -848,42 +914,3 @@ export default function OperationApprovalsTable(props) {
</div> </div>
); );
} }
const EditableCell = ({
editable,
children,
dataIndex,
record,
handleSave,
...restProps
}) => {
const toggleEdit = () => {
form.setFieldsValue({
[dataIndex]: record[dataIndex]
});
};
const save = async () => {
try {
const values = await form.validateFields();
handleSave({ ...record, ...values });
} catch (errInfo) {}
};
let childNode = children;
if (editable) {
childNode = (
<Form.Item
className='editable-input'
name={`${record.planAreaSno}_${dataIndex}`} // 고유한 이름 설정
initialValue={record[dataIndex]}
onClick={e => e.stopPropagation()} // 클릭 이벤트 전파 중지
>
<Input onPressEnter={save} onBlur={save} placeholder='' />
</Form.Item>
);
}
return <td {...restProps}>{childNode}</td>;
};

29
src/containers/flight/OperationApprovalsContainer.js

@ -120,10 +120,8 @@ export default function OperationApprovalsContainer({ mode }) {
}, []); }, []);
useEffect(() => { useEffect(() => {
if (areaCoordList.length > 0) { if (areaCoordList.length !== 0) {
if (areaCoordList[0].planSno !== 0) handlerAreaDraw(); handlerAreaDraw();
} else {
handlerRemoveArea();
} }
}, [areaCoordList]); }, [areaCoordList]);
@ -318,27 +316,14 @@ export default function OperationApprovalsContainer({ mode }) {
//현재 선택한 sno 및 areacoordList 저장 //현재 선택한 sno 및 areacoordList 저장
const handlerDetail = async area => { const handlerDetail = async area => {
if (area.length > 0) { console.log('>>', area);
if (area.length > 1) { setSelected(area[0].planAreaSno);
const planAreaSno = [];
area.map(data => {
planAreaSno.push(data.planAreaSno);
});
setSelected(planAreaSno);
} else {
setSelected([area[0].planAreaSno]);
}
setSelectedPlanSno(area[0].planSno);
setMetersRadius('0m');
handlerDistanceClose();
} else {
setSelected([]);
setSelectedPlanSno([]);
}
dispatch(clientSaveAreaCoordinateList(area)); dispatch(clientSaveAreaCoordinateList(area));
handlerMapInit(); handlerMapInit();
setMetersRadius('0m');
handlerDistanceClose();
}; };
// 지도 레이어 초기화 // 지도 레이어 초기화
@ -975,7 +960,7 @@ export default function OperationApprovalsContainer({ mode }) {
handlerApprovalCd={handlerApprovalCd} handlerApprovalCd={handlerApprovalCd}
pageName='operation' pageName='operation'
/> />
<OldOperationApprovalsTable <OperationApprovalsTable
filter={filter} filter={filter}
filterArea={filterArea} filterArea={filterArea}
filterId={filterId} filterId={filterId}

Loading…
Cancel
Save