feat: 심사자 심의 진행

main
minuk926 3 years ago
parent d857215587
commit 3d454f8beb

@ -19,6 +19,7 @@ import {
} from 'commons/ApiUrl';
import { setRowId } from './common';
import FileSaver from 'file-saver';
import _ from 'lodash';
// eslint-disable-next-line no-return-await
export async function findJudgeDatas(params) {
@ -131,28 +132,15 @@ export async function judgeFileDownload(params, alert) {
})
// eslint-disable-next-line consistent-return
.then((res) => {
if (res?.isAxiosError || res?.status === 404) {
if (res?.isAxiosError || res?.status === 404 || res?.size <= 0) {
alert.show('파일을 다운로드 할 수 없습니다 [파일정보 오류]');
} 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
if (res?.type.includes('image')) {
// const url = window.URL.createObjectURL(res);
alert.show(<img alt="~~~" src={URL.createObjectURL(res)} style={{ margin: 'auto' }} />);
// URL.revokeObjectURL()
} else {
FileSaver.saveAs(res, 'filename');
}
@ -171,3 +159,52 @@ export async function findByUserJudges(params) {
}
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(
(response) => {
Swal.close();
if (!response.data.success) {
// multipart (blob) 요청인 경우 response.data?.success === 'undefined'
if (typeof response.data?.success !== 'undefined' && !response.data?.success) {
Swal.fire({
icon: 'error',
title: 'Api Error',

@ -20,8 +20,10 @@ import NumberFormat from 'react-number-format';
import ExcelDownload from 'views/cmm/file-ctl/ExcelDownload';
import { findJudgeTargets, saveJudgeTargets } from 'apis/judge';
import PropTypes from 'prop-types';
import { useAlert } from 'react-alert';
const JudgeRegistReview = ({ scDatagb, menuName }) => {
const showAlert = useAlert();
const [scTransfer, setScTransfer] = useState('1');
const [scSeq1, setScSeq1] = useState(2022000001);
const [scSeq2, setScSeq2] = useState(2022000899);
@ -94,9 +96,13 @@ const JudgeRegistReview = ({ scDatagb, menuName }) => {
setOpen(false);
console.log(param);
saveJudgeTargets(param).then(() => {
saveJudgeTargets(param).then((res) => {
if (res?.success) {
setSelectionModel([]);
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 _ 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 { Divider, Grid, 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();
@ -111,24 +56,14 @@ const JudgeByUserReview = ({ msDatagb, menuName }) => {
});
}, [msDatagb]);
const processJudge = useCallback(
(row) => () => {
const processJudge = (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',

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

Loading…
Cancel
Save