404 lines
13 KiB
Plaintext
404 lines
13 KiB
Plaintext
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
|
|
<%@ page import="com.pms.common.utils.*"%>
|
|
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
|
|
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
|
|
<%@ page import="java.util.*" %>
|
|
<%@include file= "/init_new.jsp" %>
|
|
<%
|
|
Map info = (HashMap)(request.getAttribute("resultMap"));
|
|
String actionType = (String)request.getAttribute("actionType");
|
|
boolean isNew = "regist".equals(actionType);
|
|
%>
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
<title><%=Constants.SYSTEM_NAME%></title>
|
|
<style>
|
|
.input_title {border-left:1px solid #ccc; background-color:#f5f5f5;}
|
|
.input_sub_title {border-left:1px solid #ccc;}
|
|
.pmsPopupForm tr:last-child td{border-bottom:1px solid #ccc;}
|
|
.required-mark { color: red; font-weight: bold; margin-left: 2px; }
|
|
.pmsPopupForm td { padding: 5px 8px; }
|
|
.pmsPopupForm input[type="text"],
|
|
.pmsPopupForm input[type="number"] {
|
|
width: 100%;
|
|
box-sizing: border-box;
|
|
}
|
|
.readonly-field {
|
|
background-color: #eee !important;
|
|
}
|
|
</style>
|
|
</head>
|
|
<script>
|
|
$(function(){
|
|
fnc_datepick();
|
|
$(".select2").select2();
|
|
|
|
// 저장 버튼
|
|
$("#btnSave").click(function(){
|
|
fn_save();
|
|
});
|
|
|
|
// 프로젝트번호 변경 시 관련 정보 자동 로드 (Select2 이벤트)
|
|
$("#PROJECT_NO").on("change select2:select", function(){
|
|
var projectObjid = $(this).val();
|
|
console.log("프로젝트번호 변경됨:", projectObjid);
|
|
// PROJECT_OBJID hidden 필드에도 값 설정
|
|
$("#PROJECT_OBJID").val(projectObjid);
|
|
if(fnc_checkNull(projectObjid) != ""){
|
|
fn_loadProjectInfo(projectObjid);
|
|
} else {
|
|
fn_clearProjectInfo();
|
|
}
|
|
});
|
|
|
|
// 수주수량, 추가생산수량 변경 시 총생산수량 자동 계산
|
|
$("#ORDER_QTY, #EXTRA_PROD_QTY").on("input change", function(){
|
|
fn_calcTotalQty();
|
|
});
|
|
|
|
// 초기 데이터 로드
|
|
<% if(!isNew && info != null) { %>
|
|
// 수정 모드: 기존 데이터 표시
|
|
fn_loadExistingData();
|
|
<% } else { %>
|
|
// 신규 등록: 프로젝트가 선택된 경우 정보 자동 로드
|
|
var projectObjid = "${projectObjid}";
|
|
if(fnc_checkNull(projectObjid) != ""){
|
|
// Select2 초기화 후 값 설정 및 change 이벤트 발생
|
|
setTimeout(function(){
|
|
$("#PROJECT_NO").val(projectObjid).trigger("change");
|
|
}, 100);
|
|
}
|
|
<% } %>
|
|
});
|
|
|
|
// 날짜 선택기 초기화
|
|
function fnc_datepick(){
|
|
var $dateinput = $("input.date_icon");
|
|
for(var i=0; i<$dateinput.length; i++){
|
|
$dateinput.eq(i).attr("size","10");
|
|
$dateinput.eq(i).datepicker({
|
|
changeMonth:true,
|
|
changeYear:true
|
|
});
|
|
}
|
|
}
|
|
|
|
// 프로젝트 정보 로드
|
|
function fn_loadProjectInfo(projectObjid){
|
|
console.log("fn_loadProjectInfo 호출, projectObjid:", projectObjid);
|
|
|
|
$.ajax({
|
|
url: "/productionplanning/getProdPlanProjectInfo.do",
|
|
type: "POST",
|
|
data: { "projectObjid": projectObjid },
|
|
dataType: "json",
|
|
async: false,
|
|
success: function(data){
|
|
console.log("프로젝트 정보 응답:", data);
|
|
|
|
if(data && data.result == "success" && data.info){
|
|
var info = data.info;
|
|
console.log("프로젝트 정보:", info);
|
|
|
|
// 제품구분 (소문자 키)
|
|
if(fnc_checkNull(info.product_code) != ""){
|
|
console.log("제품구분 설정:", info.product_code);
|
|
$("#PRODUCT_CODE").val(info.product_code).trigger("change.select2");
|
|
}
|
|
|
|
// 주문유형
|
|
if(fnc_checkNull(info.category_code) != ""){
|
|
console.log("주문유형 설정:", info.category_code);
|
|
$("#CATEGORY_CODE").val(info.category_code).trigger("change.select2");
|
|
}
|
|
|
|
// 고객사 설정 (C_ 접두어 유무 모두 시도)
|
|
if(fnc_checkNull(info.customer_objid) != ""){
|
|
var customerObjid = info.customer_objid;
|
|
console.log("고객사 원본값:", customerObjid);
|
|
|
|
// 먼저 원본값으로 시도
|
|
$("#CUSTOMER_OBJID").val(customerObjid);
|
|
if($("#CUSTOMER_OBJID").val() != customerObjid) {
|
|
// C_ 제거 후 시도
|
|
customerObjid = info.customer_objid.replace("C_", "");
|
|
$("#CUSTOMER_OBJID").val(customerObjid);
|
|
}
|
|
if($("#CUSTOMER_OBJID").val() != customerObjid) {
|
|
// C_ 추가 후 시도
|
|
customerObjid = "C_" + info.customer_objid.replace("C_", "");
|
|
$("#CUSTOMER_OBJID").val(customerObjid);
|
|
}
|
|
console.log("고객사 최종설정:", $("#CUSTOMER_OBJID").val());
|
|
$("#CUSTOMER_OBJID").trigger("change.select2");
|
|
}
|
|
|
|
// 품번
|
|
$("#PART_NO").val(fnc_checkNull(info.part_no));
|
|
|
|
// 품명
|
|
$("#PART_NAME").val(fnc_checkNull(info.part_name));
|
|
|
|
// 요청납기
|
|
$("#REQ_DEL_DATE").val(fnc_checkNull(info.req_del_date));
|
|
|
|
// S/N
|
|
$("#SERIAL_NO").val(fnc_checkNull(info.serial_no));
|
|
|
|
// 수주수량
|
|
$("#ORDER_QTY").val(fnc_checkNull(info.order_qty) || 0);
|
|
|
|
// 고객사 요청사항
|
|
$("#CUSTOMER_REQUEST").val(fnc_checkNull(info.customer_request));
|
|
|
|
// 총생산수량 계산
|
|
fn_calcTotalQty();
|
|
} else {
|
|
console.log("프로젝트 정보가 없음 또는 조회 실패");
|
|
}
|
|
},
|
|
error: function(jqxhr, status, error){
|
|
console.error("프로젝트 정보 로드 실패:", error);
|
|
}
|
|
});
|
|
}
|
|
|
|
// 프로젝트 정보 초기화
|
|
function fn_clearProjectInfo(){
|
|
$("#PRODUCT_CODE").val("").trigger("change");
|
|
$("#CATEGORY_CODE").val("").trigger("change");
|
|
$("#CUSTOMER_OBJID").val("").trigger("change");
|
|
$("#PART_NO").val("");
|
|
$("#PART_NAME").val("");
|
|
$("#REQ_DEL_DATE").val("");
|
|
$("#SERIAL_NO").val("");
|
|
$("#ORDER_QTY").val("");
|
|
$("#CUSTOMER_REQUEST").val("");
|
|
$("#TOTAL_PROD_QTY").val("");
|
|
}
|
|
|
|
// 기존 데이터 로드 (수정 모드)
|
|
function fn_loadExistingData(){
|
|
// JSP EL로 기존 데이터 설정 (resultMap 키는 소문자)
|
|
<% if(info != null) { %>
|
|
// 프로젝트번호 설정
|
|
var projectObjid = "${resultMap.project_objid}";
|
|
if(projectObjid) {
|
|
$("#PROJECT_NO").val(projectObjid).trigger("change.select2");
|
|
}
|
|
// 제품구분
|
|
$("#PRODUCT_CODE").val("${resultMap.product_code}").trigger("change.select2");
|
|
// 주문유형
|
|
$("#CATEGORY_CODE").val("${resultMap.category_code}").trigger("change.select2");
|
|
// 생산유형
|
|
$("#PRODUCTION_TYPE").val("${resultMap.production_type}").trigger("change.select2");
|
|
// 고객사
|
|
$("#CUSTOMER_OBJID").val("${resultMap.customer_objid}").trigger("change.select2");
|
|
fn_calcTotalQty();
|
|
<% } %>
|
|
}
|
|
|
|
// 총생산수량 계산
|
|
function fn_calcTotalQty(){
|
|
var orderQty = parseInt($("#ORDER_QTY").val()) || 0;
|
|
var extraQty = parseInt($("#EXTRA_PROD_QTY").val()) || 0;
|
|
$("#TOTAL_PROD_QTY").val(orderQty + extraQty);
|
|
}
|
|
|
|
// 저장
|
|
function fn_save(){
|
|
// 필수값 검증
|
|
if(fnc_checkNull($("#PRODUCT_CODE").val()) == ""){
|
|
Swal.fire("제품구분을 선택해주세요.");
|
|
$("#PRODUCT_CODE").focus();
|
|
return;
|
|
}
|
|
if(fnc_checkNull($("#CATEGORY_CODE").val()) == ""){
|
|
Swal.fire("주문유형을 선택해주세요.");
|
|
$("#CATEGORY_CODE").focus();
|
|
return;
|
|
}
|
|
if(fnc_checkNull($("#PRODUCTION_TYPE").val()) == ""){
|
|
Swal.fire("생산유형을 선택해주세요.");
|
|
$("#PRODUCTION_TYPE").focus();
|
|
return;
|
|
}
|
|
if(fnc_checkNull($("#CUSTOMER_OBJID").val()) == ""){
|
|
Swal.fire("고객사를 선택해주세요.");
|
|
$("#CUSTOMER_OBJID").focus();
|
|
return;
|
|
}
|
|
if(fnc_checkNull($("#REQ_DEL_DATE").val()) == ""){
|
|
Swal.fire("요청납기를 입력해주세요.");
|
|
$("#REQ_DEL_DATE").focus();
|
|
return;
|
|
}
|
|
if(fnc_checkNull($("#PART_NO").val()) == ""){
|
|
Swal.fire("품번을 입력해주세요.");
|
|
$("#PART_NO").focus();
|
|
return;
|
|
}
|
|
if(fnc_checkNull($("#PART_NAME").val()) == ""){
|
|
Swal.fire("품명을 입력해주세요.");
|
|
$("#PART_NAME").focus();
|
|
return;
|
|
}
|
|
var orderQty = parseInt($("#ORDER_QTY").val()) || 0;
|
|
if(orderQty <= 0){
|
|
Swal.fire("수주수량을 입력해주세요.");
|
|
$("#ORDER_QTY").focus();
|
|
return;
|
|
}
|
|
|
|
if(confirm("저장하시겠습니까?")){
|
|
$.ajax({
|
|
type: "POST",
|
|
url: "/productionplanning/saveProdPlan.do",
|
|
data: $("#form1").serialize(),
|
|
dataType: "json",
|
|
success: function(data){
|
|
if(data.result == "success"){
|
|
alert(data.msg || "저장되었습니다.");
|
|
if(typeof opener.fn_search == "function"){
|
|
opener.fn_search();
|
|
}
|
|
self.close();
|
|
} else {
|
|
Swal.fire(data.msg || "저장에 실패했습니다.");
|
|
}
|
|
},
|
|
error: function(jqxhr, status, error){
|
|
Swal.fire("저장 중 오류가 발생했습니다.");
|
|
console.error(error);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
</script>
|
|
<body>
|
|
<form name="form1" id="form1" method="post">
|
|
<input type="hidden" name="OBJID" id="OBJID" value="${resultMap.objid}">
|
|
<input type="hidden" name="PROJECT_OBJID" id="PROJECT_OBJID" value="${resultMap.project_objid}">
|
|
<input type="hidden" name="actionType" id="actionType" value="${actionType}">
|
|
|
|
<section>
|
|
<div class="plm_menu_name" style="display:flex;">
|
|
<h2 style="width:100%;height:60px;text-align:center;margin-top:10px;">
|
|
<span style="font-size:24px;">생산계획 생성</span>
|
|
</h2>
|
|
</div>
|
|
|
|
<div id="businessPopupFormWrap" style="z-index:99; padding:10px;">
|
|
<table class="pmsPopupForm" style="z-index:99; width:100%;">
|
|
<colgroup>
|
|
<col width="12%">
|
|
<col width="21%">
|
|
<col width="12%">
|
|
<col width="21%">
|
|
<col width="12%">
|
|
<col width="22%">
|
|
</colgroup>
|
|
|
|
<!-- 1행: 프로젝트번호, 제품구분, 주문유형 -->
|
|
<tr>
|
|
<td class="input_title"><label>프로젝트번호</label></td>
|
|
<td>
|
|
<select name="PROJECT_NO" id="PROJECT_NO" class="select2" style="width:100%;">
|
|
<option value="">선택</option>
|
|
${code_map.project_no}
|
|
</select>
|
|
</td>
|
|
<td class="input_title"><label>제품구분<span class="required-mark">*</span></label></td>
|
|
<td>
|
|
<select name="PRODUCT_CODE" id="PRODUCT_CODE" class="select2" style="width:100%;">
|
|
<option value="">선택</option>
|
|
${code_map.product_cd}
|
|
</select>
|
|
</td>
|
|
<td class="input_title"><label>주문유형<span class="required-mark">*</span></label></td>
|
|
<td>
|
|
<select name="CATEGORY_CODE" id="CATEGORY_CODE" class="select2" style="width:100%;">
|
|
<option value="">선택</option>
|
|
${code_map.category_cd}
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
|
|
<!-- 2행: 생산유형, 고객사, 요청납기 -->
|
|
<tr>
|
|
<td class="input_title"><label>생산유형<span class="required-mark">*</span></label></td>
|
|
<td>
|
|
<select name="PRODUCTION_TYPE" id="PRODUCTION_TYPE" class="select2" style="width:100%;">
|
|
<option value="">선택</option>
|
|
${code_map.production_type_cd}
|
|
</select>
|
|
</td>
|
|
<td class="input_title"><label>고객사<span class="required-mark">*</span></label></td>
|
|
<td>
|
|
<select name="CUSTOMER_OBJID" id="CUSTOMER_OBJID" class="select2" style="width:100%;">
|
|
<option value="">선택</option>
|
|
${code_map.customer_cd}
|
|
</select>
|
|
</td>
|
|
<td class="input_title"><label>요청납기<span class="required-mark">*</span></label></td>
|
|
<td>
|
|
<input type="text" name="REQ_DEL_DATE" id="REQ_DEL_DATE" class="date_icon" value="${resultMap.req_del_date}">
|
|
</td>
|
|
</tr>
|
|
|
|
<!-- 3행: 품번, 품명, S/N -->
|
|
<tr>
|
|
<td class="input_title"><label>품번<span class="required-mark">*</span></label></td>
|
|
<td>
|
|
<input type="text" name="PART_NO" id="PART_NO" value="${resultMap.part_no}">
|
|
</td>
|
|
<td class="input_title"><label>품명<span class="required-mark">*</span></label></td>
|
|
<td>
|
|
<input type="text" name="PART_NAME" id="PART_NAME" value="${resultMap.part_name}">
|
|
</td>
|
|
<td class="input_title"><label>S/N</label></td>
|
|
<td>
|
|
<input type="text" name="SERIAL_NO" id="SERIAL_NO" value="${resultMap.serial_no}">
|
|
</td>
|
|
</tr>
|
|
|
|
<!-- 4행: 수주수량, 추가생산수량, 총생산수량 -->
|
|
<tr>
|
|
<td class="input_title"><label>수주수량<span class="required-mark">*</span></label></td>
|
|
<td>
|
|
<input type="number" name="ORDER_QTY" id="ORDER_QTY" min="0" value="${resultMap.order_qty}">
|
|
</td>
|
|
<td class="input_title"><label>추가생산수량</label></td>
|
|
<td>
|
|
<input type="number" name="EXTRA_PROD_QTY" id="EXTRA_PROD_QTY" min="0" value="${resultMap.extra_prod_qty}" placeholder="0">
|
|
</td>
|
|
<td class="input_title"><label>총생산수량</label></td>
|
|
<td>
|
|
<input type="text" name="TOTAL_PROD_QTY" id="TOTAL_PROD_QTY" class="readonly-field" readonly value="${resultMap.total_prod_qty}">
|
|
</td>
|
|
</tr>
|
|
|
|
<!-- 5행: 고객사 요청사항 -->
|
|
<tr>
|
|
<td class="input_title"><label>고객사 요청사항</label></td>
|
|
<td colspan="5">
|
|
<input type="text" name="CUSTOMER_REQUEST" id="CUSTOMER_REQUEST" value="${resultMap.customer_request}" style="width:100%;">
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="btn_wrap">
|
|
<div class="plm_btn_wrap" style="padding:10px; text-align:center;">
|
|
<input type="button" value="저장" class="plm_btns" id="btnSave">
|
|
<input type="button" value="닫기" class="plm_btns" onclick="window.close();">
|
|
</div>
|
|
</div>
|
|
</section>
|
|
</form>
|
|
</body>
|
|
</html>
|