From 0303af2827423140b39fdd4390e1a8e0217a8792 Mon Sep 17 00:00:00 2001 From: minuk926 Date: Thu, 14 Jul 2022 21:42:07 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=A3=BC=EC=A0=95=EC=B0=A8=20=EC=8B=AC?= =?UTF-8?q?=EC=82=AC=20=EB=B0=98=EC=98=81=20=EC=99=84=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/judge.js | 42 +++++++++++++++++++-- src/commons/ApiUrl.js | 1 + src/views/biz/judge/ProcessParkingJudge.jsx | 17 +++------ 3 files changed, 45 insertions(+), 15 deletions(-) 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} + )} - +