fix : 그리드 스타일 정리

main
minuk926 3 years ago
parent 6083caf307
commit 11dd7f273a

@ -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: <ResidentRegister />
element: <ResidentReview />
},
{
path: '/resident/register',

@ -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

@ -20,7 +20,7 @@ const Board = () => {
const [totalCount, setTotalCount] = useState(0);
const [rowsState, setRowsState] = useState({
page: 0,
pageSize: 10,
pageSize: 20,
rows: []
// loading: false
});

@ -19,7 +19,7 @@ const PublicBoard = () => {
const [totalCount, setTotalCount] = useState(0);
const [rowsState, setRowsState] = useState({
page: 0,
pageSize: 10,
pageSize: 20,
rows: []
// loading: false
});

@ -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 = () => {

@ -33,7 +33,7 @@ const ParkingReview = () => {
const [totalCount, setTotalCount] = useState(0);
const [rowsState, setRowsState] = useState({
page: 0,
pageSize: 10,
pageSize: 20,
rows: []
// loading: false
});

@ -22,7 +22,7 @@ const ResidentDataReview = () => {
const [totalCount, setTotalCount] = useState(0);
const [rowsState, setRowsState] = useState({
page: 0,
pageSize: 10,
pageSize: 20,
rows: []
// loading: false
});

@ -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(`삭제대상<br>${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) => (
// <Link underline="hover" href="/parking/details" rel="noopener">
<Link
underline="hover"
// onClick={() => navigate(`/parking/details?msChasu=${params.msChasu}&msSdate=${params.msSdate}&msEdate=${params.msEdate}`)}
onClick={openModalDetails}
data-target="modalDetails"
rel="noopener"
>
{/* <Link underline="hover" href="#" onClick={() => <ModalDetails />}> */}
{/* <Link underline="hover" onClick={() => <ModalDetails />}> */}
{params.value}
</Link>
// <ModalDetails />
)
},
{
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) => [<GridActionsCellItem icon={<DeleteIcon />} 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 (
<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 item xs={12}>
<Divider />
</Grid>
<Grid item xs={12}>
<Divider />
</Grid>
<MuiDataGrid columns={columns} rowsState={rowsState} totalCount={totalCount} setRowsState={setRowsState} />
</MainCard>
);
};
export default ResidentReview;

@ -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 (
<Box
sx={{
@ -52,6 +145,7 @@ const MuiDataGrid = ({
// apiRef={apiRef}
// showCellRightBorder
// showColumnRightBorder
// className={classes}
localeText={dataGridKoKR}
paginationMode="server"
getRowId={(row) => 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);

Loading…
Cancel
Save