From 2a6534630f29dbd810e33a401e8a59bee66561f3 Mon Sep 17 00:00:00 2001 From: minuk926 Date: Thu, 21 Apr 2022 21:54:55 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=9E=90=EB=A3=8C=EA=B4=80=EB=A6=AC=20?= =?UTF-8?q?=EC=83=81=EC=84=B8=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/common.js | 5 +- src/apis/judge.js | 36 ++- src/commons/ApiUrl.js | 1 + src/commons/XitCmm.js | 2 +- src/views/biz/board/PublicBoardForm.jsx | 2 +- src/views/biz/judge/JudgeDataDetailForm.jsx | 268 ++++++++++++++++++ ...geDataForm.jsx => JudgeDataModifyForm.jsx} | 12 +- ...JudgeDataForm.jsx => JudgeDataNewForm.jsx} | 69 +++-- src/views/biz/judge/JudgeDataReview.jsx | 67 ++++- src/views/biz/judge/JudgeRegistReview.jsx | 4 +- ...TargetForm.jsx => JudgeTargetSaveForm.jsx} | 6 +- src/views/cmm/ImageFileTextForm.jsx | 37 +++ 12 files changed, 449 insertions(+), 60 deletions(-) create mode 100644 src/views/biz/judge/JudgeDataDetailForm.jsx rename src/views/biz/judge/{ModifyJudgeDataForm.jsx => JudgeDataModifyForm.jsx} (98%) rename src/views/biz/judge/{NewJudgeDataForm.jsx => JudgeDataNewForm.jsx} (89%) rename src/views/biz/judge/{SaveJudgeTargetForm.jsx => JudgeTargetSaveForm.jsx} (98%) create mode 100644 src/views/cmm/ImageFileTextForm.jsx diff --git a/src/apis/common.js b/src/apis/common.js index 9f0115d..842a33a 100644 --- a/src/apis/common.js +++ b/src/apis/common.js @@ -9,8 +9,7 @@ import { GET_CMM_CODE_LIST, GET_FILE_DOWNLOAD } from 'commons/ApiUrl'; export async function getComboCodeList(param) { const params = { ...param, codeGrpId: 'TRAFFIC', codeLcd: 'GANGNAM_SIMSA' }; // eslint-disable-next-line no-return-await - const res = await axios.get(GET_CMM_CODE_LIST, { params }); - return res; + return await axios.get(GET_CMM_CODE_LIST, { params }); } // TODO: 헤더에서 파일 정보 읽을 수 있도록 변경 필요 @@ -23,7 +22,7 @@ export async function fileDownload(id, filename, alert) { }) // eslint-disable-next-line consistent-return .then((res) => { - if (res.isAxiosError) alert.show('파일을 다운로드 할 수 없습니다 [파일정보 오류]'); + if (res?.isAxiosError || res?.status === 404) alert.show('파일을 다운로드 할 수 없습니다 [파일정보 오류]'); else FileSaver.saveAs(res, filename); }); } diff --git a/src/apis/judge.js b/src/apis/judge.js index 43ca59c..5306077 100644 --- a/src/apis/judge.js +++ b/src/apis/judge.js @@ -12,9 +12,11 @@ import { SAVE_JUDGE_TARGET_LIST, GET_JUDGE_RESULT_LIST, GET_PARKING_JUDGE_RESULT_LIST, - REMOVE_JUDGE + REMOVE_JUDGE, + GET_JUDGE_FILE_DOWNLOAD } from 'commons/ApiUrl'; import { setRowId } from './common'; +import FileSaver from 'file-saver'; // eslint-disable-next-line no-return-await export async function findJudgeDatas(params) { @@ -113,3 +115,35 @@ export async function removeJudge(params) { // eslint-disable-next-line no-return-await return await axios.post(REMOVE_JUDGE, params); } + +export async function judgeFileDownload(params, alert) { + await axios + .get(GET_JUDGE_FILE_DOWNLOAD, { + responseType: 'blob', + params + }) + // eslint-disable-next-line consistent-return + .then((res) => { + if (res?.isAxiosError || res?.status === 404) { + alert.show('파일을 다운로드 할 수 없습니다 [파일정보 오류]'); + } else { + // const onChangeFile = (e) => { + // const file = e.target.files[0]; + // if (file.type.includes('image')) { + // alert.show(~~~); + // } + // handleChangeFile(file); + // }; + + // FileSaver.saveAs(res, 'filename'); + + // eslint-disable-next-line no-lonely-if + if (res?.type.includes('image')) { + // const url = window.URL.createObjectURL(res); + alert.show(~~~); + } else { + FileSaver.saveAs(res, 'filename'); + } + } + }); +} diff --git a/src/commons/ApiUrl.js b/src/commons/ApiUrl.js index 681ca0d..85eefb1 100644 --- a/src/commons/ApiUrl.js +++ b/src/commons/ApiUrl.js @@ -33,6 +33,7 @@ export const GET_JUDGE_RESULT_LIST = '/api/v1/ctgy/judge/result'; 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/commons/XitCmm.js b/src/commons/XitCmm.js index e533011..5910ce2 100644 --- a/src/commons/XitCmm.js +++ b/src/commons/XitCmm.js @@ -36,7 +36,7 @@ const XitCmm = { }, formatDateStr(dateStr, delimiter) { - return dateStr.substring(0, 4) + delimiter + dateStr.substring(4, 2) + delimiter + dateStr.substring(6); + return dateStr.substring(0, 4) + delimiter + dateStr.substring(4, 6) + delimiter + dateStr.substring(6); }, /** diff --git a/src/views/biz/board/PublicBoardForm.jsx b/src/views/biz/board/PublicBoardForm.jsx index 5e96c2c..4a0e8ab 100644 --- a/src/views/biz/board/PublicBoardForm.jsx +++ b/src/views/biz/board/PublicBoardForm.jsx @@ -14,7 +14,7 @@ import 'react-quill/dist/quill.snow.css'; import InputLabel from 'ui-component/extended/Form/InputLabel'; import { Delete, List, Save } from '@mui/icons-material'; -import { fileDownload } from '../../../apis/common'; +import { fileDownload } from 'apis/common'; import FileForm from 'views/cmm/FileForm'; const PublicBoardForm = (props) => { diff --git a/src/views/biz/judge/JudgeDataDetailForm.jsx b/src/views/biz/judge/JudgeDataDetailForm.jsx new file mode 100644 index 0000000..dba76d4 --- /dev/null +++ b/src/views/biz/judge/JudgeDataDetailForm.jsx @@ -0,0 +1,268 @@ +import { useEffect, 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 { judgeFileDownload } from '../../../apis/judge'; +import { Delete, FileDownload, FileUpload, List } from '@mui/icons-material'; +import ImageFileTextForm from '../../cmm/ImageFileTextForm'; + +// const toDate = new Date(); + +const ModifyJudgeDataForm = ({ rowData, handleModalSave, setOpen, contDocs, ingbs }) => { + 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); + }; + + const viewImg = (methodName) => { + judgeFileDownload( + { + scDatagb: rowData.scDatagb, + scCode: rowData.scCode, + methodName + }, + showAlert + ); + }; + + return ( + <> + + + + + + + + + + + + + + + 진술유형 + + + + + + + + + + + + + 접수방법 + + + + + + + + + + + + + + + + + + + + + + + + + + + + ) + }} + /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {/* {_.range(1, 9, 1).map((idx) => { */} + {/* // eslint-disable-next-line no-eval */} + {/* const fName = `rowData.scContad${idx}`; */} + {/* return ( */} + {/* */} + {/* */} + {/* */} + {/* ); */} + {/* })} */} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ); +}; +ModifyJudgeDataForm.propTypes = { + rowData: PropTypes.object.isRequired, + handleModalSave: PropTypes.func.isRequired, + setOpen: PropTypes.func.isRequired +}; +export default ModifyJudgeDataForm; diff --git a/src/views/biz/judge/ModifyJudgeDataForm.jsx b/src/views/biz/judge/JudgeDataModifyForm.jsx similarity index 98% rename from src/views/biz/judge/ModifyJudgeDataForm.jsx rename to src/views/biz/judge/JudgeDataModifyForm.jsx index c6930f9..ba1649c 100644 --- a/src/views/biz/judge/ModifyJudgeDataForm.jsx +++ b/src/views/biz/judge/JudgeDataModifyForm.jsx @@ -14,7 +14,7 @@ import FileInputForms from 'views/cmm/FileInputForms'; // const toDate = new Date(); -const ModifyJudgeDataForm = ({ rowData, handleModalSave }) => { +const JudgeDataModifyForm = ({ rowData, handleModalSave }) => { const alert = useAlert(); const [scCarnum, setScCarnum] = useState(rowData.scCarnum); @@ -147,7 +147,7 @@ const ModifyJudgeDataForm = ({ rowData, handleModalSave }) => { customInput={TextField} required label="접수일자" - format="########" + format="####-##-##" fullWidth value={scCdate} onChange={(e) => setScCdate(e?.target?.value)} @@ -172,7 +172,7 @@ const ModifyJudgeDataForm = ({ rowData, handleModalSave }) => { customInput={TextField} required label="위반일자" - format="########" + format="####-##-##" fullWidth value={scWdate} onChange={(e) => setScWdate(e?.target?.value)} @@ -184,7 +184,7 @@ const ModifyJudgeDataForm = ({ rowData, handleModalSave }) => { customInput={TextField} required label="위반시간" - format="####" + format="##:##" fullWidth value={scJbtime} onChange={(e) => setScJbtime(e?.target?.value)} @@ -454,8 +454,8 @@ const ModifyJudgeDataForm = ({ rowData, handleModalSave }) => { ); }; -ModifyJudgeDataForm.propTypes = { +JudgeDataModifyForm.propTypes = { rowData: PropTypes.object.isRequired, handleModalSave: PropTypes.func.isRequired }; -export default ModifyJudgeDataForm; +export default JudgeDataModifyForm; diff --git a/src/views/biz/judge/NewJudgeDataForm.jsx b/src/views/biz/judge/JudgeDataNewForm.jsx similarity index 89% rename from src/views/biz/judge/NewJudgeDataForm.jsx rename to src/views/biz/judge/JudgeDataNewForm.jsx index 1d1a5b4..2534424 100644 --- a/src/views/biz/judge/NewJudgeDataForm.jsx +++ b/src/views/biz/judge/JudgeDataNewForm.jsx @@ -14,15 +14,15 @@ import FileInputForms from 'views/cmm/FileInputForms'; const toDate = new Date(); -const NewJudgeDataForm = ({ handleModalSave }) => { +const JudgeDataNewForm = ({ handleModalSave, scDatagb, contDocs, ingbs }) => { const alert = useAlert(); const [scCarnum, setScCarnum] = useState(''); const [scName, setScName] = useState(''); const [scDong, setScDong] = useState(''); - const [scContDoc, setScContDoc] = useState(); + // const [scContDoc, setScContDoc] = useState(); const [selectedContDoc, setSelectedContDoc] = useState('11'); - const [scIngb, setScIngb] = useState(); + // const [scIngb, setScIngb] = useState(); const [selectedIngb, setSelectedIngb] = useState('1'); const [zippost1, setZippost1] = useState(null); const [scJuso, setScJuso] = useState(''); @@ -39,14 +39,15 @@ const NewJudgeDataForm = ({ handleModalSave }) => { const onSave = () => { // TODO : validation check 추가 const formData = new FormData(); + formData.append('scDatagb', scDatagb); formData.append('scCarnum', scCarnum); formData.append('scName', scName); formData.append('scDong', scDong); formData.append('scContDoc', selectedContDoc); - formData.append('scCdate', scCdate); + formData.append('scCdate', scCdate ? scCdate?.replace(/-/g, '') : ''); formData.append('scIngb', selectedIngb); - formData.append('scWdate', scWdate); - formData.append('scJbtime', scJbtime); + formData.append('scWdate', scWdate ? scWdate?.replace(/-/g, '') : ''); + formData.append('scJbtime', scJbtime ? scJbtime?.replace(/:/g, '') : ''); formData.append('scPos', scPos); formData.append('zippost1', zippost1); formData.append('scJuso', scJuso); @@ -64,21 +65,21 @@ const NewJudgeDataForm = ({ handleModalSave }) => { formData.append('contadFiles', v); }); - handleModalSave(formData); + 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); - }); - }, []); + // 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; @@ -129,9 +130,14 @@ const NewJudgeDataForm = ({ handleModalSave }) => { 진술유형 - setSelectedContDoc(e?.target?.value)} + > + {contDocs && + contDocs.map((contDoc) => ( {contDoc.value} @@ -147,7 +153,7 @@ const NewJudgeDataForm = ({ handleModalSave }) => { customInput={TextField} required label="접수일자" - format="########" + format="####-##-##" fullWidth value={scCdate} onChange={(e) => setScCdate(e?.target?.value)} @@ -156,9 +162,9 @@ const NewJudgeDataForm = ({ handleModalSave }) => { 접수방법 - setSelectedIngb(e?.target?.value)}> + {ingbs && + ingbs.map((ingb) => ( {ingb.value} @@ -172,7 +178,7 @@ const NewJudgeDataForm = ({ handleModalSave }) => { customInput={TextField} required label="위반일자" - format="########" + format="####-##-##" fullWidth value={scWdate} onChange={(e) => setScWdate(e?.target?.value)} @@ -184,7 +190,7 @@ const NewJudgeDataForm = ({ handleModalSave }) => { customInput={TextField} required label="위반시간" - format="####" + format="##:##" fullWidth value={scJbtime} onChange={(e) => setScJbtime(e?.target?.value)} @@ -439,7 +445,8 @@ const NewJudgeDataForm = ({ handleModalSave }) => { ); }; -NewJudgeDataForm.propTypes = { - handleModalSave: PropTypes.func.isRequired +JudgeDataNewForm.propTypes = { + handleModalSave: PropTypes.func.isRequired, + scDatagb: PropTypes.string.isRequired }; -export default NewJudgeDataForm; +export default JudgeDataNewForm; diff --git a/src/views/biz/judge/JudgeDataReview.jsx b/src/views/biz/judge/JudgeDataReview.jsx index eeec33f..6dda6b4 100644 --- a/src/views/biz/judge/JudgeDataReview.jsx +++ b/src/views/biz/judge/JudgeDataReview.jsx @@ -9,12 +9,19 @@ import MainCard from 'ui-component/cards/MainCard'; import MuiDataGrid from 'views/cmm/MuiDataGrid'; import CmmModal from 'views/cmm/CmmModal'; import { findJudge, findJudgeDatas, saveJudgeData } from 'apis/judge'; -import NewJudgeDataForm from 'views/biz/judge/NewJudgeDataForm'; -import ModifyJudgeDataForm from 'views/biz/judge/ModifyJudgeDataForm'; +import JudgeDataNewForm from 'views/biz/judge/JudgeDataNewForm'; import PropTypes from 'prop-types'; -import xitCmm from '../../../commons/XitCmm'; +import xitCmm from 'commons/XitCmm'; +import DetailJudgeDataForm from './JudgeDataDetailForm'; +import { useAlert } from 'react-alert'; +import { removePublicBoard, savePublicBoard } from '../../../apis/public'; +import { getComboCodeList } from '../../../apis/common'; const JudgeDataReview = ({ scDatagb, menuName }) => { + const showAlert = useAlert(); + const [scContDocs, setScContDocs] = useState([]); + const [scIngbs, setScIngbs] = useState([]); + const [open, setOpen] = useState(false); const [create, setCreate] = useState(false); // const [selectedRow, setSelectedRow] = useState({}); @@ -55,8 +62,8 @@ const JudgeDataReview = ({ scDatagb, menuName }) => { align: 'center', width: 120, valueFormatter: (params) => { - if (params.value == null || params.value.length < 8) return params.value; - return xitCmm.formatDateStr(params.value, '-'); + if (params.value !== null || params.value.length === 8) return xitCmm.formatDateStr(params.value, '-'); + return params.value; } }, { headerName: '접수방법', headerAlign: 'center', field: 'scIngbNm', align: 'center' }, @@ -81,9 +88,24 @@ 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]); + useEffect(() => { + getComboCodeList({ codeMcd: 'SC_CONT_DOC' }).then((res) => { + setScContDocs(res.data); + }); + getComboCodeList({ codeMcd: 'RC_INGB' }).then((res) => { + setScIngbs(res.data); + }); + }, []); + const handleCreate = () => { setTitle(`${menuName} 의견진술 자료 신규 등록`); setCreate(true); @@ -101,11 +123,23 @@ const JudgeDataReview = ({ scDatagb, menuName }) => { } }; - const handleSaveResident = (payload) => { - saveJudgeData(payload).then(() => { - search(); - setOpen(false); - }); + const handleSaveResident = (type, payload) => { + switch (type) { + case 'SAVE': + saveJudgeData(payload).then((res) => { + if (res?.success) { + search(); + setOpen(false); + } else { + showAlert.show(`${res?.data.message}`); + } + }); + break; + case 'DELETE': + alert('~~~~~~삭제 구현~~~~~~'); + break; + default: + } }; return ( @@ -130,8 +164,17 @@ const JudgeDataReview = ({ scDatagb, menuName }) => { handleCellClick={handleOnCellClick} /> - {create && } - {!create && } + {create && } + {/* {!create && } */} + {!create && ( + + )} ); diff --git a/src/views/biz/judge/JudgeRegistReview.jsx b/src/views/biz/judge/JudgeRegistReview.jsx index 6ac82d7..a119a63 100644 --- a/src/views/biz/judge/JudgeRegistReview.jsx +++ b/src/views/biz/judge/JudgeRegistReview.jsx @@ -15,7 +15,7 @@ import MuiDataGrid from 'views/cmm/MuiDataGrid'; import xitCmm from 'commons/XitCmm'; import CmmModal from 'views/cmm/CmmModal'; -import SaveJudgeTargetForm from 'views/biz/judge/SaveJudgeTargetForm'; +import JudgeTargetSaveForm from 'views/biz/judge/JudgeTargetSaveForm'; import NumberFormat from 'react-number-format'; import ExcelDownload from 'views/cmm/ExcelDownload'; import { findJudgeTargets, saveJudgeTargets } from 'apis/judge'; @@ -213,7 +213,7 @@ const JudgeRegistReview = ({ scDatagb, menuName }) => { selectionModel={selectionModel} /> - + ); diff --git a/src/views/biz/judge/SaveJudgeTargetForm.jsx b/src/views/biz/judge/JudgeTargetSaveForm.jsx similarity index 98% rename from src/views/biz/judge/SaveJudgeTargetForm.jsx rename to src/views/biz/judge/JudgeTargetSaveForm.jsx index 0589e5a..0f32f6a 100644 --- a/src/views/biz/judge/SaveJudgeTargetForm.jsx +++ b/src/views/biz/judge/JudgeTargetSaveForm.jsx @@ -17,7 +17,7 @@ import combo from 'commons/combo_data'; const toDate = new Date(); -const SaveJudgeTargetForm = ({ handleModalSave }) => { +const JudgeTargetSaveForm = ({ handleModalSave }) => { const [msuTeam, setMsuTeam] = useState(combo.teams[0].code); const [msSdate, setMsSdate] = useState(format(toDate, 'yyyy-MM-dd')); const [msStartsi, setMsStartsi] = useState(getHours(toDate)); @@ -172,8 +172,8 @@ const SaveJudgeTargetForm = ({ handleModalSave }) => { ); }; -SaveJudgeTargetForm.propTypes = { +JudgeTargetSaveForm.propTypes = { handleModalSave: PropTypes.func.isRequired // isDisabled: PropTypes.bool.isRequired }; -export default SaveJudgeTargetForm; +export default JudgeTargetSaveForm; diff --git a/src/views/cmm/ImageFileTextForm.jsx b/src/views/cmm/ImageFileTextForm.jsx new file mode 100644 index 0000000..c39f145 --- /dev/null +++ b/src/views/cmm/ImageFileTextForm.jsx @@ -0,0 +1,37 @@ +import { InputAdornment, TextField } from '@mui/material'; +import { FileDownload } from '@mui/icons-material'; +import PropTypes from 'prop-types'; + +const ImageFileTextForm = ({ labelName, fileName = '', methodName, handleViewImg }) => ( + <> + {fileName && ( + handleViewImg(methodName)} + InputProps={{ + display: 'none', + endAdornment: ( + + + + ) + }} + /> + )} + {!fileName && ( + handleViewImg(methodName)} /> + )} + +); +ImageFileTextForm.propTypes = { + labelName: PropTypes.string.isRequired, + fileName: PropTypes.string, + methodName: PropTypes.string.isRequired, + handleViewImg: PropTypes.func.isRequired +}; + +export default ImageFileTextForm;