From 3ea29bb96cc670df927f2d4c16759ab5025214ae Mon Sep 17 00:00:00 2001 From: minuk926 Date: Thu, 14 Apr 2022 19:20:45 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=8B=AC=EC=9D=98=EA=B2=B0=EA=B3=BC=20?= =?UTF-8?q?=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/index.html | 5 + src/apis/judge.js | 51 ++++- src/apis/parking.js | 11 +- src/commons/ApiUrl.js | 4 +- src/commons/combo_data.js | 1 + src/routes/MainRoutes.js | 6 - src/utils/axios.js | 13 ++ src/views/biz/judge/JudgeReview.jsx | 56 ++---- src/views/biz/judge/ModalJudgeDetail.jsx | 117 ------------ src/views/biz/judge/ModalJudgeResult.jsx | 201 ++++++++++++++++++++ src/views/biz/judge/SaveJudgeTargetForm.jsx | 2 +- src/views/biz/parking/ModalDetails.jsx | 8 - src/views/biz/parking/ParkingReview.jsx | 59 ++---- 13 files changed, 302 insertions(+), 232 deletions(-) delete mode 100644 src/views/biz/judge/ModalJudgeDetail.jsx create mode 100644 src/views/biz/judge/ModalJudgeResult.jsx delete mode 100644 src/views/biz/parking/ModalDetails.jsx diff --git a/public/index.html b/public/index.html index 30af0aa..ba41fd0 100755 --- a/public/index.html +++ b/public/index.html @@ -55,6 +55,11 @@ rel="stylesheet" crossorigin="anonymous" /> + diff --git a/src/apis/judge.js b/src/apis/judge.js index 9d6616e..186470d 100644 --- a/src/apis/judge.js +++ b/src/apis/judge.js @@ -10,7 +10,8 @@ import { GET_JUDGE_TARGET_LIST, GET_JUDGE_LIST, SAVE_JUDGE_TARGET_LIST, - GET_JUDGE_DETAIL_LIST + GET_JUDGE_RESULT_LIST, + GET_PARKING_JUDGE_RESULT_LIST } from 'commons/ApiUrl'; import { setRowId } from './common'; @@ -50,8 +51,8 @@ export async function findJudges(params) { return res; } -export async function findJudgeDetails(params) { - const res = await axios.get(GET_JUDGE_DETAIL_LIST, { params }); +export async function findJudgeResults2(params) { + const res = await axios.get(GET_JUDGE_RESULT_LIST, { params }); if (res.success) { // res.data = res.data.map((d, idx) => ({ ...d, rowId: setRowId(params, idx) })); return res; @@ -59,6 +60,50 @@ export async function findJudgeDetails(params) { return res; } +/** + * 심의 결과 가공 처리 + * @param params + * @param isParking 주정차 심의결과 요청 인지 여부 + * @returns {Promise<{judgeData: ([]|*), judgeTeam: *, totJudgeUserData: *[][], simsaUser: *}|*>} + */ +export async function findJudgeResults(params, isParking) { + const res = await axios.get(isParking ? GET_PARKING_JUDGE_RESULT_LIST : GET_JUDGE_RESULT_LIST, { params }); + + if (res && res.data) { + const totData = res.data?.totData; + + // tot데이타 정제 + const totUserData = [[], [], [], []]; + totData.forEach((data) => { + totUserData[0].push(data.BU); + totUserData[1].push(data.SEO); + totUserData[2].push(data.MIBU); + totUserData[3].push(data.TOT); + }); + + const judgeDataList = res.data?.judgeData; + judgeDataList.map((m) => { + let result = { ...m }; + const users = [...m.simsa]; + delete result.simsa; + users.map((u) => { + result = { ...result, [u.NAME]: u.msResult }; + return result; + }); + return result; + // return users.map((u) => ({ ...result, [u.NAME]: u.msResult })); + }); + + return { + totJudgeUserData: totUserData, + judgeData: res.data?.judgeData, + simsaUser: judgeDataList[0].simsa, + judgeTeam: totData[totData.length - 1].msuTeam + }; + } + return res; +} + export async function findJudgeTargets(params) { const res = await axios.get(GET_JUDGE_TARGET_LIST, { params }); if (res.success) { diff --git a/src/apis/parking.js b/src/apis/parking.js index b65449b..8b70eca 100644 --- a/src/apis/parking.js +++ b/src/apis/parking.js @@ -3,7 +3,7 @@ //---------------------------------------------------------------------------- import axios from 'utils/axios'; -import { GET_PARKING_DETAIL_LIST, GET_PARKING_JUDGE_TARGET_LIST, GET_PARKING_LIST, SAVE_PARKING_JUDGE_TARGET_LIST } from 'commons/ApiUrl'; +import { GET_PARKING_JUDGE_TARGET_LIST, GET_PARKING_LIST, SAVE_PARKING_JUDGE_TARGET_LIST } from 'commons/ApiUrl'; import { setRowId } from './common'; // eslint-disable-next-line no-return-await @@ -16,15 +16,6 @@ export async function findParkings(params) { return res; } -export async function findParkingDetails(params) { - const res = await axios.get(GET_PARKING_DETAIL_LIST, { params }); - if (res.success) { - // res.data = res.data.map((d, idx) => ({ ...d, rowId: setRowId(params, idx) })); - return res; - } - return res; -} - export async function findParkingJudgeTargets(params) { const res = await axios.get(GET_PARKING_JUDGE_TARGET_LIST, { params }); if (res.success) { diff --git a/src/commons/ApiUrl.js b/src/commons/ApiUrl.js index d4c84c6..7fc1e29 100644 --- a/src/commons/ApiUrl.js +++ b/src/commons/ApiUrl.js @@ -16,7 +16,7 @@ export const GET_BOARD_LIST = '/api/v1/ctgy/board'; // 주정차 의견 진술 export const GET_PARKING_LIST = '/api/v1/ctgy/parking'; -export const GET_PARKING_DETAIL_LIST = '/api/v1/ctgy/parking/detail'; +export const GET_PARKING_JUDGE_RESULT_LIST = '/api/v1/ctgy/parking/result'; export const GET_PARKING_JUDGE_TARGET_LIST = '/api/v1/ctgy/parking/target'; export const SAVE_PARKING_JUDGE_TARGET_LIST = '/api/v1/ctgy/parking/target'; @@ -25,7 +25,7 @@ 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 GET_JUDGE_LIST = '/api/v1/ctgy/judge'; -export const GET_JUDGE_DETAIL_LIST = '/api/v1/ctgy/judge/detail'; +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'; diff --git a/src/commons/combo_data.js b/src/commons/combo_data.js index 103fc4d..263b7f0 100644 --- a/src/commons/combo_data.js +++ b/src/commons/combo_data.js @@ -1,5 +1,6 @@ const combo = { teams: [ + { code: '', value: '-- 선택 --' }, { code: '001', value: '1팀' }, { code: '002', value: '2팀' }, { code: '003', value: '3팀' }, diff --git a/src/routes/MainRoutes.js b/src/routes/MainRoutes.js index 347d186..5b1928c 100755 --- a/src/routes/MainRoutes.js +++ b/src/routes/MainRoutes.js @@ -16,7 +16,6 @@ const Board = Loadable(lazy(() => import('views/biz/board/Board'))); // parking const ParkingReview = Loadable(lazy(() => import('views/biz/parking/ParkingReview'))); -const ParkingDetails = Loadable(lazy(() => import('views/biz/parking/ModalDetails'))); const ParkingRegister = Loadable(lazy(() => import('views/biz/parking/ParkingRegister'))); // Resident /Disabled @@ -114,11 +113,6 @@ const MainRoutes = { element: }, - { - path: '/parking/details', - element: - }, - // ---------------------------------------- { path: '/sample-page', diff --git a/src/utils/axios.js b/src/utils/axios.js index ab6b706..e19fec2 100755 --- a/src/utils/axios.js +++ b/src/utils/axios.js @@ -32,6 +32,9 @@ const alertError = (config, request, response, error) => { icon: 'error', title: 'Api Error', html: `${response.message}`, + customClass: { + container: 'alert-swal' + }, // imageUrl: timer: 5000 }).then((r) => r); @@ -42,11 +45,15 @@ const alertError = (config, request, response, error) => { const errMsg = response.data?.message || response.data?.error; console.error(`============= ${errCode}: ${errMsg} ====================`); + Swal.close(); // Alert.error(`${errCode}: ${errMsg}`); Swal.fire({ icon: 'error', title: 'Api Error', html: `${errMsg} [ ${errCode} ]`, + customClass: { + container: 'alert-swal' + }, // imageUrl: timer: 5000 }).then((r) => r); @@ -61,6 +68,9 @@ const alertError = (config, request, response, error) => { icon: 'error', title: 'Api Error', html: errMsg, + customClass: { + container: 'alert-swal' + }, // imageUrl: timer: 5000 }).then((r) => r); @@ -107,6 +117,9 @@ axiosService.interceptors.response.use( icon: 'error', title: 'Api Error', html: `${response.data.message}`, + customClass: { + container: 'alert-swal' + }, // imageUrl: timer: 5000 }).then((r) => r); diff --git a/src/views/biz/judge/JudgeReview.jsx b/src/views/biz/judge/JudgeReview.jsx index 71019d1..5b840f6 100644 --- a/src/views/biz/judge/JudgeReview.jsx +++ b/src/views/biz/judge/JudgeReview.jsx @@ -16,9 +16,9 @@ import MainCard from 'ui-component/cards/MainCard'; import MuiDataGrid from 'views/form/MuiDataGrid'; import xitCmm from 'commons/XitCmm'; import InputLabel from 'ui-component/extended/Form/InputLabel'; -import { findJudgeDetails, findJudges } from 'apis/judge'; +import { findJudgeResults, findJudges } from 'apis/judge'; import CmmModal from 'views/form/Modal/CmmModal'; -import ModalJudgeDetail from './ModalJudgeDetail'; +import ModalJudgeResult from './ModalJudgeResult'; import PropTypes from 'prop-types'; const JudgeReview = ({ msDatagb, menuName }) => { @@ -39,10 +39,12 @@ const JudgeReview = ({ msDatagb, menuName }) => { rows: [] // loading: false }); - const [judgeDetailData, setJudgeDetailData] = useState({ + const [judgeResultData, setJudgeResultData] = useState({ totJudgeUserData: [], judgeData: [], - simsaUser: [] + simsaUser: [], + selectedRow: {}, + judgeTeam: '' }); const removeJudge = useCallback( @@ -149,44 +151,14 @@ const JudgeReview = ({ msDatagb, menuName }) => { msChasu: e.row.msChasu, msuTeam: e.row.msuTeam }; - - await findJudgeDetails(params).then((response) => { - if (response && response.data) { - const totData = response.data?.totData; - - // tot데이타 정제 - const totUserData = [[], [], [], []]; - totData.forEach((data) => { - totUserData[0].push(data.BU); - totUserData[1].push(data.SEO); - totUserData[2].push(data.MIBU); - totUserData[3].push(data.TOT); - }); - - const judgeDataList = response.data?.judgeData; - judgeDataList.map((m) => { - let result = { ...m }; - const users = [...m.simsa]; - delete result.simsa; - users.map((u) => { - result = { ...result, [u.NAME]: u.msResult }; - return result; - }); - return result; - // return users.map((u) => ({ ...result, [u.NAME]: u.msResult })); - }); - - setJudgeDetailData({ - ...judgeDetailData, - totJudgeUserData: totUserData, - judgeData: response.data?.judgeData, - simsaUser: judgeDataList[0].simsa - }); - - setTitle(`${menuName} 의견진술 심의 상세 목록`); - setOpen(true); - } + const res = await findJudgeResults(params); + setJudgeResultData({ + ...res, + selectedRow: e.row }); + + setTitle(`${e.row.msCdate} ${menuName} 심사 결과 (${e.row.msChasu}차)`); + setOpen(true); } }; @@ -245,7 +217,7 @@ const JudgeReview = ({ msDatagb, menuName }) => { handleCellClick={handleOnCellClick} /> - + ); diff --git a/src/views/biz/judge/ModalJudgeDetail.jsx b/src/views/biz/judge/ModalJudgeDetail.jsx deleted file mode 100644 index 8e04f9d..0000000 --- a/src/views/biz/judge/ModalJudgeDetail.jsx +++ /dev/null @@ -1,117 +0,0 @@ -import Paper from '@mui/material/Paper'; -import Table from '@mui/material/Table'; -import TableBody from '@mui/material/TableBody'; -import TableCell, { tableCellClasses } from '@mui/material/TableCell'; -import TableContainer from '@mui/material/TableContainer'; -import TableHead from '@mui/material/TableHead'; -import TableRow from '@mui/material/TableRow'; -import { styled } from '@mui/material/styles'; -import { Divider, Grid } from '@mui/material'; -import PropTypes from 'prop-types'; - -const StyledTableCell = styled(TableCell)(({ theme }) => ({ - [`&.${tableCellClasses.head}`]: { - backgroundColor: theme.palette.common.black, - color: theme.palette.common.white - }, - [`&.${tableCellClasses.body}`]: { - // fontSize: 14 - } -})); - -const StyledTableRow = styled(TableRow)(({ theme }) => ({ - '&:nth-of-type(odd)': { - backgroundColor: theme.palette.action.hover - }, - // hide last border - '&:last-child td, &:last-child th': { - border: 0 - } -})); - -const ModalJudgeDetail = ({ totJudgeUserData, judgeData, simsaUser }) => { - const totLabel = ['부과', '서손', '미부과', '계']; - - return ( - - - - - - {/* */} - - 접수번호 - - - 차량번호 - - {simsaUser.map((u) => ( - - {u.NAME} - - ))} - - 결과 - - - - - {/* 심사 통계 */} - {totJudgeUserData.map((totData, idx) => ( - - - {totLabel[idx]} - - - {totData.map((data) => ( - - {data} - - ))} - - ))} - - - - - - - {/* 접수번호별 심사 결과 */} - {judgeData.map((row) => ( - - {/* {row.msMaincode} */} - - {row.msSeq} - - - {row.msCarnum} - - - {/* 심사위원별 심사결과 */} - {row.simsa.map((r) => ( - - {r.msuResult} - - ))} - - {/* 최종심사결과 */} - - {row.simsa[0].msResult} - - - ))} - -
-
-
- ); -}; -ModalJudgeDetail.propTypes = { - totJudgeUserData: PropTypes.array.isRequired, - judgeData: PropTypes.array.isRequired, - simsaUser: PropTypes.array.isRequired -}; - -export default ModalJudgeDetail; diff --git a/src/views/biz/judge/ModalJudgeResult.jsx b/src/views/biz/judge/ModalJudgeResult.jsx new file mode 100644 index 0000000..1adee22 --- /dev/null +++ b/src/views/biz/judge/ModalJudgeResult.jsx @@ -0,0 +1,201 @@ +import Paper from '@mui/material/Paper'; +import Table from '@mui/material/Table'; +import TableBody from '@mui/material/TableBody'; +import TableCell, { tableCellClasses } from '@mui/material/TableCell'; +import TableContainer from '@mui/material/TableContainer'; +import TableHead from '@mui/material/TableHead'; +import TableRow from '@mui/material/TableRow'; +import { styled } from '@mui/material/styles'; +import { Divider, FormControl, Grid, InputLabel, MenuItem, Select, Typography } from '@mui/material'; +import PropTypes from 'prop-types'; +import Box from '@mui/material/Box'; +import combo from 'commons/combo_data'; +import { useState } from 'react'; +import Button from '@mui/material/Button'; +import { IconSearch } from '@tabler/icons'; +import { findJudgeResults } from 'apis/judge'; +import { useAlert } from 'react-alert'; + +const StyledTableCell = styled(TableCell)(({ theme }) => ({ + [`&.${tableCellClasses.head}`]: { + backgroundColor: theme.palette.common.black, + color: theme.palette.common.white + }, + [`&.${tableCellClasses.body}`]: { + // fontSize: 14 + } +})); + +const StyledTableRow = styled(TableRow)(({ theme }) => ({ + '&:nth-of-type(odd)': { + backgroundColor: theme.palette.action.hover + }, + // hide last border + '&:last-child td, &:last-child th': { + border: 0 + } +})); + +const ModalJudgeResult = ({ totJudgeUserData, judgeData, simsaUser, selectedRow, judgeTeam }) => { + const alert = useAlert(); + const [judgeResult, setJudgeResult] = useState({ + totJudgeUserData, + judgeData, + simsaUser + }); + const [msuTeam, setMsuTeam] = useState(judgeTeam); + const totLabel = ['부과', '서손', '미부과', '계']; + console.log(totJudgeUserData, judgeData, simsaUser, selectedRow, judgeTeam); + const onSearch = async () => { + if (msuTeam) { + const params = { + msDatagb: selectedRow.msDatagb ?? '', + msSdate: selectedRow.msSdate, + msEdate: selectedRow.msEdate, + msChasu: selectedRow.msChasu, + msuTeam + }; + const res = await findJudgeResults(params, params.msDatagb === ''); + + // TODO: 에러 alert 반영 필요 + if (res && res.isAxiosError) { + setJudgeResult({ + ...judgeResult, + totJudgeUserData: [], + judgeData: [], + simsaUser: [] + }); + alert.show('조회된 데이타가 없습니다.'); + return; + } + + setJudgeResult({ + ...judgeResult, + totJudgeUserData: res.totJudgeUserData, + judgeData: res.judgeData, + simsaUser: res.simsaUser + }); + // totJudgeUserData = res.totJudgeUserData; + // judgeData = res.judgeData; + // simsaUser = res.simsaUser; + // selectedRow, + // judgeTeam: msuTeam + // }); + } + }; + + return ( + + + + + + + 심의차수: {selectedRow.msChasu}차 심의기간: {selectedRow.msSdate} ~ {selectedRow.msEdate} + + + + + + + + + + + + + + + + + + + + {/* */} + + 접수번호 + + + 차량번호 + + {judgeResult.simsaUser.map((u) => ( + + {u.NAME} + + ))} + + 결과 + + + + + {/* 심사 통계 */} + {judgeResult.totJudgeUserData.map((totData, idx) => ( + + + {totLabel[idx]} + + + {totData.map((data) => ( + + {data} + + ))} + + ))} + + + + + + + {/* 접수번호별 심사 결과 */} + {judgeResult.judgeData.map((row) => ( + + {/* {row.msMaincode} */} + + {row.msSeq} + + + {row.msCarnum} + + + {/* 심사위원별 심사결과 */} + {row.simsa.map((r) => ( + + {r.msuResult} + + ))} + + {/* 최종심사결과 */} + + {row.simsa[0].msResult} + + + ))} + +
+
+
+
+ ); +}; +ModalJudgeResult.propTypes = { + totJudgeUserData: PropTypes.array.isRequired, + judgeData: PropTypes.array.isRequired, + simsaUser: PropTypes.array.isRequired, + selectedRow: PropTypes.object.isRequired, + judgeTeam: PropTypes.string +}; + +export default ModalJudgeResult; diff --git a/src/views/biz/judge/SaveJudgeTargetForm.jsx b/src/views/biz/judge/SaveJudgeTargetForm.jsx index bde30a9..5d749b0 100644 --- a/src/views/biz/judge/SaveJudgeTargetForm.jsx +++ b/src/views/biz/judge/SaveJudgeTargetForm.jsx @@ -94,7 +94,7 @@ const SaveJudgeTargetForm = ({ handleModalSave }) => { - setMsuTeam(e.target.value)}> {combo.teams.map((team) => ( {team.value} diff --git a/src/views/biz/parking/ModalDetails.jsx b/src/views/biz/parking/ModalDetails.jsx deleted file mode 100644 index 0601a28..0000000 --- a/src/views/biz/parking/ModalDetails.jsx +++ /dev/null @@ -1,8 +0,0 @@ -import Board from '../board/Board'; - -const ModalDetails = () => ( - <> - - -); -export default ModalDetails; diff --git a/src/views/biz/parking/ParkingReview.jsx b/src/views/biz/parking/ParkingReview.jsx index 7102840..aa8da37 100644 --- a/src/views/biz/parking/ParkingReview.jsx +++ b/src/views/biz/parking/ParkingReview.jsx @@ -17,15 +17,15 @@ import MainCard from 'ui-component/cards/MainCard'; // project imports import MuiDataGrid from 'views/form/MuiDataGrid'; import xitCmm from 'commons/XitCmm'; -import { findParkings, findParkingDetails } from 'apis/parking'; +import { findParkings } from 'apis/parking'; +import { findJudgeResults } from 'apis/judge'; import InputLabel from '../../../ui-component/extended/Form/InputLabel'; -import ModalJudgeDetail from 'views/biz/judge/ModalJudgeDetail'; +import ModalJudgeResult from 'views/biz/judge/ModalJudgeResult'; import CmmModal from 'views/form/Modal/CmmModal'; const ParkingReview = () => { const isInit = useRef(true); const year = getYear(new Date()); - console.log(typeof year); const years = _.range(year, year - 14, -1); const [open, setOpen] = useState(false); @@ -41,10 +41,12 @@ const ParkingReview = () => { rows: [] // loading: false }); - const [judgeDetailData, setJudgeDetailData] = useState({ + const [judgeResultData, setJudgeResultData] = useState({ totJudgeUserData: [], judgeData: [], - simsaUser: [] + simsaUser: [], + selectedRow: {}, + judgeTeam: '' }); const removeJudge = useCallback( @@ -144,50 +146,21 @@ const ParkingReview = () => { const handleOnCellClick = async (e) => { if (e?.field === 'msDate') { const params = { - msDatagb: e.row.msDatagb, + msDatagb: '', msSdate: e.row.msSdate, msEdate: e.row.msEdate, msChasu: e.row.msChasu, msuTeam: e.row.msuTeam }; - await findParkingDetails(params).then((response) => { - if (response && response.data) { - const totData = response.data?.totData; - - // tot데이타 정제 - const totUserData = [[], [], [], []]; - totData.forEach((data) => { - totUserData[0].push(data.BU); - totUserData[1].push(data.SEO); - totUserData[2].push(data.MIBU); - totUserData[3].push(data.TOT); - }); - - const judgeDataList = response.data?.judgeData; - judgeDataList.map((m) => { - let result = { ...m }; - const users = [...m.simsa]; - delete result.simsa; - users.map((u) => { - result = { ...result, [u.NAME]: u.msResult }; - return result; - }); - return result; - // return users.map((u) => ({ ...result, [u.NAME]: u.msResult })); - }); - - setJudgeDetailData({ - ...judgeDetailData, - totJudgeUserData: totUserData, - judgeData: response.data?.judgeData, - simsaUser: judgeDataList[0].simsa - }); - - setTitle(`주정차 의견진술 심의 상세 목록`); - setOpen(true); - } + const res = await findJudgeResults(params, true); + setJudgeResultData({ + ...res, + selectedRow: e.row }); + + setTitle(`${e.row.msCdate} 주정차 심사 결과 (${e.row.msChasu}차)`); + setOpen(true); } }; @@ -246,7 +219,7 @@ const ParkingReview = () => { handleCellClick={handleOnCellClick} /> - + );