From 2d5c549f59f504f2620a8184d7ebd972d214c750 Mon Sep 17 00:00:00 2001 From: Lim Jonguk Date: Wed, 13 Apr 2022 03:26:08 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EA=B1=B0=EC=A3=BC=EC=9E=90/=EC=9E=A5?= =?UTF-8?q?=EC=95=A0=EC=9D=B8=20=EC=83=81=EC=84=B8=20=EB=AA=A9=EB=A1=9D=20?= =?UTF-8?q?=EC=A7=84=ED=96=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/biz/judge/JudgeReview.jsx | 53 +++++++++++++--- src/views/biz/judge/ModalJudgeDetail.jsx | 81 ++++++++++++------------ src/views/form/MuiDataGrid.jsx | 2 +- 3 files changed, 85 insertions(+), 51 deletions(-) diff --git a/src/views/biz/judge/JudgeReview.jsx b/src/views/biz/judge/JudgeReview.jsx index 68abbef..ff81e8a 100644 --- a/src/views/biz/judge/JudgeReview.jsx +++ b/src/views/biz/judge/JudgeReview.jsx @@ -16,14 +16,13 @@ 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 { findJudge, findJudges } from 'apis/judge'; +import { findJudge, findJudgeDetails, findJudges } from 'apis/judge'; import CmmModal from 'views/form/Modal/CmmModal'; import ModalJudgeDetail from './ModalJudgeDetail'; const JudgeReview = ({ msDatagb, menuName }) => { 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,7 +40,12 @@ const JudgeReview = ({ msDatagb, menuName }) => { rows: [] // loading: false }); - const [selectedRowData, setSelectedRowData] = useState({}); + const [judgeDetailData, setJudgeDetailData] = useState({ + totData: [], + judgeData: [], + colNames: [] + }); + const removeJudge = useCallback( (row) => () => { // setTimeout(() => { @@ -134,22 +138,51 @@ const JudgeReview = ({ msDatagb, menuName }) => { // }, [rowsState.page, rowsState.pageSize, selectedYear, searchTxt]); }, [search]); - const handleOnCellClick = (e) => { + const handleOnCellClick = async (e) => { if (e?.field === 'msDate') { // findJudge(e.row?.msDate).then((res) => { // setRowData(res.data); // setCreate(false); - setSelectedRowData({ - ...selectedRowData, + const params = { msDatagb: e.row.msDatagb, msSdate: e.row.msSdate, msEdate: e.row.msEdate, msChasu: e.row.msChasu, msuTeam: e.row.msuTeam + }; + + await findJudgeDetails(params).then((response) => { + if (response && response.data) { + const totData = response.data?.totData; + const judgeDataList = response.data?.judgeData; + const rows = 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 })); + }); + + const cols = []; + Object.keys(rows[0]).forEach((k) => { + cols.push(k); + }); + + setJudgeDetailData({ + ...judgeDetailData, + totData, + judgeData: response.data?.judgeData, + colNames: cols + }); + + setTitle(`${menuName} 의견진술 심의 상세 목록`); + setOpen(true); + } }); - setTitle(`${menuName} 의견진술 심의 상세 목록`); - setOpen(true); - // }); } }; @@ -208,7 +241,7 @@ const JudgeReview = ({ msDatagb, menuName }) => { handleCellClick={handleOnCellClick} /> - + ); diff --git a/src/views/biz/judge/ModalJudgeDetail.jsx b/src/views/biz/judge/ModalJudgeDetail.jsx index b052aaf..ade6f23 100644 --- a/src/views/biz/judge/ModalJudgeDetail.jsx +++ b/src/views/biz/judge/ModalJudgeDetail.jsx @@ -1,5 +1,5 @@ import Board from '../board/Board'; -import { useCallback, useEffect, useState } from 'react'; +import { useCallback, useEffect, useMemo, useState } from 'react'; import { findJudge, findJudgeDetails } from 'apis/judge'; import { Box, @@ -22,22 +22,23 @@ import { visuallyHidden } from '@mui/utils'; // project imports import MainCard from 'ui-component/cards/MainCard'; -const ModalDetails = ({ msDatagb, msSdate, msEdate, msChasu, msuTeam }) => { - const [rowData, setRowData] = useState({}); - - const [totalCount, setTotalCount] = useState(0); - const [rowsState, setRowsState] = useState({ - page: 0, - pageSize: 20, - rows: [] - // loading: false - }); - const [rows, setRows] = useState([]); - - const columns = []; - - const tableHeader = null; +const ModalJudgeDetail = ({ totData, judgeData, colNames }) => { + // const [rowData, setRowData] = useState({}); + // + // const [totalCount, setTotalCount] = useState(0); + // const [rowsState, setRowsState] = useState({ + // page: 0, + // pageSize: 20, + // rows: [] + // // loading: false + // }); + // const [rows, setRows] = useState([]); + // + // const columns = []; + // + // const tableHeader = null; + /* const search = useCallback(() => { const params = { msDatagb, @@ -87,15 +88,20 @@ const ModalDetails = ({ msDatagb, msSdate, msEdate, msChasu, msuTeam }) => { } }); }, [msDatagb, msSdate, msEdate, msChasu, msuTeam]); +*/ + + const init = useMemo(() => { + console.log(totData, judgeData, colNames); + }, []); - useEffect(() => { - // if (isInit.current) { - // isInit.current = false; - // return; - // } - search(); - // }, [rowsState.page, rowsState.pageSize, selectedYear, searchTxt]); - }, [search]); + // useEffect(() => { + // // if (isInit.current) { + // // isInit.current = false; + // // return; + // // } + // init(); + // // }, [rowsState.page, rowsState.pageSize, selectedYear, searchTxt]); + // }, []); return ( @@ -103,29 +109,24 @@ const ModalDetails = ({ msDatagb, msSdate, msEdate, msChasu, msuTeam }) => { - {columns.map((k) => ( - {k} + {colNames.map((name, idx) => ( + {name} ))} - {/* {rows.map((row) => ( */} - {/* */} - {/* */} - {/* {row.name} */} - {/* */} - {/* {row.calories} */} - {/* {row.fat} */} - {/* {row.carbs} */} - {/* */} - {/* {row.protein} */} - {/* */} - {/* */} - {/* ))} */} + {judgeData.map((row) => ( + + + {row.scSeq} + + {row.scCarnum} + + ))}
); }; -export default ModalDetails; +export default ModalJudgeDetail; diff --git a/src/views/form/MuiDataGrid.jsx b/src/views/form/MuiDataGrid.jsx index f1ca431..703e0ae 100644 --- a/src/views/form/MuiDataGrid.jsx +++ b/src/views/form/MuiDataGrid.jsx @@ -223,7 +223,7 @@ const MuiDataGrid = ({ MuiDataGrid.propTypes = { // apiRef: PropTypes.func, - isToolbar: PropTypes.bool.isRequired, + isToolbar: PropTypes.bool, children: PropTypes.node, isCheckbox: PropTypes.bool, // isDisableSelection: PropTypes.bool,