입고창고, 계정과목 select2 적용

This commit is contained in:
2026-03-11 19:26:10 +09:00
parent 6a2a2ef63b
commit 6575a582ef

View File

@@ -60,7 +60,16 @@ form {
//var grid;
var TYPE_STANDARD = "0001069"; //발주구분코드:일반부품
var TYPE_LONG_DLV = "0001070"; //발주구분코드:장납기부품
var TYPE_ETC = "0001538"; //발주구분코드:잡자재
var TYPE_ETC = "0001538"; //발주구분코드:잡자재
// 입고창고/계정과목 select2 초기화 (동적 생성 select 대응)
function initDeliverySelect2(scope) {
var $target = scope ? $(scope) : $(document);
$target.find("select[name='LOCATION'], select[name='SUB_LOCATION']").each(function(){
if($(this).data('select2')) $(this).select2('destroy');
$(this).select2({ width:'resolve', placeholder:'선택', allowClear:true });
});
}
$(document).ready(function(){
@@ -157,6 +166,11 @@ $(document).ready(function(){
fnc_datepick(); //달력
$(".select2").select2();
$("#LOCATION_CD, #SUB_LOCATION_CD").select2({ width:'resolve', placeholder:'선택', allowClear:true });
// 서버 렌더링된 입고창고/계정과목 select 값 설정 + select2 초기화
selectSetVal("data-select", true);
initDeliverySelect2("#addData");
var originalValue;
@@ -333,6 +347,7 @@ function fn_addarrival(){
changeYear:true
});
});
initDeliverySelect2("#addData");
$("input[name*=RECEIPT_QTY]").trigger("change");
applyScrollHandler();
}
@@ -368,6 +383,7 @@ function fn_removearrival() {
var lastCell = cells.last(); // 마지막 td를 선택
var cellsToRemove = cells.slice(-5, -1); // 마지막 td(미입고수량)를 제외하고 그 앞의 4개 td를 선택
cellsToRemove.find("select").each(function(){ if($(this).data('select2')) $(this).select2('destroy'); });
cellsToRemove.remove(); // 선택한 td를 삭제
$("input[name*=RECEIPT_QTY]").trigger("change");
/* cellsToRemove.find("input[name='OBJID']").each(function() {
@@ -923,10 +939,10 @@ function fn_location_save(){
</c:choose>
</td>
<td>
<select name="LOCATION" id="LOCATION_${item.OBJID}" data-select="${item.LOCATION}" class="LOCATION_1 _loc_opt"></select>
<select name="LOCATION" id="LOCATION_${item.OBJID}" data-select="${item.LOCATION}" class="LOCATION_1"><option value="">선택</option>${code_map.warehouse}</select>
</td>
<td>
<select name="SUB_LOCATION" id="SUB_LOCATION_${item.OBJID}" data-select="${item.SUB_LOCATION}" class="SUB_LOCATION_1 _acct_opt"></select>
<select name="SUB_LOCATION" id="SUB_LOCATION_${item.OBJID}" data-select="${item.SUB_LOCATION}" class="SUB_LOCATION_1"><option value="">선택</option>${code_map.acctCode}</select>
</td>
<td>
<input type="hidden" name="RECEIPT_INV_QTY" id="RECEIPT_INV_QTY_${item.OBJID}" value="${item.RECEIPT_QTY}" />
@@ -985,10 +1001,10 @@ function fn_location_save(){
</c:choose>
</td>
<td>
<select name="LOCATION" id="LOCATION_${item.OBJID}" class="LOCATION_${item.GROUP_SEQ} _loc_opt" data-select="${item.LOCATION}"></select>
<select name="LOCATION" id="LOCATION_${item.OBJID}" class="LOCATION_${item.GROUP_SEQ}" data-select="${item.LOCATION}"><option value="">선택</option>${code_map.warehouse}</select>
</td>
<td>
<select name="SUB_LOCATION" id="SUB_LOCATION_${item.OBJID}" class="SUB_LOCATION_${item.GROUP_SEQ} _acct_opt" data-select="${item.SUB_LOCATION}"></select>
<select name="SUB_LOCATION" id="SUB_LOCATION_${item.OBJID}" class="SUB_LOCATION_${item.GROUP_SEQ}" data-select="${item.SUB_LOCATION}"><option value="">선택</option>${code_map.acctCode}</select>
</td>
<td>
<input type="hidden" name="RECEIPT_INV_QTY" id="RECEIPT_INV_QTY_${item.OBJID}" value="${item.RECEIPT_QTY}" />
@@ -1063,10 +1079,12 @@ function fn_location_save(){
Text += "</td>"; */
$("#dataTr_${varStatus.index % partList.size()+1}").append(Text);
//selectSetVal("data-select", true);
//var selVal = $("#LOCATION_${item.OBJID}").attr("data-select");
//$("#LOCATION_${item.OBJID}").val('${item.LOCATION}').trigger("change");//.select2();
//$("#SUB_LOCATION_${item.OBJID}").select2();
$("#LOCATION_${item.OBJID}").val('${item.LOCATION}').trigger("change");
$("#SUB_LOCATION_${item.OBJID}").val('${item.SUB_LOCATION}').trigger("change");
if($.fn.select2){
$("#LOCATION_${item.OBJID}").select2({ width:'resolve', placeholder:'선택', allowClear:true });
$("#SUB_LOCATION_${item.OBJID}").select2({ width:'resolve', placeholder:'선택', allowClear:true });
}
</script>
</c:if>
</c:otherwise>
@@ -1084,9 +1102,6 @@ function fn_location_save(){
var appendText ="<td rowspan='2' class='NON_ARRIVAL_QTY_TXT' style='width:100px;'>미입고수량</td>";
$("#head1").append(appendText);
$("select._loc_opt").html(_warehouseOptHtml);
$("select._acct_opt").html(_acctCodeOptHtml);
selectSetVal("data-select", true);
</script>
<c:forEach var="item" items="${partList}" varStatus="varStatus">