Files
wace_plm/WebContent/WEB-INF/view/contractMgmt/supplyRegistPopUp.jsp
2025-11-11 14:48:22 +09:00

631 lines
22 KiB
Plaintext

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="com.pms.common.utils.*"%>
<%@ page import="java.util.*" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@include file= "/init_new.jsp" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title><%=Constants.SYSTEM_NAME%></title>
<script>
$(document).ready(function(){
$('.select2').select2();
$("#btn_close").click(function(){
self.close();
opener.fn_search();
});
// 사업자등록증 파일 목록 로드
loadBusRegFile();
// 파일 선택 시 즉시 업로드 및 뷰어 열기
$("#bus_reg_file").change(function(){
var fileInput = this;
if(fileInput.files.length > 0){
// 1개만 허용
if(fileInput.files.length > 1){
Swal.fire("사업자등록증은 1개만 업로드 가능합니다.");
$(this).val("");
return;
}
// PDF 파일만 허용
var file = fileInput.files[0];
if(file.type !== "application/pdf"){
Swal.fire("PDF 파일만 업로드 가능합니다.");
$(this).val("");
return;
}
// 즉시 업로드
uploadBusRegFileInstant(file);
}
});
});
// 선택된 파일 미리보기
function showSelectedFiles(){
var fileInput = $("#bus_reg_file")[0];
var files = fileInput.files;
if(files.length > 0){
var selectedHtml = "<div style='color:#495057; font-size:13px; margin-bottom:5px;'><strong>선택된 파일 ("+files.length+"개)</strong> <span style='color:#dc3545; font-size:12px;'>* 저장 버튼을 눌러야 업로드됩니다</span></div>";
for(var i = 0; i < files.length; i++){
selectedHtml += "<div style='padding:8px; background-color:#fff3cd; border:1px solid #ffc107; border-radius:3px; margin-bottom:5px;'>";
selectedHtml += "<span style='color:#856404; font-size:12px; margin-right:8px;'>📄</span>";
selectedHtml += "<span style='color:#856404;'>"+files[i].name+"</span>";
selectedHtml += "</div>";
}
// 기존 등록된 파일도 함께 표시
var targetObjId = $("#objid").val();
if(targetObjId){
$.ajax({
url: "/common/getFileList.do",
type: "POST",
data: {
targetObjId: targetObjId,
docType: "BUS_REG_CERT"
},
dataType: "json",
async: false,
success: function(data){
if(data && data.length > 0){
selectedHtml += "<div style='color:#495057; font-size:13px; margin-top:15px; margin-bottom:5px;'><strong>기존 등록된 파일 ("+data.length+"개)</strong></div>";
$.each(data, function(i, file){
selectedHtml += "<div style='padding:8px; background-color:#fff; border:1px solid #dee2e6; border-radius:3px; margin-bottom:5px; display:flex; justify-content:space-between; align-items:center;'>";
selectedHtml += "<div style='flex:1;'>";
selectedHtml += "<span style='color:#6c757d; font-size:12px; margin-right:8px;'>📄</span>";
selectedHtml += "<a href='javascript:viewBusRegFile(\""+file.OBJID+"\")' style='color:#0066cc; text-decoration:none;'>"+file.REAL_FILE_NAME+"</a>";
selectedHtml += "</div>";
selectedHtml += "<a href='javascript:deleteBusRegFile(\""+file.OBJID+"\")' style='color:#dc3545; text-decoration:none; font-size:12px; padding:4px 8px; border:1px solid #dc3545; border-radius:3px;'>삭제</a>";
selectedHtml += "</div>";
});
}
}
});
}
$("#busRegFileArea").html(selectedHtml);
}else{
loadBusRegFile();
}
}
// 사업자등록증 즉시 업로드 및 뷰어 열기
function uploadBusRegFileInstant(file){
var targetObjId = $("#objid").val();
if(!targetObjId){
Swal.fire("고객 정보를 먼저 저장해주세요.");
$("#bus_reg_file").val("");
return;
}
Swal.fire({
title: '업로드 중...',
text: '파일을 업로드하고 있습니다.',
allowOutsideClick: false,
didOpen: () => {
Swal.showLoading();
}
});
var formData = new FormData();
formData.append("file1", file);
formData.append("targetObjId", targetObjId);
formData.append("docType", "BUS_REG_CERT");
formData.append("docTypeName", "사업자등록증");
$.ajax({
url: "/common/fileUploadProc.do",
type: "POST",
data: formData,
processData: false,
contentType: false,
success: function(response){
Swal.close();
$("#bus_reg_file").val("");
// 파일 목록 새로고침
loadBusRegFile();
// 업로드 완료 메시지 (자동으로 새 탭 열지 않음)
Swal.fire({
icon: 'success',
title: '업로드 완료',
text: '파일이 업로드되었습니다. 파일명을 클릭하면 미리보기할 수 있습니다.',
timer: 2000,
showConfirmButton: false
});
// 부모 창 새로고침
if(opener && typeof opener.fn_search == "function"){
opener.fn_search();
}
if(opener && opener._tabulGrid){
opener._tabulGrid.replaceData();
}
},
error: function(){
Swal.fire("파일 업로드에 실패했습니다.");
$("#bus_reg_file").val("");
}
});
}
// 사업자등록증 파일 업로드 (저장 시 호출) - 여러 파일 지원
function uploadBusRegFile(callback){
var fileInput = $("#bus_reg_file")[0];
// 파일이 선택되지 않았으면 콜백만 실행
if(fileInput.files.length == 0){
if(callback) callback();
return;
}
var files = fileInput.files;
var uploadCount = 0;
var totalFiles = files.length;
// 모든 파일이 PDF인지 확인
for(var i = 0; i < files.length; i++){
var fileName = files[i].name;
var fileExt = fileName.substring(fileName.lastIndexOf('.')+1).toLowerCase();
if(fileExt != 'pdf'){
Swal.fire("PDF 파일만 업로드 가능합니다: " + fileName);
return;
}
}
// 각 파일을 순차적으로 업로드
function uploadNext(index){
if(index >= totalFiles){
// 모든 파일 업로드 완료
$("#bus_reg_file").val("");
loadBusRegFile();
if(callback) callback();
return;
}
var formData = new FormData();
formData.append("file", files[index]);
formData.append("targetObjId", $("#objid").val());
formData.append("docType", "BUS_REG_CERT");
formData.append("docTypeName", "사업자등록증");
$.ajax({
url: "/common/fileUploadProc.do",
type: "POST",
data: formData,
processData: false,
contentType: false,
success: function(data){
uploadCount++;
uploadNext(index + 1); // 다음 파일 업로드
},
error: function(){
Swal.fire("파일 업로드 중 오류가 발생했습니다: " + files[index].name);
}
});
}
// 첫 번째 파일부터 업로드 시작
uploadNext(0);
}
// 사업자등록증 파일 목록 로드
function loadBusRegFile(){
var targetObjId = $("#objid").val();
if(!targetObjId) return;
$.ajax({
url: "/common/getFileList.do",
type: "POST",
data: {
targetObjId: targetObjId,
docType: "BUS_REG_CERT"
},
dataType: "json",
success: function(data){
$("#busRegFileArea").empty();
if(data && data.length > 0){
var fileListHtml = "<div style='color:#495057; font-size:13px; margin-bottom:5px;'><strong>등록된 파일 ("+data.length+"개)</strong> <span style='color:#6c757d; font-size:11px;'>* 파일명 클릭 시 미리보기</span></div>";
$.each(data, function(i, file){
fileListHtml += "<div style='padding:8px; background-color:#fff; border:1px solid #dee2e6; border-radius:3px; margin-bottom:5px; display:flex; justify-content:space-between; align-items:center;'>";
fileListHtml += "<div style='flex:1;'>";
fileListHtml += "<span style='color:#6c757d; font-size:12px; margin-right:8px;'>📄</span>";
fileListHtml += "<a href='javascript:viewBusRegFile(\""+file.OBJID+"\")' style='color:#0066cc; text-decoration:none; font-weight:500;'>"+file.REAL_FILE_NAME+"</a>";
fileListHtml += "<span style='color:#6c757d; font-size:11px; margin-left:8px;'>("+file.REGDATE+")</span>";
fileListHtml += "</div>";
fileListHtml += "<a href='javascript:deleteBusRegFile(\""+file.OBJID+"\")' style='color:#dc3545; text-decoration:none; font-size:12px; padding:4px 8px; border:1px solid #dc3545; border-radius:3px;'>삭제</a>";
fileListHtml += "</div>";
});
$("#busRegFileArea").html(fileListHtml);
}else{
$("#busRegFileArea").html("<div style='color:#6c757d; font-size:13px; text-align:center; padding:15px;'>등록된 파일이 없습니다.</div>");
}
}
});
}
// 사업자등록증 파일 보기
function viewBusRegFile(fileObjId){
window.open("/common/downloadFile.do?objId="+fileObjId, "_blank");
}
// 사업자등록증 파일 삭제
function deleteBusRegFile(fileObjId){
Swal.fire({
title: '파일을 삭제하시겠습니까?',
text: '삭제된 파일은 복구할 수 없습니다.',
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#d33',
cancelButtonColor: '#3085d6',
confirmButtonText: '삭제',
cancelButtonText: '취소'
}).then((result) => {
if (result.isConfirmed) {
$.ajax({
url: "/common/deleteFile.do",
type: "POST",
data: {objId: fileObjId},
dataType: "json",
success: function(data){
if(data.success){
Swal.fire({
icon: 'success',
title: '삭제되었습니다.',
showConfirmButton: false,
timer: 1500
});
loadBusRegFile();
}else{
Swal.fire({
icon: 'error',
title: '삭제 실패',
text: data.message || '파일 삭제 중 오류가 발생했습니다.'
});
}
},
error: function(xhr, status, error){
console.error("삭제 오류:", error);
Swal.fire({
icon: 'error',
title: '삭제 실패',
text: '파일 삭제 중 오류가 발생했습니다.'
});
}
});
}
});
}
function saveOEMInfo(){
if(fnc_valitate("oemForm")){
Swal.fire({
title: '저장하시겠습니까?',
text: '',
icon: 'warning',
showCancelButton: true, // cancel버튼 보이기. 기본은 원래 없음
confirmButtonColor: '#3085d6', // confrim 버튼 색깔 지정
cancelButtonColor: '#d33', // cancel 버튼 색깔 지정
confirmButtonText: '확인', // confirm 버튼 텍스트 지정
cancelButtonText: '취소', // cancel 버튼 텍스트 지정
reverseButtons: false, // 버튼 순서 거꾸로
}).then(result => {
// 만약 Promise리턴을 받으면,
if (result.isConfirmed) { // 만약 모달창에서 confirm 버튼을 눌렀다면
// 먼저 사업자등록증 파일 업로드 후 저장
uploadBusRegFile(function(){
$.ajax({
url:"/contractMgmt/saveSupMgmtInfo.do",
type:"POST",
data:$("#oemForm").serialize(),
dataType:"json",
async:true,
success:function(data){
if(data.result!=''){
alert('저장되었습니다');
}
opener.fn_search();
self.close();
},
error: function(jqxhr, status, error){
}
});
});
}
});
}
}
//전체 체크 기능
function allCheck(base,name){
var checkObj = document.getElementsByName(name);
var checkFlag = base.checked;
if(0 < checkObj.length){
for(var i=0;i<checkObj.length;i++){
checkObj[i].checked = checkFlag;
}
}else{
checkObj.checked = checkFlag;
}
}
function duplicateCheck(){
var result = false;
var url = "/admin/checkSameOEMCodeAndName.do";
var oemName = $("#oemName").val();
var oemCode = $("#oemCode").val();
$.ajax({
url:url,
type:"POST",
data:{"oemName":oemName,"oemCode":oemCode,"objId":$("#oemObjid").val()},
dataType:"json",
async:false,
success:function(data){
var codeCnt = data.SAME_OEM_CODE_CNT;
var nameCnt = data.SAME_OEM_NAME_CNT;
if(codeCnt > 0){
Swal.fire("고객사 코드가 이미 존재합니다.");
result = true;
return true;
}
if(nameCnt > 0){
Swal.fire("고객사명이 이미 존재합니다.");
result = true;
return true;
}
},
error: function(jqxhr, status, error){
Swal.fire(jqxhr.statusText + ", " + status + ", " + error);
Swal.fire(jqxhr.status);
Swal.fire(jqxhr.responseText);
}
});
return result;
}
//milestone 정보를 수정한다.
function modifyMilestoneInfo(){
if(confirm("변경된 일정정보를 저장하시겠습니까?")){
$.ajax({
url:"/admin/modifyOEMMilestoneInfo.do",
type:"POST",
data:$("#oemForm").serialize(),
dataType:"json",
success:function(data){
if(data.result == "true"){
getOemMileStoneList();
Swal.fire("마일스톤이 저장되었습니다.")
}
}
});
}
}
</script>
</head>
<body>
<form name="oemForm" id="oemForm" action="" method="post">
<input type="hidden" name="objid" id="objid" value="${Info.OBJID}">
<section>
<div class="plm_menu_name">
<h2>
<span>영업관리_고객 등록/수정</span>
</h2>
</div>
<div id="businessPopupFormWrap">
<h4><span>고객정보</span></h4>
<table class="pmsPopupForm">
<colgroup>
<col width="15%">
<col width="35%">
<col width="15%">
<col width="35%">
</colgroup>
<tr>
<!-- <td class="input_title"><label for="">구분</label></td> -->
<!-- <td class="input_sub_title"> -->
<!-- <select name="supply_code" id="supply_code" style="" required reqTitle="구분" type="select" class="select2" autocomplete="off"> -->
<!-- <option value="">선택</option> -->
<%-- ${code_map.supply_code} --%>
<!-- </select> -->
<!-- </td> -->
<td class="input_title"><label for="">고객사명</label></td>
<td class="input_sub_title">
<input type="text" name="supply_name" id="supply_name" value="${Info.SUPPLY_NAME}" required reqTitle="상호명" maxlength="100">
</td>
<td class="input_title"><label for="">사업자등록번호</label></td>
<td class="input_sub_title">
<input type="text" name="bus_reg_no" id="bus_reg_no" value="${Info.BUS_REG_NO}" maxlength="100">
</td>
</tr>
<tr>
<!-- <td class="input_title"><label for="">지역</label></td> -->
<!-- <td class="input_sub_title"> -->
<!-- <select name="area_cd" id="area_cd" style="" class="select2" required reqTitle="지역" type="select" autocomplete="off"> -->
<!-- <option value="">선택</option> -->
<%-- ${code_map.area_cd} --%>
<!-- </select> -->
<!-- </td> -->
<td class="input_title"><label for="">대표자명</label></td>
<td class="input_sub_title">
<input type="text" name="charge_user_name" id="charge_user_name" value="${Info.CHARGE_USER_NAME}" required reqTitle="대표자명" maxlength="100">
</td>
<td class="input_title"><label for="">실사용자명</label></td>
<td class="input_sub_title">
<input type="text" name="reg_id" id="reg_id" value="${Info.REG_ID}" required reqTitle="실사용자명" maxlength="100">
</td>
</tr>
<tr>
<td class="input_title"><label for="">법인/주민번호</label></td>
<td class="input_sub_title">
<input type="text" name="reg_no" id="reg_no" value="${Info.REG_NO2}" maxlength="100">
</td>
<td class="input_title"><label for="">업태</label></td>
<td class="input_sub_title">
<input type="text" name="supply_busname" id="supply_busname" value="${Info.SUPPLY_BUSNAME}" maxlength="100">
</td>
</tr>
<tr>
<td class="input_title"><label for="">업종</label></td>
<td class="input_sub_title">
<input type="text" name="supply_stockname" id="supply_stockname" value="${Info.SUPPLY_STOCKNAME}" maxlength="100">
</td>
<td class="input_title"><label for="">주소</label></td>
<td class="input_sub_title">
<input type="text" name="supply_address" id="supply_address" maxlength="100" value="${Info.SUPPLY_ADDRESS}" />
</td>
</tr>
<tr>
<td class="input_title"><label for="">핸드폰</label></td>
<td class="input_sub_title">
<input type="text" name="supply_tel_no" id="supply_tel_no" value="${Info.SUPPLY_TEL_NO}" maxlength="100">
</td>
<td class="input_title"><label for="">E-MAIL</label></td>
<td class="input_sub_title">
<input type="text" name="email" id="email" value="${Info.EMAIL}" maxlength="100">
</td>
</tr>
<tr>
<td class="input_title"><label for="">OFFICE NO</label></td>
<td class="input_sub_title">
<input type="text" name="office_no" id="office_no" value="${Info.OFFICE_NO}" maxlength="100">
</td>
<td class="input_title"><label for="">FAX NO</label></td>
<td class="input_sub_title">
<input type="text" name="supply_fax_no" id="supply_fax_no" value="${Info.SUPPLY_FAX_NO}" maxlength="100">
</td>
</tr>
<!-- 담당자 정보 섹션 -->
<tr>
<td colspan="4" style="padding: 10px 0; background-color: #f5f5f5;">
<h4 style="margin: 0; padding-left: 10px;">담당자 정보</h4>
</td>
</tr>
<tr>
<td class="input_title"><label for="">담당자1</label></td>
<td class="input_sub_title">
<input type="text" name="manager1_name" id="manager1_name" value="${Info.MANAGER1_NAME}" maxlength="100" placeholder="이름">
</td>
<td class="input_title"><label for="">이메일</label></td>
<td class="input_sub_title">
<input type="text" name="manager1_email" id="manager1_email" value="${Info.MANAGER1_EMAIL}" maxlength="100" placeholder="이메일">
</td>
</tr>
<tr>
<td class="input_title"><label for="">담당자2</label></td>
<td class="input_sub_title">
<input type="text" name="manager2_name" id="manager2_name" value="${Info.MANAGER2_NAME}" maxlength="100" placeholder="이름">
</td>
<td class="input_title"><label for="">이메일</label></td>
<td class="input_sub_title">
<input type="text" name="manager2_email" id="manager2_email" value="${Info.MANAGER2_EMAIL}" maxlength="100" placeholder="이메일">
</td>
</tr>
<tr>
<td class="input_title"><label for="">담당자3</label></td>
<td class="input_sub_title">
<input type="text" name="manager3_name" id="manager3_name" value="${Info.MANAGER3_NAME}" maxlength="100" placeholder="이름">
</td>
<td class="input_title"><label for="">이메일</label></td>
<td class="input_sub_title">
<input type="text" name="manager3_email" id="manager3_email" value="${Info.MANAGER3_EMAIL}" maxlength="100" placeholder="이메일">
</td>
</tr>
<tr>
<td class="input_title"><label for="">담당자4</label></td>
<td class="input_sub_title">
<input type="text" name="manager4_name" id="manager4_name" value="${Info.MANAGER4_NAME}" maxlength="100" placeholder="이름">
</td>
<td class="input_title"><label for="">이메일</label></td>
<td class="input_sub_title">
<input type="text" name="manager4_email" id="manager4_email" value="${Info.MANAGER4_EMAIL}" maxlength="100" placeholder="이메일">
</td>
</tr>
<tr>
<td class="input_title"><label for="">담당자5</label></td>
<td class="input_sub_title">
<input type="text" name="manager5_name" id="manager5_name" value="${Info.MANAGER5_NAME}" maxlength="100" placeholder="이름">
</td>
<td class="input_title"><label for="">이메일</label></td>
<td class="input_sub_title">
<input type="text" name="manager5_email" id="manager5_email" value="${Info.MANAGER5_EMAIL}" maxlength="100" placeholder="이메일">
</td>
</tr>
<!-- 사업자등록증 첨부 섹션 -->
<tr>
<td colspan="4" style="padding: 10px; background-color: #f8f9fa; border-top: 2px solid #dee2e6;">
<strong style="font-size: 14px;">📎 사업자등록증</strong>
</td>
</tr>
<tr>
<td class="input_title" style="vertical-align: top; padding-top: 15px;"><label for="">파일 선택</label></td>
<td colspan="3" class="input_sub_title">
<div style="margin-bottom: 8px;">
<input type="file" name="bus_reg_file" id="bus_reg_file" accept=".pdf" style="width:100%; max-width:500px;">
</div>
<div style="color:#6c757d; font-size:12px; margin-bottom: 10px;">
💡 PDF 파일 1개만 가능 | 선택 시 자동 업로드 및 미리보기
</div>
<input type="hidden" name="bus_reg_file_objid" id="bus_reg_file_objid" value="${Info.BUS_REG_FILE_OBJID}">
<div id="busRegFileArea" style="margin-top:10px; padding:10px; background-color:#f8f9fa; border-radius:4px; min-height:50px;">
<!-- 업로드된 파일 목록 표시 영역 -->
</div>
</td>
</tr>
<%-- <tr>
<td><label for="">상태(활성화 여부)</label></td>
<td>
<select name="status" id="status">
<option value="">선택</option>
<option value="active" ${Info.STATUS eq 'active' ? 'selected' : ''}>활성화</option>
<option value="inActive" ${Info.STATUS eq 'inActive' ? 'selected' : ''}>비활성화</option>
</select>
</td>
</tr> --%>
</table>
</div>
<div class="btn_wrap">
<div class="plm_btn_wrap_center">
<input type="button" value="저장" class="plm_btns" onclick="javascript:saveOEMInfo();">
<input type="button" value="닫기" name="" id="btn_close" class="plm_btns" onclick="javascript:self.close();">
</div>
</div>
</section>
</form>
</body>
</html>