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

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

@ -133,7 +133,7 @@ axiosService.interceptors.response.use(
alertError(config, request, response, error);
// error 데이타 return
// 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 PublicBoardForm from './PublicBoardForm';
import { deletePublicBoard, findPublicBoards, modifyPublicBoardHitCount, savePublicBoard } from 'apis/public';
import { useAlert } from 'react-alert';
const PublicBoard = () => {
const [totalCount, setTotalCount] = useState(0);
@ -27,6 +28,7 @@ const PublicBoard = () => {
const [selectedRow, setSelectedRow] = useState({});
const [create, setCreate] = useState(false);
const [title, setTitle] = useState();
const alert = useAlert();
const columns = [
{ headerName: 'No.', headerAlign: 'center', field: 'rowId', align: 'center', width: 80 },
@ -95,9 +97,13 @@ const PublicBoard = () => {
const submitPublicBoard = (type, payload) => {
switch (type) {
case 'SAVE':
savePublicBoard(payload).then(() => {
search();
setOpen(false);
savePublicBoard(payload).then((res) => {
if (res?.success) {
search();
setOpen(false);
} else {
alert.show(`${res?.data.message}`);
}
}); // .then((res) => {
break;
case 'DELETE':

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

@ -155,8 +155,9 @@ const ParkingReview = () => {
const res = await findJudgeResults(params, true);
setJudgeResultData({
...res,
selectedRow: e.row
...res.data,
selectedRow: e.row,
judgeTeam: res.data?.judgeTeam
});
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