feat: 심의결과 반영

main
Lim Jonguk 3 years ago
parent 7778e48c5c
commit e625f9ed96

@ -69,7 +69,7 @@ export async function findJudgeResults2(params) {
export async function findJudgeResults(params, isParking) { export async function findJudgeResults(params, isParking) {
const res = await axios.get(isParking ? GET_PARKING_JUDGE_RESULT_LIST : GET_JUDGE_RESULT_LIST, { params }); const res = await axios.get(isParking ? GET_PARKING_JUDGE_RESULT_LIST : GET_JUDGE_RESULT_LIST, { params });
if (res && res.data) { if (res && res.success && res.data) {
const totJudgeUserData = res.data?.totJudgeUserData; const totJudgeUserData = res.data?.totJudgeUserData;
// tot데이타 정제 // tot데이타 정제
@ -84,15 +84,18 @@ export async function findJudgeResults(params, isParking) {
// 마지막 '결과' 맵 삭제 // 마지막 '결과' 맵 삭제
totJudgeUserData.pop(); totJudgeUserData.pop();
return { return {
// 심사자별 심사 합산 success: true,
totJudgeUsers: totJudgeUserData, data: {
// 심사자별 심사 합산에서 추출한 심사 합산 데이타 // 심사자별 심사 합산
totJudgeUserData: totUserData, totJudgeUsers: totJudgeUserData,
// 심사대상 차량 목록 // 심사자별 심사 합산에서 추출한 심사 합산 데이타
judgeCars: res.data?.judgeCarData, totJudgeUserData: totUserData,
// 차량별 심시 결과 // 심사대상 차량 목록
judgeUserData: res.data?.judgeUserData, judgeCars: res.data?.judgeCarData,
judgeTeam: res.data?.teamList[0].msuTeam // 차량별 심시 결과
judgeUserData: res.data?.judgeUserData,
judgeTeam: res.data?.teamList[0].msuTeam
}
}; };
} }
return res; return res;

@ -23,8 +23,8 @@ import 'assets/scss/style.scss';
// optional configuration // optional configuration
const options = { const options = {
position: positions.BOTTOM_CENTER, // positions.BOTTOM_CENTER, position: positions.BOTTOM_CENTER, // positions.BOTTOM_CENTER,
timeout: 2000, timeout: 5000,
type: types.INFO, // info / success / error type: types.ERROR, // info / success / error
offset: '50px', offset: '50px',
transition: transitions.SCALE, // 'scale' / fade transition: transitions.SCALE, // 'scale' / fade
containerStyle: { containerStyle: {

@ -133,7 +133,7 @@ axiosService.interceptors.response.use(
alertError(config, request, response, error); alertError(config, request, response, error);
// error 데이타 return // error 데이타 return
// return response.data; // return response.data;
return error; return response;
} }
); );

@ -0,0 +1,72 @@
import { useReducer, useEffect, useCallback } from 'react';
const initialState = {
loading: false,
data: null,
error: false
};
function reducer(state, action) {
switch (action.type) {
case 'LOADING':
return {
loading: true,
data: null,
error: null
};
case 'SUCCESS':
return {
loading: false,
data: action.data,
error: null
};
case 'ERROR':
return {
loading: false,
data: null,
error: action.error
};
case 'CLEAR':
return initialState;
default:
throw new Error(`Unhandled action type: ${action.type}`);
}
}
function useAsync(callback, deps = [], skip = false) {
const [state, dispatch] = useReducer(reducer, initialState);
// const fetchData = async () => {
// dispatch({ type: 'LOADING' });
// try {
// const data = await callback();
// dispatch({ type: 'SUCCESS', data });
// } catch (e) {
// dispatch({ type: 'ERROR', error: e });
// }
// };
const fetchData = useCallback(async () => {
dispatch({ type: 'LOADING' });
try {
const data = await callback();
dispatch({ type: 'SUCCESS', data });
} catch (e) {
dispatch({ type: 'ERROR', error: e });
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, deps);
useEffect(() => {
if (skip) return;
fetchData();
}, [fetchData, skip]);
return [state, fetchData];
}
export default useAsync;

@ -14,6 +14,7 @@ import MuiDataGrid from 'views/cmm/MuiDataGrid';
import CmmModal from 'views/cmm/CmmModal'; import CmmModal from 'views/cmm/CmmModal';
import PublicBoardForm from './PublicBoardForm'; import PublicBoardForm from './PublicBoardForm';
import { deletePublicBoard, findPublicBoards, modifyPublicBoardHitCount, savePublicBoard } from 'apis/public'; import { deletePublicBoard, findPublicBoards, modifyPublicBoardHitCount, savePublicBoard } from 'apis/public';
import { useAlert } from 'react-alert';
const PublicBoard = () => { const PublicBoard = () => {
const [totalCount, setTotalCount] = useState(0); const [totalCount, setTotalCount] = useState(0);
@ -27,6 +28,7 @@ const PublicBoard = () => {
const [selectedRow, setSelectedRow] = useState({}); const [selectedRow, setSelectedRow] = useState({});
const [create, setCreate] = useState(false); const [create, setCreate] = useState(false);
const [title, setTitle] = useState(); const [title, setTitle] = useState();
const alert = useAlert();
const columns = [ const columns = [
{ headerName: 'No.', headerAlign: 'center', field: 'rowId', align: 'center', width: 80 }, { headerName: 'No.', headerAlign: 'center', field: 'rowId', align: 'center', width: 80 },
@ -95,9 +97,13 @@ const PublicBoard = () => {
const submitPublicBoard = (type, payload) => { const submitPublicBoard = (type, payload) => {
switch (type) { switch (type) {
case 'SAVE': case 'SAVE':
savePublicBoard(payload).then(() => { savePublicBoard(payload).then((res) => {
search(); if (res?.success) {
setOpen(false); search();
setOpen(false);
} else {
alert.show(`${res?.data.message}`);
}
}); // .then((res) => { }); // .then((res) => {
break; break;
case 'DELETE': case 'DELETE':

@ -155,9 +155,9 @@ const JudgeReview = ({ msDatagb, menuName }) => {
}; };
const res = await findJudgeResults(params); const res = await findJudgeResults(params);
setJudgeResultData({ setJudgeResultData({
...res, ...res?.data,
selectedRow: e.row, selectedRow: e.row,
judgeTeam: res.judgeTeam judgeTeam: res.data?.judgeTeam
}); });
setTitle(`${e.row.msCdate} ${menuName} 심사 결과 (${e.row.msChasu}차 - 총 ${e.row.cnt}건)`); setTitle(`${e.row.msCdate} ${menuName} 심사 결과 (${e.row.msChasu}차 - 총 ${e.row.cnt}건)`);

@ -6,7 +6,7 @@ import TableContainer from '@mui/material/TableContainer';
import TableHead from '@mui/material/TableHead'; import TableHead from '@mui/material/TableHead';
import TableRow from '@mui/material/TableRow'; import TableRow from '@mui/material/TableRow';
import { styled } from '@mui/material/styles'; import { styled } from '@mui/material/styles';
import { Divider, FormControl, Grid, InputLabel, MenuItem, Select, TableFooter, Typography } from '@mui/material'; import { Divider, FormControl, Grid, InputLabel, MenuItem, Select, TableFooter, TextField, Typography } from '@mui/material';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import Box from '@mui/material/Box'; import Box from '@mui/material/Box';
import combo from 'commons/combo_data'; import combo from 'commons/combo_data';
@ -16,6 +16,7 @@ import { IconSearch } from '@tabler/icons';
import { findJudgeResults } from 'apis/judge'; import { findJudgeResults } from 'apis/judge';
import MuiAlert from 'views/cmm/MuiAlert'; import MuiAlert from 'views/cmm/MuiAlert';
import _ from 'lodash'; import _ from 'lodash';
import { useAlert } from 'react-alert';
const StyledTableCell = styled(TableCell)(({ theme }) => ({ const StyledTableCell = styled(TableCell)(({ theme }) => ({
[`&.${tableCellClasses.head}`]: { [`&.${tableCellClasses.head}`]: {
@ -54,8 +55,8 @@ const ModalJudgeResult = ({ totJudgeUsers, totJudgeUserData, judgeCars, judgeUse
title: '', title: '',
message: '' message: ''
}); });
const totLabel = ['부과', '서손', '미부과', '계']; const totLabel = ['부과', '서손', '미부과', '계'];
const alert = useAlert();
console.log(totJudgeUsers, totJudgeUserData, judgeCars, judgeUserData, judgeTeam); console.log(totJudgeUsers, totJudgeUserData, judgeCars, judgeUserData, judgeTeam);
const onSearch = async () => { const onSearch = async () => {
setAlertOpen(false); setAlertOpen(false);
@ -69,8 +70,15 @@ const ModalJudgeResult = ({ totJudgeUsers, totJudgeUserData, judgeCars, judgeUse
}; };
const res = await findJudgeResults(params, params.msDatagb === ''); const res = await findJudgeResults(params, params.msDatagb === '');
// TODO: alert if (res && res?.success) {
if (res && res.isAxiosError) { setJudgeResult({
...judgeResult,
totJudgeUsers: res.data?.totJudgeUsers,
totJudgeUserData: res.data?.totJudgeUserData,
judgeCars: res.data?.judgeCars,
judgeUserData: res.data?.judgeUserData
});
} else {
setJudgeResult({ setJudgeResult({
...judgeResult, ...judgeResult,
totJudgeUsers: [], totJudgeUsers: [],
@ -80,36 +88,27 @@ const ModalJudgeResult = ({ totJudgeUsers, totJudgeUserData, judgeCars, judgeUse
// judgeData: [], // judgeData: [],
// simsaUser: [] // simsaUser: []
}); });
// alert.show(' .'); alert.show('조회된 데이타가 없습니다.');
setAlertState({ // setAlertState({
...alertState, // ...alertState,
message: '조회된 데이타가 없습니다.' // message: ' .'
}); // });
setAlertOpen(true); // setAlertOpen(true);
// descriptionAlertsDescriptionAlerts();
} else {
setJudgeResult({
...judgeResult,
totJudgeUsers: res.totJudgeUsers,
totJudgeUserData: res.totJudgeUserData,
judgeCars: res.judgeCars,
judgeUserData: res.judgeUserData
});
} }
} }
}; };
return ( return (
<Box> <Box>
<Grid container spacing={2} alignItems="center"> <Grid container spacing={1} alignItems="center">
<Grid item xs={12}> <Grid item xs={12}>
<Grid container spacing={1}> <Grid container spacing={1}>
<Grid item> <Grid item sm={4}>
<Typography variant="subtitle1"> <Typography variant="subtitle1">
심의차수: {selectedRow.msChasu} 심의기간: {selectedRow.msSdate} ~ {selectedRow.msEdate} 심의차수: {selectedRow.msChasu} 심의기간: {selectedRow.msSdate} ~ {selectedRow.msEdate}
</Typography> </Typography>
</Grid> </Grid>
<Grid item xs={12} sm={2}> <Grid item sm={2}>
<FormControl fullWidth> <FormControl fullWidth>
<InputLabel required></InputLabel> <InputLabel required></InputLabel>
<Select defaultValue={msuTeam} onChange={(e) => setMsuTeam(e.target.value)}> <Select defaultValue={msuTeam} onChange={(e) => setMsuTeam(e.target.value)}>
@ -121,7 +120,7 @@ const ModalJudgeResult = ({ totJudgeUsers, totJudgeUserData, judgeCars, judgeUse
</Select> </Select>
</FormControl> </FormControl>
</Grid> </Grid>
<Grid item sx={{ marginTop: 3 }}> <Grid item sm={2} sx={{ marginTop: 1 }}>
<Button variant="contained" color="primary" size="small" startIcon={<IconSearch />} onClick={onSearch}> <Button variant="contained" color="primary" size="small" startIcon={<IconSearch />} onClick={onSearch}>
조회 조회
</Button> </Button>
@ -143,7 +142,7 @@ const ModalJudgeResult = ({ totJudgeUsers, totJudgeUserData, judgeCars, judgeUse
<StyledTableCell align="center" style={{ width: 130 }}> <StyledTableCell align="center" style={{ width: 130 }}>
차량번호 차량번호
</StyledTableCell> </StyledTableCell>
{judgeResult.totJudgeUsers.map((u) => ( {judgeResult?.totJudgeUsers.map((u) => (
<StyledTableCell align="center" style={{ width: 80 }}> <StyledTableCell align="center" style={{ width: 80 }}>
{u.NAME} {u.NAME}
</StyledTableCell> </StyledTableCell>
@ -155,7 +154,7 @@ const ModalJudgeResult = ({ totJudgeUsers, totJudgeUserData, judgeCars, judgeUse
</TableHead> </TableHead>
<TableBody> <TableBody>
{/* 심사 통계 */} {/* 심사 통계 */}
{judgeResult.totJudgeUserData.map((totData, idx) => ( {judgeResult?.totJudgeUserData.map((totData, idx) => (
<StyledTableRow hover key={idx}> <StyledTableRow hover key={idx}>
<StyledTableCell align="center" style={{ width: 95 }}> <StyledTableCell align="center" style={{ width: 95 }}>
{totLabel[idx]} {totLabel[idx]}
@ -174,7 +173,7 @@ const ModalJudgeResult = ({ totJudgeUsers, totJudgeUserData, judgeCars, judgeUse
<Divider /> <Divider />
</Grid> </Grid>
{/* 접수번호별 심사 결과 */} {/* 접수번호별 심사 결과 */}
{judgeResult.judgeCars.map((row, carIdx) => ( {judgeResult?.judgeCars.map((row, carIdx) => (
<StyledTableRow hover key={row.msSeq}> <StyledTableRow hover key={row.msSeq}>
{/* <StyledTableCell>{row.msMaincode}</StyledTableCell> */} {/* <StyledTableCell>{row.msMaincode}</StyledTableCell> */}
<StyledTableCell align="center" style={{ width: 95 }}> <StyledTableCell align="center" style={{ width: 95 }}>
@ -198,7 +197,7 @@ const ModalJudgeResult = ({ totJudgeUsers, totJudgeUserData, judgeCars, judgeUse
</StyledTableRow> </StyledTableRow>
))} ))}
</TableBody> </TableBody>
<TableFooter>{`${selectedRow.cnt} 건중 ${judgeResult.judgeCars.length}`}</TableFooter> <TableFooter>{judgeResult && `${selectedRow.cnt} 건중 ${judgeResult.judgeCars.length}`}</TableFooter>
</Table> </Table>
</TableContainer> </TableContainer>
</Paper> </Paper>

@ -155,8 +155,9 @@ const ParkingReview = () => {
const res = await findJudgeResults(params, true); const res = await findJudgeResults(params, true);
setJudgeResultData({ setJudgeResultData({
...res, ...res.data,
selectedRow: e.row selectedRow: e.row,
judgeTeam: res.data?.judgeTeam
}); });
setTitle(`${e.row.msCdate} 주정차 심사 결과 (${e.row.msChasu}차 - 총 ${e.row.cnt}건)`); setTitle(`${e.row.msCdate} 주정차 심사 결과 (${e.row.msChasu}차 - 총 ${e.row.cnt}건)`);

@ -0,0 +1,23 @@
import React from 'react';
const Filedownload = () => {
useEffect(() => {
if (fileData) {
const url = window.URL.createObjectURL(new Blob([fileData.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'test.xlsx');
link.setAttribute('id', 'tempLink');
document.body.appendChild(link);
link.click();
}
return () => {
const link = document.querySelector('#tempLink');
link && link.remove();
};
}, [fileData]);
return <div />;
};
export default Filedownload;
Loading…
Cancel
Save