From 7778e48c5c3dc750b03c0e176f0f8e4664a27b71 Mon Sep 17 00:00:00 2001 From: minuk926 Date: Fri, 15 Apr 2022 18:31:08 +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 --- src/apis/judge.js | 30 ++- src/views/biz/judge/JudgeReview.jsx | 7 +- src/views/biz/judge/ModalJudgeResult.jsx | 52 +++--- src/views/biz/judge/ModalJudgeResult2.jsx | 216 ++++++++++++++++++++++ src/views/biz/parking/ParkingReview.jsx | 2 +- 5 files changed, 262 insertions(+), 45 deletions(-) create mode 100644 src/views/biz/judge/ModalJudgeResult2.jsx diff --git a/src/apis/judge.js b/src/apis/judge.js index 186470d..2da4b9d 100644 --- a/src/apis/judge.js +++ b/src/apis/judge.js @@ -70,35 +70,29 @@ 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; + const totJudgeUserData = res.data?.totJudgeUserData; // tot데이타 정제 const totUserData = [[], [], [], []]; - totData.forEach((data) => { + totJudgeUserData.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 })); - }); - + // 마지막 '결과' 맵 삭제 + totJudgeUserData.pop(); return { + // 심사자별 심사 합산 + totJudgeUsers: totJudgeUserData, + // 심사자별 심사 합산에서 추출한 심사 합산 데이타 totJudgeUserData: totUserData, - judgeData: res.data?.judgeData, - simsaUser: judgeDataList[0].simsa, - judgeTeam: totData[totData.length - 1].msuTeam + // 심사대상 차량 목록 + judgeCars: res.data?.judgeCarData, + // 차량별 심시 결과 + judgeUserData: res.data?.judgeUserData, + judgeTeam: res.data?.teamList[0].msuTeam }; } return res; diff --git a/src/views/biz/judge/JudgeReview.jsx b/src/views/biz/judge/JudgeReview.jsx index c9f78c5..9aeb73e 100644 --- a/src/views/biz/judge/JudgeReview.jsx +++ b/src/views/biz/judge/JudgeReview.jsx @@ -42,6 +42,8 @@ const JudgeReview = ({ msDatagb, menuName }) => { const [judgeResultData, setJudgeResultData] = useState({ totJudgeUserData: [], judgeData: [], + judgeCars: [], + judgeUserData: [], simsaUser: [], selectedRow: {}, judgeTeam: '' @@ -154,10 +156,11 @@ const JudgeReview = ({ msDatagb, menuName }) => { const res = await findJudgeResults(params); setJudgeResultData({ ...res, - selectedRow: e.row + selectedRow: e.row, + judgeTeam: res.judgeTeam }); - setTitle(`${e.row.msCdate} ${menuName} 심사 결과 (${e.row.msChasu}차)`); + setTitle(`${e.row.msCdate} ${menuName} 심사 결과 (${e.row.msChasu}차 - 총 ${e.row.cnt}건)`); setOpen(true); } }; diff --git a/src/views/biz/judge/ModalJudgeResult.jsx b/src/views/biz/judge/ModalJudgeResult.jsx index 9b09594..af1842f 100644 --- a/src/views/biz/judge/ModalJudgeResult.jsx +++ b/src/views/biz/judge/ModalJudgeResult.jsx @@ -6,7 +6,7 @@ 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 { Divider, FormControl, Grid, InputLabel, MenuItem, Select, TableFooter, Typography } from '@mui/material'; import PropTypes from 'prop-types'; import Box from '@mui/material/Box'; import combo from 'commons/combo_data'; @@ -15,6 +15,7 @@ import Button from '@mui/material/Button'; import { IconSearch } from '@tabler/icons'; import { findJudgeResults } from 'apis/judge'; import MuiAlert from 'views/cmm/MuiAlert'; +import _ from 'lodash'; const StyledTableCell = styled(TableCell)(({ theme }) => ({ [`&.${tableCellClasses.head}`]: { @@ -36,11 +37,14 @@ const StyledTableRow = styled(TableRow)(({ theme }) => ({ } })); -const ModalJudgeResult = ({ totJudgeUserData, judgeData, simsaUser, selectedRow, judgeTeam }) => { +const ModalJudgeResult = ({ totJudgeUsers, totJudgeUserData, judgeCars, judgeUserData, selectedRow, judgeTeam }) => { const [judgeResult, setJudgeResult] = useState({ + totJudgeUsers, totJudgeUserData, - judgeData, - simsaUser + judgeCars, + judgeUserData + // judgeData + // simsaUser }); const [msuTeam, setMsuTeam] = useState(judgeTeam); const [alertOpen, setAlertOpen] = useState(false); @@ -52,8 +56,9 @@ const ModalJudgeResult = ({ totJudgeUserData, judgeData, simsaUser, selectedRow, }); const totLabel = ['부과', '서손', '미부과', '계']; - console.log(totJudgeUserData, judgeData, simsaUser, selectedRow, judgeTeam); + console.log(totJudgeUsers, totJudgeUserData, judgeCars, judgeUserData, judgeTeam); const onSearch = async () => { + setAlertOpen(false); if (msuTeam) { const params = { msDatagb: selectedRow.msDatagb ?? '', @@ -68,9 +73,12 @@ const ModalJudgeResult = ({ totJudgeUserData, judgeData, simsaUser, selectedRow, if (res && res.isAxiosError) { setJudgeResult({ ...judgeResult, + totJudgeUsers: [], totJudgeUserData: [], - judgeData: [], - simsaUser: [] + judgeCars: [], + judgeUserData: [] + // judgeData: [], + // simsaUser: [] }); // alert.show('조회된 데이타가 없습니다.'); setAlertState({ @@ -82,17 +90,12 @@ const ModalJudgeResult = ({ totJudgeUserData, judgeData, simsaUser, selectedRow, } else { setJudgeResult({ ...judgeResult, + totJudgeUsers: res.totJudgeUsers, totJudgeUserData: res.totJudgeUserData, - judgeData: res.judgeData, - simsaUser: res.simsaUser + judgeCars: res.judgeCars, + judgeUserData: res.judgeUserData }); } - // totJudgeUserData = res.totJudgeUserData; - // judgeData = res.judgeData; - // simsaUser = res.simsaUser; - // selectedRow, - // judgeTeam: msuTeam - // }); } }; @@ -140,7 +143,7 @@ const ModalJudgeResult = ({ totJudgeUserData, judgeData, simsaUser, selectedRow, 차량번호 - {judgeResult.simsaUser.map((u) => ( + {judgeResult.totJudgeUsers.map((u) => ( {u.NAME} @@ -169,10 +172,9 @@ const ModalJudgeResult = ({ totJudgeUserData, judgeData, simsaUser, selectedRow, - {/* 접수번호별 심사 결과 */} - {judgeResult.judgeData.map((row) => ( + {judgeResult.judgeCars.map((row, carIdx) => ( {/* {row.msMaincode} */} @@ -182,20 +184,21 @@ const ModalJudgeResult = ({ totJudgeUserData, judgeData, simsaUser, selectedRow, {row.msCarnum} - {/* 심사위원별 심사결과 */} - {row.simsa.map((r) => ( + {/* /!* 심사위원별 심사결과 *!/ */} + {_.range(carIdx, judgeResult.judgeUserData.length, judgeResult.judgeCars.length).map((userIdx) => ( - {r.msuResult} + {judgeResult.judgeUserData[userIdx].msuResult} ))} {/* 최종심사결과 */} - {row.simsa[0].msResult} + {judgeResult.judgeUserData[carIdx].msResult} ))} + {`총 ${selectedRow.cnt} 건중 ${judgeResult.judgeCars.length} 건`} @@ -204,9 +207,10 @@ const ModalJudgeResult = ({ totJudgeUserData, judgeData, simsaUser, selectedRow, ); }; ModalJudgeResult.propTypes = { + totJudgeUsers: PropTypes.array.isRequired, totJudgeUserData: PropTypes.array.isRequired, - judgeData: PropTypes.array.isRequired, - simsaUser: PropTypes.array.isRequired, + judgeCars: PropTypes.array.isRequired, + judgeUserData: PropTypes.array.isRequired, selectedRow: PropTypes.object.isRequired, judgeTeam: PropTypes.string }; diff --git a/src/views/biz/judge/ModalJudgeResult2.jsx b/src/views/biz/judge/ModalJudgeResult2.jsx new file mode 100644 index 0000000..c775aa3 --- /dev/null +++ b/src/views/biz/judge/ModalJudgeResult2.jsx @@ -0,0 +1,216 @@ +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 MuiAlert from 'views/cmm/MuiAlert'; + +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 = ({ judgeUsers, totJudgeUserData, judgeData, simsaUser, selectedRow, judgeTeam }) => { + const [judgeResult, setJudgeResult] = useState({ + judgeUsers, + totJudgeUserData, + judgeData + // simsaUser + }); + const [msuTeam, setMsuTeam] = useState(judgeTeam); + const [alertOpen, setAlertOpen] = useState(false); + const [alertState, setAlertState] = useState({ + // prettier-ignore + severity: "warning", + title: '', + message: '' + }); + + 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('조회된 데이타가 없습니다.'); + setAlertState({ + ...alertState, + message: '조회된 데이타가 없습니다.' + }); + setAlertOpen(true); + // descriptionAlertsDescriptionAlerts(); + } else { + 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.judgeUsers.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 = { + judgeUsers: PropTypes.array, + 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/parking/ParkingReview.jsx b/src/views/biz/parking/ParkingReview.jsx index ed07d8b..6babd2e 100644 --- a/src/views/biz/parking/ParkingReview.jsx +++ b/src/views/biz/parking/ParkingReview.jsx @@ -159,7 +159,7 @@ const ParkingReview = () => { selectedRow: e.row }); - setTitle(`${e.row.msCdate} 주정차 심사 결과 (${e.row.msChasu}차)`); + setTitle(`${e.row.msCdate} 주정차 심사 결과 (${e.row.msChasu}차 - 총 ${e.row.cnt}건)`); setOpen(true); } };