feat: 심사결과 일괄처리 적용
parent
e94f4824ec
commit
f4f07d0ad8
@ -1,249 +0,0 @@
|
||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
|
||||
import _ from 'lodash';
|
||||
import getYear from 'date-fns/getYear';
|
||||
|
||||
// material-ui
|
||||
import { GridActionsCellItem } from '@mui/x-data-grid';
|
||||
import { Divider, FormControl, Grid, InputAdornment, Link, MenuItem, OutlinedInput, Select } from '@mui/material';
|
||||
import DeleteIcon from '@mui/icons-material/Delete';
|
||||
|
||||
// assets
|
||||
import { IconSearch } from '@tabler/icons';
|
||||
|
||||
// berry ui
|
||||
import MainCard from 'ui-component/cards/MainCard';
|
||||
|
||||
// project imports
|
||||
import MuiDataGrid from 'views/cmm/mui-grid/MuiDataGrid';
|
||||
import { findParkings, removeParkingJudge } from 'apis/parking';
|
||||
import { findJudgeResults } from 'apis/judge';
|
||||
import InputLabel from 'ui-component/extended/Form/InputLabel';
|
||||
import ModalJudgeResult from 'views/biz/admin/judge/ModalJudgeResult';
|
||||
import CmmModal from 'views/cmm/CmmModal';
|
||||
import { useAlert } from 'react-alert';
|
||||
|
||||
const ParkingReview = () => {
|
||||
const isInit = useRef(true);
|
||||
const year = getYear(new Date());
|
||||
const years = _.range(year, year - 14, -1);
|
||||
|
||||
const alert = useAlert();
|
||||
const [open, setOpen] = useState(false);
|
||||
const [title, setTitle] = useState();
|
||||
|
||||
const [selectedYear, setSelectedYear] = useState(year);
|
||||
const [searchTxt, setSearchTxt] = useState('');
|
||||
|
||||
const [totalCount, setTotalCount] = useState(0);
|
||||
const [rowsState, setRowsState] = useState({
|
||||
page: 0,
|
||||
pageSize: 20,
|
||||
rows: []
|
||||
// loading: false
|
||||
});
|
||||
const [judgeResultData, setJudgeResultData] = useState({
|
||||
totJudgeUserData: [],
|
||||
judgeData: [],
|
||||
simsaUser: [],
|
||||
selectedRow: {},
|
||||
judgeTeam: ''
|
||||
});
|
||||
const [judgeDatas, setJudgeDatas] = useState([]);
|
||||
|
||||
const search = useCallback(() => {
|
||||
const params = {
|
||||
page: rowsState.page,
|
||||
size: rowsState.pageSize
|
||||
};
|
||||
|
||||
findParkings({ ...params, msYear: selectedYear, msChasu: searchTxt }).then((response) => {
|
||||
if (response && response.data) {
|
||||
setTotalCount(response.count);
|
||||
setRowsState((prevState) => ({ ...prevState, rows: response.data }));
|
||||
// apiRef.current.forceUpdate(); // .updateRowData([]);
|
||||
// apiRef.current.updateRowData([]);
|
||||
}
|
||||
});
|
||||
}, [rowsState.page, rowsState.pageSize, selectedYear, searchTxt]);
|
||||
|
||||
const removeJudge = useCallback(
|
||||
(row) => () => {
|
||||
if (window.confirm('삭제 하시겠습니까?')) {
|
||||
removeParkingJudge(row).then((response) => {
|
||||
if (response && response.success) {
|
||||
setRowsState({
|
||||
...rowsState,
|
||||
page: 0
|
||||
});
|
||||
search();
|
||||
} else {
|
||||
alert.show(response.message);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
window.close();
|
||||
}
|
||||
},
|
||||
[]
|
||||
);
|
||||
|
||||
const columns = [
|
||||
// { headerName: 'rowId', field: 'rowId' },
|
||||
{ headerName: '심의 차수', headerAlign: 'center', field: 'msChasu', align: 'center', width: 100 },
|
||||
{ headerName: '심사 건수', headerAlign: 'center', field: 'cnt', align: 'center', width: 100 },
|
||||
{
|
||||
headerName: '심사 기간',
|
||||
headerAlign: 'center',
|
||||
field: 'msDate',
|
||||
minWidth: 200,
|
||||
width: 250,
|
||||
description: '심사 기간',
|
||||
valueGetter: (params) => `${params.row.msSdate} ~ ${params.row.msEdate}`,
|
||||
renderCell: (params) => (
|
||||
<Link underline="hover" href="#">
|
||||
{params.value}
|
||||
</Link>
|
||||
),
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
headerName: '심사 마감 일시',
|
||||
headerAlign: 'center',
|
||||
field: 'msCdate',
|
||||
type: 'dateTime',
|
||||
minWidth: 150,
|
||||
width: 200,
|
||||
valueGetter: (params) => `${params.row.msCdate} ${params.row.msClosesi}`,
|
||||
align: 'center'
|
||||
},
|
||||
/*
|
||||
{
|
||||
headerName: '상태',
|
||||
headerAlign: 'center',
|
||||
field: 'msResult',
|
||||
width: 150,
|
||||
renderCell: (params) => <>{params.row.msResult === '1' ? '진행중' : '심사완료'}</>,
|
||||
align: 'center'
|
||||
},
|
||||
*/
|
||||
{
|
||||
headerName: '삭제',
|
||||
headerAlign: 'center',
|
||||
field: 'actions',
|
||||
type: 'actions',
|
||||
width: 80,
|
||||
getActions: (params) => [<GridActionsCellItem icon={<DeleteIcon />} label="Delete" onClick={removeJudge(params.row)} />],
|
||||
align: 'center'
|
||||
}
|
||||
];
|
||||
|
||||
const handleSearch = async (event) => {
|
||||
if (!selectedYear) return;
|
||||
|
||||
if (event.type === 'keydown' && event.key === 'Enter') {
|
||||
const newString = event?.target.value;
|
||||
setSearchTxt(newString);
|
||||
search();
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (isInit.current) {
|
||||
isInit.current = false;
|
||||
return;
|
||||
}
|
||||
search();
|
||||
// }, [rowsState.page, rowsState.pageSize, selectedYear, searchTxt]);
|
||||
}, [search]);
|
||||
|
||||
const handleOnCellClick = async (e) => {
|
||||
if (e?.field === 'msDate') {
|
||||
const params = {
|
||||
msDatagb: '',
|
||||
msSdate: e.row.msSdate,
|
||||
msEdate: e.row.msEdate,
|
||||
msChasu: e.row.msChasu,
|
||||
msuTeam: e.row.msuTeam
|
||||
};
|
||||
|
||||
const res = await findJudgeResults(params, true);
|
||||
const arrJudgeData = [];
|
||||
// eslint-disable-next-line no-plusplus
|
||||
for (let idx = 0; idx < res.data.judgeCars.length; idx++) {
|
||||
if (res.data.judgeUserData[idx].msResult === '0') {
|
||||
arrJudgeData.push({ msMaincode: res.data.judgeUserData[idx].msMaincode, msSeq: res.data.judgeUserData[idx].msSeq });
|
||||
}
|
||||
}
|
||||
setJudgeDatas(arrJudgeData);
|
||||
|
||||
setJudgeResultData({
|
||||
...res.data,
|
||||
selectedRow: e.row,
|
||||
judgeTeam: res.data?.judgeTeam
|
||||
});
|
||||
|
||||
setTitle(`${e.row.msCdate} 주정차 심사 결과 (${e.row.msChasu}차 - 총 ${e.row.cnt}건)`);
|
||||
setOpen(true);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<MainCard>
|
||||
<Grid container spacing={2} alignItems="center">
|
||||
<Grid item xs={12}>
|
||||
<Grid container spacing={1}>
|
||||
<Grid item xs={2}>
|
||||
<FormControl fullWidth>
|
||||
<InputLabel required>심의 년도</InputLabel>
|
||||
<Select
|
||||
size="small"
|
||||
id="reviewYear"
|
||||
name="reviewYear"
|
||||
defaultValue={year}
|
||||
onChange={(e) => setSelectedYear(e.target.value)}
|
||||
>
|
||||
{years.map((year, idx) => (
|
||||
<MenuItem key={idx} value={year}>
|
||||
{year}
|
||||
</MenuItem>
|
||||
))}
|
||||
</Select>
|
||||
</FormControl>
|
||||
</Grid>
|
||||
<Grid item>
|
||||
<OutlinedInput
|
||||
required
|
||||
placeholder="심의차수"
|
||||
onKeyDown={handleSearch}
|
||||
size="small"
|
||||
autoFocus
|
||||
endAdornment={
|
||||
<InputAdornment position="end">
|
||||
<IconSearch stroke={1.5} size="1rem" />
|
||||
</InputAdornment>
|
||||
}
|
||||
/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Grid container spacing={1} item xs={12} mt={1}>
|
||||
<Grid item xs={12}>
|
||||
<Divider />
|
||||
</Grid>
|
||||
</Grid>
|
||||
<MuiDataGrid
|
||||
columns={columns}
|
||||
rowsState={rowsState}
|
||||
totalCount={totalCount}
|
||||
setRowsState={setRowsState}
|
||||
handleCellClick={handleOnCellClick}
|
||||
/>
|
||||
<CmmModal isBackdrop title={title} open={open} setOpen={setOpen}>
|
||||
{judgeResultData?.selectedRow && <ModalJudgeResult {...judgeResultData} judgeData={judgeDatas} />}
|
||||
</CmmModal>
|
||||
</MainCard>
|
||||
);
|
||||
};
|
||||
export default ParkingReview;
|
@ -0,0 +1,86 @@
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
import Modal from '@mui/material/Modal';
|
||||
import { Divider, FormControl, Grid, IconButton, InputLabel, MenuItem, Select } from '@mui/material';
|
||||
import CloseOutlined from '@mui/icons-material/CloseOutlined';
|
||||
import MainCard from 'ui-component/cards/MainCard';
|
||||
import { IconSearch } from '@tabler/icons';
|
||||
import Button from '@mui/material/Button';
|
||||
import combo from 'commons/combo_data';
|
||||
import { useState } from 'react';
|
||||
|
||||
const style = {
|
||||
position: 'relative',
|
||||
top: '50%',
|
||||
left: '50%',
|
||||
transform: 'translate(-50%, -50%)',
|
||||
width: 500,
|
||||
minHeight: 300,
|
||||
bgcolor: 'background.paper',
|
||||
border: '2px solid #000',
|
||||
boxShadow: 24,
|
||||
p: 3
|
||||
};
|
||||
|
||||
const CmmModal = ({ isBackdrop = false, open, setOpen, title, judgeData = () => {} }) => {
|
||||
const [judgeStd, setJudgeStd] = useState('1');
|
||||
const handleClose = () => {
|
||||
setOpen(false);
|
||||
};
|
||||
|
||||
const handleJudge = () => {
|
||||
alert(`[${JSON.stringify(judgeData)}]==>>심사기준::${judgeStd}명`);
|
||||
};
|
||||
return (
|
||||
<div className="modalGroup">
|
||||
{/* <Button onClick={handleOpen}>Grid Modal(List)</Button> */}
|
||||
<Modal hideBackdrop={isBackdrop} open={open} aria-labelledby="modal-modal-title" aria-describedby="modal-modal-description">
|
||||
<MainCard
|
||||
sx={style}
|
||||
title={title}
|
||||
content
|
||||
secondary={
|
||||
<IconButton size="small" variant="rounded" onClick={handleClose}>
|
||||
<CloseOutlined fontSize="small" />
|
||||
</IconButton>
|
||||
}
|
||||
>
|
||||
<Grid container spacing={1} alignItems="center">
|
||||
<Grid item xs={12}>
|
||||
<FormControl fullWidth>
|
||||
<InputLabel required>부과 기준</InputLabel>
|
||||
<Select defaultValue={judgeStd} value={judgeStd} onChange={(e) => setJudgeStd(e.target.value)}>
|
||||
{combo.judgeStds.map((judge, idx) => (
|
||||
<MenuItem key={idx} value={judge.code}>
|
||||
{judge.value}
|
||||
</MenuItem>
|
||||
))}
|
||||
</Select>
|
||||
</FormControl>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Grid item xs={12}>
|
||||
<Divider />
|
||||
</Grid>
|
||||
<Grid container spacing={1} mt={1}>
|
||||
<Grid item xs={12} style={{ marginLeft: 'auto' }}>
|
||||
<Button variant="contained" color="primary" size="small" startIcon={<IconSearch />} onClick={handleJudge}>
|
||||
저장
|
||||
</Button>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</MainCard>
|
||||
</Modal>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
CmmModal.propTypes = {
|
||||
isBackdrop: PropTypes.bool,
|
||||
open: PropTypes.bool,
|
||||
title: PropTypes.string,
|
||||
setOpen: PropTypes.func,
|
||||
judgeData: PropTypes.array
|
||||
};
|
||||
|
||||
export default CmmModal;
|
Loading…
Reference in New Issue