Files
bns_system/WebContent/WEB-INF/view/orderMgmt/orderExcelImportPopUp.jsp
2025-09-16 14:04:11 +09:00

484 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_jqGrid.jsp"%>
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
var grid;
$(document).ready(function(){
var actionType = "${actionType}";
if(actionType != 'regist'){
$('#partExcelPopupFormWrap').remove();
$('.btn_wrap').remove();
$('.partExcelPopup').remove();
}
//fnc_datepick();
fnc_setFileDropZone("excelImportDropZone", "${objid}", "PART_EXCEL_IMPORT", "Part Excel Import Template", "setExcelFileArea",true,"fileDelete","/part/excelImportFileProc.do");
/* fnc_setFileDropZone("partAttachFileDropZone", "${objid}", "PART_IMPORT_ATTACH", "Import Part Attach File", "setPartFileArea",false,null,"/part/partImportFileProc.do"); */
//fnc_setFileDropZone("dropzone", "${targetObjId}", "${FILE_DOC_TYPE_STRUCTURE_EXCEL_IMPORT_CODE}", "${FILE_DOC_TYPE_STRUCTURE_EXCEL_IMPORT_NAME}", "setUploadTemplateFile", true, "fn_preProcessor");
$("#templateDownload").click(function(){
location.href="/template/ORDER_EXCEL_IMPORT_TEMPLATE.xlsx";
});
//Excel File Upload된 파일 목록 부분을 초기화 한다.
$("#excelImportList").hide();
//Excel File이 Upload되지 않은 경우 파트에 대한 첨부파일 영역을 hide 한다.
/* $("#partAttachFileDropZone").hide(); */
/* var spec_cd = $.parseJSON($("#spec_cd").val()); //jqGrid 구분
var mfa_cd = $.parseJSON($("#mfa_cd").val()); //jqGrid 구분
var process_cd = $.parseJSON($("#process_cd").val()); //jqGrid 구분
var sort_cd = $.parseJSON($("#sort_cd").val()); //jqGrid 구분
var supply_cd = $.parseJSON($("#supply_cd").val()); //jqGrid 계정과목 */
$("#btnDel").click(function(){
gridFn.delRow();
});
grid = $("#expenseDetailGrid").jqGrid({
url: ""
,datatype: "local"
,colNames: ["품명","규격","길이","단위","수량","단가","금액","비고","현재고수량","투입 후 예상재고","발주여부"]
,colModel: [
/* {name:"SORT",index:"SORT", width: 100, align:"center", hidden: false, sortable:false, editable:true
,editoptions:{
dataInit : function(e){
e.style.fontSize = 13;
}
}
}
,{name:"NAME",index:"NAME", width: 150, align:"center", hidden: false, sortable:false, editable:true
,editoptions:{
dataInit : function(e){
e.style.fontSize = 13;
}
}
} */
{name:"PRODUCT_NAME",index:"PRODUCT_NAME", width: 150, align:"center", hidden: false, sortable:false, editable:true
,editoptions:{
dataInit : function(e){
e.style.fontSize = 13;
}
}
}
,{name:"STANDARD",index:"STANDARD", width: 150, align:"center", hidden: false, sortable:false, editable:true
,editoptions:{
dataInit : function(e){
e.style.fontSize = 13;
}
}
,formatter:numFormat
}
,{name:"LENGTH",index:"LENGTH", width: 100, align:"center", hidden: false, sortable:false, editable:true
,editoptions:{
dataInit : function(e){
e.style.fontSize = 13;
}
}
}
,{name:"UNIT",index:"UNIT", width: 110, align:"center", hidden: false, sortable:false, editable:true
,editoptions:{
dataInit : function(e){
e.style.fontSize = 13;
}
}
}
,{name:"QTY" ,index:"QTY" , width:100, align:"center", hidden:false, sortable:false, editable: true
,editoptions:{
dataInit : function(e){
e.style.fontSize = 13;
}
}
}
,{name:"UNIT_PRICE" ,index:"UNIT_PRICE" , width:100, align:"center", hidden:false, sortable:false, editable: true
,editoptions:{
dataInit : function(e){
e.style.fontSize = 13;
}
}
,formatter:numFormat
}
,{name:"PRICE" ,index:"PRICE" , width:100, align:"center", hidden:false, sortable:false, editable: true
,editoptions:{
dataInit : function(e){
e.style.fontSize = 13;
}
}
,formatter:numFormat
}
,{name:"ORI_PRICE" ,index:"ORI_PRICE" , width:100, align:"center", hidden:false, sortable:false, editable: true
,editoptions:{
dataInit : function(e){
e.style.fontSize = 13;
}
}
,formatter:numFormat
}
,{name:"INVENTORY_QTY" ,index:"INVENTORY_QTY" , width:100, align:"center", hidden:false, sortable:false, editable: false
,editoptions:{
dataInit : function(e){
e.style.fontSize = 13;
}
}
}
,{name:"FORECAST_QTY" ,index:"FORECAST_QTY" , width:100, align:"center", hidden:false, sortable:false, editable: false
,editoptions:{
dataInit : function(e){
e.style.fontSize = 13;
}
}
}
,{name:"ORDER_YN" ,index:"ORDER_YN" , width:100, align:"center", hidden:false, sortable:false, editable: false
,editoptions:{
dataInit : function(e){
e.style.fontSize = 13;
}
}
}
]
//,cellEdit : true
//,cellsubmit : "clientArray"
,rownumbers : true
,viewrecords : true
,height : 470
,multiselect : true
,shrinkToFit : false
,autowidth : true
,sortable : false
,rowNum : 2000
,forceFit : false //컬럼의 width를 변화시킬때 그리드의 width를 고정 여부
,jsonReader : {repeatitems: false}
,mtype :"POST"
,footerrow : false //바닥합계
,userDataOnFooter: true //바닥합계
,loadComplete: function(){
}
});
gridFn.modify_search();
});
var gridFn = {
addRow : function() {
var newId = grid.getGridParam("reccount")+1;
var addData = {
"PART_NAME" : "",
"PARENT_PART_NO": "",
"PART_NO" : "",
"QTY" : "",
"SORT_CD" : "",
"SUPPLY_CD" : ""
};
grid.addRowData(newId, addData);
grid.jqGrid("editRow", newId);
}
,delRow : function(){
var selectedRowIds = grid.jqGrid("getGridParam","selarrrow");
if(selectedRowIds.length==0){
Swal.fire("삭제할 행을 선택해주십시오.");
return false;
}
for(var i = selectedRowIds.length - 1; i >= 0; i--){
grid.delRowData(selectedRowIds[i]);
}
}
,opennEdit : function() { //수정가능
var ids = grid.jqGrid("getDataIDs");
for (var i = 0; i < ids.length; i++) {
grid.jqGrid("editRow",ids[i]);
}
}
,closeEdit : function() { //수정불가
var ids = grid.jqGrid("getDataIDs");
for (var i = 0; i < ids.length; i++) {
grid.jqGrid("saveRow", ids[i], /*successFunction*/null, /*url*/"clientArray"/*, extraparam, aftersavefunc,errorfunc, afterrestorefunc*/);
}
}
,getStep2Cd : function(obj){ //2단계연결코드 재설정
var gridExpSubdCdArr = $.parseJSON($("#gridExpSubdCd").val());
var targetObj = $("#"+$(obj).attr("rowid")+"_EXP_SUBD_CD");
targetObj.empty(); //초기화
targetObj.append("<option value=\"\">선택</option>");
for(var i=0; i<gridExpSubdCdArr.length; i++){
cd = gridExpSubdCdArr[i];
if(cd["PARENT_CODE_ID"]==obj.value){
targetObj.append("<option value=\""+cd["CODE_ID"]+"\">"+cd["CODE_NAME"]+"</option>");
}
};
}
,search : function() {
grid.setGridParam({
url: "/ordermgmt/parsingExcelFile.do"
,datatype : "json"
,postData:{"targetObjId":"${objid}","docType":"PART_EXCEL_IMPORT"}
,loadComplete : function(data) {
gridFn.footerSummary();
}
,gridComplete : function() {
gridFn.opennEdit(); //수정가능
}
}).trigger("reloadGrid");
grid.setGridParam({url: "", datatype : "local"});
},modify_search : function() {
grid.setGridParam({
url: "/ordermgmt/getOrderexample.do"
,datatype : "json"
,postData : $("#form1").serialize()
,loadComplete : function(data) {
gridFn.footerSummary();
}
,gridComplete : function() {
gridFn.opennEdit(); //수정가능
}
}).trigger("reloadGrid");
grid.setGridParam({url: "", datatype : "local"});
}
,footerSummary: function(){ //자동합계
$("select[id*=_SORT_CD]").each(function(){
$(this).select2();
} );
$("select[id*=_SUPPLY_CD]").each(function(){
$(this).select2();
} );
}
}
//글자 포멧팅
function numFormat( cellvalue, options, rowObject ){
return numberWithCommas(cellvalue)
}
function numberWithCommas(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
function fn_save(){
var ids = grid.jqGrid("getDataIDs");
//Swal.fire(JSON.stringify(grid.getRowData()));
if(ids!=""){
if(fnc_valitate("form1")){
if(confirm("저장 하시겠습니까?")){
gridFn.closeEdit();
$.ajax({
url:"/ordermgmt/orderApplySave.do"
,type:"POST"
,data: $("#form1").serialize() + "&jqGrid="+ encodeURIComponent(JSON.stringify(grid.getRowData()))
,dataType:"json"
,success:function(data){
if(data =="SUCCESS"){
Swal.fire("저장되었습니다.");
top.opener.fn_search();
self.close();
};
}
,error: function(jqxhr, status, error){
}
});
}
}
}else{
Swal.fire('저장할 데이터가 없습니다.');
}
}
//Excel 파일 업로드 후 처리함수
function setExcelFileArea(){
setUploadTemplateFile("excelImport");
}
//파트 관련 첨부파일 업로드 후 처리함수
function setPartFileArea(){
setUploadTemplateFile("partAttachFile");
}
//템플릿 업로드 후 처리
function setUploadTemplateFile(type){
var docType = "";
var deleteCallBackFN = "";
if(type == "excelImport"){
docType = "PART_EXCEL_IMPORT";
deleteCallBackFN = "excelFileDelete";
}else{
$("#partAttachFileArea").empty();
docType = "PART_IMPORT_ATTACH";
deleteCallBackFN = "setPartFileArea";
}
$.ajax({
url:"/common/getFileList.do",
type:"POST",
data:{"targetObjId":"${objid}", "docType":docType},
dataType:"json",
async:false,
success:function(data){
if(null != data && 0 < data.length){
if("PART_IMPORT_ATTACH" == docType){
$("#defaultPartAttachFileRow").hide();
}
$("#"+type+"List").show();
}
$.each(data, function(i){
var s = "<tr>";
if("PART_IMPORT_ATTACH" == docType){
s += "<td>"+(i+1)+"</td>";
}
s += "<td colspan='2'><a href='javascript:fnc_downloadFile(\""+data[i].OBJID+"\")'>"+data[i].REAL_FILE_NAME+"</a></td>";
/* s += "<td>"+data[i].FILE_SIZE+"</td>"; */
s += "<td><div class='delete_btn' onclick='javascript:fnc_deleteFile(\""+data[i].OBJID+"\", \""+deleteCallBackFN+"\")'></div></td>";
s += "</tr>";
$("#"+type+"Area").append(s);
});
if(type == "excelImport"){
parsingExcelFile();
}
},
error: function(jqxhr, status, error){
Swal.fire(jqxhr.statusText + ", " + status + ", " + error);
Swal.fire(jqxhr.status);
Swal.fire(jqxhr.responseText);
}
});
}
function excelFileDelete(){
$("#excelImportArea").empty();
$("#excelImportList").hide();
$("#parsingPartList").empty();
$("#defaultExcelTemplateRow").show();
}
//Excel 파일 업로드에 따른 파트 첨부파일 영역 DISPLAY
function displayPartFileInfo(flag){
if(flag == "true"){
/* $("#partAttachFileDropZone").show(); */
$("#partAttachFileArea").empty();
$("#defaultPartAttachFileRow").show();
}else{
/* $("#partAttachFileDropZone").show(); */
$("#partAttachFileArea").empty();
$("#partAttachFileList").hide();
}
}
var duplicateCount = 0;
function parsingExcelFile(){
gridFn.search();
}
//파일을 삭제한다.
//Excel 파일 삭제 시 파트 첨부파일도 모두 삭제한다.
function fileDelete(){
if(confirm("Excel 파일을 변경하시겠습니까? 이미 예가내역서 첨부파일이 첨부된 경우 파일은 삭제됩니다.")){
$.ajax({
url:"/common/deleteFileInfo.do",
type:"POST",
data:{"targetObjId":"${objid}"},
dataType:"json",
async:true,
success:function(data){
excelFileDelete();
},
error: function(jqxhr, status, error){
Swal.fire(jqxhr.statusText + ", " + status + ", " + error);
Swal.fire(jqxhr.status);
Swal.fire(jqxhr.responseText);
}
});
}
}
</script>
</head>
<body>
<form name="form1" id="form1" action="" method="post">
<input type="hidden" name="orderobjId" id="orderobjId" value="${orderobjId}">
<input type="hidden" name="costType" id="costType" value="${costType}">
<section>
<div class="plm_menu_name">
<h2><span>예가내역서 upload</span></h2>
</div>
</section>
<div style="clear:both"></div>
<div style=" margin: 0 8px;" class='partExcelPopup'>
<div id="partExcelPopupFormWrap">
<div class="form_popup_title" style="position:relative;">&nbsp;&nbsp;&nbsp;Excel upload<img src="/images/btnExcel.png" style="position:absolute; top:9px; right:135px;"/><span style="position:absolute; top:0px; right:10px; cursor:pointer;" id="templateDownload">Template Download</span></div>
<div id="excelUploadPopupForm">
<div class="fileDnDWrap">
<div id="excelImportDropZone" class="dropzone" style="height:50px;">Drag & Drop 엑셀 템플릿</div>
<div id="excelImportList">
<table id="excelImportTable" class="excelUploadPopupForm">
<thead>
<tr><td colspan="3">Excel 첨부파일</td></tr>
</thead>
<tbody id="excelImportArea">
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<section>
<div class="btn_wrap">
<div class="plm_btn_wrap" style="padding:0 8 0 8; text-align: right;">
<input type="button" class="plm_btns" value="저장" onclick="fn_save();">
<input type="button" value="삭제" class="plm_btns" id="btnDel" name="btnDel" style="background:#dfeffc">
<input type="button" class="plm_btns" value="닫기" onclick="window.close();" >
</div>
</div>
</br></br>
<style>
#excelUploadPopupForm .dropzone {width:99.8% !important}
</style>
<div id="plm_table_wrap1" style="padding:0 8 0 8;">
<div class="excel1" style="overflow-x:scroll;overflow-y:hidden;width:100%;">
<div style="height: 500px;width:100%">
<table class="excel1" id="expenseDetailGrid"></table>
</div>
</div>
</div>
</section>
</form>
</body>
<style>
.excel1::-webkit-scrollbar-thumb {background: linear-gradient(to bottom, #f5d78e, #f5d78e) !important;}
.excel1::-webkit-scrollbar-track {background-color: white;}
.excel1::-webkit-scrollbar-button { display: none; }
</style>
</html>