diff --git a/src/apis/judge.js b/src/apis/judge.js index 5306077..6bbd324 100644 --- a/src/apis/judge.js +++ b/src/apis/judge.js @@ -13,7 +13,8 @@ import { GET_JUDGE_RESULT_LIST, GET_PARKING_JUDGE_RESULT_LIST, REMOVE_JUDGE, - GET_JUDGE_FILE_DOWNLOAD + GET_JUDGE_FILE_DOWNLOAD, + REMOVE_JUDGE_DATA } from 'commons/ApiUrl'; import { setRowId } from './common'; import FileSaver from 'file-saver'; @@ -37,6 +38,11 @@ export async function saveJudgeData(formData) { }); } +export async function removeJudgeData(params) { + // eslint-disable-next-line no-return-await + return await axios.post(REMOVE_JUDGE_DATA, params); +} + export async function findJudge(scCode) { // eslint-disable-next-line no-return-await return await axios.get(GET_JUDGE_DATA + scCode); diff --git a/src/commons/ApiUrl.js b/src/commons/ApiUrl.js index 85eefb1..6e13c51 100644 --- a/src/commons/ApiUrl.js +++ b/src/commons/ApiUrl.js @@ -28,12 +28,15 @@ export const REMOVE_PARKING_JUDGE = '/api/v1/ctgy/parking/remove'; export const GET_JUDGE_DATA_LIST = '/api/v1/ctgy/judge/data'; export const SAVE_JUDGE_DATA = '/api/v1/ctgy/judge/data'; export const GET_JUDGE_DATA = '/api/v1/ctgy/judge/data/'; +export const REMOVE_JUDGE_DATA = '/api/v1/ctgy/judge/data/remove'; + export const GET_JUDGE_LIST = '/api/v1/ctgy/judge'; export const GET_JUDGE_RESULT_LIST = '/api/v1/ctgy/judge/result'; +export const GET_JUDGE_FILE_DOWNLOAD = '/api/v1/ctgy/cmm/download/judge'; + export const GET_JUDGE_TARGET_LIST = '/api/v1/ctgy/judge/target'; export const SAVE_JUDGE_TARGET_LIST = '/api/v1/ctgy/judge/target'; export const REMOVE_JUDGE = '/api/v1/ctgy/judge/remove'; -export const GET_JUDGE_FILE_DOWNLOAD = '/api/v1/ctgy/cmm/download/judge'; // 사용자 관리 export const GET_USER_LIST = '/api/v1/ctgy/user'; diff --git a/src/views/biz/judge/JudgeDataDetailForm.jsx b/src/views/biz/judge/JudgeDataDetailForm.jsx index dba76d4..760cc46 100644 --- a/src/views/biz/judge/JudgeDataDetailForm.jsx +++ b/src/views/biz/judge/JudgeDataDetailForm.jsx @@ -1,35 +1,29 @@ -import { useEffect, useState } from 'react'; +import { useState } from 'react'; import PropTypes from 'prop-types'; import NumberFormat from 'react-number-format'; import { useAlert } from 'react-alert'; -import _ from 'lodash'; - import { Grid, TextField, MenuItem, Select, FormControl, InputLabel, InputAdornment, Divider } from '@mui/material'; import Button from '@mui/material/Button'; -import { IconSearch, IconFileDownload } from '@tabler/icons'; +import { IconSearch } from '@tabler/icons'; import { judgeFileDownload } from '../../../apis/judge'; -import { Delete, FileDownload, FileUpload, List } from '@mui/icons-material'; +import { Delete, List } from '@mui/icons-material'; import ImageFileTextForm from '../../cmm/ImageFileTextForm'; -// const toDate = new Date(); - -const ModifyJudgeDataForm = ({ rowData, handleModalSave, setOpen, contDocs, ingbs }) => { +const ModifyJudgeDataForm = ({ rowData, contDocs, ingbs, setOpen, handleModalSave, onModify }) => { const showAlert = useAlert(); const [selectedContDoc, setSelectedContDoc] = useState(rowData.scContDoc); const [selectedIngb, setSelectedIngb] = useState(rowData.scIngb); - const onModify = () => {}; - const onList = () => { setOpen(false); }; const onRemove = () => { - handleModalSave('DELETE', rowData.scCode); + handleModalSave('DELETE', { scCode: rowData.scCode }); }; const viewImg = (methodName) => { @@ -150,7 +144,7 @@ const ModifyJudgeDataForm = ({ rowData, handleModalSave, setOpen, contDocs, ingb fullWidth required label="우편번호" - value={rowData.zippost1} + value={rowData.zipcode1} InputProps={{ display: 'none', readOnly: true, @@ -262,7 +256,10 @@ const ModifyJudgeDataForm = ({ rowData, handleModalSave, setOpen, contDocs, ingb }; ModifyJudgeDataForm.propTypes = { rowData: PropTypes.object.isRequired, + contDocs: PropTypes.array.isRequired, + ingbs: PropTypes.array.isRequired, handleModalSave: PropTypes.func.isRequired, - setOpen: PropTypes.func.isRequired + setOpen: PropTypes.func.isRequired, + onModify: PropTypes.func.isRequired }; export default ModifyJudgeDataForm; diff --git a/src/views/biz/judge/JudgeDataModifyForm.jsx b/src/views/biz/judge/JudgeDataModifyForm.jsx index ba1649c..63bfe76 100644 --- a/src/views/biz/judge/JudgeDataModifyForm.jsx +++ b/src/views/biz/judge/JudgeDataModifyForm.jsx @@ -1,4 +1,4 @@ -import { useEffect, useState } from 'react'; +import { useState } from 'react'; import PropTypes from 'prop-types'; import NumberFormat from 'react-number-format'; @@ -9,22 +9,19 @@ import { Grid, TextField, MenuItem, Select, FormControl, InputLabel, InputAdornm import Button from '@mui/material/Button'; import { IconSearch } from '@tabler/icons'; -import { getComboCodeList } from 'apis/common'; import FileInputForms from 'views/cmm/FileInputForms'; // const toDate = new Date(); -const JudgeDataModifyForm = ({ rowData, handleModalSave }) => { +const JudgeDataModifyForm = ({ rowData, contDocs, ingbs, setOpen, handleModalSave }) => { const alert = useAlert(); const [scCarnum, setScCarnum] = useState(rowData.scCarnum); const [scName, setScName] = useState(rowData.scName); const [scDong, setScDong] = useState(rowData.scDong); - const [scContDoc, setScContDoc] = useState(); const [selectedContDoc, setSelectedContDoc] = useState(rowData.scContDoc); - const [scIngb, setScIngb] = useState(); const [selectedIngb, setSelectedIngb] = useState(rowData.scIngb); - const [zippost1, setZippost1] = useState(`${rowData.zippost1}${rowData.zippost2}`); + const [zipcode1, setZipcode1] = useState((rowData.zipcode1 ?? '') + (rowData.zipcode2 ?? '')); const [scJuso, setScJuso] = useState(rowData.scJuso); const [scBunji, setScBunji] = useState(rowData.scBunji); const [scWdate, setScWdate] = useState(rowData.scWdate); @@ -48,7 +45,7 @@ const JudgeDataModifyForm = ({ rowData, handleModalSave }) => { formData.append('scWdate', scWdate); formData.append('scJbtime', scJbtime); formData.append('scPos', scPos); - formData.append('zippost1', zippost1); + formData.append('zipcode1', zipcode1); formData.append('scJuso', scJuso); formData.append('scBunji', scBunji); @@ -67,19 +64,6 @@ const JudgeDataModifyForm = ({ rowData, handleModalSave }) => { handleModalSave(formData); }; - useEffect(() => { - // setSelectedContDoc('11'); - setScContDoc([]); - getComboCodeList({ codeMcd: 'SC_CONT_DOC' }).then((res) => { - console.log(res); - setScContDoc(res.data); - }); - getComboCodeList({ codeMcd: 'RC_INGB' }).then((res) => { - console.log(res); - setScIngb(res.data); - }); - }, []); - const handleChangeFile = (e) => { const fileKey = e.target.name; const fileArrKey = fileKey + e.target.dataset.index; @@ -129,9 +113,14 @@ const JudgeDataModifyForm = ({ rowData, handleModalSave }) => { 진술유형 - setSelectedContDoc(e?.target?.value)} + > + {contDocs && + contDocs.map((contDoc) => ( {contDoc.value} @@ -156,9 +145,9 @@ const JudgeDataModifyForm = ({ rowData, handleModalSave }) => { 접수방법 - setSelectedIngb(e?.target?.value)}> + {ingbs && + ingbs.map((ingb) => ( {ingb.value} @@ -192,7 +181,7 @@ const JudgeDataModifyForm = ({ rowData, handleModalSave }) => { - + { onChange={(e) => setScPos(e?.target?.value)} /> + + + + + + @@ -210,8 +205,8 @@ const JudgeDataModifyForm = ({ rowData, handleModalSave }) => { fullWidth required label="우편번호" - value={zippost1} - onChange={(e) => setZippost1(e?.target?.value)} + value={zipcode1 ?? ''} + onChange={(e) => setZipcode1(e?.target?.value)} InputProps={{ display: 'none', readOnly: true, @@ -456,6 +451,9 @@ const JudgeDataModifyForm = ({ rowData, handleModalSave }) => { }; JudgeDataModifyForm.propTypes = { rowData: PropTypes.object.isRequired, - handleModalSave: PropTypes.func.isRequired + contDocs: PropTypes.array.isRequired, + ingbs: PropTypes.array.isRequired, + handleModalSave: PropTypes.func.isRequired, + setOpen: PropTypes.func.isRequired }; export default JudgeDataModifyForm; diff --git a/src/views/biz/judge/JudgeDataNewForm.jsx b/src/views/biz/judge/JudgeDataNewForm.jsx index 2534424..5175854 100644 --- a/src/views/biz/judge/JudgeDataNewForm.jsx +++ b/src/views/biz/judge/JudgeDataNewForm.jsx @@ -1,4 +1,4 @@ -import { useEffect, useState } from 'react'; +import { useState } from 'react'; import PropTypes from 'prop-types'; import NumberFormat from 'react-number-format'; @@ -9,22 +9,19 @@ import { Grid, TextField, MenuItem, Select, FormControl, InputLabel, InputAdornm import Button from '@mui/material/Button'; import { IconSearch } from '@tabler/icons'; -import { getComboCodeList } from 'apis/common'; import FileInputForms from 'views/cmm/FileInputForms'; const toDate = new Date(); -const JudgeDataNewForm = ({ handleModalSave, scDatagb, contDocs, ingbs }) => { +const JudgeDataNewForm = ({ scDatagb, contDocs, ingbs, handleModalSave }) => { const alert = useAlert(); const [scCarnum, setScCarnum] = useState(''); const [scName, setScName] = useState(''); const [scDong, setScDong] = useState(''); - // const [scContDoc, setScContDoc] = useState(); const [selectedContDoc, setSelectedContDoc] = useState('11'); - // const [scIngb, setScIngb] = useState(); const [selectedIngb, setSelectedIngb] = useState('1'); - const [zippost1, setZippost1] = useState(null); + const [zipcode1, setZipcode1] = useState(null); const [scJuso, setScJuso] = useState(''); const [scBunji, setScBunji] = useState(''); const [scWdate, setScWdate] = useState(null); @@ -49,7 +46,7 @@ const JudgeDataNewForm = ({ handleModalSave, scDatagb, contDocs, ingbs }) => { formData.append('scWdate', scWdate ? scWdate?.replace(/-/g, '') : ''); formData.append('scJbtime', scJbtime ? scJbtime?.replace(/:/g, '') : ''); formData.append('scPos', scPos); - formData.append('zippost1', zippost1); + formData.append('zipcode1', zipcode1); formData.append('scJuso', scJuso); formData.append('scBunji', scBunji); @@ -68,19 +65,6 @@ const JudgeDataNewForm = ({ handleModalSave, scDatagb, contDocs, ingbs }) => { handleModalSave('SAVE', formData); }; - // useEffect(() => { - // // setSelectedContDoc('11'); - // setScContDoc([]); - // getComboCodeList({ codeMcd: 'SC_CONT_DOC' }).then((res) => { - // console.log(res); - // setScContDoc(res.data); - // }); - // getComboCodeList({ codeMcd: 'RC_INGB' }).then((res) => { - // console.log(res); - // setScIngb(res.data); - // }); - // }, []); - const handleChangeFile = (e) => { const fileKey = e.target.name; const fileArrKey = fileKey + e.target.dataset.index; @@ -209,8 +193,8 @@ const JudgeDataNewForm = ({ handleModalSave, scDatagb, contDocs, ingbs }) => { fullWidth required label="우편번호" - value={zippost1} - onChange={(e) => setZippost1(e?.target?.value)} + value={zipcode1} + onChange={(e) => setZipcode1(e?.target?.value)} InputProps={{ display: 'none', readOnly: true, @@ -446,7 +430,9 @@ const JudgeDataNewForm = ({ handleModalSave, scDatagb, contDocs, ingbs }) => { ); }; JudgeDataNewForm.propTypes = { - handleModalSave: PropTypes.func.isRequired, - scDatagb: PropTypes.string.isRequired + scDatagb: PropTypes.string.isRequired, + contDocs: PropTypes.array.isRequired, + ingbs: PropTypes.array.isRequired, + handleModalSave: PropTypes.func.isRequired }; export default JudgeDataNewForm; diff --git a/src/views/biz/judge/JudgeDataReview.jsx b/src/views/biz/judge/JudgeDataReview.jsx index 6dda6b4..ef12e0f 100644 --- a/src/views/biz/judge/JudgeDataReview.jsx +++ b/src/views/biz/judge/JudgeDataReview.jsx @@ -8,14 +8,14 @@ import MainCard from 'ui-component/cards/MainCard'; // project imports import MuiDataGrid from 'views/cmm/MuiDataGrid'; import CmmModal from 'views/cmm/CmmModal'; -import { findJudge, findJudgeDatas, saveJudgeData } from 'apis/judge'; +import { findJudge, findJudgeDatas, removeJudgeData, saveJudgeData } from 'apis/judge'; import JudgeDataNewForm from 'views/biz/judge/JudgeDataNewForm'; import PropTypes from 'prop-types'; import xitCmm from 'commons/XitCmm'; -import DetailJudgeDataForm from './JudgeDataDetailForm'; +import JudgeDataDetailForm from './JudgeDataDetailForm'; import { useAlert } from 'react-alert'; -import { removePublicBoard, savePublicBoard } from '../../../apis/public'; import { getComboCodeList } from '../../../apis/common'; +import JudgeDataModifyForm from './JudgeDataModifyForm'; const JudgeDataReview = ({ scDatagb, menuName }) => { const showAlert = useAlert(); @@ -24,6 +24,8 @@ const JudgeDataReview = ({ scDatagb, menuName }) => { const [open, setOpen] = useState(false); const [create, setCreate] = useState(false); + const [detail, setDetail] = useState(false); + const [modify, setModify] = useState(false); // const [selectedRow, setSelectedRow] = useState({}); const [title, setTitle] = useState(); const [rowData, setRowData] = useState({}); @@ -88,12 +90,6 @@ const JudgeDataReview = ({ scDatagb, menuName }) => { }, [rowsState.page, rowsState.pageSize, scDatagb]); useEffect(() => { - getComboCodeList({ codeMcd: 'SC_CONT_DOC' }).then((res) => { - setScContDocs(res.data); - }); - getComboCodeList({ codeMcd: 'RC_INGB' }).then((res) => { - setScIngbs(res.data); - }); search(); }, [search]); @@ -107,17 +103,21 @@ const JudgeDataReview = ({ scDatagb, menuName }) => { }, []); const handleCreate = () => { - setTitle(`${menuName} 의견진술 자료 신규 등록`); + setModify(false); + setDetail(false); setCreate(true); + setTitle(`${menuName} 의견진술 자료 신규 등록`); setOpen(true); }; const handleOnCellClick = (e) => { if (e?.field === 'scSeq') { findJudge(e.row?.scCode).then((res) => { - setRowData(res.data); setCreate(false); - setTitle(`${menuName} 의견진술 자료 변경`); + setModify(false); + setDetail(true); + setRowData(res.data); + setTitle(`${menuName} 의견진술 자료 상세`); setOpen(true); }); } @@ -128,20 +128,43 @@ const JudgeDataReview = ({ scDatagb, menuName }) => { case 'SAVE': saveJudgeData(payload).then((res) => { if (res?.success) { - search(); + setCreate(false); + setModify(false); + setDetail(false); setOpen(false); + search(); } else { showAlert.show(`${res?.data.message}`); } }); break; case 'DELETE': - alert('~~~~~~삭제 구현~~~~~~'); + removeJudgeData(payload).then((res) => { + if (res?.success) { + setCreate(false); + setModify(false); + setDetail(false); + setOpen(false); + search(); + } else { + showAlert.show(`${res?.data.message}`); + } + }); break; default: } }; + const openModify = () => { + setOpen(false); + setCreate(false); + setDetail(false); + + setModify(true); + setTitle(`${menuName} 의견진술 자료 변경`); + setOpen(true); + }; + return ( @@ -166,13 +189,24 @@ const JudgeDataReview = ({ scDatagb, menuName }) => { {create && } {/* {!create && } */} - {!create && ( - + )} + {modify && ( + )} diff --git a/src/views/cmm/ImageFileTextForm.jsx b/src/views/cmm/ImageFileTextForm.jsx index c39f145..cc99f90 100644 --- a/src/views/cmm/ImageFileTextForm.jsx +++ b/src/views/cmm/ImageFileTextForm.jsx @@ -11,7 +11,7 @@ const ImageFileTextForm = ({ labelName, fileName = '', methodName, handleViewImg fullWidth label={labelName} value={fileName} - onClick={(e) => handleViewImg(methodName)} + onClick={() => handleViewImg(methodName)} InputProps={{ display: 'none', endAdornment: ( @@ -23,7 +23,7 @@ const ImageFileTextForm = ({ labelName, fileName = '', methodName, handleViewImg /> )} {!fileName && ( - handleViewImg(methodName)} /> + handleViewImg(methodName)} /> )} );