Files
wace_plm/WebContent/WEB-INF/view/admin/clientMng/clientExcelImportPopUp.jsp
2025-11-26 11:12:42 +09:00

945 lines
40 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>
<style type="text/css">
::-webkit-scrollbar-thumb {
background: linear-gradient(to bottom, #f5d78e, #f5d78e);
}
</style>
<script type="text/javascript">
var grid;
$(document).ready(function(){
// 거래처 구분 코드 (안전하게 파싱)
var client_type_value = $("textarea#client_type").val();
var client_type = {};
try {
if (client_type_value && client_type_value.trim() !== "") {
client_type = $.parseJSON(client_type_value);
}
} catch(e) {
console.warn("client_type JSON 파싱 실패, 빈 객체 사용:", e);
client_type = {};
}
//fnc_datepick();
console.log("=== 엑셀 업로드 초기화 시작 ===");
console.log("objid:", "${objid}");
console.log("excelImportDropZone 존재:", $("#excelImportDropZone").length);
// 드래그앤드롭 기본 동작 완전 차단
window.addEventListener('dragover', function(e) {
e.preventDefault();
}, false);
window.addEventListener('drop', function(e) {
e.preventDefault();
}, false);
// 드롭존 설정
fnc_setFileDropZone("excelImportDropZone", "${objid}", "CLIENT_EXCEL_IMPORT", "Client Excel Import Template", "setExcelFileArea",true,"fileDelete","/admin/excelImportFileProc.do");
// 파일 input의 클릭 이벤트가 부모로 전파되지 않게 막기
$("#excelFileInput").on("click", function(e) {
e.stopPropagation();
});
// 드롭존 클릭 시 파일 선택 창 열기
$("#excelImportDropZone").on("click", function(e) {
// input 자체를 클릭한 경우는 무시
if ($(e.target).is("#excelFileInput")) {
return;
}
console.log("드롭존 클릭됨!");
e.preventDefault();
e.stopPropagation();
$("#excelFileInput")[0].click(); // jQuery trigger 대신 native click 사용
});
// 파일 선택 시 업로드
$("#excelFileInput").on("change", function(e) {
console.log("파일 input change 이벤트 발생!");
var files = e.target.files;
if (files && files.length > 0) {
console.log("선택된 파일:", files[0].name, "크기:", files[0].size);
// 확인 창 표시
if(confirm(files.length + "개의 파일을 업로드 하시겠습니까?")) {
var data = new FormData();
for (var i = 0; i < files.length; i++) {
data.append('file', files[i]);
}
data.append("targetObjId", "${objid}");
data.append("docType", "CLIENT_EXCEL_IMPORT");
data.append("docTypeName", "Client Excel Import Template");
$.ajax({
url: "/admin/excelImportFileProc.do",
method: 'post',
data: data,
dataType: 'text',
processData: false,
contentType: false,
beforeSend: function() {
console.log("업로드 시작...");
},
success: function(res) {
console.log("업로드 성공!", res);
alert("업로드 완료!");
setExcelFileArea(); // 파일 목록 새로고침
},
error: function(jqxhr, status, error) {
console.error("업로드 실패:", status, error);
alert("업로드 실패: " + error);
}
});
}
// input 초기화 (같은 파일 재선택 가능하게)
$(this).val('');
} else {
console.log("파일이 선택되지 않음");
}
});
console.log("=== 드롭존 설정 완료 ===");
grid = $("#clientDetailGrid").jqGrid({
url: ""
,datatype: "local"
,colNames: ["","회사코드","거래처코드","거래처명","TR_NMK","거래처약칭","ATTR_NMK","구분","사업자등록번호","주민등록번호","대표자명","CEO_NMK",
"업태","종목","우편번호","주소1","주소2","ADDR_FG","전화번호","팩스번호","홈페이지","메일주소","LIQ_RS","주류여부",
"국가명","분류코드","분류명","등급코드","등급명","수금거래처코드","수금거래처명","지역코드명","지역명",
"거래시작일","거래종료일","사용여부",
"계약시작일","계약종료일","거래형태","할인율","계약금액","월용역비","결제조건","RCP_TP","여신한도금액","한도회귀일",
"매입_금융기관코드","매입_금융기관명","매입_지점명","매입_결제계좌","매입_예금주명","매입_지급예정","매입_전표유형","매입_세무구분",
"매출_은행코드","매출_수금은행명","매출_계좌개설점","매출_계좌번호","매출_수금예정","매출_전표유형","매출_세무구분",
"업체담당_부서명","업체담당_직급","업체담당_담당업무","업체담당_담당자명","업체담당_전화번호","업체담당_내선번호","업체담당_핸드폰번호","업체담당_메일주소",
"관리담당_부서코드","관리담당_부서명","관리담당_직급명","관리담당_담당업무","관리담당_사원코드","관리담당_사원명","관리담당_전화번호","관리담당_내선번호","관리담당_핸드폰번호","관리담당_메일주소","관리담당_비고",
"수신처_비고","수신처_우편번호","수신처_주소1","수신처_주소2","REC_ADDR_FG","수신처_전화번호","수신처_팩스번호",
"프로젝트코드","프로젝트명","PJT_NMK","외부데이터코드","전자세금계산서여부","단위신고거래처","종사업장번호","조달청다수공급자",
"USER_DEF_DC1","USER_DEF_DC2",
"USE_FG","USE_NM","BIZCON_FG","BIZCON_NM","SHIP_TP","SHIP_NM",
"예정일구분","예정일","용도구분","FOR_YN","CHECK_DATA",
"CHECK_STATE","CHECK_ORDER","FIXED_ORDER"]
,colModel: [
{name:"rn",index:"rn", width: 25, align:"center", hidden: false, sortable:false, editable:false}
,{name:"COMP_CODE",index:"COMP_CODE", width: 100, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"CLIENT_CD",index:"CLIENT_CD", width: 200, align:"center", hidden: false, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"CLIENT_NM",index:"CLIENT_NM", width: 200, align:"center", hidden: false, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"TR_NMK",index:"TR_NMK", width: 200, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"CLIENT_NMK",index:"CLIENT_NMK", width: 200, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"ATTR_NMK",index:"ATTR_NMK", width: 100, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"CLIENT_TYPE",index:"CLIENT_TYPE", width: 100, align:"center", hidden: false, sortable:false, editable:true
,edittype:"select"
,formatter:"select"
,editoptions:{
value: client_type
,dataInit : function(e){
e.style.width = "92%";
e.style.fontSize = 13;
}
}
}
,{name:"BUS_REG_NO",index:"BUS_REG_NO", width: 150, align:"center", hidden: false, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"RESIDENT_NO",index:"RESIDENT_NO", width: 150, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"CEO_NM",index:"CEO_NM", width: 150, align:"center", hidden: false, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"CEO_NMK",index:"CEO_NMK", width: 100, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"BUS_TYPE",index:"BUS_TYPE", width: 150, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"BUS_ITEM",index:"BUS_ITEM", width: 150, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"POST_NO",index:"POST_NO", width: 100, align:"center", hidden: false, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"ADDR1",index:"ADDR1", width: 300, align:"center", hidden: false, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"ADDR2",index:"ADDR2", width: 300, align:"center", hidden: false, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"ADDR_FG",index:"ADDR_FG", width: 100, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"TEL_NO",index:"TEL_NO", width: 150, align:"center", hidden: false, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"FAX_NO",index:"FAX_NO", width: 150, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"HOMEPAGE",index:"HOMEPAGE", width: 200, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"EMAIL",index:"EMAIL", width: 200, align:"center", hidden: false, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"LIQ_RS",index:"LIQ_RS", width: 100, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"TR_FG",index:"TR_FG", width: 100, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"COUNTRY_NM",index:"COUNTRY_NM", width: 150, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"CLASS_CD",index:"CLASS_CD", width: 100, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"CLASS_NM",index:"CLASS_NM", width: 150, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"GRADE_CD",index:"GRADE_CD", width: 100, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"GRADE_NM",index:"GRADE_NM", width: 150, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"COLLECT_CLIENT_CD",index:"COLLECT_CLIENT_CD", width: 150, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"COLLECT_CLIENT_NM",index:"COLLECT_CLIENT_NM", width: 200, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"REGION_CD",index:"REGION_CD", width: 100, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"REGION_NM",index:"REGION_NM", width: 150, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"TRADE_START_DT",index:"TRADE_START_DT", width: 100, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"TRADE_END_DT",index:"TRADE_END_DT", width: 100, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"USE_YN",index:"USE_YN", width: 80, align:"center", hidden: false, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"CONTRACT_START_DT",index:"CONTRACT_START_DT", width: 100, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"CONTRACT_END_DT",index:"CONTRACT_END_DT", width: 100, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"TRADE_TYPE",index:"TRADE_TYPE", width: 100, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"DISCOUNT_RATE",index:"DISCOUNT_RATE", width: 100, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"CONTRACT_AMT",index:"CONTRACT_AMT", width: 120, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"MONTHLY_FEE",index:"MONTHLY_FEE", width: 100, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"PAYMENT_TERM",index:"PAYMENT_TERM", width: 150, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"RCP_TP",index:"RCP_TP", width: 100, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"CREDIT_LIMIT",index:"CREDIT_LIMIT", width: 120, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"LIMIT_RETURN_DAY",index:"LIMIT_RETURN_DAY", width: 100, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"PUR_BANK_CD",index:"PUR_BANK_CD", width: 100, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"PUR_BANK_NM",index:"PUR_BANK_NM", width: 150, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"PUR_BRANCH_NM",index:"PUR_BRANCH_NM", width: 150, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"PUR_ACCOUNT_NO",index:"PUR_ACCOUNT_NO", width: 150, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"PUR_ACCOUNT_HOLDER",index:"PUR_ACCOUNT_HOLDER", width: 150, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"PUR_PAY_PLAN",index:"PUR_PAY_PLAN", width: 150, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"PUR_SLIP_TYPE",index:"PUR_SLIP_TYPE", width: 100, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"PUR_TAX_TYPE",index:"PUR_TAX_TYPE", width: 100, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"SALE_BANK_CD",index:"SALE_BANK_CD", width: 100, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"SALE_BANK_NM",index:"SALE_BANK_NM", width: 150, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"SALE_BRANCH_NM",index:"SALE_BRANCH_NM", width: 150, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"SALE_ACCOUNT_NO",index:"SALE_ACCOUNT_NO", width: 150, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"SALE_COLLECT_PLAN",index:"SALE_COLLECT_PLAN", width: 150, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"SALE_SLIP_TYPE",index:"SALE_SLIP_TYPE", width: 100, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"SALE_TAX_TYPE",index:"SALE_TAX_TYPE", width: 100, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"VENDOR_DEPT_NM",index:"VENDOR_DEPT_NM", width: 150, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"VENDOR_POSITION",index:"VENDOR_POSITION", width: 100, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"VENDOR_DUTY",index:"VENDOR_DUTY", width: 150, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"VENDOR_MANAGER_NM",index:"VENDOR_MANAGER_NM", width: 150, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"VENDOR_TEL",index:"VENDOR_TEL", width: 120, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"VENDOR_EXT",index:"VENDOR_EXT", width: 80, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"VENDOR_MOBILE",index:"VENDOR_MOBILE", width: 120, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"VENDOR_EMAIL",index:"VENDOR_EMAIL", width: 200, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"MGR_DEPT_CD",index:"MGR_DEPT_CD", width: 100, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"MGR_DEPT_NM",index:"MGR_DEPT_NM", width: 150, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"MGR_POSITION",index:"MGR_POSITION", width: 100, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"MGR_DUTY",index:"MGR_DUTY", width: 150, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"MGR_EMP_CD",index:"MGR_EMP_CD", width: 100, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"MGR_EMP_NM",index:"MGR_EMP_NM", width: 150, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"MGR_TEL",index:"MGR_TEL", width: 120, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"MGR_EXT",index:"MGR_EXT", width: 80, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"MGR_MOBILE",index:"MGR_MOBILE", width: 120, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"MGR_EMAIL",index:"MGR_EMAIL", width: 200, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"MGR_REMARK",index:"MGR_REMARK", width: 200, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"REC_REMARK",index:"REC_REMARK", width: 200, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"REC_POST_NO",index:"REC_POST_NO", width: 100, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"REC_ADDR1",index:"REC_ADDR1", width: 300, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"REC_ADDR2",index:"REC_ADDR2", width: 300, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"REC_ADDR_FG",index:"REC_ADDR_FG", width: 100, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"REC_TEL",index:"REC_TEL", width: 120, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"REC_FAX",index:"REC_FAX", width: 120, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"PROJECT_CD",index:"PROJECT_CD", width: 100, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"PROJECT_NM",index:"PROJECT_NM", width: 200, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"PJT_NMK",index:"PJT_NMK", width: 100, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"EXT_DATA_CD",index:"EXT_DATA_CD", width: 100, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"E_TAX_YN",index:"E_TAX_YN", width: 80, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"UNIT_REPORT_CLIENT",index:"UNIT_REPORT_CLIENT", width: 150, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"SUB_BUS_NO",index:"SUB_BUS_NO", width: 120, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"PROCUREMENT_YN",index:"PROCUREMENT_YN", width: 80, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"USER_DEF_DC1",index:"USER_DEF_DC1", width: 150, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"USER_DEF_DC2",index:"USER_DEF_DC2", width: 150, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"USE_FG",index:"USE_FG", width: 100, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"USE_NM",index:"USE_NM", width: 150, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"BIZCON_FG",index:"BIZCON_FG", width: 100, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"BIZCON_NM",index:"BIZCON_NM", width: 150, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"SHIP_TP",index:"SHIP_TP", width: 100, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"SHIP_NM",index:"SHIP_NM", width: 150, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"PLAN_DAY_TYPE",index:"PLAN_DAY_TYPE", width: 100, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"PLAN_DAY",index:"PLAN_DAY", width: 100, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"PURPOSE_TYPE",index:"PURPOSE_TYPE", width: 100, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"FOR_YN",index:"FOR_YN", width: 80, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"CHECK_DATA",index:"CHECK_DATA", width: 200, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"CHECK_STATE",index:"CHECK_STATE", width: 100, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"CHECK_ORDER",index:"CHECK_ORDER", width: 100, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
,{name:"FIXED_ORDER",index:"FIXED_ORDER", width: 100, align:"center", hidden: true, sortable:false, editable:true
,editoptions:{dataInit : function(e){e.style.fontSize = 13;}}
}
]
,rownumbers : true
,viewrecords : true
,height : 330
,multiselect : false
,shrinkToFit : false
,autowidth : true
,sortable : false
,rowNum : 2000
,forceFit : false //컬럼의 width를 변화시킬때 그리드의 width를 고정 여부
,jsonReader : {repeatitems: false}
,mtype :"POST"
,footerrow : false //바닥합계
,userDataOnFooter: true //바닥합계
,loadComplete: function(){
}
,onCellSelect: function(rowid,icol,cellcontent,e){
var value = $("#"+rowid+"_CLIENT_CD").val();
if(icol==10){
fn_ClientDetail(value);
}
}
});
//gridFn.search();
});
function fn_count(){
// jqGrid 데이터로 중복 체크 (DB 조회 대신 JavaScript로 처리)
var gridData = grid.getRowData();
var dupCnt = 0;
var nowCnt = 0;
// 각 행의 CLIENT_CD로 DB에 이미 존재하는지 체크
for(var i = 0; i < gridData.length; i++){
var clientCd = gridData[i].CLIENT_CD;
if(clientCd && clientCd.trim() !== ""){
// AJAX로 중복 체크
$.ajax({
url:"/admin/checkDuplicateClientMngList.do",
type:"POST",
data:{"CLIENT_CD": clientCd},
dataType:"json",
async: false,
success:function(data){
if(data.result == "true"){
dupCnt++; // 중복
} else {
nowCnt++; // 신규
}
},
error: function(jqxhr, status, error){
nowCnt++; // 에러 시 신규로 간주
}
});
}
}
$("#dup_cnt").text(dupCnt);
$("#now_cnt").text(nowCnt);
}
//SR자료등록 팝업
function fn_ClientDetail(objId){
window.open("/admin/clientDetailPopUp.do?OBJID="+objId, "", "width=1750, height=460");
}
var gridFn = {
addRow : function() {
var newId = grid.getGridParam("reccount")+1;
var addData = {
"CLIENT_CD": "",
"CLIENT_NM": "",
"CLIENT_NMK": "",
"CLIENT_TYPE": "",
"BUS_REG_NO": "",
"RESIDENT_NO": "",
"CEO_NM": "",
"BUS_TYPE": "",
"BUS_ITEM": "",
"POST_NO": "",
"ADDR1": "",
"ADDR2": "",
"TEL_NO": "",
"FAX_NO": "",
"HOMEPAGE": "",
"EMAIL": "",
"REMARK": ""
};
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")+"_CLIENT_TYPE_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() {
//save_excel();
grid.setGridParam({
url: "/admin/parsingExcelClient.do"
,datatype : "json"
,postData:{"targetObjId":"${objid}","docType":"CLIENT_EXCEL_IMPORT"}
,loadComplete : function() {
gridFn.footerSummary();
fn_count();
}
,gridComplete : function() {
gridFn.opennEdit(); //수정가능
}
}).trigger("reloadGrid");
grid.setGridParam({url: "", datatype : "local"});
}
/* ,modify_search : function() {
Swal.fire('asdsadas');
grid.setGridParam({
url: "/partmgmt/parsingExcelData.do"
,datatype : "json"
,postData : {"targetObjId":"${objid}"}
,loadComplete : function(data) {
gridFn.footerSummary();
}
,gridComplete : function() {
gridFn.opennEdit(); //수정가능
}
}).trigger("reloadGrid");
grid.setGridParam({url: "", datatype : "local"});
} */
,footerSummary: function(){ //자동합계
$("select[id*=_CLIENT_TYPE]").each(function(){
$(this).select2();
} );
}
}
/* function save_excel(){
$.ajax({
url:"/partmgmt/parsingExcelFile.do?targetObjId=${objid}&docType=PART_EXCEL_IMPORT"
,type:"POST"
,data:""
,dataType:"json"
//,contentType: "application/json; charset=utf-8"
,success:function(data){
gridFn.modify_search();
}
,error: function(jqxhr, status, error){
}
});
} */
function fn_save(){
var ids = grid.jqGrid("getDataIDs");
if(ids!=""){
if(fnc_valitate("form1")){
if(confirm("저장 하시겠습니까? 기등록된 거래처는 제외 됩니다.")){
gridFn.closeEdit();
var gridData = JSON.stringify(grid.getRowData());
gridData = gridData.replace(/&/gi, "§");
gridData = gridData.replace(/%/gi, "※");
$.ajax({
url:"/admin/clientApplySave.do"
,type:"POST"
,data: $("#form1").serialize() + "&jqGrid="+ gridData
,dataType:"json"
//,contentType: "application/json; charset=utf-8"
,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 = "CLIENT_EXCEL_IMPORT";
deleteCallBackFN = "excelFileDelete";
}else{
$("#clientAttachFileArea").empty();
docType = "CLIENT_IMPORT_ATTACH";
deleteCallBackFN = "setClientFileArea";
}
$.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("CLIENT_IMPORT_ATTACH" == docType){
$("#defaultClientAttachFileRow").hide();
}
$("#"+type+"List").show();
}
$.each(data, function(i){
var s = "<tr>";
if("CLIENT_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><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();
$("#parsingClientList").empty();
$("#defaultClientExcelTemplateRow").show();
}
//Excel 파일 업로드에 따른 파트 첨부파일 영역 DISPLAY
function displayPartFileInfo(flag){
if(flag == "true"){
$("#partAttachFileDropZone").show();
$("#clientAttachFileArea").empty();
$("#defaultClientAttachFileRow").show();
}else{
$("#partAttachFileDropZone").show();
$("#clientAttachFileArea").empty();
$("#clientAttachFileList").hide();
}
}
var duplicateCount = 0;
function parsingExcelFile(){
gridFn.search();
}
function savePart(){
if(0 < $("input[name='clientObjId']").length){
var cnt = 0;
$("input[name='clientObjId']").each(function(idx){
var targetObjId = $(this).val();
// 검증 로직 생략
if(cnt == 0){
$("input[name='clientObjId']").each(function(idx){
var otherObjId = $(this).val();
if(otherObjId != targetObjId){
if($("#"+otherObjId+"_CLIENT_CD").val() == $("#"+targetObjId+"_CLIENT_CD").val()){
Swal.fire("문서내 중복되는 거래처코드가 존재 합니다.("+$("#"+otherObjId+"_CLIENT_CD").val()+","+$("#"+targetObjId+"_CLIENT_CD").val()+")");
cnt++;
return false;
}
}
});
}
});
if(duplicateCount > 0){
Swal.fire("등록 불가한 거래처코드가 있어 저장할 수 없습니다.");
return false;
}
if(0 == cnt){
if(confirm("해당거래처 정보를 저장하시겠습니까?")){
var param = $("#form1").serialize();
$.ajax({
type : "POST",
url : "/admin/clientApplySave.do",
data: param,
dataType:"json",
async:false,
error: function(jqxhr, status, error){
Swal.fire(jqxhr.statusText + ", " + status + ", " + error);
Swal.fire(jqxhr.status);
Swal.fire(jqxhr.responseText);
},
success: function(result){
if(null != result){
Swal.fire(result.message);
opener.search();
self.close();
}
}
});
}
}
}else{
Swal.fire("저장할 정보가 없습니다.");
}
}
//파일을 삭제한다.
//Excel 파일 삭제 시 파트 첨부파일도 모두 삭제한다.
function fileDelete(){
if(confirm("Excel 파일을 변경하시겠습니까? 이미 Client 첨부파일이 첨부된 경우 파일은 삭제됩니다.")){
$.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="hiddenForm" id="hiddenForm" method="post">
<input type="hidden" name="OBJID" id="OBJID">
</form>
<form name="form1" id="form1" action="" method="post">
<input type="hidden" name="importPopObjid" id="importPopObjid" value="${objid}">
<input type="hidden" name="client_mgmt_objid" id="client_mgmt_objid" value="${client_mgmt_objid}">
<input type="hidden" name="upg_no" id="upg_no" value="${upg_objid}">
<input type="hidden" name="client_name" id="client_name" value="${client_name}">
<input type="hidden" name="client_type" id="client_type" value="${client_type}">
<section>
<div class="plm_menu_name">
<h2><span>거래처관리_Excel upload</span></h2>
</div>
</section>
<div style="font-size:12px;float:left;margin:13px 13px 5px 13px">
회사코드 <select name="comp_code" id="comp_code" disabled="disabled">
<option value="">선택</option>
${code_map.comp_code}
</select>
<!-- <select name="model_code" id="model_code" style="" class="select2" autocomplete="off" disabled="disabled"> -->
<!-- </select> -->
</div>
<div style="clear:both"></div>
<div style=" margin: 0 8px;">
<div id="clientExcelPopupFormWrap">
<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="clientExcelUploadPopupForm">
<div class="fileDnDWrap">
<div id="excelImportDropZone" class="dropzone" style="height:80px; line-height:80px; text-align:center; border:2px dotted #8296C2; background:#f9f9f9; cursor:pointer;">
<span style="color:#666;">📁 엑셀 파일을 드래그 & 드롭 또는 클릭하여 선택하세요</span>
<input type="file" id="excelFileInput" accept=".xlsx,.xls" style="display:none;">
</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="gridFn.search();">
<input type="button" class="plm_btns" value="저장" onclick="fn_save();">
<input type="button" class="plm_btns" value="닫기" onclick="window.close();" >
</div>
<div class="ascendig_text">
<font size="3px" style="padding-left: 10px;">신규 <span id="now_cnt">0</span>건</font>
<font size="3px">중복 <span id="dup_cnt">0</span>건</font>
</div>
</div>
</br></br>
<style>
#excelUploadPopupForm .dropzone {width:99.8% !important}
</style>
<div id="client_table_wrap1" style="padding:0 8 0 8;">
<div style="">
<div style="height: 270px;">
<table id="clientDetailGrid"></table>
<!-- <div id="jqGridPager"></div> -->
</div>
</div>
</div>
</section>
</form>
<textarea style="width:0px; height:0px; visibility: hidden;" id="comp_code">${code_map.comp_code}</textarea><!-- 코드동적설정 -->
<textarea style="width:0px; height:0px; visibility: hidden;" id="client_type">${code_map.client_type}</textarea><!-- 코드동적설정 -->
<textarea style="width:0px; height:0px; visibility: hidden;" id="client_addr1">${code_map.client_addr1}</textarea><!-- 코드동적설정 -->
</body>
</html>