diff --git a/src/apis/judge.js b/src/apis/judge.js index 8d53737..4f200f0 100644 --- a/src/apis/judge.js +++ b/src/apis/judge.js @@ -23,7 +23,8 @@ import { GET_PARKING_IMAGE2, GET_PARKING_FRECAD_IMAGE, GET_PARKING_CONTAD_IMAGE, - GET_PARKING_PICAD_IMAGE + GET_PARKING_PICAD_IMAGE, + GET_PARKING_JUDGE_FILE_DOWNLOAD } from 'commons/ApiUrl'; import { setRowId } from './common'; import FileSaver from 'file-saver'; @@ -235,6 +236,33 @@ export async function findJudgeImages(row) { return res; } +async function parkingJudgeImgList(arrImgInfo, fieldName) { + console.log(arrImgInfo); + const arrRtn = []; + // eslint-disable-next-line no-restricted-syntax + for (const idx of _.range(1, arrImgInfo.length + 1, 1)) { + if (arrImgInfo[idx - 1].imgName) { + // eslint-disable-next-line no-await-in-loop + await axios + .get(GET_PARKING_JUDGE_FILE_DOWNLOAD, { + responseType: 'blob', + params: { absFileName: arrImgInfo[idx - 1].url } + }) + // eslint-disable-next-line no-loop-func + .then((r) => { + if (r.size > 0) { + arrRtn.push({ imgName: arrImgInfo[idx - 1].imgName, url: URL.createObjectURL(r) }); + } else { + arrRtn.push({ imgName: arrImgInfo[idx - 1].imgName, url: '/images/noFile.png' }); + } + }); + } else { + arrRtn.push({ imgName: '', url: '/images/noImage.png' }); + } + } + return arrRtn; +} + export async function saveJudgeResult(params) { // eslint-disable-next-line no-return-await return await axios.post(SAVE_JUDGE_RESULT, params); @@ -247,10 +275,16 @@ export async function findParkingImages(rcMaincode) { await axios.get(GET_PARKING_PICAD_IMAGE + rcMaincode) ]); + const [frecads, contads, picads] = await Promise.all([ + parkingJudgeImgList(frecadImgs?.data, 'frecad'), + parkingJudgeImgList(contadImgs?.data, 'contad'), + parkingJudgeImgList(picadImgs?.data, 'picad') + ]); + return { - arrFrecadImg: frecadImgs?.data ?? [], - arrContadImg: contadImgs?.data ?? [], - arrPicadImg: picadImgs?.data ?? [] + arrFrecadImg: frecads, + arrContadImg: contads, + arrPicadImg: picads }; } diff --git a/src/commons/ApiUrl.js b/src/commons/ApiUrl.js index 7e53332..807ca8f 100644 --- a/src/commons/ApiUrl.js +++ b/src/commons/ApiUrl.js @@ -51,6 +51,7 @@ export const GET_PARKING_CONTAD_IMAGE = '/api/v2/ctgy/parking/judge/contad/'; export const SAVE_PARKING_JUDGE_RESULT = '/api/v2/ctgy/parking/judge'; export const GET_JUDGE_FILE_DOWNLOAD = '/api/v2/ctgy/cmm/download/judge'; +export const GET_PARKING_JUDGE_FILE_DOWNLOAD = '/api/v2/ctgy/cmm/download/park'; // 사용자 관리 export const GET_USER_LIST = '/api/v2/ctgy/user'; diff --git a/src/views/biz/judge/ProcessParkingJudge.jsx b/src/views/biz/judge/ProcessParkingJudge.jsx index 6abeb27..a7a909b 100644 --- a/src/views/biz/judge/ProcessParkingJudge.jsx +++ b/src/views/biz/judge/ProcessParkingJudge.jsx @@ -94,7 +94,7 @@ const ProcessParkingJudge = (props) => { return ( <> - + {frecadImgs?.map((img, idx) => ( @@ -111,23 +111,18 @@ const ProcessParkingJudge = (props) => { ))} - + {selectedImg && ( - {selectedImg.imgName} + + {selectedImg.imgName} + )} - +