//contextRoot 경로 var contextPath = '/edu'; /*-------------------------------------------------------------------------------------------- Spec : 숫자만 입력 / 세자리 콤마 Argument : string Return : string Example : class="numfmt" ==> 샘플페이지 : bsnsPblancForm.jsp // 숫자/세자리 콤마 ==> 페이지 상단에 설정 //$('.numfmt').commaNumber(); // 숫자만 입력 ==> 페이지 상단에 설정 //$('.number').onlyNumber(); // 숫자이외의 값 삭제 ==> 저장시 사용 //$('.numfmt').removeText(); ---------------------------------------------------------------------------------------------*/ (function ($) { // 숫자 제외하고 모든 문자 삭제. $.fn.removeText = function(_v, ext){ if(ext == null) ext =""; var patten = new RegExp("[^0-9"+ext+"]", "g"); if(typeof(_v)==="undefined"){ $(this).each(function(){ this.value = this.value.replace(patten,''); }); }else{ return _v.replace(patten,''); } }; // 세자리 꼼마 $.fn.numberFormat = function(_v){ this.proc = function(_v){ var tmp = '', number = '', cutlen = 3, comma = ',' i = 0, len = _v.length, mod = (len % cutlen), k = cutlen - mod; for(var i;i < len;i++){ number = number + _v.charAt(i); if(i < len - 1){ k++; if((k % cutlen) == 0){ number = number + comma; k = 0; } } } return number; }; var proc = this.proc; if(typeof(_v)==="undefined"){ $(this).each(function(){ this.value = proc($(this).removeText(this.value)); }); }else{ return proc(_v); } }; // 숫자만. $.fn.onlyNumber = function (p){ $(this).each(function(i) { //$(this).attr({'style':'text-align:right'}); this.value = $(this).removeText(this.value); $(this).bind('keypress keyup',function(e){ this.value = $(this).removeText(this.value); }); }); }; // 위 두개의 합성. // 숫자만 + 세자리 콤마. $.fn.commaNumber = function (p){ $(this).each(function(i) { //$(this).attr({'style':'text-align:right'}); this.value = $(this).removeText(this.value); this.value = $(this).numberFormat(this.value); $(this).bind('keypress keyup',function(e){ this.value = $(this).removeText(this.value); this.value = $(this).numberFormat(this.value); }); }); }; // 위 두개의 합성. // '-' 숫자. $.fn.extNumber = function (p){ $(this).each(function(i) { this.value = $(this).removeText(this.value, p); $(this).bind('keypress keyup',function(e){ this.value = $(this).removeText(this.value, p); }); }); }; })(jQuery); // 탭 이동 function fn_tabMove(url) { $("#pform").attr("target", "_self"); $("#pform").attr("action", url); $("#pform").submit(); } //필수 입력값 체크 function fn_val_chk(id){ var _type = $(id).attr('type'); if(_type == "text" || $(id)[0].type == "textarea"){ var _val = $.trim($(id).val()); $(id).val(_val); if(_val.length < 1){ alert($(id).attr('title')+"을(를) 입력해 주세요."); $(id).focus(); return true; }else{ return false; } }else{ var _val = $(id).val(); if(_val.length < 1){ alert($(id).attr('title')+"을(를) 선택해 주세요."); $(id).focus(); return true; }else{ return false; } } } // 숫자 체크 function fn_num(val) { var Num = "1234567890"; for (var i=0; i 1) { for(var i=0; i 1) { for(var j=0; j 1 && cur.charAt(0) == "0" && cur.charAt(1) != ".")){ dotIndex = i; if(dotIndex == 0){ if (cur.charAt(0) == ".") leftString="0."; else leftString=""; return leftString; } break; } } if(dotIndex != 0){ //dot가 있을 경우.. leftString = cur.substr(0, dotIndex); rightString = cur.substr(dotIndex+1); rightString = rightString.replace(/\./g,""); }else{ //없으면.. leftString = cur; } len=leftString.length-3; while(len>0){ leftString=leftString.substr(0,len)+","+leftString.substr(len); len-=3; } if(rightString != ".") return (leftString + "." + rightString); else return leftString; } // 콤마를 제거 function fn_comma_remove(val) { var rtn = parseFloat(val.replace(/,/gi, "")); if(isNaN(rtn)){ return 0; }else{ return rtn; } } /*****************************************************************/ /**************************** 승인상태코드 ***************************/ /*****************************************************************/ // 과제_제출 승인상태코드 저장 function go_stat(cmd){ $("#cmd").val(cmd); var confmCode = $("#confmCode").val(); if(confmCode == "R"){ go_return_resn(); }else{ go_stat_exec(); } } // 과제_제출 반려사유 입력 function go_return_resn(){ var st = Math.ceil((parent.screen.height-500)/2); var sl = Math.ceil((parent.screen.width-200)/2); $("#returnDiv").dialog({ modal : false, resizable : false, position:[sl,st], buttons : { "저장" : function() { if($("#returnResnDiv").val() == ''){ alert("반려사유를 입력해 주세요."); $("#returnResnDiv").focus(); return; }else{ $("#returnResn").val($("#returnResnDiv").val()); go_stat_exec(); $(this).dialog("close"); } }, "닫기" : function() { $(this).dialog("close"); } } }); } // 과제_제출 승인상태코드 저장 실행 function go_stat_exec(){ if(confirm("저장하시겠습니까?")){ $.ajax({ url : contextPath+'/spt/cmmnInfo/confmCodeExec.do', type : "POST", dataType : "json", data : $("#pform").serialize(), success : function(data) { /* if(data.success == "Y"){ alert(data.message); }else{ alert(data.message); } */ if($("#confmCode").val() == "C"){ $("#confmCodeBtn").hide(); } go_list(); } }); } } //[멘토링] 과제_제출 승인상태코드 저장 function go_stat_mntr_task(cmd){ $("#cmd").val(cmd); var confmCode = $("#confmCode").val(); if(confmCode == "R"){ go_return_resn_mntr_task(); }else{ go_stat_exec_mntr_task(); } } // [멘토링] 과제_제출 반려사유 입력 function go_return_resn_mntr_task(){ var st = Math.ceil((parent.screen.height-500)/2); var sl = Math.ceil((parent.screen.width-200)/2); $("#returnDiv").dialog({ modal : false, resizable : false, position:[sl,st], buttons : { "저장" : function() { if($("#returnResnDiv").val() == ''){ alert("반려사유를 입력해 주세요."); $("#returnResnDiv").focus(); return; }else{ $("#returnResn").val($("#returnResnDiv").val()); go_stat_exec_mntr_task(); $(this).dialog("close"); } }, "닫기" : function() { $(this).dialog("close"); } } }); } // [멘토링] 과제_제출 승인상태코드 저장 실행 function go_stat_exec_mntr_task(){ if(confirm("저장하시겠습니까?")){ $.ajax({ url : contextPath+'/institution/spt/cmmnInfo/confmCodeExecMntrTask.do', type : "POST", dataType : "json", data : $("#pform").serialize(), success : function(data) { if(data.success == "Y"){ alert(data.message); }else{ alert(data.message); } } }); } } //[멘토링] 수행_제출 승인상태코드 저장 function go_stat_mntr_exc(cmd){ $("#cmd").val(cmd); var confmCode = $("#confmCode").val(); if(confmCode == "R"){ go_return_resn_mntr_exc(); }else{ go_stat_exec_mntr_exc(); } } // [멘토링] 수행_제출 반려사유 입력 function go_return_resn_mntr_exc(){ var st = Math.ceil((parent.screen.height-500)/2); var sl = Math.ceil((parent.screen.width-200)/2); $("#returnDiv").dialog({ modal : false, resizable : false, position:[sl,st], buttons : { "저장" : function() { if($("#returnResnDiv").val() == ''){ alert("반려사유를 입력해 주세요."); $("#returnResnDiv").focus(); return; }else{ $("#returnResn").val($("#returnResnDiv").val()); go_stat_exec_mntr_exc(); $(this).dialog("close"); } }, "닫기" : function() { $(this).dialog("close"); } } }); } // [멘토링] 수행_제출 승인상태코드 저장 실행 function go_stat_exec_mntr_exc(){ if(confirm("저장하시겠습니까?")){ $.ajax({ url : contextPath+'/institution/spt/cmmnInfo/confmCodeExecMntrExc.do', type : "POST", dataType : "json", data : $("#pform").serialize(), success : function(data) { if(data.success == "Y"){ alert(data.message); }else{ alert(data.message); } } }); } } /** 첨부파일 ***************************************************************/ function fnMultiFileAdd() { if ( $(".td-input-wrap").children(".file-wrap").length >= 9) { alert('9개까지 등록 가능합니다.'); return; } // 첨부파일 갯수체크 var attachFileSize = $(".td-input-wrap").children(".file-wrap").length; attachFileSize++; var fileHtml = ""; fileHtml += "
"; fileHtml += "
"; fileHtml += " "; fileHtml += " 삭제"; fileHtml += "
"; fileHtml += "
"; $(".td-input-wrap").append(fileHtml); } function fnMultiFileInit() { var fileHtml = ""; fileHtml += "
"; fileHtml += "
"; fileHtml += " "; fileHtml += " 추가"; fileHtml += "  (hwp, doc, docx, ppt, pptx, xls, xlsx, pdf, txt, zip)"; fileHtml += "
"; fileHtml += "
"; $(".td-input-wrap").append(fileHtml); } function fnMultiFileDelete(atchFileId, fileSn, obj){ if(confirm("첨부파일을 삭제하시겠습니까?")){ $.ajax({ url : contextPath+"/cmm/fms/deleteFile.do", data : {atchFileId:atchFileId, fileSn:fileSn}, dataType : "json", type : 'post', async: "true", success : function(result) { $(obj).closest(".file-wrap").remove(); // 파일첨부가 0이면 최소하나 추가 if ( $(".td-input-wrap").children(".file-wrap").length == 0) { fnMultiFileInit(); } //alert("첨부파일이 정상적으로 삭제 되었습니다."); }, error : function(e) { alert("error :" + e.responseText); } }); } } function fnFileDelete(atchFileId, fileSn, obj){ if(confirm("첨부파일을 삭제하시겠습니까?")){ $.ajax({ url : contextPath+"/cmm/fms/deleteFile.do", data : {atchFileId:atchFileId, fileSn:fileSn}, dataType : "json", type : 'post', async: "true", success : function(result) { $("#fileDivSn_file_"+fileSn).empty(); $("#uploadFile_"+fileSn).show(); $("#uploadSpan_"+fileSn).show(); // 파일업로드 폼 생성 //var fileHtml = ""; //fileHtml += " "; //$("#fileDivSn_"+fileSn).append(fileHtml); //alert("첨부파일이 정상적으로 삭제 되었습니다."); }, error : function(e) { alert("error :" + e.responseText); } }); } } function fnFileDown(atchFileId, fileSn){ $("#atchFileId").val(atchFileId); $("#fileSn").val(fileSn); $("#fileForm").attr("target", "hiddenDownloadFrame"); $("#fileForm").attr("action", contextPath+"/cmm/fms/fileDown.do"); $("#fileForm").submit(); } function fnFileDownHis(atchFileId, fileSn){ if(atchFileId == "rept_template.xlsx" || atchFileId == "mber_template.xlsx"){ $("#atchFileId").val(atchFileId); $("#fileSn").val(fileSn); $("#fileForm").attr("target", "hiddenDownloadFrame"); $("#fileForm").attr("action", contextPath+"/cmm/fms/fileDown.do"); $("#fileForm").submit(); }else{ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // 01) Validation if (! atchFileId) { alert("파일 KEY가 없습니다."); return; } // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // 02) Key 설정 var mapPk = {}; mapPk.ATCH_FILE_ID = atchFileId; mapPk.FILE_SN = fileSn; // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // 03) Parameter 설정 var jsonParam = {}; jsonParam.COMPANY_ID = "SEMAS" ; jsonParam.SYS_CD = "EDUWWW" ; jsonParam.DWLD_MTHD = "UUID" ; jsonParam.BIZNES_ID = "X4020" ; jsonParam.CRTFC_DN_VALUE = $("#_crtfcDnValue").val(); jsonParam.ATCH_FILE_PK = GetJson2Base64(mapPk) ; jsonParam.ORGINL_FILE_NM = "" ; // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // 10) Call Form var url = $("#_cmnDwldUrl").val()+"?rawParam=" + GetJson2Base64(jsonParam); var status = "toolbar=no,directories=no,scrollbars=no,resizable=no,status=no,menubar=no,width=550, height=345, top=200,left=200"; window.open(url, "CmnDownFile", status); } } function fnCmnZipFileDown(atchFileListid, dwldUrl, dwldParam){ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // 02) Key 설정 var mapPk = {}; mapPk.ATCH_FILE_ID = $("#"+atchFileListid).val() ; // PK 설정 mapPk.FILE_SN = "" ; var ATCH_FILE_PK = GetJson2Base64(mapPk) ; // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // 03) Parameter 설정 var jsonParam = {}; jsonParam.COMPANY_ID = "SEMAS" ; // 회사 ID jsonParam.SYS_CD = "EDUMNG" ; // 시스템 코드 jsonParam.DWLD_MTHD = "DIRECT" ; // 다운로드 방식 jsonParam.BIZNES_ID = "X4020" ; // 업무 ID jsonParam.CRTFC_DN_VALUE = $("#_crtfcDnValue").val(); // 인증 DN값 jsonParam.ATCH_FILE_PK = ATCH_FILE_PK ; // PK 설정 jsonParam.ORGINL_FILE_NM = "일괄다운로드.zip" ; // 원본 파일명 jsonParam.DWLD_URL = window.location.protocol+"//"+window.location.host+dwldUrl ; // 다운로드 URL //jsonParam.DWLD_URL = "https://edu.sbiz.or.kr"+dwldUrl ; // 다운로드 URL jsonParam.DWLD_PARAM = dwldParam ; // 다운로드 Parameter // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // 10) Call Form var url = $("#_cmnDwldUrl").val()+"?rawParam=" + GetJson2Base64(jsonParam); var status = "toolbar=no,directories=no,scrollbars=no,resizable=no,status=no,menubar=no,width=550, height=345, top=200,left=200"; window.open(url, "CmnDownFile", status); } //테이블 Row 추가 function fnRowAdd(tblId) { var trLength = $("#"+tblId+" > tbody:first > tr").length+1; if(trLength>5) { alert('5개까지 추가 가능합니다.'); return; } var trHtml = $("#"+tblId+" > tbody:first > tr:first").html(); $("#"+tblId+" tbody:last").append(""+trHtml+""); // 생성 Row 초기화 $("#"+tblId+" tbody:last tr:last input").val(""); $("#"+tblId+" tr:last select").val(""); $("#"+tblId+" tbody:last tr:last input").attr("checked",false); } // 테이블 Row 삭제 function fnRowDelete(tblId) { var trLength = $("#"+tblId+" > tbody:first > tr").length; if(trLength>1) { $("#"+tblId+" tbody > tr:last").remove(); } } //테이블 2Row 추가 function fnTwoRowAdd(tblId) { var trLength = $("#"+tblId+" > tbody:first > tr").length+2; if(trLength>10) { alert('5개까지 추가 가능합니다.'); return; } var trHtml1 = $("#"+tblId+" > tbody:first > tr:first").html(); var trHtml2 = $("#"+tblId+" > tbody:first > tr:first").next().html(); $("#"+tblId+" tbody:last").append(""+trHtml1+""+trHtml2+""); // 생성 Row 초기화 $("#"+tblId+" tbody:last tr:last input").val(""); $("#"+tblId+" tr:last select").val(""); $("#"+tblId+" tbody:last tr:last input").attr("checked",false); fnTitleSet(tblId, 2); } //테이블 2Row 삭제 function fnTwoRowDelete(tblId) { var trLength = $("#"+tblId+" > tbody:first > tr").length; if(trLength>2) { $("#"+tblId+" tbody > tr:last").remove(); $("#"+tblId+" tbody > tr:last").remove(); } fnTitleSet(tblId, 2); } //테이블 3Row 추가 function fnThreeRowAdd(tblId) { var trLength = $("#"+tblId+" > tbody:first > tr").length+3; if(trLength>15) { alert('5개까지 추가 가능합니다.'); return; } var trHtml1 = $("#"+tblId+" > tbody:first > tr:first").html(); var trHtml2 = $("#"+tblId+" > tbody:first > tr:first").next().html(); var trHtml3 = $("#"+tblId+" > tbody:first > tr:first").next().next().html(); $("#"+tblId+" tbody:last").append(""+trHtml1+""+trHtml2+""+trHtml3+""); // 생성 Row 초기화 $("#"+tblId+" > tbody:first > tr:last").find('input').val(''); $("#"+tblId+" > tbody:first > tr:last").find('select').val(''); $("#"+tblId+" > tbody:first > tr:last").find('input').attr("checked",false); $("#"+tblId+" > tbody:first > tr:last").prev().find('input').val(''); $("#"+tblId+" > tbody:first > tr:last").prev().find('select').val(''); $("#"+tblId+" > tbody:first > tr:last").prev().find('input').attr("checked",false); fnTitleSet(tblId, 3); } //테이블 3Row 삭제 function fnThreeRowDelete(tblId) { var trLength = $("#"+tblId+" > tbody:first > tr").length; if(trLength>3) { $("#"+tblId+" tbody > tr:last").remove(); $("#"+tblId+" tbody > tr:last").remove(); $("#"+tblId+" tbody > tr:last").remove(); } fnTitleSet(tblId, 3); } //테이블 4Row 추가 function fnFourRowAdd(tblId) { var trLength = $("#"+tblId+" > tbody:first > tr").length+4; if(trLength>20) { alert('5개까지 추가 가능합니다.'); return; } var trHtml1 = $("#"+tblId+" > tbody:first > tr:first").html(); var trHtml2 = $("#"+tblId+" > tbody:first > tr:first").next().html(); var trHtml3 = $("#"+tblId+" > tbody:first > tr:first").next().next().html(); var trHtml4 = $("#"+tblId+" > tbody:first > tr:first").next().next().next().html(); $("#"+tblId+" tbody:last").append(""+trHtml1+""+trHtml2+""+trHtml3+""+trHtml4+""); // 생성 Row 초기화 $("#"+tblId+" > tbody:first > tr:last").find('input').val(''); $("#"+tblId+" > tbody:first > tr:last").find('select').val(''); $("#"+tblId+" > tbody:first > tr:last").find('input').attr("checked",false); $("#"+tblId+" > tbody:first > tr:last").prev().find('input').val(''); $("#"+tblId+" > tbody:first > tr:last").prev().find('select').val(''); $("#"+tblId+" > tbody:first > tr:last").prev().find('input').attr("checked",false); $("#"+tblId+" > tbody:first > tr:last").prev().prev().find('input').val(''); $("#"+tblId+" > tbody:first > tr:last").prev().prev().find('select').val(''); $("#"+tblId+" > tbody:first > tr:last").prev().prev().find('input').attr("checked",false); $("#"+tblId+" > tbody:first > tr:last").prev().prev().prev().find('input').val(''); $("#"+tblId+" > tbody:first > tr:last").prev().prev().prev().find('select').val(''); $("#"+tblId+" > tbody:first > tr:last").prev().prev().prev().find('input').attr("checked",false); var chkBox = $("#"+tblId+" > tbody:first > tr:last").find('input:checkbox'); chkBox.attr('id',chkBox.attr('id')+$("#"+tblId+" > tbody:first").find('input:checkbox').length); chkBox.next().attr('for',chkBox.next().attr('for')+$("#"+tblId+" > tbody:first").find('input:checkbox').length); fnTitleSet(tblId, 4); } //테이블 4Row 삭제 function fnFourRowDelete(tblId) { var trLength = $("#"+tblId+" > tbody:first > tr").length; if(trLength>4) { $("#"+tblId+" tbody > tr:last").remove(); $("#"+tblId+" tbody > tr:last").remove(); $("#"+tblId+" tbody > tr:last").remove(); $("#"+tblId+" tbody > tr:last").remove(); } fnTitleSet(tblId, 4); } //function trInit(trObj){ // //// $(trObj).find('input').val(''); //// $(trObj).find('select').val(''); //// $(trObj).find('input').attr("checked",false); // // $(trObj).find('input').each(function(){ // var inName = $(this).attr('name'); // $('input[name='+inName+']').each(function(i){ // $(this).attr('title', $(this).attr('title')+i); // }); // }); //} function fnTitleSet(id, rowCnt){ var idx = 0; var cnt = 1; $("#"+id).find('tbody').find('tr').each(function(){ idx++; $(this).find('input', 'select').each(function(){ if($(this).attr('title') != undefined){ var title = $(this).attr('title').replace(/[0-9]/g, ""); $(this).attr('title', title+cnt); } }); if(idx == rowCnt){ idx =0; cnt++; } }); } $(document).on('click', '#fnRowDel', function(){ if ( $(".td-input-wrap").children(".file-wrap").length == 1) { alert("더 이상 삭제하실 수 없습니다."); return; } $(this).closest(".file-wrap").remove(); }); /** 첨부파일 ***************************************************************/ //파일 용량 체크 function checkFile(obj, patten, maxsize){ var file = obj.files; if(maxsize == null){ maxsize = 10 } if(file[0].size>1024*1024*maxsize){ alert(maxsize+"MB 이하 파일만 등록할 수 있습니다."); $(obj).val(''); return; } if(patten == null || patten == ""){ patten = ".hwp.ppt.pptx.xls.xlsx.doc.docx.pdf.jpg.jpeg.png.gif.zip.alz.egg"; if($(obj).attr("accept") != null && $(obj).attr("accept") != ""){ patten = $(obj).attr("accept"); } } var filename = obj.value.substring(obj.value.lastIndexOf(".")).toLowerCase(); if(patten.indexOf(filename) < 0){ alert("등록 할 수 없는 첨부파일 입니다.\n※ "+patten+" 파일만 등록 가능 합니다."); $(obj).val(''); return; } } function modal(){ return { on:function(str){ $('[data-skin="modal"][data-name="'+str+'"]').show(); $("body").attr("data-modal","yes"); }, off:function(){ $('[data-skin="modal"]').hide(); $("body").removeAttr("data-modal"); } } } var modal = modal(); function alertbox(){ return { on:function(str){ $('[data-skin="alert"][data-name="'+str+'"]').show(); $("body").attr("data-modal","yes"); }, off:function(){ $('[data-skin="alert"]').hide(); $("body").removeAttr("data-modal"); } } } var alertBox = alertbox();