구매리스트 가공 추가, 품의서 생성도 소재, 가공 분리
This commit is contained in:
@@ -461,32 +461,8 @@ function fn_initGrid() {
|
||||
title: '지급/사급',
|
||||
field: 'SUPPLY_TYPE'
|
||||
},
|
||||
// 17. 소재
|
||||
{
|
||||
headerHozAlign: 'center',
|
||||
hozAlign: 'left',
|
||||
width: 100,
|
||||
title: '소재',
|
||||
field: 'RAW_MATERIAL'
|
||||
},
|
||||
// 18. 사이즈
|
||||
{
|
||||
headerHozAlign: 'center',
|
||||
hozAlign: 'left',
|
||||
width: 100,
|
||||
title: '사이즈',
|
||||
field: 'SIZE'
|
||||
},
|
||||
// 19. 소재품번
|
||||
{
|
||||
headerHozAlign: 'center',
|
||||
hozAlign: 'center',
|
||||
width: 120,
|
||||
title: '소재품번',
|
||||
field: 'RAW_MATERIAL_NO'
|
||||
},
|
||||
// 20. 소재소요량
|
||||
{
|
||||
// 20. 소재소요량
|
||||
{
|
||||
headerHozAlign: 'center',
|
||||
hozAlign: 'right',
|
||||
width: 100,
|
||||
@@ -529,27 +505,46 @@ function fn_initGrid() {
|
||||
return value ? Number(value).toLocaleString() : '0';
|
||||
}
|
||||
},
|
||||
// 24. 가공업체 (수정가능 - Select2 에디터)
|
||||
|
||||
// 17. 소재 -> 소재재질
|
||||
{
|
||||
headerHozAlign: 'center',
|
||||
hozAlign: 'left',
|
||||
width: 100,
|
||||
title: '소재재질',
|
||||
field: 'RAW_MATERIAL'
|
||||
},
|
||||
// 18. 사이즈 -> 규격
|
||||
{
|
||||
headerHozAlign: 'center',
|
||||
hozAlign: 'left',
|
||||
width: 100,
|
||||
title: '규격',
|
||||
field: 'SIZE'
|
||||
},
|
||||
// 19. 소재품번
|
||||
{
|
||||
headerHozAlign: 'center',
|
||||
hozAlign: 'center',
|
||||
width: 120,
|
||||
title: '소재품번',
|
||||
field: 'RAW_MATERIAL_NO'
|
||||
},
|
||||
// 30. 공급업체 (수정가능 - Select2 에디터)
|
||||
{
|
||||
headerHozAlign: 'center',
|
||||
hozAlign: 'left',
|
||||
width: 150,
|
||||
title: '<span style="background-color: #FFFF00; padding: 2px 5px;">가공업체</span>',
|
||||
field: 'PROCESSING_VENDOR',
|
||||
title: '<span style="background-color: #FFFF00; padding: 2px 5px;">공급업체</span>',
|
||||
field: 'VENDOR_PM',
|
||||
editor: function(cell, onRendered, success, cancel, editorParams) {
|
||||
// Select2 에디터
|
||||
// Select2 에디터 (가공업체와 동일한 목록 사용)
|
||||
return createSelect2Editor(processingVendorList)(cell, onRendered, success, cancel, editorParams);
|
||||
},
|
||||
formatter: function(cell) {
|
||||
var value = cell.getValue();
|
||||
|
||||
// 저장된 값이 없으면 기본값 '5001'(RPS) 설정
|
||||
if(value === undefined || value === null || value === '') {
|
||||
value = '5001';
|
||||
cell.getRow().update({PROCESSING_VENDOR: value}, false);
|
||||
}
|
||||
|
||||
// OBJID로 업체명 조회하여 표시
|
||||
if(!value) return '';
|
||||
// processingVendorList에서 해당 값의 이름 찾기
|
||||
for(var i = 0; i < processingVendorList.length; i++) {
|
||||
if(processingVendorList[i].id == value) {
|
||||
return processingVendorList[i].text;
|
||||
@@ -558,27 +553,41 @@ function fn_initGrid() {
|
||||
return value;
|
||||
}
|
||||
},
|
||||
/* // 25. 가공납기 - 주석처리
|
||||
// 31. 단가 (수정가능) -> 소재단가
|
||||
{
|
||||
headerHozAlign: 'center',
|
||||
hozAlign: 'center',
|
||||
hozAlign: 'right',
|
||||
width: 100,
|
||||
title: '가공납기',
|
||||
field: 'PROCESSING_DEADLINE'
|
||||
title: '<span style="background-color: #FFFF00; padding: 2px 5px;">소재단가</span>',
|
||||
field: 'UNIT_PRICE',
|
||||
editor: 'number',
|
||||
editable: true,
|
||||
formatter: function(cell) {
|
||||
var value = cell.getValue();
|
||||
return value ? Number(value).toLocaleString() : '0';
|
||||
}
|
||||
},
|
||||
// 26. 연삭납기
|
||||
// 32. 총단가 -> 소재총단가
|
||||
{
|
||||
headerHozAlign: 'center',
|
||||
hozAlign: 'center',
|
||||
hozAlign: 'right',
|
||||
width: 100,
|
||||
title: '연삭납기',
|
||||
field: 'GRINDING_DEADLINE'
|
||||
}, */
|
||||
title: '소재총단가',
|
||||
field: 'TOTAL_PRICE',
|
||||
formatter: function(cell) {
|
||||
var data = cell.getRow().getData();
|
||||
var qty = parseFloat(data.PO_QTY) || 0;
|
||||
var unitPrice = parseFloat(data.UNIT_PRICE) || 0;
|
||||
var totalPrice = qty * unitPrice;
|
||||
return totalPrice > 0 ? totalPrice.toLocaleString() : '0';
|
||||
}
|
||||
},
|
||||
|
||||
// 27. 사용여부 (수정가능)
|
||||
{
|
||||
headerHozAlign: 'center',
|
||||
hozAlign: 'center',
|
||||
width: 80,
|
||||
width: 90,
|
||||
title: '<span style="background-color: #FFFF00; padding: 2px 5px;">사용여부</span>',
|
||||
field: 'USE_YN',
|
||||
editor: 'list',
|
||||
@@ -638,21 +647,28 @@ function fn_initGrid() {
|
||||
return value ? Number(value).toLocaleString() : '0';
|
||||
}
|
||||
},
|
||||
// 30. 공급업체 (수정가능 - Select2 에디터)
|
||||
|
||||
// 24. 가공업체 (수정가능 - Select2 에디터)
|
||||
{
|
||||
headerHozAlign: 'center',
|
||||
hozAlign: 'left',
|
||||
width: 150,
|
||||
title: '<span style="background-color: #FFFF00; padding: 2px 5px;">공급업체</span>',
|
||||
field: 'VENDOR_PM',
|
||||
title: '<span style="background-color: #FFFF00; padding: 2px 5px;">가공업체</span>',
|
||||
field: 'PROCESSING_VENDOR',
|
||||
editor: function(cell, onRendered, success, cancel, editorParams) {
|
||||
// Select2 에디터 (가공업체와 동일한 목록 사용)
|
||||
// Select2 에디터
|
||||
return createSelect2Editor(processingVendorList)(cell, onRendered, success, cancel, editorParams);
|
||||
},
|
||||
formatter: function(cell) {
|
||||
var value = cell.getValue();
|
||||
if(!value) return '';
|
||||
// processingVendorList에서 해당 값의 이름 찾기
|
||||
|
||||
// 저장된 값이 없으면 기본값 '5001'(RPS) 설정
|
||||
if(value === undefined || value === null || value === '') {
|
||||
value = '5001';
|
||||
cell.getRow().update({PROCESSING_VENDOR: value}, false);
|
||||
}
|
||||
|
||||
// OBJID로 업체명 조회하여 표시
|
||||
for(var i = 0; i < processingVendorList.length; i++) {
|
||||
if(processingVendorList[i].id == value) {
|
||||
return processingVendorList[i].text;
|
||||
@@ -661,13 +677,13 @@ function fn_initGrid() {
|
||||
return value;
|
||||
}
|
||||
},
|
||||
// 31. 단가 (수정가능)
|
||||
// 가공단가 (수정가능)
|
||||
{
|
||||
headerHozAlign: 'center',
|
||||
hozAlign: 'right',
|
||||
width: 100,
|
||||
title: '<span style="background-color: #FFFF00; padding: 2px 5px;">단가</span>',
|
||||
field: 'UNIT_PRICE',
|
||||
title: '<span style="background-color: #FFFF00; padding: 2px 5px;">가공단가</span>',
|
||||
field: 'PROCESSING_UNIT_PRICE',
|
||||
editor: 'number',
|
||||
editable: true,
|
||||
formatter: function(cell) {
|
||||
@@ -675,28 +691,94 @@ function fn_initGrid() {
|
||||
return value ? Number(value).toLocaleString() : '0';
|
||||
}
|
||||
},
|
||||
// 32. 총단가
|
||||
// 가공총단가 (가공단가 × 제작수량)
|
||||
{
|
||||
headerHozAlign: 'center',
|
||||
hozAlign: 'right',
|
||||
width: 100,
|
||||
title: '총단가',
|
||||
field: 'TOTAL_PRICE',
|
||||
title: '가공총단가',
|
||||
field: 'PROCESSING_TOTAL_PRICE',
|
||||
formatter: function(cell) {
|
||||
var data = cell.getRow().getData();
|
||||
var qty = parseFloat(data.PO_QTY) || 0;
|
||||
var unitPrice = parseFloat(data.UNIT_PRICE) || 0;
|
||||
var totalPrice = qty * unitPrice;
|
||||
return totalPrice > 0 ? totalPrice.toLocaleString() : '0';
|
||||
var productionQty = parseFloat(data.PRODUCTION_QTY) || 0;
|
||||
var processingUnitPrice = parseFloat(data.PROCESSING_UNIT_PRICE) || 0;
|
||||
var processingTotalPrice = productionQty * processingUnitPrice;
|
||||
return processingTotalPrice > 0 ? processingTotalPrice.toLocaleString() : '0';
|
||||
}
|
||||
},
|
||||
// 33. 품의서작성일
|
||||
// 총합계 (소재총단가 + 가공총단가)
|
||||
{
|
||||
headerHozAlign: 'center',
|
||||
hozAlign: 'right',
|
||||
width: 100,
|
||||
title: '총합계',
|
||||
field: 'GRAND_TOTAL_PRICE',
|
||||
formatter: function(cell) {
|
||||
var data = cell.getRow().getData();
|
||||
// 소재총단가: 발주수량 × 소재단가
|
||||
var poQty = parseFloat(data.PO_QTY) || 0;
|
||||
var unitPrice = parseFloat(data.UNIT_PRICE) || 0;
|
||||
var materialTotalPrice = poQty * unitPrice;
|
||||
// 가공총단가: 제작수량 × 가공단가
|
||||
var productionQty = parseFloat(data.PRODUCTION_QTY) || 0;
|
||||
var processingUnitPrice = parseFloat(data.PROCESSING_UNIT_PRICE) || 0;
|
||||
var processingTotalPrice = productionQty * processingUnitPrice;
|
||||
// 총합계
|
||||
var grandTotal = materialTotalPrice + processingTotalPrice;
|
||||
return grandTotal > 0 ? grandTotal.toLocaleString() : '0';
|
||||
}
|
||||
},
|
||||
/* // 25. 가공납기 - 주석처리
|
||||
{
|
||||
headerHozAlign: 'center',
|
||||
hozAlign: 'center',
|
||||
width: 100,
|
||||
title: '품의서작성일',
|
||||
field: 'PROPOSAL_DATE'
|
||||
title: '가공납기',
|
||||
field: 'PROCESSING_DEADLINE'
|
||||
},
|
||||
// 26. 연삭납기
|
||||
{
|
||||
headerHozAlign: 'center',
|
||||
hozAlign: 'center',
|
||||
width: 100,
|
||||
title: '연삭납기',
|
||||
field: 'GRINDING_DEADLINE'
|
||||
}, */
|
||||
|
||||
|
||||
// 33. 소재 품의서작성일
|
||||
{
|
||||
headerHozAlign: 'center',
|
||||
hozAlign: 'center',
|
||||
width: 110,
|
||||
title: '소재품의서일',
|
||||
field: 'PROPOSAL_DATE',
|
||||
formatter: function(cell) {
|
||||
var value = cell.getValue();
|
||||
if(!value) return '';
|
||||
// YYYY-MM-DD 형식으로 표시
|
||||
if(value.length >= 10) {
|
||||
return value.substring(0, 10);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
},
|
||||
// 34. 가공 품의서작성일
|
||||
{
|
||||
headerHozAlign: 'center',
|
||||
hozAlign: 'center',
|
||||
width: 110,
|
||||
title: '가공품의서일',
|
||||
field: 'PROCESSING_PROPOSAL_DATE',
|
||||
formatter: function(cell) {
|
||||
var value = cell.getValue();
|
||||
if(!value) return '';
|
||||
// YYYY-MM-DD 형식으로 표시
|
||||
if(value.length >= 10) {
|
||||
return value.substring(0, 10);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
@@ -719,8 +801,8 @@ function fn_initGrid() {
|
||||
var row = cell.getRow();
|
||||
var data = row.getData();
|
||||
|
||||
// 발주수량 또는 단가 변경 시 총단가 자동 계산
|
||||
if(field === 'PO_QTY' || field === 'UNIT_PRICE') {
|
||||
// 발주수량, 소재단가, 가공단가 변경 시 총단가 자동 계산
|
||||
if(field === 'PO_QTY' || field === 'UNIT_PRICE' || field === 'PROCESSING_UNIT_PRICE') {
|
||||
row.reformat();
|
||||
}
|
||||
});
|
||||
@@ -856,11 +938,19 @@ function fn_save() {
|
||||
|
||||
// 저장 전 데이터 가공
|
||||
gridData.forEach(function(item) {
|
||||
// TOTAL_PRICE 계산 (PO_QTY * UNIT_PRICE)
|
||||
// 소재총단가 계산 (PO_QTY * UNIT_PRICE)
|
||||
var poQty = parseFloat(item.PO_QTY) || 0;
|
||||
var unitPrice = parseFloat(item.UNIT_PRICE) || 0;
|
||||
item.TOTAL_PRICE = poQty * unitPrice;
|
||||
|
||||
// 가공총단가 계산 (PRODUCTION_QTY * PROCESSING_UNIT_PRICE)
|
||||
var productionQty = parseFloat(item.PRODUCTION_QTY) || 0;
|
||||
var processingUnitPrice = parseFloat(item.PROCESSING_UNIT_PRICE) || 0;
|
||||
item.PROCESSING_TOTAL_PRICE = productionQty * processingUnitPrice;
|
||||
|
||||
// 총합계 계산 (소재총단가 + 가공총단가)
|
||||
item.GRAND_TOTAL_PRICE = item.TOTAL_PRICE + item.PROCESSING_TOTAL_PRICE;
|
||||
|
||||
// 사용여부 변환: 사용/미사용 → Y/N
|
||||
if(item.USE_YN === '사용') {
|
||||
item.USE_YN = 'Y';
|
||||
|
||||
@@ -196,7 +196,7 @@ var columns = [
|
||||
,{headerHozAlign : 'center', hozAlign : 'center', title : "유/무상", field :"PAID_TYPE_NAME" , widthGrow:0.9 }
|
||||
,{headerHozAlign : 'center', hozAlign : 'left', title : "품번", field :"PART_NO" , widthGrow:1.4}
|
||||
,{headerHozAlign : 'center', hozAlign : 'left' , title : "품명", field :"PART_NAME" , widthGrow:1.8 }
|
||||
,{headerHozAlign : 'center', hozAlign : 'center', title : "구매요청서", field :"HAS_PURCHASE_REQUEST" , widthGrow:1.1,
|
||||
,{headerHozAlign : 'center', hozAlign : 'center', title : "견적요청서", field :"HAS_PURCHASE_REQUEST" , widthGrow:1.1,
|
||||
formatter: function(cell, formatterParams, onRendered){
|
||||
// 구매요청서 작성 여부: HAS_PURCHASE_REQUEST가 'Y'이면 구매요청서 작성됨
|
||||
var data = cell.getData();
|
||||
@@ -214,6 +214,24 @@ var columns = [
|
||||
}
|
||||
}
|
||||
}
|
||||
// ,{headerHozAlign : 'center', hozAlign : 'center', title : "구매요청서", field :"HAS_PURCHASE_REQUEST" , widthGrow:1.1,
|
||||
// formatter: function(cell, formatterParams, onRendered){
|
||||
// // 구매요청서 작성 여부: HAS_PURCHASE_REQUEST가 'Y'이면 구매요청서 작성됨
|
||||
// var data = cell.getData();
|
||||
// var hasPurchaseRequest = fnc_checkNull(data.HAS_PURCHASE_REQUEST);
|
||||
// var iconClass = (hasPurchaseRequest == 'Y') ? 'file_icon' : 'file_empty_icon';
|
||||
// return '<a href="#" class="File ' + iconClass + '" style="width:20px; height:20px; display:inline-block;"></a>';
|
||||
// },
|
||||
// cellClick : function(e, cell) {
|
||||
// var data = cell.getData();
|
||||
// var hasPurchaseRequest = fnc_checkNull(data.HAS_PURCHASE_REQUEST);
|
||||
|
||||
// // 구매요청서가 작성된 경우(파란색 아이콘)만 팝업 열기
|
||||
// if(hasPurchaseRequest == 'Y') {
|
||||
// fn_openSalesRequestFormPopUp(data.OBJID);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
,{headerHozAlign : 'center', hozAlign : 'center', title : "요청인", field :"REQUEST_USER_NAME" , widthGrow:1.1,
|
||||
// 요청인: 구매요청서 작성 시에만 표시
|
||||
formatter: function(cell, formatterParams, onRendered){
|
||||
@@ -297,7 +315,7 @@ function fn_openSalesRequestPopUp(objId){
|
||||
if(mbomHeaderObjid) {
|
||||
url += "&MBOM_HEADER_OBJID=" + mbomHeaderObjid;
|
||||
}
|
||||
window.open(url,"purchaseListPopUp","width=1400,height=800,scrollbars=yes,resizable=yes");
|
||||
window.open(url,"purchaseListPopUp","width=1800,height=800,scrollbars=yes,resizable=yes");
|
||||
}
|
||||
|
||||
//구매요청서 작성 팝업 (구매요청서 파일 아이콘 클릭 시)
|
||||
@@ -489,9 +507,9 @@ function fn_formPopUp(objId,sales_request_objid){
|
||||
|
||||
/**
|
||||
* 품의서 생성 함수
|
||||
* - 선택된 구매요청서에서 단가가 입력된 품목만 필터링
|
||||
* - 선택된 구매요청서에서 소재단가/가공단가가 입력된 품목만 필터링
|
||||
* - 이미 품의서가 생성된 품목은 제외
|
||||
* - 하나의 품의서로 생성
|
||||
* - 소재/가공 각각 별도 품의서 생성
|
||||
*/
|
||||
function fn_createProposal() {
|
||||
// 1. 선택된 행 확인
|
||||
@@ -528,79 +546,73 @@ function fn_createProposal() {
|
||||
dataType: "json",
|
||||
success: function(response) {
|
||||
if(response.resultFlag === "S") {
|
||||
var targetParts = response.data;
|
||||
var excludedParts = response.excludedParts || []; // 공급업체 미입력 품목
|
||||
var materialParts = response.materialTargetParts || [];
|
||||
var processingParts = response.processingTargetParts || [];
|
||||
var materialExcluded = response.materialExcludedParts || [];
|
||||
var processingExcluded = response.processingExcludedParts || [];
|
||||
|
||||
// 3. 대상 품목 확인
|
||||
if(!targetParts || targetParts.length == 0) {
|
||||
if(materialParts.length == 0 && processingParts.length == 0) {
|
||||
var excludedHtml = fn_buildExcludedHtml(materialExcluded, processingExcluded);
|
||||
Swal.fire({
|
||||
title: '알림',
|
||||
text: '품의서를 생성할 품목이 없습니다.\n(단가와 공급업체가 모두 입력되고 품의서가 생성되지 않은 품목만 대상)',
|
||||
html: '품의서를 생성할 품목이 없습니다.<br/>(소재단가+공급업체 또는 가공단가+가공업체가 입력되고 품의서가 생성되지 않은 품목만 대상)' + excludedHtml,
|
||||
icon: 'info'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// 4. 품의서 생성 확인
|
||||
var partCount = targetParts.length;
|
||||
var partListHtml = targetParts.map(function(part) {
|
||||
return '- ' + fnc_checkNull(part.PART_NO) + ' / ' + fnc_checkNull(part.PART_NAME);
|
||||
}).join('<br/>');
|
||||
// 4. 품의서 생성 확인 - 소재/가공 구분 표시
|
||||
var confirmHtml = '<div style="text-align:left;">';
|
||||
|
||||
// 공급업체 미입력으로 제외된 품목이 있는 경우 알림 추가
|
||||
var excludedHtml = '';
|
||||
if(excludedParts && excludedParts.length > 0) {
|
||||
var excludedListHtml = excludedParts.map(function(part) {
|
||||
// 소재 품의서 대상
|
||||
if(materialParts.length > 0) {
|
||||
var materialListHtml = materialParts.map(function(part) {
|
||||
return '- ' + fnc_checkNull(part.PART_NO) + ' / ' + fnc_checkNull(part.PART_NAME);
|
||||
}).join('<br/>');
|
||||
|
||||
excludedHtml = '<div style="margin-top:15px; padding:10px; background-color:#fff3cd; border:1px solid #ffc107; border-radius:4px;">' +
|
||||
'<p style="color:#856404; font-weight:bold; margin-bottom:5px;">⚠️ 공급업체 미입력으로 제외된 품목 (' + excludedParts.length + '건)</p>' +
|
||||
'<div style="max-height:100px; overflow-y:auto; font-size:11px; color:#856404;">' +
|
||||
excludedListHtml +
|
||||
'</div>' +
|
||||
confirmHtml += '<div style="margin-bottom:15px; padding:10px; background-color:#e3f2fd; border:1px solid #2196F3; border-radius:4px;">' +
|
||||
'<p style="color:#1565C0; font-weight:bold; margin-bottom:5px;">📦 소재 품의서 (' + materialParts.length + '건)</p>' +
|
||||
'<div style="max-height:100px; overflow-y:auto; font-size:11px;">' + materialListHtml + '</div>' +
|
||||
'</div>';
|
||||
}
|
||||
|
||||
// 가공 품의서 대상
|
||||
if(processingParts.length > 0) {
|
||||
var processingListHtml = processingParts.map(function(part) {
|
||||
return '- ' + fnc_checkNull(part.PART_NO) + ' / ' + fnc_checkNull(part.PART_NAME);
|
||||
}).join('<br/>');
|
||||
|
||||
confirmHtml += '<div style="margin-bottom:15px; padding:10px; background-color:#fff3e0; border:1px solid #FF9800; border-radius:4px;">' +
|
||||
'<p style="color:#E65100; font-weight:bold; margin-bottom:5px;">⚙️ 가공 품의서 (' + processingParts.length + '건)</p>' +
|
||||
'<div style="max-height:100px; overflow-y:auto; font-size:11px;">' + processingListHtml + '</div>' +
|
||||
'</div>';
|
||||
}
|
||||
|
||||
// 제외된 품목 표시
|
||||
confirmHtml += fn_buildExcludedHtml(materialExcluded, processingExcluded);
|
||||
confirmHtml += '</div>';
|
||||
|
||||
// 생성될 품의서 개수 표시
|
||||
var proposalCount = (materialParts.length > 0 ? 1 : 0) + (processingParts.length > 0 ? 1 : 0);
|
||||
|
||||
Swal.fire({
|
||||
title: '품의서 생성',
|
||||
html: '<div style="text-align:left;">' +
|
||||
'<p>총 <strong>' + partCount + '건</strong>의 품목으로 품의서를 생성합니다.</p>' +
|
||||
'<div style="max-height:150px; overflow-y:auto; border:1px solid #ddd; padding:10px; margin-top:10px; font-size:12px;">' +
|
||||
partListHtml +
|
||||
'</div>' +
|
||||
excludedHtml +
|
||||
'</div>',
|
||||
html: '<p style="margin-bottom:10px;"><strong>' + proposalCount + '개</strong>의 품의서가 생성됩니다.</p>' + confirmHtml,
|
||||
icon: 'question',
|
||||
showCancelButton: true,
|
||||
confirmButtonText: '생성',
|
||||
cancelButtonText: '취소'
|
||||
cancelButtonText: '취소',
|
||||
width: '600px'
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
fn_executeCreateProposal(salesRequestObjid, targetParts);
|
||||
fn_executeCreateProposal(salesRequestObjid, null);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// 실패 시에도 공급업체 미입력 품목 정보 표시
|
||||
var excludedParts = response.excludedParts || [];
|
||||
var excludedHtml = '';
|
||||
|
||||
if(excludedParts && excludedParts.length > 0) {
|
||||
var excludedListHtml = excludedParts.map(function(part) {
|
||||
return '- ' + fnc_checkNull(part.PART_NO) + ' / ' + fnc_checkNull(part.PART_NAME);
|
||||
}).join('<br/>');
|
||||
|
||||
excludedHtml = '<br/><br/><div style="text-align:left; padding:10px; background-color:#fff3cd; border:1px solid #ffc107; border-radius:4px;">' +
|
||||
'<p style="color:#856404; font-weight:bold; margin-bottom:5px;">⚠️ 공급업체 미입력 품목 (' + excludedParts.length + '건)</p>' +
|
||||
'<div style="max-height:150px; overflow-y:auto; font-size:11px; color:#856404;">' +
|
||||
excludedListHtml +
|
||||
'</div>' +
|
||||
'</div>';
|
||||
}
|
||||
|
||||
Swal.fire({
|
||||
title: '알림',
|
||||
html: (response.message || '품목 조회 중 오류가 발생했습니다.') + excludedHtml,
|
||||
html: response.message || '품목 조회 중 오류가 발생했습니다.',
|
||||
icon: 'info'
|
||||
});
|
||||
}
|
||||
@@ -608,13 +620,44 @@ function fn_createProposal() {
|
||||
error: function(xhr, status, error) {
|
||||
Swal.fire({
|
||||
title: '오류',
|
||||
text: '서버 통신 중 오류가 발생했습니다.22',
|
||||
text: '서버 통신 중 오류가 발생했습니다.',
|
||||
icon: 'error'
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 제외된 품목 HTML 생성
|
||||
*/
|
||||
function fn_buildExcludedHtml(materialExcluded, processingExcluded) {
|
||||
var html = '';
|
||||
|
||||
if(materialExcluded && materialExcluded.length > 0) {
|
||||
var listHtml = materialExcluded.map(function(part) {
|
||||
return '- ' + fnc_checkNull(part.PART_NO) + ' / ' + fnc_checkNull(part.PART_NAME);
|
||||
}).join('<br/>');
|
||||
|
||||
html += '<div style="margin-top:10px; padding:10px; background-color:#fff3cd; border:1px solid #ffc107; border-radius:4px;">' +
|
||||
'<p style="color:#856404; font-weight:bold; margin-bottom:5px;">⚠️ 소재 - 공급업체 미입력 (' + materialExcluded.length + '건)</p>' +
|
||||
'<div style="max-height:80px; overflow-y:auto; font-size:11px; color:#856404;">' + listHtml + '</div>' +
|
||||
'</div>';
|
||||
}
|
||||
|
||||
if(processingExcluded && processingExcluded.length > 0) {
|
||||
var listHtml = processingExcluded.map(function(part) {
|
||||
return '- ' + fnc_checkNull(part.PART_NO) + ' / ' + fnc_checkNull(part.PART_NAME);
|
||||
}).join('<br/>');
|
||||
|
||||
html += '<div style="margin-top:10px; padding:10px; background-color:#fff3cd; border:1px solid #ffc107; border-radius:4px;">' +
|
||||
'<p style="color:#856404; font-weight:bold; margin-bottom:5px;">⚠️ 가공 - 가공업체 미입력 (' + processingExcluded.length + '건)</p>' +
|
||||
'<div style="max-height:80px; overflow-y:auto; font-size:11px; color:#856404;">' + listHtml + '</div>' +
|
||||
'</div>';
|
||||
}
|
||||
|
||||
return html;
|
||||
}
|
||||
|
||||
/**
|
||||
* 품의서 생성 실행
|
||||
*/
|
||||
@@ -623,15 +666,16 @@ function fn_executeCreateProposal(salesRequestObjid, targetParts) {
|
||||
url: "/salesMng/createProposalFromPurchaseList.do",
|
||||
type: "POST",
|
||||
data: {
|
||||
SALES_REQUEST_MASTER_OBJID: salesRequestObjid,
|
||||
TARGET_PARTS: JSON.stringify(targetParts)
|
||||
SALES_REQUEST_MASTER_OBJID: salesRequestObjid
|
||||
},
|
||||
dataType: "json",
|
||||
success: function(response) {
|
||||
if(response.resultFlag === "S") {
|
||||
// 서버에서 반환한 메시지 사용 (소재/가공 품의서 번호 포함)
|
||||
var message = response.message || '품의서가 생성되었습니다.';
|
||||
Swal.fire({
|
||||
title: '생성 완료',
|
||||
text: '품의서가 생성되었습니다.\n품의서 관리에서 확인하세요.',
|
||||
html: message.replace(/\n/g, '<br/>'),
|
||||
icon: 'success'
|
||||
}).then(() => {
|
||||
fn_search(); // 목록 새로고침
|
||||
@@ -639,12 +683,13 @@ function fn_executeCreateProposal(salesRequestObjid, targetParts) {
|
||||
} else {
|
||||
Swal.fire({
|
||||
title: '오류',
|
||||
text: response.message || '품의서 생성 중 오류가 발생했습니다.',
|
||||
html: (response.message || '품의서 생성 중 오류가 발생했습니다.').replace(/\n/g, '<br/>'),
|
||||
icon: 'error'
|
||||
});
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error("품의서 생성 오류:", status, error);
|
||||
Swal.fire({
|
||||
title: '오류',
|
||||
text: '서버 통신 중 오류가 발생했습니다.',
|
||||
|
||||
Reference in New Issue
Block a user