812 lines
26 KiB
Plaintext
812 lines
26 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);
|
|
|
|
// 등록일: 새 등록이면 오늘 날짜, 수정이면 저장된 값
|
|
String regDate = "";
|
|
String writerName = "";
|
|
String writerId = "";
|
|
if(isNew) {
|
|
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd");
|
|
regDate = sdf.format(new java.util.Date());
|
|
writerName = connectUserName;
|
|
writerId = connectUserId;
|
|
} else if(info != null) {
|
|
regDate = CommonUtils.nullToEmpty((String)info.get("regdate"));
|
|
writerName = CommonUtils.nullToEmpty((String)info.get("writer_name"));
|
|
writerId = CommonUtils.nullToEmpty((String)info.get("writer"));
|
|
}
|
|
%>
|
|
<!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;
|
|
}
|
|
|
|
/* S/N 입력 필드 placeholder 색상 */
|
|
#SERIAL_NO::placeholder {
|
|
color: #999 !important;
|
|
opacity: 1;
|
|
}
|
|
#SERIAL_NO::-webkit-input-placeholder {
|
|
color: #999 !important;
|
|
}
|
|
#SERIAL_NO::-moz-placeholder {
|
|
color: #999 !important;
|
|
opacity: 1;
|
|
}
|
|
#SERIAL_NO:-ms-input-placeholder {
|
|
color: #999 !important;
|
|
}
|
|
#SERIAL_NO {
|
|
cursor: pointer;
|
|
}
|
|
</style>
|
|
</head>
|
|
<script>
|
|
// S/N 관리 변수
|
|
var snList = [];
|
|
var snCounter = 1;
|
|
|
|
$(function(){
|
|
fnc_datepick();
|
|
$(".select2").select2();
|
|
|
|
// 품번/품명 Select2 AJAX 초기화
|
|
initPartSelect2();
|
|
|
|
// 저장 버튼
|
|
$("#btnSave").click(function(){
|
|
fn_save();
|
|
});
|
|
|
|
// S/N 클릭 시 팝업 오픈
|
|
$("#SERIAL_NO").click(function() {
|
|
fn_openSnManagePopup();
|
|
}).attr("placeholder", "클릭하여 S/N 추가").attr("readonly", true);
|
|
|
|
// 페이지 로드 시 기존 S/N 데이터가 있으면 파싱
|
|
var initialSnValue = $("#SERIAL_NO").val();
|
|
if(initialSnValue && initialSnValue.trim() != '') {
|
|
var snArray = initialSnValue.split(',');
|
|
var initialSnList = [];
|
|
for(var i = 0; i < snArray.length; i++) {
|
|
if(snArray[i].trim() != '') {
|
|
initialSnList.push({
|
|
id: i + 1,
|
|
value: snArray[i].trim()
|
|
});
|
|
}
|
|
}
|
|
if(initialSnList.length > 0) {
|
|
snList = initialSnList;
|
|
snCounter = initialSnList.length + 1;
|
|
}
|
|
}
|
|
|
|
// 프로젝트번호 변경 시 관련 정보 자동 로드 (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);
|
|
}
|
|
<% } %>
|
|
});
|
|
|
|
// 품번/품명 Select2 AJAX 초기화
|
|
function initPartSelect2() {
|
|
// 품번 Select2
|
|
$("#PART_NO").select2({
|
|
placeholder: "품번 검색...",
|
|
allowClear: true,
|
|
width: '100%',
|
|
minimumInputLength: 1,
|
|
language: {
|
|
inputTooShort: function() { return "1글자 이상 입력하세요"; },
|
|
searching: function() { return "검색 중..."; },
|
|
noResults: function() { return "검색 결과가 없습니다"; }
|
|
},
|
|
ajax: {
|
|
url: '/contractMgmt/searchPartList.do',
|
|
dataType: 'json',
|
|
type: 'POST',
|
|
delay: 250,
|
|
data: function(params) { return { searchTerm: params.term }; },
|
|
processResults: function(data) {
|
|
return {
|
|
results: $.map(data, function(item) {
|
|
return {
|
|
id: item.PART_NO || item.part_no,
|
|
text: item.PART_NO || item.part_no,
|
|
partName: item.PART_NAME || item.part_name,
|
|
partObjid: item.OBJID || item.objid
|
|
};
|
|
})
|
|
};
|
|
},
|
|
cache: true
|
|
}
|
|
}).on('select2:select', function(e) {
|
|
var data = e.params.data;
|
|
// 품명 자동 설정
|
|
if(data.partName) {
|
|
// 품명 Select2에 옵션 추가 및 선택
|
|
var newOption = new Option(data.partName, data.partName, true, true);
|
|
$("#PART_NAME").append(newOption).trigger('change');
|
|
}
|
|
// hidden 필드에 OBJID 저장
|
|
$("#PART_OBJID").val(data.partObjid);
|
|
});
|
|
|
|
// 품명 Select2
|
|
$("#PART_NAME").select2({
|
|
placeholder: "품명 검색...",
|
|
allowClear: true,
|
|
width: '100%',
|
|
minimumInputLength: 1,
|
|
language: {
|
|
inputTooShort: function() { return "1글자 이상 입력하세요"; },
|
|
searching: function() { return "검색 중..."; },
|
|
noResults: function() { return "검색 결과가 없습니다"; }
|
|
},
|
|
ajax: {
|
|
url: '/contractMgmt/searchPartList.do',
|
|
dataType: 'json',
|
|
type: 'POST',
|
|
delay: 250,
|
|
data: function(params) { return { searchTerm: params.term }; },
|
|
processResults: function(data) {
|
|
return {
|
|
results: $.map(data, function(item) {
|
|
return {
|
|
id: item.PART_NAME || item.part_name,
|
|
text: item.PART_NAME || item.part_name,
|
|
partNo: item.PART_NO || item.part_no,
|
|
partObjid: item.OBJID || item.objid
|
|
};
|
|
})
|
|
};
|
|
},
|
|
cache: true
|
|
}
|
|
}).on('select2:select', function(e) {
|
|
var data = e.params.data;
|
|
// 품번 자동 설정
|
|
if(data.partNo) {
|
|
var newOption = new Option(data.partNo, data.partNo, true, true);
|
|
$("#PART_NO").append(newOption).trigger('change');
|
|
}
|
|
// hidden 필드에 OBJID 저장
|
|
$("#PART_OBJID").val(data.partObjid);
|
|
});
|
|
}
|
|
|
|
// 날짜 선택기 초기화
|
|
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");
|
|
}
|
|
|
|
// 품번 (Select2)
|
|
var partNo = fnc_checkNull(info.part_no);
|
|
if(partNo != "") {
|
|
var newOption = new Option(partNo, partNo, true, true);
|
|
$("#PART_NO").append(newOption).trigger('change');
|
|
}
|
|
|
|
// 품명 (Select2)
|
|
var partName = fnc_checkNull(info.part_name);
|
|
if(partName != "") {
|
|
var newOption = new Option(partName, partName, true, true);
|
|
$("#PART_NAME").append(newOption).trigger('change');
|
|
}
|
|
|
|
// 요청납기
|
|
$("#REQ_DEL_DATE").val(fnc_checkNull(info.req_del_date));
|
|
|
|
// S/N
|
|
var serialNoVal = fnc_checkNull(info.serial_no);
|
|
$("#SERIAL_NO").val(serialNoVal);
|
|
// snList 동기화 (AJAX 로드 시에도 팝업 목록 갱신)
|
|
snList = [];
|
|
snCounter = 1;
|
|
if(serialNoVal && serialNoVal.trim() != '') {
|
|
var snArr = serialNoVal.split(',');
|
|
for(var si = 0; si < snArr.length; si++) {
|
|
if(snArr[si].trim() != '') {
|
|
snList.push({ id: snCounter++, value: snArr[si].trim() });
|
|
}
|
|
}
|
|
}
|
|
|
|
// 수주수량
|
|
$("#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(null).trigger("change");
|
|
$("#PART_NAME").val(null).trigger("change");
|
|
$("#PART_OBJID").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);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
// ========== S/N 관리 함수 ==========
|
|
|
|
// S/N 관리 팝업 열기
|
|
function fn_openSnManagePopup() {
|
|
// 기존 데이터 로드
|
|
var serialNoValue = $("#SERIAL_NO").val();
|
|
if(serialNoValue && serialNoValue.trim() != '' && snList.length == 0) {
|
|
var snArray = serialNoValue.split(',');
|
|
for(var i = 0; i < snArray.length; i++) {
|
|
if(snArray[i].trim() != '') {
|
|
snList.push({
|
|
id: snCounter++,
|
|
value: snArray[i].trim()
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
// 팝업 HTML 생성
|
|
var popupHtml = '<div style="padding:10px; color:#333;">';
|
|
popupHtml += ' <h3 style="margin:0 0 15px 0; text-align:center; color:#333;">S/N 관리</h3>';
|
|
popupHtml += ' <div id="snListContainer" style="margin-bottom:15px; max-height:300px; overflow-y:auto; color:#333;"></div>';
|
|
popupHtml += ' <div style="margin-bottom:15px; display:flex; gap:5px;">';
|
|
popupHtml += ' <input type="text" id="newSnInput" placeholder="S/N 입력" style="flex:1; padding:8px; border:1px solid #ddd; border-radius:4px; color:#333;">';
|
|
popupHtml += ' <button type="button" onclick="fn_addSn()" class="plm_btns">추가</button>';
|
|
popupHtml += ' </div>';
|
|
popupHtml += ' <div style="text-align:center; margin-top:20px; display:flex; gap:10px; justify-content:center;">';
|
|
popupHtml += ' <button type="button" onclick="fn_openSequentialSnPopup()" class="plm_btns">연속번호생성</button>';
|
|
popupHtml += ' <button type="button" onclick="fn_confirmSnList()" class="plm_btns">확인</button>';
|
|
popupHtml += ' <button type="button" onclick="fn_closeSnPopup()" class="plm_btns">취소</button>';
|
|
popupHtml += ' </div>';
|
|
popupHtml += '</div>';
|
|
|
|
// 팝업 오픈
|
|
Swal.fire({
|
|
html: popupHtml,
|
|
width: '700px',
|
|
showConfirmButton: false,
|
|
showCloseButton: true,
|
|
onOpen: function() {
|
|
setTimeout(function() {
|
|
fn_renderSnList();
|
|
// 엔터키로 추가
|
|
$("#newSnInput").keypress(function(e) {
|
|
if(e.which == 13) {
|
|
fn_addSn();
|
|
return false;
|
|
}
|
|
});
|
|
}, 50);
|
|
}
|
|
});
|
|
}
|
|
|
|
// S/N 목록 렌더링
|
|
function fn_renderSnList() {
|
|
var html = '<table style="width:100%; margin-bottom:10px; border-collapse:collapse; border:1px solid #ddd; color:#333;">';
|
|
html += '<colgroup><col width="15%"><col width="65%"><col width="20%"></colgroup>';
|
|
html += '<thead><tr style="background:#f5f5f5; color:#333;">';
|
|
html += '<th style="padding:10px; border:1px solid #ddd; text-align:center; color:#333;">번호</th>';
|
|
html += '<th style="padding:10px; border:1px solid #ddd; text-align:center; color:#333;">S/N</th>';
|
|
html += '<th style="padding:10px; border:1px solid #ddd; text-align:center; color:#333;">삭제</th>';
|
|
html += '</tr></thead>';
|
|
html += '<tbody>';
|
|
|
|
if(snList.length == 0) {
|
|
html += '<tr><td colspan="3" style="text-align:center; padding:30px; color:#999; border:1px solid #ddd;">등록된 S/N이 없습니다.</td></tr>';
|
|
} else {
|
|
for(var i = 0; i < snList.length; i++) {
|
|
html += '<tr>';
|
|
html += '<td style="text-align:center; padding:8px; border:1px solid #ddd; color:#333;">' + (i+1) + '</td>';
|
|
html += '<td style="padding:8px; border:1px solid #ddd; color:#333;">' + snList[i].value + '</td>';
|
|
html += '<td style="text-align:center; padding:8px; border:1px solid #ddd;">';
|
|
html += '<button type="button" onclick="fn_deleteSn(' + snList[i].id + ')" class="plm_btns" style="padding:5px 10px; font-size:12px;">삭제</button>';
|
|
html += '</td>';
|
|
html += '</tr>';
|
|
}
|
|
}
|
|
html += '</tbody></table>';
|
|
|
|
$("#snListContainer").html(html);
|
|
}
|
|
|
|
// S/N 추가
|
|
function fn_addSn() {
|
|
var newSn = $("#newSnInput").val().trim();
|
|
if(newSn == '') {
|
|
Swal.fire("S/N을 입력해주세요.");
|
|
return;
|
|
}
|
|
|
|
// 중복 체크
|
|
for(var i = 0; i < snList.length; i++) {
|
|
if(snList[i].value == newSn) {
|
|
Swal.fire("이미 등록된 S/N입니다.");
|
|
return;
|
|
}
|
|
}
|
|
|
|
snList.push({
|
|
id: snCounter++,
|
|
value: newSn
|
|
});
|
|
|
|
$("#newSnInput").val('');
|
|
fn_renderSnList();
|
|
}
|
|
|
|
// S/N 삭제
|
|
function fn_deleteSn(id) {
|
|
for(var i = 0; i < snList.length; i++) {
|
|
if(snList[i].id == id) {
|
|
snList.splice(i, 1);
|
|
break;
|
|
}
|
|
}
|
|
fn_renderSnList();
|
|
}
|
|
|
|
// S/N 목록 확인 및 적용
|
|
function fn_confirmSnList() {
|
|
var snValues = [];
|
|
for(var i = 0; i < snList.length; i++) {
|
|
snValues.push(snList[i].value);
|
|
}
|
|
|
|
$("#SERIAL_NO").val(snValues.join(', '));
|
|
Swal.close();
|
|
}
|
|
|
|
// S/N 팝업 닫기
|
|
function fn_closeSnPopup() {
|
|
Swal.close();
|
|
}
|
|
|
|
// 연속번호 생성 팝업
|
|
function fn_openSequentialSnPopup() {
|
|
var seqHtml = '<div style="padding:10px; color:#333;">';
|
|
seqHtml += '<h3 style="margin:0 0 15px 0; text-align:center; color:#333;">연속번호 생성</h3>';
|
|
seqHtml += '<table style="width:100%; border-collapse:collapse;">';
|
|
seqHtml += '<tr><td style="padding:8px; text-align:right; width:30%;">접두어:</td>';
|
|
seqHtml += '<td style="padding:8px;"><input type="text" id="seqPrefix" style="width:100%; padding:5px;" placeholder="예: SN-"></td></tr>';
|
|
seqHtml += '<tr><td style="padding:8px; text-align:right;">시작번호:</td>';
|
|
seqHtml += '<td style="padding:8px;"><input type="number" id="seqStart" style="width:100%; padding:5px;" value="1"></td></tr>';
|
|
seqHtml += '<tr><td style="padding:8px; text-align:right;">종료번호:</td>';
|
|
seqHtml += '<td style="padding:8px;"><input type="number" id="seqEnd" style="width:100%; padding:5px;" value="10"></td></tr>';
|
|
seqHtml += '<tr><td style="padding:8px; text-align:right;">자릿수:</td>';
|
|
seqHtml += '<td style="padding:8px;"><input type="number" id="seqDigits" style="width:100%; padding:5px;" value="3" min="1" max="10"></td></tr>';
|
|
seqHtml += '</table>';
|
|
seqHtml += '<div style="text-align:center; margin-top:15px;">';
|
|
seqHtml += '<button type="button" onclick="fn_generateSequentialSn()" class="plm_btns">생성</button>';
|
|
seqHtml += '<button type="button" onclick="fn_closeSeqPopup()" class="plm_btns" style="margin-left:10px;">취소</button>';
|
|
seqHtml += '</div></div>';
|
|
|
|
Swal.fire({
|
|
html: seqHtml,
|
|
width: '400px',
|
|
showConfirmButton: false,
|
|
showCloseButton: true
|
|
});
|
|
}
|
|
|
|
// 연속번호 생성
|
|
function fn_generateSequentialSn() {
|
|
var prefix = $("#seqPrefix").val();
|
|
var start = parseInt($("#seqStart").val()) || 1;
|
|
var end = parseInt($("#seqEnd").val()) || 10;
|
|
var digits = parseInt($("#seqDigits").val()) || 3;
|
|
|
|
if(start > end) {
|
|
Swal.fire("시작번호가 종료번호보다 클 수 없습니다.");
|
|
return;
|
|
}
|
|
|
|
if(end - start > 999) {
|
|
Swal.fire("한 번에 1000개 이상 생성할 수 없습니다.");
|
|
return;
|
|
}
|
|
|
|
for(var i = start; i <= end; i++) {
|
|
var numStr = String(i).padStart(digits, '0');
|
|
var newSn = prefix + numStr;
|
|
|
|
// 중복 체크
|
|
var isDup = false;
|
|
for(var j = 0; j < snList.length; j++) {
|
|
if(snList[j].value == newSn) {
|
|
isDup = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if(!isDup) {
|
|
snList.push({
|
|
id: snCounter++,
|
|
value: newSn
|
|
});
|
|
}
|
|
}
|
|
|
|
Swal.close();
|
|
fn_openSnManagePopup();
|
|
}
|
|
|
|
// 연속번호 팝업 닫기
|
|
function fn_closeSeqPopup() {
|
|
Swal.close();
|
|
fn_openSnManagePopup();
|
|
}
|
|
</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>
|
|
<select name="PART_NO" id="PART_NO" style="width:100%;">
|
|
<option value="">선택</option>
|
|
<c:if test="${not empty resultMap.part_no}">
|
|
<option value="${resultMap.part_no}" selected>${resultMap.part_no}</option>
|
|
</c:if>
|
|
</select>
|
|
<input type="hidden" name="PART_OBJID" id="PART_OBJID" value="${resultMap.part_objid}">
|
|
</td>
|
|
<td class="input_title"><label>품명<span class="required-mark">*</span></label></td>
|
|
<td>
|
|
<select name="PART_NAME" id="PART_NAME" style="width:100%;">
|
|
<option value="">선택</option>
|
|
<c:if test="${not empty resultMap.part_name}">
|
|
<option value="${resultMap.part_name}" selected>${resultMap.part_name}</option>
|
|
</c:if>
|
|
</select>
|
|
</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>
|
|
<input type="text" name="REG_DATE" id="REG_DATE" value="<%=regDate%>" class="readonly-field" readonly style="width:100%;">
|
|
</td>
|
|
<td class="input_title"><label>등록자</label></td>
|
|
<td>
|
|
<input type="hidden" name="WRITER" id="WRITER" value="<%=writerId%>">
|
|
<input type="text" name="WRITER_NAME" id="WRITER_NAME" value="<%=writerName%>" class="readonly-field" readonly style="width:100%;">
|
|
</td>
|
|
</tr>
|
|
|
|
<!-- 6행: 고객사 요청사항 -->
|
|
<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>
|