378 lines
14 KiB
Plaintext
378 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"%>
|
|
<%@ 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;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<link rel="stylesheet" href="/css/selectMulti.css">
|
|
|
|
<script type="text/javascript">
|
|
$(document).ready(function(){
|
|
|
|
$("input").keyup(function(e){
|
|
if(e.keyCode == 13){
|
|
$("#page").val("1");
|
|
fn_search();
|
|
}
|
|
});
|
|
|
|
$('.select2').select2();
|
|
fnc_datepick();
|
|
|
|
// 조회 버튼
|
|
$("#btnSearch").click(function(){
|
|
$("#page").val("1");
|
|
fn_search();
|
|
});
|
|
|
|
// 삭제 버튼
|
|
$("#btnDelete").click(function(){
|
|
fn_delete();
|
|
});
|
|
|
|
// 메일발송 버튼
|
|
$("#btnSend").click(function(){
|
|
fn_sendMail();
|
|
});
|
|
|
|
fn_search();
|
|
|
|
setTimeout(() => fnc_calculateContentHeight("gridDiv", 15), 50);
|
|
$("#gridDiv").off("fnc_calculateContentHeight");
|
|
$(window).resize(function() {
|
|
fnc_calculateContentHeight("gridDiv", 15);
|
|
});
|
|
});
|
|
|
|
// 그리드 컬럼 정의
|
|
var columns = [
|
|
{title:'OBJID', field:'OBJID', visible:false},
|
|
{title:'SALES_REQUEST_MASTER_OBJID', field:'SALES_REQUEST_MASTER_OBJID', visible:false},
|
|
{title:'PROJECT_MGMT_OBJID', field:'PROJECT_MGMT_OBJID', visible:false},
|
|
{title:'VENDOR_OBJID', field:'VENDOR_OBJID', visible:false},
|
|
{title:'VENDOR_TYPE', field:'VENDOR_TYPE', visible:false},
|
|
|
|
{headerHozAlign:'center', hozAlign:'center', width:110, title:'견적번호', field:'QUOTATION_REQUEST_NO',
|
|
formatter: function(cell, formatterParams, onRendered){
|
|
var value = fnc_checkNull(cell.getValue());
|
|
return "<a href='#none' style='color:#0000EE'>" + value + "</a>";
|
|
},
|
|
cellClick: function(e, cell){
|
|
var objId = fnc_checkNull(cell.getData().OBJID);
|
|
fn_formPopUp(objId);
|
|
}
|
|
},
|
|
{headerHozAlign:'center', hozAlign:'center', widthGrow:1, title:'요청번호', field:'REQUEST_MNG_NO'},
|
|
{headerHozAlign:'center', hozAlign:'center', widthGrow:0.7, title:'구매유형', field:'PURCHASE_TYPE_NAME'},
|
|
{headerHozAlign:'center', hozAlign:'center', widthGrow:1.1, title:'프로젝트번호', field:'PROJECT_NUMBER'},
|
|
{headerHozAlign:'center', hozAlign:'center', widthGrow:0.7, title:'주문유형', field:'ORDER_TYPE_NAME'},
|
|
{headerHozAlign:'center', hozAlign:'center', widthGrow:0.7, title:'제품구분', field:'PRODUCT_NAME_TITLE'},
|
|
{headerHozAlign:'center', hozAlign:'left', widthGrow:1.2, title:'품번', field:'PART_NO',
|
|
formatter: function(cell, formatterParams, onRendered){
|
|
var partNo = fnc_checkNull(cell.getValue());
|
|
var detailCount = parseInt(fnc_checkNull(cell.getData().DETAIL_COUNT)) || 0;
|
|
if(partNo === '') return '';
|
|
if(detailCount > 1) {
|
|
return partNo + ' <span style="color:#888;">외 ' + (detailCount - 1) + '건</span>';
|
|
}
|
|
return partNo;
|
|
}
|
|
},
|
|
{headerHozAlign:'center', hozAlign:'left', widthGrow:1.5, title:'품명', field:'PART_NAME',
|
|
formatter: function(cell, formatterParams, onRendered){
|
|
var partName = fnc_checkNull(cell.getValue());
|
|
var detailCount = parseInt(fnc_checkNull(cell.getData().DETAIL_COUNT)) || 0;
|
|
if(partName === '') return '';
|
|
if(detailCount > 1) {
|
|
return partName + ' <span style="color:#888;">외 ' + (detailCount - 1) + '건</span>';
|
|
}
|
|
return partName;
|
|
}
|
|
},
|
|
{headerHozAlign:'center', hozAlign:'left', widthGrow:1.2, title:'공급업체', field:'VENDOR_NAME',
|
|
formatter: function(cell, formatterParams, onRendered){
|
|
var value = fnc_checkNull(cell.getValue());
|
|
var vendorType = fnc_checkNull(cell.getData().VENDOR_TYPE);
|
|
var badge = '';
|
|
if(vendorType === 'SUPPLY') {
|
|
badge = ' <span style="font-size:10px; color:#2196F3;">[공급]</span>';
|
|
} else if(vendorType === 'PROCESSING') {
|
|
badge = ' <span style="font-size:10px; color:#4CAF50;">[가공]</span>';
|
|
}
|
|
return value + badge;
|
|
}
|
|
},
|
|
{headerHozAlign:'center', hozAlign:'center', widthGrow:0.8, title:'견적요청서', field:'QUOTATION_REQUEST_NO',
|
|
formatter: function(cell, formatterParams, onRendered){
|
|
return '<a href="#" class="File file_icon" style="width:20px; height:20px; display:inline-block;"></a>';
|
|
},
|
|
cellClick: function(e, cell){
|
|
var objId = fnc_checkNull(cell.getData().OBJID);
|
|
fn_formPopUp(objId);
|
|
}
|
|
},
|
|
{headerHozAlign:'center', hozAlign:'center', widthGrow:0.8, title:'메일발송', field:'MAIL_SEND_DATE_TITLE',
|
|
formatter: function(cell, formatterParams, onRendered){
|
|
var sendYn = fnc_checkNull(cell.getData().MAIL_SEND_YN);
|
|
var sendDate = fnc_checkNull(cell.getValue());
|
|
if(sendYn === 'Y' && sendDate !== ''){
|
|
return '<span style="color:green;">' + sendDate + '</span>';
|
|
} else {
|
|
return '<span style="color:#999;">미발송</span>';
|
|
}
|
|
}
|
|
},
|
|
{headerHozAlign:'center', hozAlign:'center', widthGrow:0.7, title:'수신견적서', field:'ATTACH_FILE_CNT',
|
|
formatter: fnc_subInfoValueFormatter,
|
|
cellClick: function(e, cell){
|
|
var objId = fnc_checkNull(cell.getData().OBJID);
|
|
fn_openAttachFilePopUp(objId);
|
|
}
|
|
},
|
|
{headerHozAlign:'center', hozAlign:'center', widthGrow:0.7, title:'작성자', field:'WRITER_NAME'}
|
|
];
|
|
|
|
// 조회
|
|
function fn_search(){
|
|
_tabulGrid = fnc_tabul_search(_tabul_layout_fitColumns, _tabulGrid, "/salesMng/quotationRequestListPaging.do", columns, true);
|
|
}
|
|
|
|
// 상세 팝업
|
|
function fn_formPopUp(objId){
|
|
var popup_width = 1200;
|
|
var popup_height = 800;
|
|
var url = "/salesMng/quotationRequestFormPopup.do?QUOTATION_REQUEST_MASTER_OBJID=" + objId;
|
|
|
|
window.open(url, "quotationRequestFormPopup", "width="+popup_width+",height="+popup_height+",menubar=no,scrollbars=yes,resizable=yes");
|
|
}
|
|
|
|
// 수신견적서 첨부파일 팝업
|
|
function fn_openAttachFilePopUp(objId) {
|
|
var popup_width = 800;
|
|
var popup_height = 300;
|
|
var params = "?targetObjId=" + objId + "&docType=QUOTATION_RECEIVED&docTypeName=수신견적서";
|
|
var url = "/common/FileRegistPopup.do" + params;
|
|
var popup = window.open(url, "attachFilePopUp", "width=" + popup_width + ",height=" + popup_height + ",scrollbars=yes,resizable=yes");
|
|
|
|
// 팝업 닫힘 감지하여 해당 행의 파일 카운트 업데이트
|
|
fn_watchPopupClose(popup, objId, 'ATTACH_FILE_CNT', 'QUOTATION_RECEIVED');
|
|
}
|
|
|
|
// 팝업 닫힘 감지 및 파일 카운트 업데이트
|
|
function fn_watchPopupClose(popup, objId, fieldName, docType) {
|
|
var checkPopup = setInterval(function() {
|
|
if(popup.closed) {
|
|
clearInterval(checkPopup);
|
|
fn_updateFileCnt(objId, fieldName, docType);
|
|
}
|
|
}, 500);
|
|
}
|
|
|
|
// 파일 카운트 업데이트
|
|
function fn_updateFileCnt(objId, fieldName, docType) {
|
|
$.ajax({
|
|
url: "/common/getFileList.do",
|
|
type: "POST",
|
|
data: { targetObjId: objId, docType: docType },
|
|
dataType: "json",
|
|
success: function(data) {
|
|
var cnt = data ? data.length : 0;
|
|
var rows = _tabulGrid.getRows();
|
|
rows.forEach(function(row) {
|
|
if(row.getData().OBJID == objId) {
|
|
row.update({ [fieldName]: cnt });
|
|
}
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
// 삭제
|
|
function fn_delete(){
|
|
var selectedData = _tabulGrid.getSelectedData();
|
|
|
|
if(selectedData.length < 1){
|
|
Swal.fire("삭제할 행을 선택해주세요.");
|
|
return false;
|
|
}
|
|
|
|
// 발송완료 상태 확인
|
|
for(var i = 0; i < selectedData.length; i++){
|
|
var status = fnc_checkNull(selectedData[i].STATUS);
|
|
if(status === 'sent' || status === 'received' || status === 'completed'){
|
|
Swal.fire("발송완료/견적수신/완료 상태는 삭제할 수 없습니다.");
|
|
return false;
|
|
}
|
|
}
|
|
|
|
Swal.fire({
|
|
title: '확인',
|
|
text: '선택한 ' + selectedData.length + '건을 삭제하시겠습니까?',
|
|
icon: 'warning',
|
|
showCancelButton: true,
|
|
confirmButtonText: '삭제',
|
|
cancelButtonText: '취소'
|
|
}).then((result) => {
|
|
if(result.isConfirmed){
|
|
var deletePromises = [];
|
|
|
|
for(var i = 0; i < selectedData.length; i++){
|
|
var objId = fnc_checkNull(selectedData[i].OBJID);
|
|
deletePromises.push(
|
|
$.ajax({
|
|
type: "POST",
|
|
url: "/salesMng/deleteQuotationRequest.do",
|
|
data: { QUOTATION_REQUEST_MASTER_OBJID: objId },
|
|
dataType: "json"
|
|
})
|
|
);
|
|
}
|
|
|
|
Promise.all(deletePromises).then(function(results){
|
|
Swal.fire({
|
|
title: '완료',
|
|
text: '삭제되었습니다.',
|
|
icon: 'success'
|
|
}).then(() => {
|
|
fn_search();
|
|
});
|
|
}).catch(function(error){
|
|
Swal.fire({
|
|
title: '오류',
|
|
text: '삭제 중 오류가 발생했습니다.',
|
|
icon: 'error'
|
|
});
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
// 메일 발송
|
|
function fn_sendMail(){
|
|
var selectedData = _tabulGrid.getSelectedData();
|
|
|
|
if(selectedData.length < 1){
|
|
Swal.fire("메일을 발송할 행을 선택해주세요.");
|
|
return false;
|
|
} else if(selectedData.length > 1){
|
|
Swal.fire("한번에 한 개의 견적요청서만 발송 가능합니다.");
|
|
return false;
|
|
}
|
|
|
|
var objId = fnc_checkNull(selectedData[0].OBJID);
|
|
var mailSendYn = fnc_checkNull(selectedData[0].MAIL_SEND_YN);
|
|
|
|
// 이미 발송된 경우 재발송 확인
|
|
if(mailSendYn === 'Y'){
|
|
Swal.fire({
|
|
title: '이미 발송된 견적요청서입니다.',
|
|
text: '다시 발송하시겠습니까?',
|
|
icon: 'warning',
|
|
showCancelButton: true,
|
|
confirmButtonText: '재발송',
|
|
cancelButtonText: '취소'
|
|
}).then((result) => {
|
|
if(result.isConfirmed){
|
|
fn_openMailFormPopup(objId);
|
|
}
|
|
});
|
|
return false;
|
|
}
|
|
|
|
fn_openMailFormPopup(objId);
|
|
}
|
|
|
|
// 메일 발송 팝업
|
|
function fn_openMailFormPopup(quotationRequestObjId){
|
|
var popup_width = 850;
|
|
var popup_height = 650;
|
|
var url = "/salesMng/quotationRequestMailPopup.do?QUOTATION_REQUEST_MASTER_OBJID=" + quotationRequestObjId;
|
|
|
|
window.open(url, "quotationRequestMailForm", "width="+popup_width+",height="+popup_height+",menubar=no,scrollbars=yes,resizable=yes");
|
|
}
|
|
|
|
</script>
|
|
<body>
|
|
<form name="form1" id="form1" action="" method="post">
|
|
<input type="hidden" name="actionType" id="actionType">
|
|
<input type="hidden" name="SALES_REQUEST_MASTER_OBJID" id="SALES_REQUEST_MASTER_OBJID" value="${param.SALES_REQUEST_MASTER_OBJID}">
|
|
|
|
<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" class="plm_btns" value="메일발송" id="btnSend">
|
|
<input type="button" class="plm_btns" value="삭제" id="btnDelete" style="background-color:#dc3545; border-color:#dc3545;">
|
|
<input type="button" class="plm_btns" value="조회" id="btnSearch">
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div id="plmSearchZon">
|
|
<table class="">
|
|
|
|
<tr>
|
|
<td><label for="Year">년도</label></td>
|
|
<td>
|
|
<select name="Year" id="Year" class="select2" autocomplete="off">
|
|
<option value="">선택</option>
|
|
<c:forEach begin="${sysYear-4}" end="${sysYear}" var="req_year">
|
|
<option value="${req_year}"${param.Year eq req_year ? 'selected':'' }>${req_year}</option>
|
|
</c:forEach>
|
|
</select>
|
|
</td>
|
|
|
|
<td><label for="">프로젝트번호</label></td>
|
|
<td><select name="PROJECT_NO" id="PROJECT_NO" class="select2" autocomplete="off" style="width:190px;"><option value="">선택</option>${code_map.project_no}</select></td>
|
|
|
|
<td><label for="">견적요청서No.</label></td>
|
|
<td><select name="QUOTATION_REQUEST_NO" id="QUOTATION_REQUEST_NO" class="select2" autocomplete="off" style="width:160px;"><option value="">선택</option>${code_map.quotation_request_no}</select></td>
|
|
|
|
<td><label for="">공급업체</label></td>
|
|
<td><select name="VENDOR_OBJID" id="VENDOR_OBJID" class="select2" autocomplete="off" style=""><option value="">선택</option>${code_map.vendor_objid}</select></td>
|
|
|
|
<td><label for="">메일발송</label></td>
|
|
<td><select name="MAIL_SEND_YN" id="MAIL_SEND_YN" class="select2" autocomplete="off" style="">${code_map.mail_send_yn}</select></td>
|
|
|
|
<td><label for="">작성자</label></td>
|
|
<td><select name="writer" id="writer" class="select2" autocomplete="off" style=""><option value="">선택</option>${code_map.writer}</select></td>
|
|
|
|
<td><label for="">제품구분</label></td>
|
|
<td><select name="product_cd" id="product_cd" class="select2" autocomplete="off" style=""><option value="">선택</option>${code_map.product_cd}</select></td>
|
|
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
<%@include file= "/WEB-INF/view/common/common_gridArea.jsp" %>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</body>
|
|
</html>
|