feat: 관리자 - 환경설정 - 위원회 코드관리 삭제 시, 선택 안 된 항목 삭제 안 되는 버그 수정 건

thkim
thkim 2024-02-29 16:08:49 +09:00
parent a93fa295ed
commit 29215ccaae
3 changed files with 89 additions and 9 deletions

View File

@ -15,6 +15,9 @@ import AddIcon from '@mui/icons-material/Add';
import styledComponent from "styled-components";
import * as EgovNet from 'api/egovFetch';
const StyledDiv = styledComponent.div`
.text-item.active {
background-color: #676767;
@ -27,10 +30,14 @@ function generate(items, element, onClickListner,nameKey,
let returnValue = [];
let nIndex = 0;
Object.keys(items).forEach(function(key) {
returnValue = [
...returnValue,
React.cloneElement(element, {
key,
'data-key' : key,
'data-index' : nIndex,
},
<Card className="text-item" sx={{ '&': { boxShadow: 'none' } }} key={key} data-index={nIndex} onClick={(e) => {onClickListner(e, key);}}>
<CardActionArea sx={{ px: 1 }}>
@ -114,10 +121,19 @@ function ListCreateUpdateDelete(props) {
<ListItem
secondaryAction={
<div>
<IconButton sx={{ mx: 0 }} edge="start" aria-label="edit">
<IconButton sx={{ mx: 0 }} edge="start" aria-label="edit" onClick={(e)=> {alert('수정 클릭')}}>
<EditIcon />
</IconButton>
<IconButton edge="end" aria-label="delete">
<IconButton edge="end" aria-label="delete" onClick={(e)=> {
const dataKey = Number(e.currentTarget.parentNode.parentNode.parentNode.getAttribute('data-key'));
let paramCodeGroup = null;
if( props.depthSelectedArrayIndex > 0 ) {
paramCodeGroup = props.itemIndex[props.depthSelectedArrayIndex-1];
}
props.onClickDeleteItem(e, paramCodeGroup, props.paramCodeLevel, props.depthSelectedArrayIndex, props.items[dataKey]);
}}>
<DeleteIcon />
</IconButton>
</div>

View File

@ -4,15 +4,10 @@ import Box from '@mui/material/Box';
import * as EgovNet from 'api/egovFetch';
import CommitteeCodeRegistrationPopup from './CommitteeCodeMgt/CommitteeCodeRegistrationPopup';
import ListCreateUpdateDelete from '../../../components/list/ListCreateUpdateDelete'
import ListLabelInputs from '../../../components/list/ListLabelInputs'
import URL from 'constants/url';
import { default as EgovLeftNav } from 'components/leftmenu/EgovLeftNavAdmin';
@ -37,7 +32,7 @@ function CommitteeCodeMgt(props) {
// '' item , '' .
useEffect(function () {
if( typeof depthSelectedIndex[0] !== "undefined" && depth01List[depthSelectedIndex[0]].orgId !== undefined) {
if( typeof depthSelectedIndex[0] !== "undefined" && depth01List[depthSelectedIndex[0]] && depth01List[depthSelectedIndex[0]].orgId !== undefined) {
setSearchCondition({ paramCodeGroup: depth01List[depthSelectedIndex[0]].orgId, paramCodeLevel: 'LV_02' });
setDepth02List({});
setDepth03List({});
@ -153,6 +148,66 @@ function CommitteeCodeMgt(props) {
]);
const onClickDeleteItem = (e, paramCodeGroup, paramCodeLevel, depthSelectedArrayIndex, deleteItem) => {
if( deleteItem.orgId === undefined ) {
alert('삭제 대상이 존재하지 않습니다.');
return false;
}
const requestOptions = {
method: "DELETE",
headers: {
'Content-type': 'application/json',
}
};
EgovNet.requestFetch(`/admin/config/committee-code-management/${deleteItem.orgId}`,
requestOptions,
function (resp) {
// .
let forChangeObject = {...searchCondition, paramCodeGroup, paramCodeLevel};
setSearchCondition(forChangeObject);
// .
//
// .
if( Number(depthSelectedIndex[depthSelectedArrayIndex]) === Number(deleteItem.orgId) ) {
//
// .
for( let i = depthSelectedArrayIndex + 1; i<4; i++ ) {
//setSearchCondition({...searchCondition, paramCodeLevel : createCondition.paramCodeLevel});
depthSelectedIndex[i] = undefined;
}
let forChangeObject = [...depthSelectedIndex];
setDepthSelectedIndex(forChangeObject);
// eslint-disable-next-line default-case
switch(depthSelectedArrayIndex) {
case 0:
setDepth02List({});
// eslint-disable-next-line no-fallthrough
case 1:
setDepth03List({});
// eslint-disable-next-line no-fallthrough
case 2:
setDepth04List({});
}
}
alert('삭제 되었습니다.');
}
);
}
const Location = React.memo(function Location() {
return (
<div className="location">
@ -211,6 +266,7 @@ function CommitteeCodeMgt(props) {
idKey="orgId"
isPopupOpen = {isCommitteeCodeRegistrationPopupOpen}
setIsPopupOpen = {setIsCommitteeCodeRegistrationPopupOpen}
onClickDeleteItem={onClickDeleteItem}
/>
<ListCreateUpdateDelete
title="총괄위원회"
@ -220,11 +276,14 @@ function CommitteeCodeMgt(props) {
depthSelectedArrayIndex={1}
createCondition={createCondition}
setCreateCondition={setCreateCondition}
searchCondition={searchCondition}
setSearchCondition={setSearchCondition}
paramCodeLevel="LV_02"
nameKey="orgNm"
idKey="orgId"
isPopupOpen = {isCommitteeCodeRegistrationPopupOpen}
setIsPopupOpen = {setIsCommitteeCodeRegistrationPopupOpen}
onClickDeleteItem={onClickDeleteItem}
/>
<ListCreateUpdateDelete
title="건설기준위원회"
@ -234,11 +293,14 @@ function CommitteeCodeMgt(props) {
depthSelectedArrayIndex={2}
createCondition={createCondition}
setCreateCondition={setCreateCondition}
searchCondition={searchCondition}
setSearchCondition={setSearchCondition}
paramCodeLevel="LV_03"
nameKey="orgNm"
idKey="orgId"
isPopupOpen = {isCommitteeCodeRegistrationPopupOpen}
setIsPopupOpen = {setIsCommitteeCodeRegistrationPopupOpen}
onClickDeleteItem={onClickDeleteItem}
/>
<ListCreateUpdateDelete
title="실무위원회"
@ -248,11 +310,14 @@ function CommitteeCodeMgt(props) {
depthSelectedArrayIndex={3}
createCondition={createCondition}
setCreateCondition={setCreateCondition}
searchCondition={searchCondition}
setSearchCondition={setSearchCondition}
paramCodeLevel="LV_04"
nameKey="orgNm"
idKey="orgId"
isPopupOpen = {isCommitteeCodeRegistrationPopupOpen}
setIsPopupOpen = {setIsCommitteeCodeRegistrationPopupOpen}
onClickDeleteItem={onClickDeleteItem}
/>
</Box>

View File

@ -28,7 +28,6 @@ function CommitteeCodeRegistrationPopup(props) {
EgovNet.requestFetch(`/admin/config/committee-code-management`,
requestOptions,
function (resp) {
//window.location.reload();
// .
props.setSearchCondition({...props.searchCondition, paramCodeLevel : props.createCondition.paramCodeLevel});