393 lines
14 KiB
Plaintext
393 lines
14 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"%>
|
|
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
|
|
<%@ page import="com.pms.common.utils.*"%>
|
|
<%@ page import="java.util.*" %>
|
|
<%@include file= "/init.jsp" %>
|
|
<c:set var="now" value="<%=new java.util.Date() %>"/>
|
|
<c:set var="sysYear"><fmt:formatDate value="${now}" pattern="yyyy" /></c:set>
|
|
<%
|
|
// DB에서 메뉴명 조회 (공통 유틸 사용)
|
|
String menuObjId = request.getParameter("menuObjId");
|
|
String menuName = CommonUtils.getMenuName(menuObjId, "구매관리_품의서관리");
|
|
%>
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
<title><%=Constants.SYSTEM_NAME%></title>
|
|
<style>
|
|
body, html {
|
|
overflow-x: hidden;
|
|
width: 100%;
|
|
margin: 0;
|
|
padding: 0;
|
|
}
|
|
.pmsPopupForm tr:last-child td {
|
|
border-bottom: none;
|
|
}
|
|
.select2-selection__choice {
|
|
font-size: 11px;
|
|
background-color: #fff !important;
|
|
border: none !important;
|
|
margin-right: 0px !important;
|
|
}
|
|
.select2-selection__choice__remove {
|
|
display: contents !important;
|
|
}
|
|
.select2-container .select2-selection--multiple {
|
|
min-height: 20px !important;
|
|
}
|
|
.select2-container--default .select2-selection--multiple .select2-selection__choice {
|
|
margin-top: 3.5px !important;
|
|
}
|
|
.select2-selection__rendered {
|
|
height: 18px !important;
|
|
}
|
|
/* 구매유형 멀티선택 - 세로 스크롤 */
|
|
#purchase_type + .select2-container .select2-selection--multiple {
|
|
max-height: 52px !important;
|
|
min-height: 18px !important;
|
|
overflow-y: auto !important;
|
|
}
|
|
#purchase_type + .select2-container .select2-selection__rendered {
|
|
height: auto !important;
|
|
max-height: 48px !important;
|
|
overflow-y: auto !important;
|
|
}
|
|
.swal2-styled {
|
|
padding: 1em 1.5em !important;
|
|
}
|
|
</style>
|
|
<script>
|
|
var _tabulGrid;
|
|
|
|
$(document).ready(function(){
|
|
// DOM 렌더링 완료 후 그리드 높이 계산
|
|
setTimeout(function() {
|
|
fnc_calculateContentHeight("gridDiv", 10);
|
|
}, 100);
|
|
|
|
$(window).resize(function() {
|
|
fnc_calculateContentHeight("gridDiv", 10);
|
|
});
|
|
|
|
$('.select2').select2();
|
|
|
|
$("input[type=text]").keyup(function(e){
|
|
if(e.keyCode == 13){
|
|
$("#btnSearch").trigger("click");
|
|
}
|
|
});
|
|
|
|
// 조회
|
|
$("#btnSearch").click(function(){
|
|
fn_search();
|
|
});
|
|
|
|
// 결재상신 (Amaranth10 전자결재 SSO 방식)
|
|
$("#btnApproval").click(function(){
|
|
var selectedData = _tabulGrid.getSelectedData();
|
|
if(selectedData.length<1){
|
|
Swal.fire("결재상신할 행을 선택해주십시오.");
|
|
return false;
|
|
}else if(selectedData.length>1){
|
|
Swal.fire("한번에 한개의 결재만 가능합니다.");
|
|
return false;
|
|
}else{
|
|
var amaranthStatus = fnc_checkNull(selectedData[0].AMARANTH_STATUS);
|
|
|
|
if(amaranthStatus == "inProcess"){
|
|
Swal.fire("결재 진행중인 건은 상신할 수 없습니다.");
|
|
return false;
|
|
}else if(amaranthStatus == "complete"){
|
|
Swal.fire("결재 완료된 건은 상신할 수 없습니다.");
|
|
return false;
|
|
}else{
|
|
if(confirm("결재상신 하시겠습니까?")){
|
|
var objId = fnc_checkNull(selectedData[0].OBJID);
|
|
fn_openAmaranthApproval(objId);
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
// 발주서생성 - 양식 선택 팝업
|
|
$("#btnCreatePO").click(function(){
|
|
var selectedRowIds = _tabulGrid.getSelectedData();
|
|
if(selectedRowIds.length < 1){
|
|
Swal.fire("발주서를 생성할 행을 선택해주십시오.");
|
|
return false;
|
|
}
|
|
|
|
var statusTitle = fnc_checkNull(selectedRowIds[0].STATUS_TITLE);
|
|
if(statusTitle != '결재완료'){
|
|
Swal.fire("결재완료 상태만 발주서 생성이 가능합니다.");
|
|
return false;
|
|
}
|
|
|
|
// 발주서 양식 선택 팝업
|
|
Swal.fire({
|
|
title: '발주서 양식을 선택하세요',
|
|
html: '<div style="display:flex; justify-content:center; gap:12px; margin:20px 0;">' +
|
|
'<button onclick="window.openGeneralPO()" class="swal2-confirm swal2-styled" style="margin:0; background-color:#3085d6; min-width:140px;">일반 발주서</button>' +
|
|
'<button onclick="window.openOutsourcingPO()" class="swal2-confirm swal2-styled" style="margin:0; background-color:#28a745; min-width:140px;">외주가공 발주서</button>' +
|
|
'<button onclick="window.openEnglishPO()" class="swal2-confirm swal2-styled" style="margin:0; background-color:#6f42c1; min-width:140px;">영문 발주서</button>' +
|
|
'</div>',
|
|
showConfirmButton: false,
|
|
showCancelButton: true,
|
|
cancelButtonText: '취소',
|
|
cancelButtonColor: '#d33'
|
|
});
|
|
|
|
// 일반 발주서 양식으로 발주서 자동 생성
|
|
window.openGeneralPO = function() {
|
|
Swal.close();
|
|
fn_createPurchaseOrder(selectedRowIds, "general");
|
|
};
|
|
|
|
// 외주가공 발주서 양식으로 발주서 자동 생성
|
|
window.openOutsourcingPO = function() {
|
|
Swal.close();
|
|
fn_createPurchaseOrder(selectedRowIds, "outsourcing");
|
|
};
|
|
|
|
// 영문 발주서 양식으로 발주서 자동 생성
|
|
window.openEnglishPO = function() {
|
|
Swal.close();
|
|
fn_createPurchaseOrder(selectedRowIds, "english");
|
|
};
|
|
});
|
|
|
|
// 발주서 자동 생성 (기존 로직 + 양식 타입 추가)
|
|
function fn_createPurchaseOrder(selectedRowIds, formType) {
|
|
Swal.fire({
|
|
title: '발주서 생성',
|
|
text: '선택한 품의서로 ' + (formType == 'general' ? '일반' : formType == 'outsourcing' ? '외주가공' : '영문') + ' 발주서를 생성하시겠습니까?',
|
|
icon: 'question',
|
|
showCancelButton: true,
|
|
confirmButtonText: '생성',
|
|
cancelButtonText: '취소'
|
|
}).then((result) => {
|
|
if (result.isConfirmed) {
|
|
// 선택된 품의서 목록을 JSON으로 변환
|
|
var jqGridData = JSON.stringify(selectedRowIds);
|
|
|
|
$.ajax({
|
|
url: "/purchaseOrder/purchaseOrder_salesRequest_Save.do",
|
|
type: "POST",
|
|
data: {
|
|
jqGrid: jqGridData,
|
|
FORM_TYPE: formType // 양식 타입 추가
|
|
},
|
|
success: function(result) {
|
|
if(result == "SUCCESS") {
|
|
Swal.fire({
|
|
title: '완료',
|
|
text: '발주서가 생성되었습니다.',
|
|
icon: 'success'
|
|
}).then(() => {
|
|
fn_search(); // 목록 새로고침
|
|
});
|
|
} else {
|
|
Swal.fire('오류', '발주서 생성 중 오류가 발생했습니다.', 'error');
|
|
}
|
|
},
|
|
error: function() {
|
|
Swal.fire('오류', '서버 통신 중 오류가 발생했습니다.', 'error');
|
|
}
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
fn_search();
|
|
_fnc_datepick();
|
|
});
|
|
|
|
// 그리드 컬럼 정의
|
|
var columns = [
|
|
{title:'OBJID', field:'OBJID', visible: false},
|
|
{title:'STATUS', field:'STATUS', visible: false},
|
|
{headerHozAlign:'center', hozAlign:'center', title:"품의서 No", field:"PROPOSAL_NO", widthGrow:1.2,
|
|
formatter: fnc_createGridAnchorTag,
|
|
cellClick : function(e, cell) {
|
|
fn_openProposalFormPopUp(cell.getData().OBJID);
|
|
}
|
|
},
|
|
{headerHozAlign:'center', hozAlign:'left', title:"프로젝트번호", field:"PROJECT_NUMBER", widthGrow:1.3},
|
|
{headerHozAlign:'center', hozAlign:'center', title:"구매유형", field:"PURCHASE_TYPE_NAME", widthGrow:1.0},
|
|
{headerHozAlign:'center', hozAlign:'center', title:"주문유형", field:"ORDER_TYPE_NAME", widthGrow:1.0},
|
|
{headerHozAlign:'center', hozAlign:'center', title:"제품구분", field:"PRODUCT_NAME_TITLE", widthGrow:1.0},
|
|
{headerHozAlign:'center', hozAlign:'left', title:"품번", field:"PART_NO", widthGrow:1.5},
|
|
{headerHozAlign:'center', hozAlign:'left', title:"품명", field:"PART_NAME", widthGrow:1.8},
|
|
{title:'AMARANTH_STATUS', field:'AMARANTH_STATUS', visible: false},
|
|
{headerHozAlign:'center', hozAlign:'center', title:"결재상태", field:"STATUS_TITLE", widthGrow:1.0,
|
|
formatter:function(cell){
|
|
var val = fnc_checkNull(cell.getValue());
|
|
if(val == "결재 상신중") return "<span style='color:#e67e22; font-weight:bold;'>" + val + "</span>";
|
|
if(val == "결재완료") return "<span style='color:#27ae60; font-weight:bold;'>" + val + "</span>";
|
|
if(val == "반려") return "<span style='color:#e74c3c; font-weight:bold;'>" + val + "</span>";
|
|
return val;
|
|
}
|
|
},
|
|
{headerHozAlign:'center', hozAlign:'center', title:"작성일", field:"REGDATE_TITLE", widthGrow:1.0},
|
|
{headerHozAlign:'center', hozAlign:'center', title:"작성자", field:"WRITER_NAME", widthGrow:1.0}
|
|
];
|
|
|
|
// 검색
|
|
function fn_search(){
|
|
// 기존 hidden 제거
|
|
$("input[name='purchase_types']").remove();
|
|
|
|
// 구매유형 멀티선택 값 처리
|
|
var selectedPurchaseTypes = $("#purchase_type").val();
|
|
if(selectedPurchaseTypes && selectedPurchaseTypes.length > 0) {
|
|
$('<input>').attr({
|
|
type: 'hidden',
|
|
name: 'purchase_types',
|
|
value: selectedPurchaseTypes.join(',')
|
|
}).appendTo('#form1');
|
|
}
|
|
|
|
_tabulGrid = fnc_tabul_search(_tabul_layout_fitColumns, _tabulGrid, "/salesMng/proposalMngGridList.do", columns, true);
|
|
}
|
|
|
|
// Amaranth10 전자결재 SSO 팝업 열기
|
|
function fn_openAmaranthApproval(objId){
|
|
var selectedData = _tabulGrid.getSelectedData();
|
|
var proposalNo = fnc_checkNull(selectedData[0].PROPOSAL_NO);
|
|
var title = "품의서 결재" + (proposalNo ? " - " + proposalNo : "");
|
|
|
|
$.ajax({
|
|
url: "/approval/getAmaranthSsoUrl.do",
|
|
type: "POST",
|
|
data: {
|
|
"targetType": "PROPOSAL",
|
|
"targetObjId": objId,
|
|
"approvalTitle": title,
|
|
"outProcessCode": "${AMARANTH_OUT_PROCESS_CODE}",
|
|
"formId": "",
|
|
"compSeq": "1000",
|
|
"deptSeq": ""
|
|
},
|
|
dataType: "json",
|
|
success: function(data){
|
|
if(data.resultCode == 0 && data.resultData && data.resultData.fullUrl){
|
|
var fullUrl = data.resultData.fullUrl;
|
|
window.open(fullUrl, "amaranthApproval", "width=1200,height=900,scrollbars=yes,resizable=yes");
|
|
} else {
|
|
Swal.fire("결재 연동 오류: " + (data.resultMsg || "알 수 없는 오류"));
|
|
}
|
|
},
|
|
error: function(xhr, status, error){
|
|
console.error("Amaranth SSO URL 요청 오류:", error);
|
|
Swal.fire("결재 시스템 연동 중 오류가 발생했습니다.");
|
|
}
|
|
});
|
|
}
|
|
|
|
// 품의서 상세 팝업
|
|
function fn_openProposalFormPopUp(objId){
|
|
var url = "/salesMng/proposalFormPopUp.do?PROPOSAL_OBJID=" + fnc_checkNull(objId);
|
|
window.open(url, "proposalFormPopUp", "width=1200,height=900,scrollbars=yes,resizable=yes");
|
|
}
|
|
|
|
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
|
|
});
|
|
}
|
|
}
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<form name="form1" id="form1" action="" method="post">
|
|
<input type="hidden" name="actionType" id="actionType" value="" />
|
|
<div class="min_part_enroll">
|
|
<div class="content-box">
|
|
<div class="content-box-s">
|
|
<div class="plm_menu_name_gdnsi">
|
|
<h2>
|
|
<span><%=menuName%></span>
|
|
</h2>
|
|
<div class="btnArea">
|
|
<input type="button" value="조회" class="plm_btns" id="btnSearch">
|
|
<input type="button" value="결재상신" class="plm_btns" id="btnApproval" style="background:#17a2b8; color:white;">
|
|
<input type="button" value="발주서생성" class="plm_btns" id="btnCreatePO" style="background:#28a745; color:white;">
|
|
</div>
|
|
</div>
|
|
|
|
<div id="plmSearchZon">
|
|
<table>
|
|
<tbody>
|
|
<tr>
|
|
<td class="align_r"><label>품의서 No</label></td>
|
|
<td>
|
|
<input type="text" name="SEARCH_PROPOSAL_NO" id="SEARCH_PROPOSAL_NO" style="width:150px;" value="${param.SEARCH_PROPOSAL_NO}"/>
|
|
</td>
|
|
<td class="align_r"><label>프로젝트번호</label></td>
|
|
<td>
|
|
<input type="text" name="SEARCH_PROJECT_NO" id="SEARCH_PROJECT_NO" style="width:150px;" value="${param.SEARCH_PROJECT_NO}"/>
|
|
</td>
|
|
<td class="align_r"><label>결재상태</label></td>
|
|
<td>
|
|
<select name="SEARCH_STATUS" id="SEARCH_STATUS" class="select2" style="width:130px;">
|
|
<option value="">전체</option>
|
|
<option value="create">작성중</option>
|
|
<option value="inProcess">결재중</option>
|
|
<option value="approvalComplete">결재완료</option>
|
|
<option value="reject">반려</option>
|
|
</select>
|
|
</td>
|
|
<td class="align_r"><label>작성일</label></td>
|
|
<td>
|
|
<input type="text" name="regdate_start" id="regdate_start" style="width:110px;" autocomplete="off" value="${param.regdate_start}" class="date_icon">~
|
|
<input type="text" name="regdate_end" id="regdate_end" style="width:110px;" autocomplete="off" value="${param.regdate_end}" class="date_icon">
|
|
</td>
|
|
<%-- 구매유형 (멀티선택) --%>
|
|
<td class="align_r"><label for="purchase_type">구매유형</label></td>
|
|
<td>
|
|
<select name="purchase_type" id="purchase_type" class="select2" autocomplete="off" style="width:200px;" multiple="multiple">
|
|
${code_map.purchase_type}
|
|
</select>
|
|
</td>
|
|
<%-- 작성자 --%>
|
|
<td class="align_r"><label for="writer">작성자</label></td>
|
|
<td>
|
|
<select name="writer" id="writer" class="select2" autocomplete="off" style="">
|
|
<option value="">선택</option>
|
|
${code_map.writer}
|
|
</select>
|
|
</td>
|
|
<%-- 제품구분 --%>
|
|
<td class="align_r"><label for="part_type">제품구분</label></td>
|
|
<td>
|
|
<select name="part_type" id="part_type" class="select2" autocomplete="off" style="">
|
|
<option value="">선택</option>
|
|
${code_map.part_type}
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<%@include file= "/WEB-INF/view/common/common_gridArea.jsp" %>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</body>
|
|
<style>
|
|
.container::-webkit-scrollbar-thumb {background: linear-gradient(to bottom, #f5d78e, #f5d78e) !important;}
|
|
.container::-webkit-scrollbar-track {background-color: white !important;}
|
|
.container::-webkit-scrollbar-button { display: none !important;}
|
|
</style>
|
|
</html>
|
|
|