ERP-node/WebContent/WEB-INF/view/inventoryMng/materialRequestFormPopUp.jsp

633 lines
22 KiB
Plaintext

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ page import="com.pms.common.utils.*"%>
<%@ page import="java.util.*"%>
<%@include file="/init.jsp"%>
<!DOCTYPE html>
<html>
<head>
<c:set var="now" value="<%=new java.util.Date() %>" />
<c:set var="sysYear"><fmt:formatDate value="${now}" pattern="yyyy" /></c:set>
<title><%=Constants.SYSTEM_NAME%></title>
<script type="text/javascript"></script>
<script>
$(document).ready(function() {
<%-- $(".WRITER").val('<%=connectUserName%>'); --%>
/* $(".select2").each(function(i,o){
$(this).val( $(this).attr("data-value") ).trigger("change");
}); */
selectSetVal("data-select", true);
$('.select2').select2();
//fnc_datepick2(); //달력
$("input:text[numberOnly]").on("keyup", function() {
$(this).val(fnc_addComma($(this).val().replace(/[^0-9]/g,"")));
});
$("input[name*=QTY]").each(function(){
$(this).val(fnc_addComma($(this).val()));
});
//닫기
$("#btnClose").click(function(){
self.close(0);
});
//자재불출
$("#btnAccept").click(function(){
fn_accept();
});
$("#btnCopy").click(function() {
fn_copy();
});
$("#btnSave").click(function(){
/* if(fnc_valitate("form1")){ */
if(fn_checkInputData()){
if(confirm("저장하시겠습니까?")){
$("input[name*='_QTY']").each(function(){
$(this).val($(this).val().replace(/,/gi,""));
});
$.ajax({
url:"/inventoryMng/saveInventoryRequest.do"
,type:"POST"
,data: $("#form1").serialize()
,dataType:"json"
,async:false
,success:function(data){
alert(data.message);
opener.fn_search();
self.close();
}
,error: function(jqxhr, status, error){
}
});
}
}
/* } */
});
//취소
$("#btnCancel").click(function(){
var objId = $(this).attr("data-OBJID");
var params = "?objId="+objId;
document.form1.action ="/project/wbs/wbsTaskListDetailPopUp.do"+params;
document.form1.target ="_self";
document.form1.submit();
});
//체크박스 전체선택/전체해제
$("#allCheck").click(function(){
if($("#allCheck").prop("checked")) {
$("input[type=checkbox]").prop("checked",true);
} else {
$("input[type=checkbox]").prop("checked",false);
}
});
$("#btnDelete").click(function(){
fn_deleteWBSTask2();
});
});
</script>
<script>
/* function fn_reload(){
location.reload();
} */
function fn_deleteWBSTask2(){
var checkArr = new Array();
$("input[name=CHK_OBJID]:checked").each(function(){
var objId = fnc_checkNull($(this).val().replace(" ",""));
checkArr.push(objId);
});
if(0 < checkArr.length){
if(confirm("삭제하시겠습니까?")){
$.ajax({
type : "POST",
url:"/project/deleteWBSTask.do",
data: {"checkArr":checkArr.join()},
dataType:"json",
success:function(data){
Swal.fire(data.msg);
if(data.result =="true"){
fn_reload();
}
}
,error: function(jqxhr, status, error){
}
});
}
}else{
Swal.fire("선택된 대상이 없습니다.");
return false;
}
}
function deleteUpdate(){
//확정
// name을 가지는 checkbox 중 체크표시된 항목의 전체 개수
if($("input:checkbox[name=chk]:checked").length > 0){
// 현재 체크된 체크박스의 li 정보 얻기
var checkObjId = '';
$("input:checkbox[name=chk]:checked").each(function(index, val) {
if (this.checked)
{
if(index == 0 ){
checkObjId = $(this).attr("data-OBJID");
}else{
checkObjId += ','+$(this).attr("data-OBJID");
}
}
});
deleteProcess(checkObjId);
} else {
Swal.fire("삭제 항목을 선택해주세요.");
}
}
function completeProcess(checkObjId){
if(confirm("확정 하시겠습니까?")){
$.ajax({
url:"/project/completeWBSTask.do",
type:"POST",
data:{"ObjId":checkObjId},
dataType:"json",
success:function(data){
Swal.fire("확정 되었습니다.");
complete_load();
},
error: function(jqxhr, status, error){
}
});
}
}
function deleteProcess(checkObjId){
if(confirm("삭제 하시겠습니까?")){
$.ajax({
url:"/project/wbs/deleteWBSTask.do",
type:"POST",
data:{"ObjId":checkObjId},
dataType:"json",
success:function(data){
Swal.fire("삭제 되었습니다.");
complete_load();
},
error: function(jqxhr, status, error){
}
});
}
}
function fn_checkInputData(){
var returnFlag = true;
//var projectUnitMap = {};
$("input[name=IN_OBJID]").each(function(i) {
var targetObjId = $(this).val();
// Find rows with the same IN_OBJID
var rowsWithSameObjId = $("input[name=IN_OBJID]").filter(function() {
return $(this).val() === targetObjId;
}).closest('tr');
var projectUnitMap = {};
var totalRequestQty = 0;
var originalUseCnt = Number($(rowsWithSameObjId[0]).find("#USE_CNT_" + targetObjId).text());
rowsWithSameObjId.each(function() {
var projectNo = $(this).find("select[name=project_no]").val();
var unit = $(this).find("select[name=unit_code]").val();
var REQUEST_QTY = Number($(this).find("input[name=REQUEST_QTY]").val().replace(/,/gi,""));
//var USE_CNT = Number($(this).find("#USE_CNT_" + targetObjId).text());
var projectUnitKey = projectNo + "_" + unit;
//alert("projectUnitKey:"+projectUnitKey);
if (projectUnitMap[projectUnitKey]) {
Swal.fire("중복된 유닛이 존재합니다.");
returnFlag = false;
return false;
} else {
projectUnitMap[projectUnitKey] = true;
}
totalRequestQty += REQUEST_QTY;
//alert("USE_CNT: " + USE_CNT + ", Current REQUEST_QTY: " + REQUEST_QTY + ", Total REQUEST_QTY: " + totalRequestQty);
//alert("originalUseCnt:"+originalUseCnt);
if (totalRequestQty > originalUseCnt) {
Swal.fire("불출의뢰수량의 합계가 보유수량을 초과합니다.");
returnFlag = false;
return false;
}
});
if (!returnFlag) {
return false; // Break out of the outer loop if a validation fails
}
/* var targetObjId = $(this).val();
var projectNo = $("#project_no_"+targetObjId).val();
var unit = $("#unit_code_"+targetObjId).val();
var REQUEST_QTY = Number($("#REQUEST_QTY_"+targetObjId).val().replace(/,/gi,""));
var USE_CNT = Number($("#USE_CNT_"+targetObjId).text());
var projectUnitKey = projectNo + "_" + unit;
if (projectUnitMap[projectUnitKey]) {
Swal.fire("중복된 유닛이 존재합니다.");
returnFlag = false;
return false;
} else {
projectUnitMap[projectUnitKey] = true;
}
alert("USE_CNT:"+USE_CNT);
alert("REQUEST_QTY:"+REQUEST_QTY);
if(USE_CNT < REQUEST_QTY){
Swal.fire("불출의뢰수량이 보유수량을 초과합니다.");
returnFlag = false;
return false;
} */
//var OUT_QTY = $("#OUT_QTY_"+targetObjId).val();
//alert("targetObjId:"+targetObjId+"REQUEST_QTY:"+REQUEST_QTY);
/* if(REQUEST_QTY > 0){
if(projectNo == ''){
Swal.fire("프로젝트번호를 선택해주세요.");
returnFlag = false;
return false;
}
if(unit == ''){
Swal.fire("유닛명을 선택해주세요.");
returnFlag = false;
return false;
}
} */
/* if(REQUEST_QTY != OUT_QTY){
Swal.fire("불출의뢰수량과 인계수량은 같아야합니다.");
returnFlag = false;
return false;
} */
});
return returnFlag;
}
//자재불출
function fn_accept() {
Swal.fire({
title: '불출하시겠습니까?',
text: '',
icon: 'warning',
showCancelButton: true, // cancel버튼 보이기. 기본은 원래 없음
confirmButtonColor: '#3085d6', // confrim 버튼 색깔 지정
cancelButtonColor: '#d33', // cancel 버튼 색깔 지정
confirmButtonText: '확인', // confirm 버튼 텍스트 지정
cancelButtonText: '취소', // cancel 버튼 텍스트 지정
reverseButtons: false, // 버튼 순서 거꾸로
}).then(result => {
// 만약 Promise리턴을 받으면,
if (result.isConfirmed) { // 만약 모달창에서 confirm 버튼을 눌렀다면
$.ajax({
url:"/inventoryMng/acceptInventoryRequestInfo.do",
type:"POST",
data:$("#form1").serialize(),
dataType:"json",
success:function(data){
alert(data.message);
opener.fn_search();
self.close();
},
error: function(jqxhr, status, error){
}
});
}
});
}
function chageSelect(objId, unit){
var projectNo = $("#project_no_"+objId).val();
fn_UnitCodeList(projectNo, "unit_code_"+objId, unit);
}
function chageUnitSelect(objId){
var project_objid = $("#project_no_"+objId).val();
var unit_code = $("#unit_code_"+objId).val();
var part_objid = $("#PART_OBJID_"+objId).val();
var resultList = fnc_getJsonAllDataListBySqlId({"sqlId":"inventoryMng.getPartQTYInfoList", "PROJECT_OBJID":project_objid, "UNIT_CODE":unit_code, "PART_OBJID":part_objid });
if(0 < resultList.length){
var DESIGN_QTY = resultList[0].DESIGN_QTY;
var OUT_QTY = resultList[0].OUT_QTY;
var PRE_BOOKING_QTY = resultList[0].PRE_BOOKING_QTY;
$("#design_qty_"+objId).text(DESIGN_QTY);
$("#out_qty_"+objId).text(OUT_QTY);
$("#pre_booking_qty_"+objId).text(PRE_BOOKING_QTY);
$("#REQUEST_QTY_"+objId).val(DESIGN_QTY);
}else{
$("#design_qty_"+objId).text("0");
$("#out_qty_"+objId).text("0");
$("#pre_booking_qty_"+objId).text("0");
$("#REQUEST_QTY_"+objId).val("0");
}
}
function fn_copy() {
// Get all checked checkboxes
var checkedBoxes = $("input[name=chk_objId]:checked");
if (checkedBoxes.length === 0) {
alert("복사할 행을 선택해주세요.");
return;
}
// For each checked row
checkedBoxes.each(function() {
var originalRow = $(this).closest('tr');
var newRow = originalRow.clone();
// Generate a unique timestamp-based ID for this copy
var uniqueId = 'copy_' + new Date().getTime() + '_' + Math.random().toString(36).substr(2, 5);
// Uncheck the checkbox in the new row and update its ID
var newCheckbox = newRow.find('input[type="checkbox"]');
newCheckbox.prop('checked', false);
newCheckbox.attr('id', 'chk_objId_' + uniqueId);
newCheckbox.attr('data-objId', uniqueId);
// Update hidden input IDs
// newRow.find('input[name="IN_OBJID"]').val(uniqueId);
//newRow.find('input[name="PART_OBJID"]').attr('id', 'PART_OBJID_' + uniqueId);
// Update project_no select
var originalProjectSelect = originalRow.find('select[name="project_no"]');
var newProjectSelect = newRow.find('select[name="project_no"]');
var selectedProjectValue = originalProjectSelect.val();
// Store the original data-select value
var originalUnitValue = originalRow.find('select[name="unit_code"]').data('select');
// Update IDs and handlers
newProjectSelect.attr('id', 'project_no_' + uniqueId);
newProjectSelect.attr('onchange', 'chageSelect("' + uniqueId + '","' + originalUnitValue + '")');
// Update unit_code select
var newUnitSelect = newRow.find('select[name="unit_code"]');
newUnitSelect.attr('id', 'unit_code_' + uniqueId);
newUnitSelect.attr('onchange', 'chageUnitSelect("' + uniqueId + '")');
// Update other element IDs
newRow.find('#design_qty_' + originalRow.find('input[name="IN_OBJID"]').val())
.attr('id', 'design_qty_' + uniqueId);
newRow.find('#out_qty_' + originalRow.find('input[name="IN_OBJID"]').val())
.attr('id', 'out_qty_' + uniqueId);
newRow.find('#pre_booking_qty_' + originalRow.find('input[name="IN_OBJID"]').val())
.attr('id', 'pre_booking_qty_' + uniqueId);
newRow.find('#USE_CNT_' + originalRow.find('input[name="IN_OBJID"]').val())
.attr('id', 'USE_CNT_' + uniqueId);
// Update REQUEST_QTY input
var newRequestQty = newRow.find('input[name="REQUEST_QTY"]');
newRequestQty.attr('id', 'REQUEST_QTY_' + uniqueId);
// Remove select2 instances before cloning
newRow.find('.select2').each(function() {
$(this).removeClass('select2-hidden-accessible').next('.select2-container').remove();
});
// Insert the new row after the original
originalRow.after(newRow);
// Reinitialize select2 for the new selects
newRow.find('.select2').select2();
// Set the previously selected values
newProjectSelect.val(selectedProjectValue).trigger('change');
// Call chageSelect to populate unit_code
chageSelect(uniqueId, originalUnitValue);
// Reapply number formatting
newRow.find("input:text[numberOnly]").on("keyup", function() {
$(this).val(fnc_addComma($(this).val().replace(/[^0-9]/g,"")));
});
});
}
//자동계산
/* function fn_calc(objid){
var value = $("#REQUEST_QTY_"+objid).val();
$("#OUT_QTY_"+objid).val(value);
} */
</script>
</head>
<body class="bodyNoScrollX">
<form name="hiddenForm" id="hiddenForm" method="post">
<!-- <input type="hidden" name="OBJID" id="OBJID"> -->
<input type="hidden" name="PARENT_OBJID" id="PARENT_OBJID" value="${param.OBJID}">
</form>
<form name="form1" id="form1" action="" method="post">
<input type="hidden" name="INVENTORY_REQUEST_MASTER_OBJID" id="INVENTORY_REQUEST_MASTER_OBJID" value="${resultMap.OBJID}">
<input type="hidden" name="projectObjId" value="${param.OBJID}">
<input type="hidden" name="parentObjId">
<input type="hidden" name="taskObjId">
<input type="hidden" name="projStep">
<input type="hidden" name="status">
<%-- <input type="hidden" name="OBJID" value="${param.OBJID}"> --%>
<div class="plm_menu_name">
</div>
<section class="contents_page_basic_margin" style="margin: 10px; height: calc(100% - 100px);;">
<div>
<table class="pmsPopupForm" style="z-index:99; height:50px; left-margin: 0;">
<colgroup>
<!-- <col width="10%">
<col width="10%"> -->
<col width="20%">
<col width="80%">
</colgroup>
<tr>
<%-- <td class="input_title"><label for="">프로젝트번호</label></td>
<td><select name="project_no" id="project_no" required reqTitle="프로젝트번호" type="select" class="select2" autocomplete="off" ><option value="">선택</option>${code_map.project_no}</select></td> --%>
<td class="input_title"><label for="">비고</label></td>
<td class="input_sub_title"><input type="text" name="REMARK" value="${resultMap.REMARK}"style="height:99%"/></td>
</tr>
</table>
</div>
<div class="plm_table_wrap" style="height: auto;">
<div class="in_table_scroll_wrap _table1" style="height:26px; width: 98%;">
<table class="plm_table" style="position:absolute; border-Spacing:0; border-Collapse: separate; width: 99%;">
<colgroup>
<col width="20px">
<col width="70px">
<col width="140px">
<col width="90px">
<col width="150px">
<col width="70px">
<col width="70px">
<col width="70px">
<col width="60px">
<col width="60px">
<c:if test="${param.action ne 'view'}">
<col width="50px">
<col width="50px">
</c:if>
<col width="80px">
<col width="80px">
<col width="60px">
<col width="50px">
<!-- <col width="60px"> -->
<!-- <col width="60px">
<col width="60px"> -->
</colgroup>
<thead>
<tr class="plm_thead">
<td ><input type="checkbox" id="allCheck"></td>
<td class="editableHeader">프로젝트번호</td>
<td class="editableHeader">유닛명</td>
<td>품번</td>
<td>품명</td>
<td>재질</td>
<td>사양(규격)</td>
<td>MAKER</td>
<td>PART구분</td>
<td>수입검사자</td>
<c:if test="${param.action ne 'view'}">
<td>설계수량</td>
<td>보유수량</td>
</c:if>
<td>Location</td>
<td>Sub_Location</td>
<td class="editableHeader">불출의뢰수량</td>
<td>불출완료수량</td>
<!-- <td>사전예약수량</td> -->
<!-- <td class="">인계수량</td>
<td class="">인계일</td>
<td class="">인계자</td>
<td class="">인수자</td> -->
</tr>
</thead>
</table>
</div>
<div class="plm_scroll_table" style="height:auto;">
<table id="dataTable" class="plm_table" style="width:99.4%; ">
<colgroup>
<col width="20px">
<col width="70px">
<col width="140px">
<col width="90px">
<col width="150px">
<col width="70px">
<col width="70px">
<col width="70px">
<col width="60px">
<col width="60px">
<c:if test="${param.action ne 'view'}">
<col width="50px">
<col width="50px">
</c:if>
<col width="80px">
<col width="80px">
<col width="60px">
<col width="50px">
<!-- <col width="60px"> -->
<!-- <col width="60px">
<col width="60px"> -->
</colgroup>
<tbody class="font_white">
<c:choose>
<c:when test="${empty inventoryMngList}">
<tr style="text-align:center;">
<td align="center" colspan="11">조회된 데이터가 없습니다.</td>
</tr>
</c:when>
<c:otherwise>
<c:forEach var="item" items="${inventoryMngList}" varStatus="varStatus">
<tr>
<input type="hidden" name="OBJID" value="${item.OBJID}" />
<input type="hidden" name="IN_OBJID" value="${item.IN_OBJID}" />
<input type="hidden" name="PART_OBJID" id="PART_OBJID_${item.IN_OBJID}" value="${item.PART_OBJID}" />
<td><input style="width: 15px; height: 15px" type="checkbox" value="${item.IN_OBJID}" name="chk_objId" id="chk_objId" data-objId="${item.IN_OBJID}"></td>
<td title="${item.PROJECT_NO}" class="align_l"><select name="project_no" id="project_no_${item.IN_OBJID}" required reqTitle="프로젝트번호" data-select="${item.CONTRACT_OBJID}" onchange="chageSelect('${item.IN_OBJID}','${item.UNIT}')" type="select" class="select2" autocomplete="off" ><option value="">선택</option>${code_map.project_no}</select></td>
<td title="${item.UNIT}" class="align_l"><select name="unit_code" id="unit_code_${item.IN_OBJID}" style="" data-select="${item.UNIT}"class="select2" autocomplete="off" onchange="chageUnitSelect('${item.IN_OBJID}')"></select></td>
<td title="${item.PART_NO}" class="align_l">${item.PART_NO}</td>
<td title="${item.PART_NAME}"class="align_l">${item.PART_NAME}</td>
<td title="${item.MATERIAL}"class="align_l">${item.MATERIAL}</td>
<td title="${item.SPEC}"class="align_l">${item.SPEC}</td>
<td title="${item.MAKER}"class="align_l">${item.MAKER}</td>
<td title="${item.PART_TYPE_NAME}">${item.PART_TYPE_NAME}</td>
<td title="${item.WRITER_NAME}">${item.WRITER_NAME}</td>
<c:if test="${param.action ne 'view'}">
<td title="${item.DESIGN_QTY}" id="design_qty_${item.IN_OBJID}">${item.DESIGN_QTY}</td>
<td title="${item.USE_CNT}" id="USE_CNT_${item.IN_OBJID}">${item.USE_CNT}</td>
</c:if>
<td title="${item.LOCATION_NAME }">${item.LOCATION_NAME}</td>
<td title="${item.SUB_LOCATION_NAME }">${item.SUB_LOCATION_NAME}</td>
<td title="${item.REQUEST_QTY}">
<c:choose>
<c:when test="${item.REQUEST_QTY eq null}">
<input type="text" name="REQUEST_QTY" id="REQUEST_QTY_${item.IN_OBJID}" value="<fmt:formatNumber value="${item.DESIGN_QTY}" pattern="#,###" />" numberOnly />
</c:when>
<c:otherwise>
<input type="text" name="REQUEST_QTY" id="REQUEST_QTY_${item.IN_OBJID}" value="<fmt:formatNumber value="${item.REQUEST_QTY}" pattern="#,###" />" numberOnly <%-- onchange="fn_calc('${item.OBJID}');" --%>/>
</c:otherwise>
</c:choose>
</td>
<td title="${item.OUT_QTY}" id="out_qty_${item.IN_OBJID}">${item.OUT_QTY}</td>
<%-- <td title="${item.PRE_BOOKING_QTY}" id="pre_booking_qty_${item.IN_OBJID}">${item.PRE_BOOKING_QTY}</td> --%>
<%-- <td title="${item.OUT_DATE}"></td>
<td title="${item.WRITER}"></td>
<td title="${item.ACQ_USER}"> --%>
<%-- <select name="ACQ_USER" required reqTitle="인수자" data-select="${item.ACQ_USER}" type="select" class="select2" autocomplete="off" >
<option value="">선택</option>
${code_map.user_id}
</select> --%>
</td>
</tr>
</c:forEach>
</c:otherwise>
</c:choose>
</tbody>
</table>
</div>
<div class="btn_wrap" style="top:20px">
<div class="plm_btn_wrap_center">
<c:if test="${param.action ne 'view'}">
<input type="button" value="저장" id="btnSave" class="plm_btns">
<input type="button" value="복사" class="plm_btns" id = "btnCopy">
<!-- <input type="button" value="자재불출" class="plm_btns" id="btnAccept"> -->
</c:if>
<input type="button" value="닫기" id="btnClose" class="plm_btns">
</div>
</div>
</div>
</section>
</form>
</body>
</html>