From 50baa3d75e22e94047bb303efa5e3d83dd5cc7c6 Mon Sep 17 00:00:00 2001 From: hjjeong Date: Wed, 29 Oct 2025 17:59:19 +0900 Subject: [PATCH] =?UTF-8?q?=EC=9D=BC=EB=B0=98=EA=B2=AC=EC=A0=81=EC=84=9C?= =?UTF-8?q?=20=ED=85=9C=ED=94=8C=EB=A6=BF=20=EB=B3=80=EA=B2=BD,=20?= =?UTF-8?q?=EA=B2=AC=EC=A0=81=EC=84=9C=20pdf=20=EB=B3=80=ED=99=98=ED=95=98?= =?UTF-8?q?=EC=97=AC=20=EB=A9=94=EC=9D=BC=20=EC=B2=A8=EB=B6=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WebContent/WEB-INF/dispatcher-servlet.xml | 11 + .../view/contractMgmt/estimateList_new.jsp | 157 ++++++++- .../view/contractMgmt/estimateTemplate1.jsp | 302 +++++++++++++++--- src/com/pms/common/utils/MailUtil.java | 5 +- .../controller/ContractMgmtController.java | 13 +- .../service/ContractMgmtService.java | 278 ++++++++++------ tomcat-conf/server.xml | 8 +- 7 files changed, 621 insertions(+), 153 deletions(-) diff --git a/WebContent/WEB-INF/dispatcher-servlet.xml b/WebContent/WEB-INF/dispatcher-servlet.xml index 8a5b95d..0769b0a 100644 --- a/WebContent/WEB-INF/dispatcher-servlet.xml +++ b/WebContent/WEB-INF/dispatcher-servlet.xml @@ -42,6 +42,17 @@ + + + + + + + + + + + diff --git a/WebContent/WEB-INF/view/contractMgmt/estimateList_new.jsp b/WebContent/WEB-INF/view/contractMgmt/estimateList_new.jsp index 1948ab4..bf768b7 100644 --- a/WebContent/WEB-INF/view/contractMgmt/estimateList_new.jsp +++ b/WebContent/WEB-INF/view/contractMgmt/estimateList_new.jsp @@ -668,21 +668,169 @@ function fn_sendEstimateMail(contractObjId){ return; } + // 1단계: 견적서 템플릿 정보 조회 Swal.fire({ - title: '메일 발송 중...', + title: '견적서 조회 중...', text: '잠시만 기다려주세요.', allowOutsideClick: false, - didOpen: () => { + onOpen: () => { Swal.showLoading(); } }); $.ajax({ - url: "/contractMgmt/sendEstimateMail.do", + url: "/contractMgmt/getEstimateTemplateList.do", type: "POST", data: { objId: contractObjId }, dataType: "json", success: function(data){ + if(data.result === "success" && data.list && data.list.length > 0){ + // 최종 차수 견적서 찾기 + var latestEstimate = data.list[0]; // 이미 차수 내림차순으로 정렬되어 있음 + var templateObjId = latestEstimate.OBJID || latestEstimate.objid; + var templateType = latestEstimate.TEMPLATE_TYPE || latestEstimate.template_type || latestEstimate.templateType; + + // 2단계: 견적서 페이지를 새 창으로 열고 PDF 생성 + fn_generatePdfAndSendMail(contractObjId, templateObjId, templateType); + } else { + Swal.close(); + Swal.fire({ + title: '오류', + text: '견적서를 찾을 수 없습니다.', + icon: 'error' + }); + } + }, + error: function(xhr, status, error){ + Swal.close(); + console.error("견적서 조회 오류:", xhr, status, error); + Swal.fire({ + title: '오류', + text: '견적서 조회 중 오류가 발생했습니다.', + icon: 'error' + }); + } + }); +} + +// PDF 생성 및 메일 발송 +function fn_generatePdfAndSendMail(contractObjId, templateObjId, templateType){ + Swal.fire({ + title: 'PDF 생성 중...', + text: '견적서를 PDF로 변환하고 있습니다.', + allowOutsideClick: false, + onOpen: () => { + Swal.showLoading(); + } + }); + + // 견적서 페이지 URL 생성 + var url = ""; + if(templateType === "1"){ + url = "/contractMgmt/estimateTemplate1.do?templateObjId=" + templateObjId; + } else if(templateType === "2"){ + url = "/contractMgmt/estimateTemplate2.do?templateObjId=" + templateObjId; + } + + // 숨겨진 iframe으로 페이지 로드 + var iframe = $('