diff --git a/src/routes/MainRoutes.js b/src/routes/MainRoutes.js index d464fed..973e901 100755 --- a/src/routes/MainRoutes.js +++ b/src/routes/MainRoutes.js @@ -22,6 +22,7 @@ const ParkingRegister = Loadable(lazy(() => import('views/biz/parking/ParkingReg // resident const ResidentDataReview = Loadable(lazy(() => import('views/biz/resident/ResidentDataReview'))); const ResidentRegister = Loadable(lazy(() => import('views/biz/resident/ResidentRegist'))); +const ResidentReview = Loadable(lazy(() => import('views/biz/resident/ResidentReview'))); // component const ModalForm = Loadable(lazy(() => import('views/form/Modal'))); @@ -66,7 +67,7 @@ const MainRoutes = { }, { path: '/resident/review', - element: + element: }, { path: '/resident/register', diff --git a/src/utils/axios.js b/src/utils/axios.js index f613fa5..a59aac8 100755 --- a/src/utils/axios.js +++ b/src/utils/axios.js @@ -39,7 +39,14 @@ const alertError = (config, request, response, error) => { } if (response.data) { const errCode = response.data.code || response.data.status; - const errMsg = response.data.code !== '' && response.data.code !== null ? response.data.message : response.data.error; + let errMsg = ''; + if (response.data.code !== '' && response.data.code !== null) { + if (response.data.message !== '' && response.data.message != null) { + errMsg = response.data.message; + } else { + errMsg = response.data.error; + } + } console.error(`${errCode}: ${errMsg}`); console.error('================================='); @@ -99,6 +106,7 @@ axiosServices.interceptors.response.use( /** * after axios response */ +// TODO : 에러 alert 처리가 안돼고 있는데... axiosService.interceptors.response.use( (response) => { Swal.close(); @@ -115,7 +123,7 @@ axiosService.interceptors.response.use( return Promise.resolve(response.data); }, ({ config, request, response, ...error }) => { - Swal.close(); + // Swal.close(); console.error('========== ApiService.response Error Data =========='); alertError(config, request, response, error); // error 데이타 return diff --git a/src/views/biz/board/Board.jsx b/src/views/biz/board/Board.jsx index 82063c8..61f10b9 100644 --- a/src/views/biz/board/Board.jsx +++ b/src/views/biz/board/Board.jsx @@ -20,7 +20,7 @@ const Board = () => { const [totalCount, setTotalCount] = useState(0); const [rowsState, setRowsState] = useState({ page: 0, - pageSize: 10, + pageSize: 20, rows: [] // loading: false }); diff --git a/src/views/biz/board/PublicBoard.jsx b/src/views/biz/board/PublicBoard.jsx index 1e7b58a..6f59b29 100644 --- a/src/views/biz/board/PublicBoard.jsx +++ b/src/views/biz/board/PublicBoard.jsx @@ -19,7 +19,7 @@ const PublicBoard = () => { const [totalCount, setTotalCount] = useState(0); const [rowsState, setRowsState] = useState({ page: 0, - pageSize: 10, + pageSize: 20, rows: [] // loading: false }); diff --git a/src/views/biz/board/PublicBoardForm.jsx b/src/views/biz/board/PublicBoardForm.jsx index f307bb7..289bbfc 100644 --- a/src/views/biz/board/PublicBoardForm.jsx +++ b/src/views/biz/board/PublicBoardForm.jsx @@ -22,11 +22,11 @@ const PublicBoardForm = (props) => { const { create, inCode, inDept, inTitle, inHit, inName, inNalja, inFilename, inContents, setOpen, handleModalSave } = props; const alert = useAlert(); const quillRef = useRef(); - const [dept, setDept] = useState(inDept || '주정차위반'); - const [subject, setSubject] = useState(inTitle || ''); - const [contents, setContents] = useState(inContents || ''); + const [dept, setDept] = useState(create ? '주정차위반' : inDept); + const [subject, setSubject] = useState(create ? '' : inTitle); + const [contents, setContents] = useState(create ? '' : inContents); const [filesInfo, setFilesInfo] = useState(); - const [selectedFile, setSelectedFile] = useState(inFilename || ''); // 파일 + const [selectedFile, setSelectedFile] = useState(create ? '' : inFilename); // 파일 // const [fileData, setFileData] = useState(); const onList = () => { diff --git a/src/views/biz/parking/ParkingReview.jsx b/src/views/biz/parking/ParkingReview.jsx index 9bc22aa..b534b8b 100644 --- a/src/views/biz/parking/ParkingReview.jsx +++ b/src/views/biz/parking/ParkingReview.jsx @@ -33,7 +33,7 @@ const ParkingReview = () => { const [totalCount, setTotalCount] = useState(0); const [rowsState, setRowsState] = useState({ page: 0, - pageSize: 10, + pageSize: 20, rows: [] // loading: false }); diff --git a/src/views/biz/resident/ResidentDataReview.jsx b/src/views/biz/resident/ResidentDataReview.jsx index 1cf7095..8439ea3 100644 --- a/src/views/biz/resident/ResidentDataReview.jsx +++ b/src/views/biz/resident/ResidentDataReview.jsx @@ -22,7 +22,7 @@ const ResidentDataReview = () => { const [totalCount, setTotalCount] = useState(0); const [rowsState, setRowsState] = useState({ page: 0, - pageSize: 10, + pageSize: 20, rows: [] // loading: false }); diff --git a/src/views/biz/resident/ResidentReview.jsx b/src/views/biz/resident/ResidentReview.jsx new file mode 100644 index 0000000..f17fe61 --- /dev/null +++ b/src/views/biz/resident/ResidentReview.jsx @@ -0,0 +1,200 @@ +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/form/MuiDataGrid'; +import xitCmm from 'commons/XitCmm'; +import { findParkings } from 'apis/parking'; +import InputLabel from '../../../ui-component/extended/Form/InputLabel'; + +const ResidentReview = () => { + const isInit = useRef(true); + const year = getYear(new Date()); + console.log(typeof year); + const years = _.range(year, year - 14, -1); + + 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 removeSimsa = useCallback( + (row) => () => { + // setTimeout(() => { + // setRowsState((prevRows) => prevRows.filter((row) => row.rowId !== rowId)); + // }); + xitCmm.alertParam(`삭제대상
${JSON.stringify(row)}`); + console.log(row); + }, + [] + ); + + const openModalDetails = () => {}; + + /* + ms_maincode : '민원코드' + ms_seq : '접수번호' + ms_carnum : '차량번호' + ms_year : '년도' + ms_chasu : '차수' + ms_sdate : '심사시작일시' + ms_startsi : '심사시작시간' + ms_edate : '심사종료일시' + ms_cdate : '심사마감일시' + ms_closesi : '심사마감시간' + ms_wdate : '단속일자' + ms_pos : '단속장소' + ms_result : '결과코드' + ms_jbtime : '단속시간' + */ + const columns = [ + // { headerName: 'rowId', field: 'rowId' }, + { headerName: '심의차수', headerAlign: 'center', field: 'msChasu' }, + { headerName: '심사건수', headerAlign: 'center', field: 'cnt' }, + { + headerName: '심사기간', + headerAlign: 'center', + field: 'msDate', + minWidth: 180, + description: '심사기간', + valueGetter: (params) => `${params.row.msSdate} ~ ${params.row.msEdate}`, + renderCell: (params) => ( + // + navigate(`/parking/details?msChasu=${params.msChasu}&msSdate=${params.msSdate}&msEdate=${params.msEdate}`)} + onClick={openModalDetails} + data-target="modalDetails" + rel="noopener" + > + {/* }> */} + {/* }> */} + {params.value} + + // + ) + }, + { + headerName: '심사마감일시', + headerAlign: 'center', + field: 'msCdate', + type: 'dateTime', + minWidth: 125, + valueGetter: (params) => `${params.row.msCdate} ${params.row.msClosesi}` + }, + { headerName: '상태', field: 'msResult', renderCell: (params) => <>{params.row.msResult === '1' ? '진행중' : '심사완료'} }, + { + headerName: '삭제', + headerAlign: 'center', + field: 'actions', + type: 'actions', + width: 80, + getActions: (params) => [} label="Delete" onClick={removeSimsa(params.row)} />] + } + ]; + + 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 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]); + + return ( + + + + + + + 심의 년도 + + + + + + + + } + /> + + + + + + + + + + + + + ); +}; +export default ResidentReview; diff --git a/src/views/form/MuiDataGrid.jsx b/src/views/form/MuiDataGrid.jsx index 18e8ef2..58a2a41 100644 --- a/src/views/form/MuiDataGrid.jsx +++ b/src/views/form/MuiDataGrid.jsx @@ -1,12 +1,96 @@ +import { useCallback } from 'react'; import PropTypes from 'prop-types'; // material-ui -import { DataGrid } from '@mui/x-data-grid'; +import { DataGrid, gridClasses } from '@mui/x-data-grid'; +import { grey } from '@mui/material/colors'; import Box from '@mui/material/Box'; -import { useTheme } from '@mui/material/styles'; +// import { useTheme } from '@mui/material/styles'; +import { useTheme } from '@mui/styles'; import dataGridKoKR from './defaultDataGridLocale'; import CustomPagination from './CustomPagination'; +// TODO : grid style +/* +const styles = (theme) => ({ + dataGrid: { + minHeight: '132px', + + '& .MuiDataGrid-dataContainer, & .MuiDataGrid-viewport': { + minWidth: 'auto!important' + }, + + '& .MuiDataGrid-viewport': { + width: 'fit-content', + maxWidth: 'none!important', + minWidth: '100%!important' + }, + + '& .MuiDataGrid-viewport, & .MuiDataGrid-renderingZone, & .MuiDataGrid-row': { + maxHeight: 'fit-content!important' + }, + + '& .MuiDataGrid-renderingZone': { + transform: 'none!important', + marginRight: '-16px' + }, + + '& .MuiDataGrid-columnHeaderTitle, & .MuiDataGrid-cell': { + textOverflow: 'unset', + whiteSpace: 'normal', + lineHeight: '1.2!important', + maxHeight: 'fit-content!important', + minHeight: 'auto!important', + height: 'auto', + display: 'flex', + alignItems: 'center', + alignSelf: 'stretch', + + '& > div': { + maxHeight: 'inherit', + width: '100%', + whiteSpace: 'initial', + lineHeight: '1' + } + }, + + '& .MuiDataGrid-columnHeader > div': { + height: '100%' + }, + + '& .MuiDataGrid-columnHeaderWrapper': { + maxHeight: 'none!important', + flex: '1 0 auto' + }, + + '& .MuiDataGrid-row .MuiDataGrid-columnsContainer': { + maxHeight: 'none!important' + }, + + '& .MuiDataGrid-cell': { + overflowWrap: 'anywhere', + padding: '0', + + '&--textRight div': { + textAlign: 'right', + justifyContent: 'flex-end' + }, + + '&:last-of-type > div': { + paddingRight: theme.spacing(3) + }, + + '& > div': { + padding: '0.75em', + display: 'flex', + alignSelf: 'stretch', + alignItems: 'center' + } + } + } +}); +*/ + // project imports const MuiDataGrid = ({ // apiRef = () => {}, @@ -19,10 +103,19 @@ const MuiDataGrid = ({ handleCellClick = () => {}, handleSelection = () => {}, selectionModel = [] + // classes }) => { const theme = useTheme(); const { pageSize } = rowsState; + const getRowSpacing = useCallback( + (params) => ({ + top: params.isFirstVisible ? 0 : 0.5, + bottom: params.isLastVisible ? 0 : 0.5 + }), + [] + ); + return ( row.rowId} @@ -76,6 +170,24 @@ const MuiDataGrid = ({ }} hideFooterRowCount={false} hideFooterSelectedRowCount={false} + getRowSpacing={getRowSpacing} + headerHeight={40} + rowHeight={27} + // TODO : grid background style + sx={{ + [`& .${gridClasses.columnHeader}`]: { + // bgcolor: (theme) => (theme.palette.mode === 'light' ? grey[200] : grey[800]) + }, + [`& .${gridClasses.columnHeaderTitle}`]: { + // bgcolor: (theme) => (theme.palette.mode === 'light' ? grey[200] : grey[800]), + display: 'flex', + alignItems: 'center' + // alignSelf: 'stretch' + }, + [`& .${gridClasses.row}`]: { + bgcolor: (theme) => (theme.palette.mode === 'light' ? grey[200] : grey[800]) + } + }} initialState={{ pagination: { pageSize: rowsState.pageSize, @@ -101,3 +213,4 @@ MuiDataGrid.propTypes = { }; export default MuiDataGrid; +// export default withStyles(styles, { withTheme: true })(MuiDataGrid);