From 2af89d02a87727dcd402461d53bf20e06896d858 Mon Sep 17 00:00:00 2001 From: minuk926 Date: Mon, 2 May 2022 20:53:00 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=8B=AC=EC=82=AC=EC=9E=90=20=EC=8B=AC?= =?UTF-8?q?=EC=9D=98=20=EC=A7=84=ED=96=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/contexts/JWTContext.js | 3 +- src/routes/MainRoutes.js | 2 +- src/views/biz/judge/JudgeByUserReview.jsx | 305 ++++++++++++++++++++++ src/views/biz/judge/JudgeReview.jsx | 275 ------------------- src/views/biz/judge/ProcessJudge.jsx | 124 +++++++++ src/views/biz/judge/ProcessJudge2.jsx | 97 +++++++ 6 files changed, 529 insertions(+), 277 deletions(-) create mode 100644 src/views/biz/judge/JudgeByUserReview.jsx delete mode 100644 src/views/biz/judge/JudgeReview.jsx create mode 100644 src/views/biz/judge/ProcessJudge.jsx create mode 100644 src/views/biz/judge/ProcessJudge2.jsx diff --git a/src/contexts/JWTContext.js b/src/contexts/JWTContext.js index 126d0d6..86880cc 100755 --- a/src/contexts/JWTContext.js +++ b/src/contexts/JWTContext.js @@ -115,7 +115,8 @@ export const JWTProvider = ({ children }) => { user: { id: user.userid, email: user.email, - name: user.name + name: user.name, + team: user.team } } }); diff --git a/src/routes/MainRoutes.js b/src/routes/MainRoutes.js index 5c11192..5bb659d 100755 --- a/src/routes/MainRoutes.js +++ b/src/routes/MainRoutes.js @@ -22,7 +22,7 @@ const ParkingRegister = Loadable(lazy(() => import('views/biz/admin/parking/Park const JudgeDataReview = Loadable(lazy(() => import('views/biz/admin/judge/JudgeDataReview'))); const JudgeReview = Loadable(lazy(() => import('views/biz/admin/judge/JudgeReview'))); const JudgeRegistReview = Loadable(lazy(() => import('views/biz/admin/judge/JudgeRegistReview'))); -const UserByJudgeReview = Loadable(lazy(() => import('views/biz/judge/JudgeReview'))); +const UserByJudgeReview = Loadable(lazy(() => import('views/biz/judge/JudgeByUserReview'))); // user const UserManager = Loadable(lazy(() => import('views/biz/user/UserManager'))); diff --git a/src/views/biz/judge/JudgeByUserReview.jsx b/src/views/biz/judge/JudgeByUserReview.jsx new file mode 100644 index 0000000..b1d4e24 --- /dev/null +++ b/src/views/biz/judge/JudgeByUserReview.jsx @@ -0,0 +1,305 @@ +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 { Divider, FormControl, Grid, InputAdornment, Link, MenuItem, OutlinedInput, Select, Typography } from '@mui/material'; +import CreditScoreIcon from '@mui/icons-material/CreditScore'; +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 InputLabel from 'ui-component/extended/Form/InputLabel'; +import { findByUserJudges } from 'apis/judge'; +import CmmModal from 'views/cmm/CmmModal'; +import ProcessJudge from './ProcessJudge'; +import useAuth from 'hooks/useAuth'; +import { Delete } from '@mui/icons-material'; +import Button from '@mui/material/Button'; +import { useAlert } from 'react-alert'; + +const itemData = [ + { + img: 'https://images.unsplash.com/photo-1551963831-b3b1ca40c98e', + title: 'Breakfast' + }, + { + img: 'https://images.unsplash.com/photo-1551782450-a2132b4ba21d', + title: 'Burger' + }, + { + img: 'https://images.unsplash.com/photo-1522770179533-24471fcdba45', + title: 'Camera' + }, + { + img: 'https://images.unsplash.com/photo-1444418776041-9c7e33cc5a9c', + title: 'Coffee' + }, + { + img: 'https://images.unsplash.com/photo-1533827432537-70133748f5c8', + title: 'Hats' + }, + { + img: 'https://images.unsplash.com/photo-1558642452-9d2a7deb7f62', + title: 'Honey' + }, + { + img: 'https://images.unsplash.com/photo-1516802273409-68526ee1bdd6', + title: 'Basketball' + }, + { + img: 'https://images.unsplash.com/photo-1518756131217-31eb79b20e8f', + title: 'Fern' + }, + { + img: 'https://images.unsplash.com/photo-1597645587822-e99fa5d45d25', + title: 'Mushrooms' + }, + { + img: 'https://images.unsplash.com/photo-1567306301408-9b74779a11af', + title: 'Tomato basil' + }, + { + img: 'https://images.unsplash.com/photo-1471357674240-e1a485acb3e1', + title: 'Sea star' + }, + { + img: 'https://images.unsplash.com/photo-1589118949245-7d38baf380d6', + title: 'Bike' + } +]; + +const JudgeByUserReview = ({ msDatagb, menuName }) => { + const { user } = useAuth(); + const showAlert = useAlert(); + const [totalCount, setTotalCount] = useState(0); + const [rowsState, setRowsState] = useState({ + page: 0, + pageSize: 100, + rows: [] + // loading: false + }); + const [open, setOpen] = useState(false); + const [title, setTitle] = useState(''); + const [rowDatas, setRowDatas] = useState([]); + const [minSdate, setMinSdate] = useState(''); + const [maxEdate, setMaxEdate] = useState(''); + const [minSeq, setMinSeq] = useState(0); + const [maxSeq, setMaxSeq] = useState(0); + + const search = useCallback(() => { + const params = { + msDatagb + }; + + findByUserJudges(params).then((res) => { + if (res && res.data) { + setTotalCount(res.count); + setRowsState((prevState) => ({ ...prevState, rows: res.data })); + const arrMsSeq = res.data.map((r) => r.msSeq); + setMinSdate(_.min(res.data.map((r) => r.msSdate))); + setMaxEdate(_.max(res.data.map((r) => r.msEdate))); + setMinSeq(_.min(arrMsSeq)); + setMaxSeq(_.max(arrMsSeq)); + } + }); + }, [msDatagb]); + + const processJudge = useCallback( + (row) => () => { + setTitle(`${menuName} 심의 - ${row.msSeq}`); + setRowDatas([row]); + setOpen(true); + }, + [] + ); + + const columns = [ + // { headerName: 'rowId', field: 'rowId' }, + { + headerName: 'msMaincode', + headerAlign: 'center', + field: 'msMaincode', + align: 'center', + width: 100 + }, + { + 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: 'msDate', + minWidth: 200, + width: 250, + description: '심사 기간', + valueGetter: (params) => `${params.row.msSdate} ~ ${params.row.msEdate}`, + 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: 'actions', + type: 'actions', + width: 80, + getActions: (params) => [ + } label="개별심사" onClick={processJudge(params.row)} /> + ], + align: 'center' + } + ]; + + const handleSearch = async (event) => { + if (event.type === 'keydown' && event.key === 'Enter') { + const newString = event?.target.value; + search(); + } + }; + + const onJudge = useCallback(() => { + setTitle(`${menuName} 심의`); + setRowDatas(rowsState?.rows); + setOpen(true); + }, []); + useEffect(() => { + search(); + // }, [rowsState.page, rowsState.pageSize, selectedYear, searchTxt]); + }, [search]); + + return ( + + + + + + [ 심의기간 : {' '} + + {minSdate} ~ {maxEdate} + {' '} + ] + + + + + [ 접수번호 : + + {' '} + {minSeq} ~ {maxSeq} + {' '} + ] + + + + + + + [ {user?.name} 위원 / + {user?.team?.substring(2)}팀 ] + + + + + + + {/* */} + {/* */} + {/* */} + + + + + + + + + + + + ); +}; +JudgeByUserReview.propTypes = { + msDatagb: PropTypes.string.isRequired, + menuName: PropTypes.string.isRequired +}; + +export default JudgeByUserReview; diff --git a/src/views/biz/judge/JudgeReview.jsx b/src/views/biz/judge/JudgeReview.jsx deleted file mode 100644 index 837f313..0000000 --- a/src/views/biz/judge/JudgeReview.jsx +++ /dev/null @@ -1,275 +0,0 @@ -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 { Divider, FormControl, Grid, InputAdornment, Link, MenuItem, OutlinedInput, Select } from '@mui/material'; -import CreditScoreIcon from '@mui/icons-material/CreditScore'; -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 InputLabel from 'ui-component/extended/Form/InputLabel'; -import { findByUserJudges } 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: 'msDate', - minWidth: 200, - width: 250, - description: '심사 기간', - valueGetter: (params) => `${params.row.msSdate} ~ ${params.row.msEdate}`, - renderCell: (params) => ( - - {params.value} - - ), - 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: 'actions', - type: 'actions', - width: 80, - getActions: (params) => [ - } label="개별심사" onClick={execJudge(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: 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 ( - - - - - - - 심의 년도 - - - - - - - - } - /> - - - - - - - - - - - -
Empty
-
-
- ); -}; -JudgeReview.propTypes = { - msDatagb: PropTypes.string.isRequired, - menuName: PropTypes.string.isRequired -}; - -export default JudgeReview; diff --git a/src/views/biz/judge/ProcessJudge.jsx b/src/views/biz/judge/ProcessJudge.jsx new file mode 100644 index 0000000..a8940cb --- /dev/null +++ b/src/views/biz/judge/ProcessJudge.jsx @@ -0,0 +1,124 @@ +import React, { useEffect, useState } from 'react'; +import { CardMedia, ImageList, ImageListItem } from '@mui/material'; +import { useDropzone } from 'react-dropzone'; +import { Image } from '@mui/icons-material'; +import Box from '@mui/material/Box'; +import PropTypes from 'prop-types'; +import { judgeFileDownload } from '../../../apis/judge'; +import _ from 'lodash'; + +const itemData = [ + { + img: 'https://images.unsplash.com/photo-1551963831-b3b1ca40c98e', + title: 'Breakfast' + }, + { + img: 'https://images.unsplash.com/photo-1551782450-a2132b4ba21d', + title: 'Burger' + }, + { + img: 'https://images.unsplash.com/photo-1522770179533-24471fcdba45', + title: 'Camera' + }, + { + img: 'https://images.unsplash.com/photo-1444418776041-9c7e33cc5a9c', + title: 'Coffee' + }, + { + img: 'https://images.unsplash.com/photo-1533827432537-70133748f5c8', + title: 'Hats' + }, + { + img: 'https://images.unsplash.com/photo-1558642452-9d2a7deb7f62', + title: 'Honey' + }, + { + img: 'https://images.unsplash.com/photo-1516802273409-68526ee1bdd6', + title: 'Basketball' + }, + { + img: 'https://images.unsplash.com/photo-1518756131217-31eb79b20e8f', + title: 'Fern' + }, + { + img: 'https://images.unsplash.com/photo-1597645587822-e99fa5d45d25', + title: 'Mushrooms' + }, + { + img: 'https://images.unsplash.com/photo-1567306301408-9b74779a11af', + title: 'Tomato basil' + }, + { + img: 'https://images.unsplash.com/photo-1471357674240-e1a485acb3e1', + title: 'Sea star' + }, + { + img: 'https://images.unsplash.com/photo-1589118949245-7d38baf380d6', + title: 'Bike' + } +]; + +const ProcessJudge = ({ rowDatas, showAlert }) => { + const [previewImage, setPreviewImage] = useState(); + + const { getRootProps, getInputProps } = useDropzone({ + accept: 'image/*', + onDrop: (acceptedFiles) => { + setPreviewImage(URL.createObjectURL(itemData[0].img)); + } + }); + + const viewImg = (scDatagb, scCode, methodName) => { + judgeFileDownload( + { + scDatagb, + scCode, + methodName + }, + showAlert + ); + }; + + // rowDatas[0]?[`scFrecad`]; + // rowDatas[0]?[`scContad`]; + // 1. 데이타 조회 - msMaincode로 gnRecallSc + // 2. 이미지 조회 - judgeFileDownload : data['scPicad1'] 가 있는 경우 + useEffect(() => { + rowDatas?.forEach((r) => _.range(1, 5, 1).forEach((idx) => viewImg(r.scDatagb, r.msMaincode, `scPicad${idx}`))); + }, []); + + return ( + <> + + + + + ); +}; + +ProcessJudge.propTypes = { + rowDatas: PropTypes.array.isRequired, + showAlert: PropTypes.object +}; + +export default ProcessJudge; diff --git a/src/views/biz/judge/ProcessJudge2.jsx b/src/views/biz/judge/ProcessJudge2.jsx new file mode 100644 index 0000000..4604cf1 --- /dev/null +++ b/src/views/biz/judge/ProcessJudge2.jsx @@ -0,0 +1,97 @@ +import React, { useState } from 'react'; +import { CardMedia, ImageList, ImageListItem } from '@mui/material'; +import { useDropzone } from 'react-dropzone'; +import { Image } from '@mui/icons-material'; +import Box from '@mui/material/Box'; + +const itemData = [ + { + img: 'https://images.unsplash.com/photo-1551963831-b3b1ca40c98e', + title: 'Breakfast' + }, + { + img: 'https://images.unsplash.com/photo-1551782450-a2132b4ba21d', + title: 'Burger' + }, + { + img: 'https://images.unsplash.com/photo-1522770179533-24471fcdba45', + title: 'Camera' + }, + { + img: 'https://images.unsplash.com/photo-1444418776041-9c7e33cc5a9c', + title: 'Coffee' + }, + { + img: 'https://images.unsplash.com/photo-1533827432537-70133748f5c8', + title: 'Hats' + }, + { + img: 'https://images.unsplash.com/photo-1558642452-9d2a7deb7f62', + title: 'Honey' + }, + { + img: 'https://images.unsplash.com/photo-1516802273409-68526ee1bdd6', + title: 'Basketball' + }, + { + img: 'https://images.unsplash.com/photo-1518756131217-31eb79b20e8f', + title: 'Fern' + }, + { + img: 'https://images.unsplash.com/photo-1597645587822-e99fa5d45d25', + title: 'Mushrooms' + }, + { + img: 'https://images.unsplash.com/photo-1567306301408-9b74779a11af', + title: 'Tomato basil' + }, + { + img: 'https://images.unsplash.com/photo-1471357674240-e1a485acb3e1', + title: 'Sea star' + }, + { + img: 'https://images.unsplash.com/photo-1589118949245-7d38baf380d6', + title: 'Bike' + } +]; + +const ProcessJudge2 = () => { + const [previewImage, setPreviewImage] = useState(); + + const { getRootProps, getInputProps } = useDropzone({ + accept: 'image/*', + onDrop: (acceptedFiles) => { + setPreviewImage(URL.createObjectURL(itemData[0].img)); + } + }); + + return ( + <> + + + + + ); +}; + +export default ProcessJudge2;