ERP-node/WebContent/WEB-INF/view/salesMng/salesRequestFormPopUp_toast...

570 lines
17 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"%>
<%@ page import="java.util.*" %>
<%@include file= "/init_toastGrid.jsp" %>
<%
PersonBean person = (PersonBean)session.getAttribute(Constants.PERSON_BEAN);
String userId = CommonUtils.checkNull(person.getUserId());
%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title><%=Constants.SYSTEM_NAME%></title>
</head>
<script>
var grid;
$(function(){
$("#btnClose").click(function(){
self.close(0);
});
$("#btnReg").click(function(){
fn_save();
});
$("#btnAdd").click(function(){
//파트 추가를 위한 팝업을 호출한다.
fn_openPartPopUp();
});
$("#btnDelete").click(function(){
fn_deleteRow();
});
$("#btnDrawingDownload").click(function(){
fn_getDrawingDownload();
});
$("#PRODUCT_GROUP").change(function(){
$("#PRODUCT").empty();
if("" != this.value){
fnc_getCodeListAppend(this.value,"PRODUCT","${resultMap.PRODUCT}");
}
});
$(document).on("change", ".targetPartner", function(){
var targetObjId = fnc_checkNull($('option:selected',this).attr("data-target_objid"));
var targetPrice = fnc_checkNull($('option:selected',this).attr("data-price"));
var targetQty = fnc_checkNull($('option:selected',this).attr("data-qty"));
if("" != targetObjId){
$("#TARGET_PARTNER_PRICE_"+targetObjId).val(targetPrice);
$("#TARGET_PARTNER_QTY_"+targetObjId).val(targetQty);
}
});
fnc_getCodeListAppend("0000182","CATEGORY_CD","${resultMap.CATEGORY_CD}");
fnc_getCodeListAppend("0000001","PRODUCT_GROUP","${resultMap.PRODUCT_GROUP}");
if("" != "${resultMap.PRODUCT_GROUP}"){
fnc_getCodeListAppend("${resultMap.PRODUCT_GROUP}","PRODUCT","${resultMap.PRODUCT}");
}
fnc_getCodeListAppend("0000259","REQUEST_STATUS","${resultMap.REQUEST_STATUS}");
fnc_getUserList2("SALES_MNG_USER_ID", "${resultMap.SALES_MNG_USER_ID}");
$("#PRODUCT_GROUP").change(function(){
$("#PRODUCT").empty();
if("" != this.value){
fnc_getCodeListAppend(this.value,"PRODUCT","${resultMap.PRODUCT}");
}
});
grid = new tui.Grid({
el: document.getElementById('grid'),
scrollX: false,
scrollY: true,
bodyHeight:330,
columns: [
{header:'품명(재질,규격) / 품번', name:'TARGET_TITLE', width:300},
{header:'단위', name:'UNIT_TITLE', width:60, align:'center'},
{header:'수량', name:'QTY', editor:'text', width:70, align:'center'},
{
header:'납기요청일',
name:'DELIVERY_REQUEST_DATE',
editor:{
type: 'datePicker',
options: {
format: 'yyyy-MM-dd'
}
},
width:120,
align:'center'
},
{
header:'업체',
name:'PARTNER_OBJID',
formatter: 'listItemText',
editor: {
type: 'select',
options: {
listItems: [
{ text: 'Deluxe', value: '1' },
{ text: 'EP', value: '2' },
{ text: 'Single', value: '3' }
]
}
},
align:'center'
},
{
header:'업체단가',
name:'PARTNER_PRICE',
editor:'text',
align:'center'
},
{header:'비고', name:'REMARK', editor:'text', align:'center'},
{header:'상태', name:'STATUS', hidden:true},
{header:'OBJID', name:'OBJID', hidden:true},
{header:'PART_OBJID', name:'PART_OBJID', hidden:true},
{header:'SALES_BOM_QTY_OBJID', name:'SALES_BOM_QTY_OBJID', hidden:true}
],
header: {
height: 30
},
rowHeaders: ['rowNum','checkbox'],
rowHeight:'auto',
columnOptions:{
resizable: true
}
});
tui.Grid.applyTheme("striped");
fn_getSalesRequestTargetPartList();
fnc_setFileDropZone("salesMngRequestDropZone", "${resultMap.OBJID}", "SALES_MNG_REQUEST", "구매의뢰서 첨부파일", "fileAreaDraw",false,null,null);
fileAreaDraw();
});
</script>
<script>
function fn_getSalesRequestTargetPartList(){
$.ajax({
url:"/salesMng/getSalesRequestTargetList.do",
type:"POST",
data:{"SALES_REQUEST_MASTER_OBJID":"${resultMap.OBJID}"},
dataType:"json",
async:false,
success:function(data){
if(0 < data.length){
grid.resetData(data);
if("reception" == "${resultMap.STATUS}"){
grid.disableColumn("QTY");
grid.disableColumn("DELIVERY_REQUEST_DATE");
grid.disableColumn("REMARK");
}
}
},
error: function(jqxhr, status, error){
}
});
}
/* 파트 추가 시 그리드에 Row 추가 */
function fn_addRow(rowData){
console.log("rowData:"+rowData);
grid.appendRow(
rowData,
{
focus: true
}
);
}
/* 파트 추가 시 그리드에 Row 추가 */
function fn_deleteRow(){
var targetList = grid.getCheckedRowKeys();
console.log("targetList:"+targetList);
console.log("targetList.length:"+targetList.length);
if(0 < targetList.length){
if(confirm("선택된 내용을 삭제하시겠습니까?")){
for(var i=0;i<targetList.length;i++){
var rowKey = targetList[i];
grid.removeRow(rowKey);
}
}
}else{
Swal.fire("선택된 내용이 없습니다.");
return false;
}
}
function fn_openPartPopUp(){
window.open("/partMng/partMngListPopUp.do?callBackFn=fn_addRow&callType=salesRequestForm", "tempPartListPopup", "width=1200, height=750, toolbar=no, status=no, menubar=no, location=no, scrollbars=yes, resizable=yes");
}
function fn_edit(){
if(confirm("수정하시겠습니까?")){
var form1 = document.form1;
form1.action = "/devMng/moldDevRequestFormPopUp.do";
form1.submit();
}
}
//결재정보를 가져온다.
function fn_getApprovalLine(){
var scheduleList = new Array();
<c:forEach items="${approvalList}" var="approvalItem">
var seq = "${approvalItem.SEQ}";
var targetUserName = "${approvalItem.TARGET_USER_NAME}";
var procDate = "${approvalItem.PROC_DATE}";
if(1 == seq){
$("#reviewerName").append(targetUserName);
$("#reviewerDate").append(procDate);
}
if(2 == seq){
$("#confirmName").append(targetUserName);
$("#confirmDate").append(procDate);
}
</c:forEach>
}
function fileAreaDraw(){
fn_fileCallback2("salesMngRequest","SALES_MNG_REQUEST");
}
function fn_fileCallback2(areaId,fileType){
$.ajax({
url:"/common/getFileList.do",
type:"POST",
data:{"targetObjId":"${resultMap.OBJID}", "docType":fileType},
dataType:"json",
async:false,
success:function(data){
if(0 < data.length){
//첨부파일 목록 영역 show
$("#"+areaId+"FileArea").empty();
if(0 < $("#"+areaId+"DefaultRow").length){
$("#"+areaId+"DefaultRow").hide();
}
$.each(data, function(i){
var appendText = "";
var path = data[i].FILE_PATH;
var fileName = data[i].SAVED_FILE_NAME;
var fileExt = data[i].UPPER_FILE_EXT;
appendText += "<colgroup>";
appendText +=" <col width='10%''>";
appendText +=" <col width='*'>";
appendText +=" <col width='20%'>";
appendText +=" </colgroup>";
appendText+= "<tr>";
appendText+= " <td>"+[i+1]+"</td>";
appendText+= " <td class='align_l'>";
appendText+= " <a href='javascript:fnc_downloadFile(\""+data[i].OBJID+"\")'>&nbsp;&nbsp;"+data[i].REAL_FILE_NAME+"</a>";
if(data[i].WRITER=="${connectUserId}" || 'plm_admin'== "${connectUserId}"){
appendText+= "<a href='javascript:fileDelete(\""+data[i].OBJID+"\",\""+areaId+"\")'><div class='delete_btn'></div></a>";
}
appendText+= "</td>";
appendText+= " <td>"+data[i].REGDATE+"</td>";
appendText+= "</tr>";
$("#"+areaId+"FileArea").append(appendText);
});
}else{
$("#"+areaId+"DropZone").show();
$("#"+areaId+"AttachFileList").hide();
$("#"+areaId+"FileArea").empty();
var appendText = "";
appendText += "<tr>";
appendText += "<td>첨부 파일이 없습니다.</td>";
appendText +="</tr>";
$("#"+areaId+"FileArea").append(appendText);
}
},
error: function(jqxhr, status, error){
}
});
}//파일 첨부 END
/*첨부 파일 삭제 */
function fileDelete(fileObjId,areaId){
var type =areaId;
if(confirm("파일을 삭제하시겠습니까?")){
$.ajax({
url:"/common/deleteFileInfo.do",
type:"POST",
data:{"objId":fileObjId},
dataType:"json",
async:true,
success:function(data){
fileAreaDraw();
},
error: function(jqxhr, status, error){
}
});
}
}
function fn_save(){
var formData = $("#form1").serialize();
var rowDataList = grid.getData();
console.log("rowDataList:"+rowDataList);
if(0 < rowDataList.length){
if(confirm("저장하시겠습니까?")){
$.ajax({
type: "POST",
url: "/salesMng/saveSalesRequestInfo.do",
data: $("#form1").serialize() + "&rowDataList="+ JSON.stringify(rowDataList),
dataType:"json",
success:function(data){
Swal.fire(data.msg);
if(data.result){
opener.fn_search();
self.close();
}
},
error: function(jqxhr, status, error){
}
});
}
}else{
Swal.fire("지정된 구매의뢰 부품이 없습니다.");
return false;
}
}
function fn_getDrawingDownload(){
var gridData = $("#partListGrid").getRowData();
if(0 < gridData.length){
var targetPartList = [];
for(var i=0;i<gridData.length;i++){
targetPartList.push(gridData[i].PART_OBJID);
}
var form = document.form1;
form.TARGET_DRAWING_DOWNLOAD.value = targetPartList.join();
form.action = "/devMng/getDrawingDownload.do";
form.submit();
}else{
Swal.fire("일괄다운로드 대상 Part가 없습니다.");
return false;
}
}
function fn_openPartPopup(objId){
window.open("/partMng/partMngDetailPopUp.do?OBJID="+objId, "tempPartListPopup", "width=600, height=700, toolbar=no, status=no, menubar=no, location=no, scrollbars=yes, resizable=yes");
}
</script>
<style>
.input_title {border-left:1px solid #ccc;}
.input_sub_title {border-left:1px solid #ccc;}
.pmsPopupForm tr:last-child td{border-bottom:1px solid #ccc;}
</style>
<body>
<form name="form1" id="form1" action="" method="post">
<input type="hidden" name="SALES_REQUEST_MASTER_OBJID" id="SALES_REQUEST_MASTER_OBJID" value="${resultMap.OBJID}">
<input type="hidden" name="STATUS" id="STATUS" value="${resultMap.STATUS}">
<input type="hidden" name="TARGET_DRAWING_DOWNLOAD" id="TARGET_DRAWING_DOWNLOAD">
<section>
<div class="plm_menu_name" style="display:flex;">
<h2 style="width:50%;text-align:center;margin-top:15px;">
<span style="font-size:30px;">구매의뢰 등록</span>
</h2>
<table class="pmsPopupForm" style="width:50%;background:white;">
<colgroup>
<col width="20%">
<col width="20%">
<col width="20%">
<col width="20%">
</colgroup>
<tr style="border-spacing: 0;border-bottom:1px solid #ccc;border-left:1px solid #ccc;">
<td class="input_title" rowspan="3" style="text-align:center;">
<label>결재</label>
</td>
<td class="input_title" style="text-align:center;">
<label>작성자</label>
</td>
<td class="input_title" style="text-align:center;">
<label>검토</label>
</td>
<td class="input_title" style="text-align:center;">
<label>승인</label>
</td>
</tr>
<tr style="border-spacing: 0;border-bottom:1px solid #ccc;">
<td class="input_sub_title" style="text-align:center;">
${resultMap.WRITER_TITLE}<!-- 작성자이름 -->
</td>
<td class="input_sub_title" style="text-align:center;" id="reviewerName"></td>
<td class="input_sub_title" style="text-align:center;" id="confirmName"></td>
</tr>
<tr style="border-spacing: 0;border-bottom:1px solid #ccc;border-left:1px solid #ccc;">
<td class="input_sub_title" style="text-align:center;">
${resultMap.REGDATE_TITLE}<!-- 작성일자 -->
</td>
<td class="input_sub_title" style="text-align:center;" id="reviewerDate"></td>
<td class="input_sub_title" style="text-align:center;" id="confirmDate"></td>
</tr>
</table>
</div>
<div id="businessPopupFormWrap" style="z-index:99;">
<table class="pmsPopupForm" style="z-index:99;">
<colgroup>
<col width="9.5%">
<col width="*">
<col width="9.5%">
<col width="*">
<col width="9.5%">
<col width="*">
<col width="9.5%">
<col width="*">
</colgroup>
<tr>
<td class="input_title" colspan="8">
<label for="">구매의뢰 제품</label>
</td>
</tr>
<tr>
<td class="input_title"><label for="">관리번호</label></td>
<td class="input_sub_title">
<input type="hidden" name="REQUEST_MNG_NO" id="REQUEST_MNG_NO" value="${resultMap.REQUEST_MNG_NO}">
<input type="text" value="${resultMap.REQUEST_MNG_NO}" placeholder="저장 시 자동채번됩니다.">
</td>
<td class="input_title"><label for="">제품구분</label></td>
<td class="input_sub_title">
<select name="CATEGORY_CD" id="CATEGORY_CD" required reqTitle="제품구분" type="select"></select>
</td>
<td class="input_title"><label for="supply_code">제품군</label></td>
<td class="input_sub_title">
<select name="PRODUCT_GROUP" id="PRODUCT_GROUP" required reqTitle="제품군1" type="select"></select>
</td>
<td class="input_title"><label for="area_cd">제품</label></td>
<td class="input_sub_title">
<select name="PRODUCT" id="PRODUCT" required reqTitle="제품1" type="select"></select>
</td>
</tr>
<tr>
<td class="input_title"><label for="area_cd">구매담당자</label></td>
<td class="input_sub_title">
<select name="SALES_MNG_USER_ID" id="SALES_MNG_USER_ID" required reqTitle="구매담당자" type="select"></select>
</td>
<td class="input_title"><label for="">요청승인여부</label></td>
<td class="input_sub_title">
<select name="REQUEST_STATUS" id="REQUEST_STATUS" reqTitle="요청승인여부" type="select"></select>
</td>
<td class="input_title"><label for="supply_code">비고</label></td>
<td class="input_sub_title" colspan="3">
<input type="text" name="REQUEST_STATUS_REMARK" id="REQUEST_STATUS_REMARK" value="${resultMap.REQUEST_STATUS_REMARK}">
</td>
</tr>
<tr>
<td class="input_title"><label for="area_cd">제목</label></td>
<td class="input_sub_title" colspan="7">
<input type="text" name="TITLE" id="TITLE" value="${resultMap.TITLE}">
</td>
</tr>
</table>
</div>
</form>
<div id="businessPopupFormWrap" style="z-index:99;">
<c:if test="${'create' eq resultMap.STATUS}">
<div class="plm_btn_wrap">
<input type="button" value="추가" class="plm_btns" id="btnAdd">
<input type="button" value="삭제" class="plm_btns" id="btnDelete">
</div>
</c:if>
<table class="pmsPopupForm" style="margin-top:30px;z-index:99;">
<tr>
<td class="input_title">
<label for="">구매의뢰 부품</label>
</td>
</tr>
<tr>
<td>
<div class="plm_table_wrap container" style="width:100%;z-index:99;">
<table class="plm_table" id="grid" style="z-index:2;"></table>
</div>
</td>
</tr>
</table>
</div>
<div id="businessPopupFormWrap" style="height:180px;">
<table class="pmsPopupForm">
<tr>
<td class="input_title">
<label for="">파일첨부</label>
</td>
</tr>
<tr>
<td>
<div id="salesMngRequestDropZone" class="dropzone"style="width:99% !important;">Drag & Drop Files Here</div>
</td>
</tr>
<tr>
<td>
<div class="project_form_in_table"style="width:100%" id="salesMngRequestFileAreaTable" >
<div style="overflow-y:scroll;">
<table class="" style="width:100%;">
<colgroup>
<col width="10%">
<col width="*">
<col width="20%">
</colgroup>
<thead>
<tr class="plm_thead">
<td>No</td>
<td>첨부파일명</td>
<td>등록일</td>
</tr>
</thead>
</table>
</div>
<div class="plm_scroll_table" style="height:75px;">
<table class="plm_table">
<colgroup>
<col width="10%">
<col width="*">
<col width="20%">
</colgroup>
</table>
<table id="salesMngRequestFileArea" class="fileListscrollTbody">
<tr>
<td colspan="3">첨부 파일이 없습니다.</td>
</tr>
</table>
</div>
</div>
</td>
</tr>
</table>
</div>
<div class="btn_wrap">
<div class="plm_btn_wrap_center">
<input type="button" value="저장" class="plm_btns" id="btnReg">
<input type="button" value="도면일괄다운로드" id="btnDrawingDownload" class="plm_btns align_r">
<input type="button" value="닫기" id="btnClose" class="plm_btns">
</div>
</div>
</section>
</body>
</html>