feat: 심사자 심의 진행

main
minuk926 3 years ago
parent d857215587
commit 3d454f8beb

@ -19,6 +19,7 @@ import {
} from 'commons/ApiUrl'; } from 'commons/ApiUrl';
import { setRowId } from './common'; import { setRowId } from './common';
import FileSaver from 'file-saver'; import FileSaver from 'file-saver';
import _ from 'lodash';
// eslint-disable-next-line no-return-await // eslint-disable-next-line no-return-await
export async function findJudgeDatas(params) { export async function findJudgeDatas(params) {
@ -131,28 +132,15 @@ export async function judgeFileDownload(params, alert) {
}) })
// eslint-disable-next-line consistent-return // eslint-disable-next-line consistent-return
.then((res) => { .then((res) => {
if (res?.isAxiosError || res?.status === 404) { if (res?.isAxiosError || res?.status === 404 || res?.size <= 0) {
alert.show('파일을 다운로드 할 수 없습니다 [파일정보 오류]'); alert.show('파일을 다운로드 할 수 없습니다 [파일정보 오류]');
} else { } else {
if (res?.size <= 0) {
alert.show('File not found!');
return false;
}
// const onChangeFile = (e) => {
// const file = e.target.files[0];
// if (file.type.includes('image')) {
// alert.show(<img alt="~~~" src={URL.createObjectURL(res.data)} style={{ margin: 'auto' }} />);
// }
// handleChangeFile(file);
// };
// FileSaver.saveAs(res, 'filename');
// eslint-disable-next-line no-lonely-if // eslint-disable-next-line no-lonely-if
if (res?.type.includes('image')) { if (res?.type.includes('image')) {
// const url = window.URL.createObjectURL(res); // const url = window.URL.createObjectURL(res);
alert.show(<img alt="~~~" src={URL.createObjectURL(res)} style={{ margin: 'auto' }} />); alert.show(<img alt="~~~" src={URL.createObjectURL(res)} style={{ margin: 'auto' }} />);
// URL.revokeObjectURL()
} else { } else {
FileSaver.saveAs(res, 'filename'); FileSaver.saveAs(res, 'filename');
} }
@ -171,3 +159,52 @@ export async function findByUserJudges(params) {
} }
return res; return res;
} }
// eslint-disable-next-line consistent-return
async function judgeImgDownload(params, alert) {
// const res = await
// eslint-disable-next-line no-return-await
return await axios.get(GET_JUDGE_FILE_DOWNLOAD, {
responseType: 'blob',
params
});
}
async function judgeImgList(res, scCode, fieldCnt, fieldName, dataGb, methodName, alert) {
const arrRtn = [];
// eslint-disable-next-line no-restricted-syntax
for (const idx of _.range(1, fieldCnt, 1)) {
if (res?.data[`${fieldName}${idx}`]) {
// eslint-disable-next-line no-await-in-loop
await judgeImgDownload({ scDatagb: dataGb, scCode, methodName: `${methodName}${idx}` }, alert).then((r) => {
console.log(r);
if (r.size > 0) arrRtn.push(URL.createObjectURL(r));
}); // .then((r) => {
}
}
console.log(arrRtn);
return arrRtn;
}
export async function findImages(row, alert) {
const dataGb = row?.msDatagb;
const scCode = row?.msMaincode;
const res = await findJudge(scCode);
console.log(res);
if (res.success) {
const [picadImgs, frecadImgs, contadImgs] = await Promise.all([
judgeImgList(res, scCode, 5, 'scPicad', dataGb, 'getScPicad', alert),
judgeImgList(res, scCode, 5, 'scFrecad', dataGb, 'getScFrecad', alert),
judgeImgList(res, scCode, 9, 'scContad', dataGb, 'getScContad', alert)
]);
console.log(picadImgs, frecadImgs, contadImgs);
return {
arrPicadImg: picadImgs,
arrFrecadImg: frecadImgs,
arrContadImg: contadImgs
};
}
return res;
}

@ -113,7 +113,8 @@ axiosServices.interceptors.response.use(
axiosService.interceptors.response.use( axiosService.interceptors.response.use(
(response) => { (response) => {
Swal.close(); Swal.close();
if (!response.data.success) { // multipart (blob) 요청인 경우 response.data?.success === 'undefined'
if (typeof response.data?.success !== 'undefined' && !response.data?.success) {
Swal.fire({ Swal.fire({
icon: 'error', icon: 'error',
title: 'Api Error', title: 'Api Error',

@ -20,8 +20,10 @@ import NumberFormat from 'react-number-format';
import ExcelDownload from 'views/cmm/file-ctl/ExcelDownload'; import ExcelDownload from 'views/cmm/file-ctl/ExcelDownload';
import { findJudgeTargets, saveJudgeTargets } from 'apis/judge'; import { findJudgeTargets, saveJudgeTargets } from 'apis/judge';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { useAlert } from 'react-alert';
const JudgeRegistReview = ({ scDatagb, menuName }) => { const JudgeRegistReview = ({ scDatagb, menuName }) => {
const showAlert = useAlert();
const [scTransfer, setScTransfer] = useState('1'); const [scTransfer, setScTransfer] = useState('1');
const [scSeq1, setScSeq1] = useState(2022000001); const [scSeq1, setScSeq1] = useState(2022000001);
const [scSeq2, setScSeq2] = useState(2022000899); const [scSeq2, setScSeq2] = useState(2022000899);
@ -94,9 +96,13 @@ const JudgeRegistReview = ({ scDatagb, menuName }) => {
setOpen(false); setOpen(false);
console.log(param); console.log(param);
saveJudgeTargets(param).then(() => { saveJudgeTargets(param).then((res) => {
if (res?.success) {
setSelectionModel([]); setSelectionModel([]);
search(); search();
} else {
showAlert.show(`${res?.data.message}`);
}
}); });
}; };

@ -1,80 +1,25 @@
import { useCallback, useEffect, useRef, useState } from 'react'; import { useCallback, useEffect, useState } from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import _ from 'lodash'; import _ from 'lodash';
import getYear from 'date-fns/getYear';
// material-ui // material-ui
import { GridActionsCellItem } from '@mui/x-data-grid'; import { GridActionsCellItem } from '@mui/x-data-grid';
import { Divider, FormControl, Grid, InputAdornment, Link, MenuItem, OutlinedInput, Select, Typography } from '@mui/material'; import { Divider, Grid, Typography } from '@mui/material';
import CreditScoreIcon from '@mui/icons-material/CreditScore'; import CreditScoreIcon from '@mui/icons-material/CreditScore';
import { IconSearch } from '@tabler/icons';
// berry ui // berry ui
import MainCard from 'ui-component/cards/MainCard'; import MainCard from 'ui-component/cards/MainCard';
// project imports // project imports
import MuiDataGrid from 'views/cmm/mui-grid/MuiDataGrid'; import MuiDataGrid from 'views/cmm/mui-grid/MuiDataGrid';
import InputLabel from 'ui-component/extended/Form/InputLabel';
import { findByUserJudges } from 'apis/judge'; import { findByUserJudges } from 'apis/judge';
import CmmModal from 'views/cmm/CmmModal'; import CmmModal from 'views/cmm/CmmModal';
import ProcessJudge from './ProcessJudge'; import ProcessJudge from './ProcessJudge';
import useAuth from 'hooks/useAuth'; import useAuth from 'hooks/useAuth';
import { Delete } from '@mui/icons-material';
import Button from '@mui/material/Button'; import Button from '@mui/material/Button';
import { useAlert } from 'react-alert'; 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 JudgeByUserReview = ({ msDatagb, menuName }) => {
const { user } = useAuth(); const { user } = useAuth();
const showAlert = useAlert(); const showAlert = useAlert();
@ -111,24 +56,14 @@ const JudgeByUserReview = ({ msDatagb, menuName }) => {
}); });
}, [msDatagb]); }, [msDatagb]);
const processJudge = useCallback( const processJudge = (row) => () => {
(row) => () => {
setTitle(`${menuName} 심의 - ${row.msSeq}`); setTitle(`${menuName} 심의 - ${row.msSeq}`);
setRowDatas([row]); setRowDatas([row]);
setOpen(true); setOpen(true);
}, };
[]
);
const columns = [ const columns = [
// { headerName: 'rowId', field: 'rowId' }, // { headerName: 'rowId', field: 'rowId' },
{
headerName: 'msMaincode',
headerAlign: 'center',
field: 'msMaincode',
align: 'center',
width: 100
},
{ {
headerName: '접수번호', headerName: '접수번호',
headerAlign: 'center', headerAlign: 'center',

@ -1,94 +1,50 @@
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { CardMedia, ImageList, ImageListItem } from '@mui/material'; import { CardMedia, Grid } from '@mui/material';
import { useDropzone } from 'react-dropzone'; import { findImages } from '../../../apis/judge';
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'; import _ from 'lodash';
const itemData = [ const ProcessJudge = (props) => {
{ const { rowDatas, showAlert } = props;
img: 'https://images.unsplash.com/photo-1551963831-b3b1ca40c98e', const [picadImgs, setPicadImgs] = useState([]);
title: 'Breakfast' const [frecadImgs, setFrecadImgs] = useState([]);
}, const [contadImgs, setContadImgs] = useState([]);
{
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 getImgList = (row) => {
const [previewImage, setPreviewImage] = useState(); findImages(row, showAlert).then((res) => {
const { arrPicadImg, arrFrecadImg, arrContadImg } = res;
const { getRootProps, getInputProps } = useDropzone({ console.log(res);
accept: 'image/*', // console.log(arrPicadImg, arrFrecadImg, arrContadImg);
onDrop: (acceptedFiles) => { setPicadImgs(arrPicadImg);
setPreviewImage(URL.createObjectURL(itemData[0].img)); setFrecadImgs(arrFrecadImg);
} setContadImgs(arrContadImg);
}); });
const viewImg = (scDatagb, scCode, methodName) => {
judgeFileDownload(
{
scDatagb,
scCode,
methodName
},
showAlert
);
}; };
// rowDatas[0]?[`scFrecad`];
// rowDatas[0]?[`scContad`];
// 1. - msMaincode gnRecallSc
// 2. - judgeFileDownload : data['scPicad1']
useEffect(() => { useEffect(() => {
rowDatas?.forEach((r) => _.range(1, 5, 1).forEach((idx) => viewImg(r.scDatagb, r.msMaincode, `scPicad${idx}`))); getImgList(rowDatas[0]);
}, []); }, []);
return ( return (
<> <>
<Grid container spacing={1}>
{picadImgs?.map((img, idx) => (
<Grid item xs={3} key={idx} columnSpacing={1}>
<CardMedia
component="img"
sx={{
height: 233,
width: 350,
maxHeight: { xs: 233, md: 167 },
maxWidth: { xs: 350, md: 250 }
}}
src={img}
/>
</Grid>
))}
</Grid>
<Grid container spacing={1}>
{frecadImgs?.map((img, idx) => (
<Grid item xs={3} key={idx} columnSpacing={1}>
<CardMedia <CardMedia
component="img" component="img"
sx={{ sx={{
@ -97,10 +53,15 @@ const ProcessJudge = ({ rowDatas, showAlert }) => {
maxHeight: { xs: 233, md: 167 }, maxHeight: { xs: 233, md: 167 },
maxWidth: { xs: 350, md: 250 } maxWidth: { xs: 350, md: 250 }
}} }}
src={itemData[0].img} src={img}
// src={previewImage}
/> />
<Box </Grid>
))}
</Grid>
<Grid container spacing={1}>
{contadImgs?.map((img, idx) => (
<Grid item xs={3} key={idx} columnSpacing={1}>
<CardMedia
component="img" component="img"
sx={{ sx={{
height: 233, height: 233,
@ -108,17 +69,18 @@ const ProcessJudge = ({ rowDatas, showAlert }) => {
maxHeight: { xs: 233, md: 167 }, maxHeight: { xs: 233, md: 167 },
maxWidth: { xs: 350, md: 250 } maxWidth: { xs: 350, md: 250 }
}} }}
alt="The house from the offer." src={img}
src={itemData[0].img}
/> />
<Image src={itemData[0].img} /> </Grid>
))}
</Grid>
</> </>
); );
}; };
ProcessJudge.propTypes = { // ProcessJudge.propTypes = {
rowDatas: PropTypes.array.isRequired, // rowDatas: PropTypes.object.isRequired,
showAlert: PropTypes.object // showAlert: PropTypes.object
}; // };
export default ProcessJudge; export default ProcessJudge;

Loading…
Cancel
Save