parent
e14ed3e528
commit
e23a8c43a3
@ -0,0 +1,286 @@
|
||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
import _ from 'lodash';
|
||||
import getYear from 'date-fns/getYear';
|
||||
|
||||
// material-ui
|
||||
import { GridActionsCellItem } from '@mui/x-data-grid';
|
||||
import { Button, Divider, FormControl, Grid, InputAdornment, Link, MenuItem, OutlinedInput, Select } from '@mui/material';
|
||||
import DeleteIcon from '@mui/icons-material/Delete';
|
||||
import { IconSearch, IconFileReport } from '@tabler/icons';
|
||||
|
||||
// berry ui
|
||||
import MainCard from 'ui-component/cards/MainCard';
|
||||
|
||||
// project imports
|
||||
import MuiDataGrid from 'views/cmm/mui-grid/MuiDataGrid';
|
||||
import InputLabel from 'ui-component/extended/Form/InputLabel';
|
||||
import { findByUserJudges, findJudgeResults, findJudges, removeJudge } from 'apis/judge';
|
||||
import CmmModal from 'views/cmm/CmmModal';
|
||||
|
||||
const JudgeReview = ({ msDatagb, menuName }) => {
|
||||
const isInit = useRef(true);
|
||||
const year = getYear(new Date());
|
||||
const years = _.range(year, year - 14, -1);
|
||||
|
||||
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: 100,
|
||||
rows: []
|
||||
// loading: false
|
||||
});
|
||||
const [judgeResultData, setJudgeResultData] = useState({
|
||||
totJudgeUserData: [],
|
||||
judgeData: [],
|
||||
judgeCars: [],
|
||||
judgeUserData: [],
|
||||
simsaUser: [],
|
||||
selectedRow: {},
|
||||
judgeTeam: ''
|
||||
});
|
||||
|
||||
const search = useCallback(() => {
|
||||
const params = {
|
||||
msDatagb
|
||||
};
|
||||
|
||||
findByUserJudges(params).then((response) => {
|
||||
if (response && response.data) {
|
||||
setTotalCount(response.count);
|
||||
setRowsState((prevState) => ({ ...prevState, rows: response.data }));
|
||||
// apiRef.current.forceUpdate(); // .updateRowData([]);
|
||||
// apiRef.current.updateRowData([]);
|
||||
}
|
||||
});
|
||||
}, [msDatagb, selectedYear, searchTxt]);
|
||||
|
||||
const execJudge = useCallback(
|
||||
(row) => () => {
|
||||
// removeJudge(row).then((response) => {
|
||||
// if (response && response.success) {
|
||||
// setRowsState({
|
||||
// ...rowsState,
|
||||
// page: 0
|
||||
// });
|
||||
// search();
|
||||
// } else {
|
||||
// alert.show(response.message);
|
||||
// }
|
||||
// });
|
||||
},
|
||||
[]
|
||||
);
|
||||
|
||||
const columns = [
|
||||
// { headerName: 'rowId', field: 'rowId' },
|
||||
{ headerName: '접수번호', headerAlign: 'center', field: 'msSeq', align: 'center', width: 100 },
|
||||
{ headerName: '심의차수', headerAlign: 'center', field: 'msChasu', align: 'center', width: 100 },
|
||||
{ headerName: '차량번호', headerAlign: 'center', field: 'msCarnum', align: 'center', width: 100 },
|
||||
{
|
||||
headerName: '심의결정',
|
||||
headerAlign: 'center',
|
||||
field: 'msResult',
|
||||
align: 'center',
|
||||
renderCell: (params) => {
|
||||
switch (params.row.msResult) {
|
||||
case '0':
|
||||
return '심의전';
|
||||
// break;
|
||||
case '1':
|
||||
return '부과';
|
||||
// break;
|
||||
case '2':
|
||||
return '미부과';
|
||||
// break;
|
||||
default:
|
||||
return params.row.msResult;
|
||||
}
|
||||
},
|
||||
width: 100
|
||||
},
|
||||
{
|
||||
headerName: '심의결정(msu)',
|
||||
headerAlign: 'center',
|
||||
field: 'msuResult',
|
||||
align: 'center',
|
||||
renderCell: (params) => {
|
||||
switch (params.row.msResult) {
|
||||
case '0':
|
||||
return '심의전';
|
||||
// break;
|
||||
case '1':
|
||||
return '부과';
|
||||
// break;
|
||||
case '2':
|
||||
return '미부과';
|
||||
// break;
|
||||
default:
|
||||
return params.row.msResult;
|
||||
}
|
||||
},
|
||||
width: 100
|
||||
},
|
||||
{
|
||||
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) => {
|
||||
switch (params.row.msResult) {
|
||||
case '0':
|
||||
return '심의전';
|
||||
// break;
|
||||
case '1':
|
||||
return '부과';
|
||||
// break;
|
||||
case '2':
|
||||
return '미부과';
|
||||
// break;
|
||||
default:
|
||||
return params.row.msResult;
|
||||
}
|
||||
},
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
headerName: '개별심사',
|
||||
headerAlign: 'center',
|
||||
field: 'actions',
|
||||
type: 'actions',
|
||||
width: 80,
|
||||
// getActions: (params) => [<GridActionsCellItem icon={<IconFileReport />} label="개별심사" onClick={deleteJudge(params.row)} />],
|
||||
getActions: (params) => [
|
||||
<Button color="warning" onClick={execJudge(params.row)}>
|
||||
처리
|
||||
</Button>
|
||||
],
|
||||
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: e.row.msDatagb,
|
||||
msSdate: e.row.msSdate,
|
||||
msEdate: e.row.msEdate,
|
||||
msChasu: e.row.msChasu,
|
||||
msuTeam: e.row.msuTeam
|
||||
};
|
||||
const res = await findJudgeResults(params);
|
||||
setJudgeResultData({
|
||||
...res?.data,
|
||||
selectedRow: e.row,
|
||||
judgeTeam: res.data?.judgeTeam
|
||||
});
|
||||
|
||||
setTitle(`${e.row.msCdate} ${menuName} 심사 결과 (${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"
|
||||
autoComplete
|
||||
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
|
||||
isHideFooter
|
||||
columns={columns}
|
||||
rowsState={rowsState}
|
||||
totalCount={totalCount}
|
||||
setRowsState={setRowsState}
|
||||
handleCellClick={handleOnCellClick}
|
||||
// handleSelection={handleSelection}
|
||||
// selectionModel={selectionModel}
|
||||
/>
|
||||
<CmmModal isBackdrop title={title} open={open} setOpen={setOpen}>
|
||||
<div>Empty</div>
|
||||
</CmmModal>
|
||||
</MainCard>
|
||||
);
|
||||
};
|
||||
JudgeReview.propTypes = {
|
||||
msDatagb: PropTypes.string.isRequired,
|
||||
menuName: PropTypes.string.isRequired
|
||||
};
|
||||
|
||||
export default JudgeReview;
|
Loading…
Reference in New Issue