diff --git a/WebContent/WEB-INF/view/salesMng/salesRequestFormPopUp.jsp b/WebContent/WEB-INF/view/salesMng/salesRequestFormPopUp.jsp index e24d242..4344428 100644 --- a/WebContent/WEB-INF/view/salesMng/salesRequestFormPopUp.jsp +++ b/WebContent/WEB-INF/view/salesMng/salesRequestFormPopUp.jsp @@ -500,7 +500,7 @@ function fn_Supply_save(){ } } -// 구매요청서 확정 처리 +// 구매요청서 확정 처리 (저장 후 확정) function fn_confirm(){ var masterObjId = $("#SALES_REQUEST_MASTER_OBJID").val(); @@ -509,15 +509,28 @@ function fn_confirm(){ return; } - // 품목이 있는지 확인 if($("#partListArea tr").length < 1){ Swal.fire("품목이 없습니다. 먼저 품목을 추가하고 저장해주세요."); return; } + if(!fnc_validate("form1")){ + return; + } + + var zeroQty = false; + $("input[name*=QTY]").each(function(){ + if ($(this).val() == 0){ + Swal.fire('수량이 0 입니다.'); + zeroQty = true; + return false; + } + }); + if(zeroQty) return; + Swal.fire({ title: '확정', - text: '확정하시겠습니까? 확정 후에는 수정이 불가능합니다.', + text: '현재 내용을 저장하고 확정하시겠습니까? 확정 후에는 수정이 불가능합니다.', icon: 'warning', showCancelButton: true, confirmButtonColor: '#5cb85c', @@ -526,29 +539,46 @@ function fn_confirm(){ cancelButtonText: '취소' }).then((result) => { if (result.isConfirmed) { + // 폼 데이터를 먼저 저장 $.ajax({ type: "POST", - url: "/salesMng/confirmSalesRequest.do", - data: { "SALES_REQUEST_MASTER_OBJID": masterObjId }, + url: "/salesMng/saveSalesRequestInfo.do", + data: $("#form1").serialize(), dataType: "json", - success: function(data){ - if(data.result){ - Swal.fire({ - title: '완료', - text: '확정되었습니다.', - icon: 'success' - }).then(() => { - if(typeof opener.fn_search == "function"){ - opener.fn_search(); + success: function(saveData){ + if(saveData.result !== false){ + // 저장 성공 → 확정 처리 + $.ajax({ + type: "POST", + url: "/salesMng/confirmSalesRequest.do", + data: { "SALES_REQUEST_MASTER_OBJID": masterObjId }, + dataType: "json", + success: function(data){ + if(data.result){ + Swal.fire({ + title: '완료', + text: '저장 및 확정되었습니다.', + icon: 'success' + }).then(() => { + if(typeof opener.fn_search == "function"){ + opener.fn_search(); + } + self.close(); + }); + } else { + Swal.fire('오류', data.msg || '확정 처리 중 오류가 발생했습니다.', 'error'); + } + }, + error: function(jqxhr, status, error){ + Swal.fire('오류', '확정 처리 중 오류가 발생했습니다.', 'error'); } - self.close(); }); } else { - Swal.fire('오류', data.msg || '확정 처리 중 오류가 발생했습니다.', 'error'); + Swal.fire('오류', saveData.msg || '저장 중 오류가 발생했습니다.', 'error'); } }, error: function(jqxhr, status, error){ - Swal.fire('오류', '서버 통신 중 오류가 발생했습니다.', 'error'); + Swal.fire('오류', '저장 중 오류가 발생했습니다.', 'error'); } }); } diff --git a/src/com/pms/mapper/purchaseOrder.xml b/src/com/pms/mapper/purchaseOrder.xml index dfbe16f..4575f32 100644 --- a/src/com/pms/mapper/purchaseOrder.xml +++ b/src/com/pms/mapper/purchaseOrder.xml @@ -3476,7 +3476,7 @@ WHERE 1=1 - ORDER BY POM.REGDATE DESC + ORDER BY POM.REGDATE DESC, SPLIT_PART( PURCHASE_ORDER_NO, '-', 3)::NUMERIC DESC