diff --git a/WebContent/WEB-INF/view/contractMgmt/estimateAndOrderRegistFormPopup.jsp b/WebContent/WEB-INF/view/contractMgmt/estimateAndOrderRegistFormPopup.jsp
index 9e0b650..793814a 100644
--- a/WebContent/WEB-INF/view/contractMgmt/estimateAndOrderRegistFormPopup.jsp
+++ b/WebContent/WEB-INF/view/contractMgmt/estimateAndOrderRegistFormPopup.jsp
@@ -366,12 +366,19 @@
var orderQuantity = $row.find(".item-order-quantity").val().replace(/,/g, "").trim();
var orderUnitPrice = $row.find(".item-order-unit-price").val().replace(/,/g, "").trim();
+ var product = $row.find(".item-product").val();
+ if(!product || product == "") {
+ alert((i+1) + "번째 품목의 제품구분을 선택해주세요.");
+ $row.find(".item-product").focus();
+ return false;
+ }
+
if(!partObjId || partObjId == "") {
alert((i+1) + "번째 품목의 품번을 선택해주세요.");
$row.find(".item-part-no-select").focus();
return false;
}
-
+
if(orderQuantity == "" || orderQuantity == "0") {
alert((i+1) + "번째 품목의 수주수량을 입력해주세요.");
$row.find(".item-order-quantity").focus();
@@ -405,6 +412,7 @@
var item = {
objId: $row.find(".item-objid").val() || '',
+ product: $row.find(".item-product").val(),
partObjId: $row.find(".item-part-objid").val(),
partNo: $row.find(".item-part-no").val() ? $row.find(".item-part-no").val().trim() : "",
partName: $row.find(".item-part-name").val() ? $row.find(".item-part-name").val().trim() : "",
@@ -448,7 +456,14 @@
var html = '
';
html += '| ' + (itemCounter-1) + ' | ';
-
+
+ // 제품구분 드롭다운
+ html += '';
+ html += '';
+ html += ' | ';
+
// 품번 셀렉트박스
html += '';
html += ' |
';
$("#itemListBody").append(html);
-
+
+ // 제품구분 드롭다운 초기화
+ fnc_getCodeListAppend("0000001", "PRODUCT_" + itemId, "");
+ $("#PRODUCT_" + itemId).select2({ width: '100%' });
+
// 품번/품명 옵션 채우기
fn_fillPartOptions(itemId, null, null, null);
@@ -563,7 +582,12 @@
// 총액 직접 수정시에도 합계는 갱신
fn_calculateTotal();
});
-
+
+ // Machine 수량 분할: 수주수량 입력 완료 시 체크
+ $("#" + itemId + " .item-order-quantity").on("blur", function() {
+ fn_handleMachineExpansion(itemId);
+ });
+
// 품목 정보 저장
var itemData = {
id: itemId,
@@ -612,11 +636,69 @@
if(existingData.dueDate) $("#" + itemId + " .item-due-date").val(existingData.dueDate);
if(existingData.customerRequest) $("#" + itemId + " .item-customer-request").val(existingData.customerRequest);
if(existingData.returnReason) $("#" + itemId + " .item-return-reason").val(existingData.returnReason).trigger('change');
+ if(existingData.product) {
+ fnc_getCodeListAppend("0000001", "PRODUCT_" + itemId, existingData.product);
+ $("#PRODUCT_" + itemId).select2({ width: '100%' });
+ }
}
-
+
itemList.push(itemData);
}
+ // Machine(0000928) 제품구분 수량 분할 처리
+ function fn_handleMachineExpansion(itemId) {
+ var $row = $("#" + itemId);
+ var productVal = $row.find(".item-product").val();
+ if(productVal !== '0000928') return;
+
+ var qtyInput = $row.find(".item-order-quantity").val().replace(/,/g, "").trim();
+ var qty = parseInt(qtyInput);
+ if(isNaN(qty) || qty <= 1) return;
+
+ // 현재 행의 데이터 수집
+ var partObjId = $row.find(".item-part-objid").val();
+ var partNo = $row.find(".item-part-no").val();
+ var partName = $row.find(".item-part-name").val();
+ var dueDate = $row.find(".item-due-date").val();
+ var returnReason = $row.find(".item-return-reason").val();
+ var customerRequest = $row.find(".item-customer-request").val();
+ var orderUnitPrice = $row.find(".item-order-unit-price").val();
+
+ // 현재 행의 수량을 1로 변경
+ $row.find(".item-order-quantity").val("1");
+ fn_calculateItemAmount(itemId);
+
+ // 나머지 qty-1개 행 추가
+ for(var i = 1; i < qty; i++) {
+ fn_addItemRow();
+ var $lastRow = $("#itemListBody .item-row:last");
+ var lastItemId = $lastRow.attr("id");
+
+ // 제품구분 설정
+ fnc_getCodeListAppend("0000001", "PRODUCT_" + lastItemId, "0000928");
+ $("#PRODUCT_" + lastItemId).select2({ width: '100%' });
+
+ // 품번/품명 설정
+ if(partObjId) {
+ $lastRow.find(".item-part-objid").val(partObjId);
+ $lastRow.find(".item-part-no").val(partNo);
+ $lastRow.find(".item-part-name").val(partName);
+ var $pnSelect = $("#PART_NO_" + lastItemId);
+ var $pnameSelect = $("#PART_NAME_" + lastItemId);
+ $pnSelect.append(new Option(partNo, partObjId, true, true));
+ $pnameSelect.append(new Option(partName, partObjId, true, true));
+ }
+
+ $lastRow.find(".item-order-quantity").val("1");
+ if(orderUnitPrice) $lastRow.find(".item-order-unit-price").val(orderUnitPrice);
+ if(dueDate) $lastRow.find(".item-due-date").val(dueDate);
+ if(returnReason) $lastRow.find(".item-return-reason").val(returnReason).trigger('change');
+ if(customerRequest) $lastRow.find(".item-customer-request").val(customerRequest);
+ fn_calculateItemAmount(lastItemId);
+ }
+ fn_calculateTotal();
+ }
+
// 기존 품목 데이터 로드 (수정 모드)
function fn_loadExistingItems() {
<%
@@ -656,7 +738,14 @@
var html = '';
html += '| ' + (itemCounter-1) + ' | ';
-
+
+ // 제품구분 드롭다운
+ html += '';
+ html += '';
+ html += ' | ';
+
// 품번 셀렉트박스
html += '';
html += ' |