From 4534e52c58fbe56a1a257d3e66a940b6a5a04e49 Mon Sep 17 00:00:00 2001 From: Lim Jonguk Date: Mon, 14 Mar 2022 20:52:35 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=8B=AC=EC=9D=98=EB=AA=A9=EB=A1=9D=20?= =?UTF-8?q?=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/BoardService.js | 14 ---- src/apis/OpstBizService.js | 32 +++++++++ src/commons/ApiUrl.js | 1 + src/commons/XitCmm.js | 23 +++--- src/ui-component/MuiGridList.jsx | 7 +- src/views/biz/board/Board.jsx | 6 +- src/views/biz/board/PublicBoard.jsx | 6 +- src/views/biz/parking/Regist.jsx | 2 +- src/views/biz/parking/Review.jsx | 107 +++++++++++++++++++--------- 9 files changed, 127 insertions(+), 71 deletions(-) delete mode 100644 src/apis/BoardService.js create mode 100644 src/apis/OpstBizService.js diff --git a/src/apis/BoardService.js b/src/apis/BoardService.js deleted file mode 100644 index 23e3493..0000000 --- a/src/apis/BoardService.js +++ /dev/null @@ -1,14 +0,0 @@ -import { BOARD_LIST_URL } from 'commons/ApiUrl'; -import axios from 'utils/axios'; - -class BoardService { - // eslint-disable-next-line no-return-await - getBoardList = async (params) => await axios.get(BOARD_LIST_URL, { params }); - // const res = await axios.get(BOARD_LIST_URL, { params }); - // return res; - // axios.get(BOARD_LIST_URL, { params }).then((r) => { - // console.log(r); - // return r; - // }); -} -export default new BoardService(); diff --git a/src/apis/OpstBizService.js b/src/apis/OpstBizService.js new file mode 100644 index 0000000..07b0a7c --- /dev/null +++ b/src/apis/OpstBizService.js @@ -0,0 +1,32 @@ +import { BOARD_LIST_URL, SIMSA_LIST_URL } from 'commons/ApiUrl'; +import axios from 'utils/axios'; + +class OpstBizService { + // eslint-disable-next-line no-return-await + getBoardList = async (params) => { + const res = await axios.get(BOARD_LIST_URL, { params }); + if (res.success) { + res.data = res.data.map((d, idx) => ({ ...d, rowId: idx })); + return res; + } + return res; + }; + + // const res = await axios.get(BOARD_LIST_URL, { params }); + // return res; + // axios.get(BOARD_LIST_URL, { params }).then((r) => { + // console.log(r); + // return r; + // }); + + // eslint-disable-next-line no-return-await + getSimsa680GroupList = async (params) => { + const res = await axios.get(SIMSA_LIST_URL, { params }); + if (res.success) { + res.data = res.data.map((d, idx) => ({ ...d, rowId: idx })); + return res; + } + return res; + }; +} +export default new OpstBizService(); diff --git a/src/commons/ApiUrl.js b/src/commons/ApiUrl.js index e3c24ff..d29f348 100644 --- a/src/commons/ApiUrl.js +++ b/src/commons/ApiUrl.js @@ -3,3 +3,4 @@ export const LOGIN_URL = '/api/v1/ctgy/account/login'; export const CMM_CODE_LIST_URL = '/api/v1/biz/cmm/combo'; export const BOARD_LIST_URL = '/api/v1/ctgy/board'; +export const SIMSA_LIST_URL = '/api/v1/ctgy/simsa/review'; diff --git a/src/commons/XitCmm.js b/src/commons/XitCmm.js index c988148..1be85bc 100644 --- a/src/commons/XitCmm.js +++ b/src/commons/XitCmm.js @@ -76,7 +76,7 @@ const XitCmm = { * validation check error message * @param message */ - alertParam: (message: string) => { + alertParam: (message) => { Swal.fire({ icon: 'warning', html: message, @@ -90,7 +90,7 @@ const XitCmm = { * API Error message * @param message */ - alertError: (message: string) => { + alertError: (message) => { Swal.fire({ icon: 'error', title: 'API error', @@ -108,10 +108,7 @@ const XitCmm = { * @param validator */ - useInput( - initalValue: T, - validator?: (value: string) => boolean - ): [T, Dispatch>, (e?: React.ChangeEvent) => void] { + useInput(initalValue, validator) { const [value, setValue] = useState < typeof initalValue > initalValue; const changer = useCallback( (e) => { @@ -171,8 +168,8 @@ const XitCmm = { * @param name * @returns string */ - getParameterByName: (name: string) => { - name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]'); + getParameterByName: (name) => { + name = name.replace(/[\\[]/, '\\[').replace(/[\]]/, '\\]'); const regex = new RegExp(`[\\?&]${name}=([^&#]*)`); const results = regex.exec(window.location.search); return results == null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' ')); @@ -198,7 +195,7 @@ const XitCmm = { * @param name * @returns {string|number|null} */ - urlParam: (name: string) => { + urlParam: (name) => { // var url = decodeURIComponent(window.location.href); const results = new RegExp(`[?&]${name}=([^&#]*)`).exec(window.location.href); if (results == null) { @@ -212,7 +209,7 @@ const XitCmm = { * @param paramName * @returns {string} */ - getParameters: (paramName: string) => { + getParameters: (paramName) => { // 리턴값을 위한 변수 선언 let returnValue; @@ -240,7 +237,7 @@ const XitCmm = { * @param value - The value of the cookie * @param expireDays */ - setCookie: (name: string, value: string, expireDays: number = 1) => { + setCookie: (name, value, expireDays = 1) => { const todayDate = new Date(); todayDate.setTime(todayDate.getTime() + expireDays * 24 * 60 * 60 * 1000); const expired = todayDate.toISOString(); // .toGMTString(); @@ -251,14 +248,14 @@ const XitCmm = { * * @param name */ - getCookie: (name: string) => document.cookie.split(';').some((c) => c.trim().startsWith(`${name}=`)), + getCookie: (name) => document.cookie.split(';').some((c) => c.trim().startsWith(`${name}=`)), /** * * @param name - The name of the cookie to be set * @param value - The value of the cookie */ - removeCookie: (name: string, value?: string) => { + removeCookie: (name, value) => { if (!value) document.cookie = `${name}=Max-Age=-99999999;`; else document.cookie = `${name}=${encodeURIComponent(value)}${{ expires: 'Sun, 01-May-2019 14:00:00 UTC' }}`; } diff --git a/src/ui-component/MuiGridList.jsx b/src/ui-component/MuiGridList.jsx index e5982a8..31f3c0c 100644 --- a/src/ui-component/MuiGridList.jsx +++ b/src/ui-component/MuiGridList.jsx @@ -8,14 +8,14 @@ import { useTheme } from '@mui/material/styles'; // project imports -const MuiGridList = ({ columns, rowsState, totalCount, setRowsState }) => { +const MuiGridList = ({ setRowId, columns, rowsState, totalCount, setRowsState }) => { // const { columns, rowsState, totalCount, setRowsState } = props; const theme = useTheme(); return ( { > row.ciContentno} + getRowId={(row) => row.rowId} rowCount={totalCount} checkboxSelection disableSelectionOnClick @@ -53,6 +53,7 @@ const MuiGridList = ({ columns, rowsState, totalCount, setRowsState }) => { }; MuiGridList.propTypes = { + setRowId: PropTypes.func, columns: PropTypes.array, rowsState: PropTypes.any, totalCount: PropTypes.number, diff --git a/src/views/biz/board/Board.jsx b/src/views/biz/board/Board.jsx index 9fa00c5..ac3857c 100644 --- a/src/views/biz/board/Board.jsx +++ b/src/views/biz/board/Board.jsx @@ -24,7 +24,7 @@ import MainCard from 'ui-component/cards/MainCard'; // project imports import MuiGridList from 'ui-component/MuiGridList'; -import boardService from 'apis/BoardService'; +import opstBizService from 'apis/OpstBizService'; const Board = () => { const [category, setCategory] = useState('ciTitle'); @@ -65,7 +65,7 @@ const Board = () => { useEffect(() => { let params = { - page: rowsState.page + 1, + page: rowsState.page, size: rowsState.pageSize }; @@ -76,7 +76,7 @@ const Board = () => { }; } - boardService.getBoardList(params).then((response) => { + opstBizService.getBoardList(params).then((response) => { console.log(response); if (response && response.data) { setTotalCount(response.count); diff --git a/src/views/biz/board/PublicBoard.jsx b/src/views/biz/board/PublicBoard.jsx index ef26877..f87ddda 100644 --- a/src/views/biz/board/PublicBoard.jsx +++ b/src/views/biz/board/PublicBoard.jsx @@ -13,7 +13,7 @@ import MainCard from 'ui-component/cards/MainCard'; // project imports import MuiGridList from 'ui-component/MuiGridList'; import InputLabel from 'ui-component/extended/Form/InputLabel'; -import boardService from '../../../apis/BoardService'; +import opstBizService from '../../../apis/OpstBizService'; const PublicBoard = () => { const [totalCount, setTotalCount] = useState(0); @@ -45,11 +45,11 @@ const PublicBoard = () => { useEffect(() => { const params = { - page: rowsState.page + 1, + page: rowsState.page, size: rowsState.pageSize }; - boardService.getBoardList(params).then((response) => { + opstBizService.getBoardList(params).then((response) => { console.log(response); if (response && response.data) { setTotalCount(response.count); diff --git a/src/views/biz/parking/Regist.jsx b/src/views/biz/parking/Regist.jsx index 0670e5d..08b009c 100644 --- a/src/views/biz/parking/Regist.jsx +++ b/src/views/biz/parking/Regist.jsx @@ -75,7 +75,7 @@ const ParkingRegister = () => { useEffect(() => { const params = { - page: rowsState.page + 1, + page: rowsState.page, size: rowsState.pageSize }; }, [rowsState.page, rowsState.pageSize]); // rowsState.page, rowsState.pageSize, rowsState.rows]); diff --git a/src/views/biz/parking/Review.jsx b/src/views/biz/parking/Review.jsx index 57083ac..2543d82 100644 --- a/src/views/biz/parking/Review.jsx +++ b/src/views/biz/parking/Review.jsx @@ -1,9 +1,11 @@ -import { useEffect, useState } from 'react'; +import { useCallback, useEffect, useMemo, useState } from 'react'; import _ from 'lodash'; // material-ui -import { Button, Divider, Grid, InputAdornment, MenuItem, OutlinedInput, Select } from '@mui/material'; +import { GridActionsCellItem } from '@mui/x-data-grid'; +import { Divider, Grid, InputAdornment, MenuItem, OutlinedInput, Select } from '@mui/material'; +import DeleteIcon from '@mui/icons-material/Delete'; import MuiTooltip from '@mui/material/Tooltip'; // assets @@ -14,9 +16,10 @@ import MainCard from 'ui-component/cards/MainCard'; // project imports import MuiGridList from 'ui-component/MuiGridList'; -import boardService from 'apis/BoardService'; +import opstBizService from 'apis/OpstBizService'; import moment from 'moment'; import { useTheme } from '@mui/material/styles'; +import xitCmm from 'commons/XitCmm'; const ParkingReview = () => { const theme = useTheme(); @@ -33,58 +36,94 @@ const ParkingReview = () => { rows: [] // loading: false }); + const [rows, setRows] = useState(); + const removeSimsa = useCallback( + (row) => () => { + // setTimeout(() => { + // setRowsState((prevRows) => prevRows.filter((row) => row.rowId !== rowId)); + // }); + xitCmm.alertParam(`삭제대상
${JSON.stringify(row)}`); + console.log(row); + }, + [] + ); + + /* + 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: '심의차수', field: 'ciCode' }, - { headerName: '심사건수', field: 'ciContentno' }, - { headerName: '심사기간', field: 'ciTitle', editable: true }, - { headerName: '심사마감일시', field: 'ciId' }, - { headerName: '상태', field: 'ciPwd' }, + // { headerName: 'rowId', field: 'rowId' }, + { headerName: '심의차수', field: 'msChasu' }, + { headerName: '심사건수', field: 'cnt' }, + { + headerName: '심사기간', + field: 'msDate', + minWidth: 180, + description: 'dddddd', + valueGetter: (params) => `${params.row.msSdate} ~ ${params.row.msEdate}` + }, { - headerName: '삭제하기', - field: 'ciEmail', - renderCell: (params) => ( - - {params.value} - - - ) + headerName: '심사마감일시', + field: 'msCdate', + type: 'dateTime', + minWidth: 125, + valueGetter: (params) => `${params.row.msCdate} ${params.row.msClosesi}` + }, + { headerName: '상태', field: 'msResult', renderCell: (params) => <>{params.value === '1' ? '진행중' : '심사완료'} }, + { + headerName: '삭제', + field: 'actions', + type: 'actions', + width: 80, + getActions: (params) => [} label="Delete" onClick={removeSimsa(params.row)} />] } ]; - const handleSearch = async (event) => { - if (event.type === 'keydown' && event.key === 'Enter') { - const newString = event?.target.value; - setSearchTxt(newString); - } - }; - useEffect(() => { + const search = () => { let params = { - page: rowsState.page + 1, + page: rowsState.page, size: rowsState.pageSize }; if (searchTxt) { params = { ...params, - year: selectedYear + msYear: selectedYear, + msChasu: searchTxt }; } - boardService.getBoardList(params).then((response) => { + opstBizService.getSimsa680GroupList(params).then((response) => { console.log(response); if (response && response.data) { setTotalCount(response.count); setRowsState((prevState) => ({ ...prevState, rows: response.data })); } }); - }, [rowsState.page, rowsState.pageSize, searchTxt]); // rowsState.page, rowsState.pageSize, rowsState.rows]); + }; + + const handleSearch = async (event) => { + if (!selectedYear) return; + + if (event.type === 'keydown' && event.key === 'Enter') { + const newString = event?.target.value || selectedYear; + setSearchTxt(newString); + search(); + } + }; return (