From 5a487640cebfe1f293c3121679b5d53c33eb5adc Mon Sep 17 00:00:00 2001 From: leebeomjun Date: Mon, 18 Mar 2024 15:22:56 +0900 Subject: [PATCH] =?UTF-8?q?=EB=8F=99=EA=B8=B0=EC=8B=9D=20=EB=8C=80?= =?UTF-8?q?=ED=99=94=EC=83=81=EC=9E=90=20=EB=8B=A4=EC=9D=B4=EC=96=BC?= =?UTF-8?q?=EB=A1=9C=EA=B7=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../webapp/resources/js/base/base-fims.js | 67 +++++++++++++++---- .../webapp/resources/js/fims/photo-main.js | 8 +-- 2 files changed, 59 insertions(+), 16 deletions(-) diff --git a/src/main/webapp/resources/js/base/base-fims.js b/src/main/webapp/resources/js/base/base-fims.js index 85654e41..2453c3ca 100644 --- a/src/main/webapp/resources/js/base/base-fims.js +++ b/src/main/webapp/resources/js/base/base-fims.js @@ -1,3 +1,58 @@ +/************************************************************************** +* 동기식 대화상자 +**************************************************************************/ +async function confirm2(msg){ + return await dialog2(msg, "confirm"); +} + +async function alert2(msg){ + return await dialog2(msg, "alert"); +} + +async function dialog2(msg, type){ + var dlgId = "dlg-" + uuid(); + var resp = await fetch(wctx.url("/resources/html/dialog.html")); + var template = await resp.text(); + var container = "
{content}
"; + content = container.replace(/{content}/g, msg); + var backdropID = dlgId + "-backdrop"; + var tmpl = template.replace(/{id}/g, dlgId).replace(/{title}/g, "").replace(/{size}/, "").replace("",""); + tmpl = tmpl.replace("data-bs-backdrop=\"static\"", "data-bs-backdrop=\"static\" data-bs-keyboard=\"false\""); + tmpl = tmpl.replace("text-end hidden","text-end"); + tmpl = tmpl.replace("btn-primary","btn-primary btn-ok"); + var dlg = $(tmpl).appendTo("body"); + if(type == "confirm"){ + dlg.find(".modal-footer").append(''); + } + dlg.find(".modal-header").remove(); + dlg.find(".modal-body").html(content).fadeIn(); + dlg.on("hidden.bs.modal", function() { + $("#" + dlgId +",#" + backdropID).remove(); + }); + dlg.modal("show"); + $(".modal-backdrop").each(function() { + var backdrop = $(this); + if (!backdrop.prop("id")){ + backdrop.prop("id", backdropID); + } + }); + + setDialogZindex(); + + return new Promise(resolve => { + dlg[0].querySelector(".btn-ok").addEventListener("click", () => { + dlg.modal("hide"); + resolve(true); + }); + if(type == "confirm"){ + dlg[0].querySelector(".btn-cancel").addEventListener("click", () => { + dlg.modal("hide"); + resolve(false); + }); + } + }); +} + /************************************************************************** * 모달창 z-index 초기화 **************************************************************************/ @@ -40,18 +95,6 @@ function focusOK() { }); } -/************************************************************************** -* 파일 다운로드 -**************************************************************************/ -function downloadFile(filePath, fileName, tempAreaId){ - var a = document.createElement("a"); - a.href = resp.filePath; - a.download = resp.fileName; - document.getElementById(tempAreaId).appendChild(a); - a.click(); - document.getElementById(tempAreaId).removeChild(a); -} - /************************************************************************** * pdf파일 미리보기 창 **************************************************************************/ diff --git a/src/main/webapp/resources/js/fims/photo-main.js b/src/main/webapp/resources/js/fims/photo-main.js index 4838f56b..308b0352 100644 --- a/src/main/webapp/resources/js/fims/photo-main.js +++ b/src/main/webapp/resources/js/fims/photo-main.js @@ -35,10 +35,10 @@ function settingPhotoMain(pageName, crdnIdElementId, carInfoFunc, carLinkFunc){ }); //편집버튼 - $("#btnEditPhoto--"+pageName).on('click', () => { + $("#btnEditPhoto--"+pageName).on('click', async() => { var checked = $("#displayForExist--"+pageName).find("[name='existPhoto']:checked"); if(checked.length < 1){ - alert("선택된 사진이 없습니다."); + await alert2("선택된 사진이 없습니다."); return; } @@ -50,11 +50,11 @@ function settingPhotoMain(pageName, crdnIdElementId, carInfoFunc, carLinkFunc){ ); }); //삭제버튼 - $("#btnDeleteExistPhoto--"+pageName).on('click', () => { + $("#btnDeleteExistPhoto--"+pageName).on('click', async() => { var checked = $("#displayForExist--"+pageName).find("[name='existPhoto']:checked"); if(checked.length < 1){ - alert("선택된 사진이 없습니다."); + await alert2("선택된 사진이 없습니다."); return; }