선거문자 엑셀불러오기 기능수정

This commit is contained in:
wyh 2024-09-30 09:35:56 +09:00
parent 2e69da4f15
commit adfc5fbf12

View File

@ -7,9 +7,233 @@
<script type="text/javascript" src="<c:url value='/publish/js/content.js'/>"></script>
<script type="text/javascript" src="<c:url value='/js/txtSpecialReplace.js?date=202304250001'/>"></script>
<!-- 주소록 유효성 체크 공통유틸로 인해 추가 -->
<script type="text/javascript" src="<c:url value='/js/web/addr/cmn.js?date=202409021440'/>"></script>
<% pageContext.setAttribute("newLineChar", "\r\n"); %>
<script type="text/javascript">
$(document).ready(function(){
//받는사람 연락처 내용 처리
//Tabulator AJAX Data Loading
tableL = new Tabulator(".callList_box", {
height:"255px",
layout:"fitColumns",
headerHozAlign:"center",
validationMode:"highlight",
placeholder:"복사(Ctrl+C)한 내용을 여기에 붙여넣기(Ctrl+V) 해주세요.", //fit columns to width of table (optional)
resizableColumns:false,
columnDefaults:{ // 공통설정
hozAlign: "center",
headerHozAlign: "center",
editor: "input",
editor: false
},
columns:[ //Define Table Columns
{formatter:"rowSelection", headerHozAlign:"center", titleFormatter:"rowSelection",clipboard:false, hozAlign:"center", width:5, headerSort:false, cellClick:function(e, cell){
cell.getRow().toggleSelect();
}},
// {formatter:"rownum", align:"center", title:"No", hozAlign:"center", headerHozAlign:"center", field:"No", width:30},
{formatter:"rownum", align:"center" ,title:"No", hozAlign:"center", headerHozAlign:"center", width:40},
{title:"이름", field:"name", editor:false, validator:["maxLength:12"], cellEdited:function(cell){
fnReplCell();
}},
{title:"휴대폰", field:"phone", width:100, editor:false, validator:["required","minLength:10", "maxLength:12"]},
{title:"[*1*]", field:"rep1", minWidth:60, editor:false, validator:["maxLength:40"], cellEdited:function(cell){
fnReplCell();
}},
{title:"[*2*]", field:"rep2", minWidth:60, editor:false, validator:["maxLength:40"], cellEdited:function(cell){
fnReplCell();
}},
{title:"[*3*]", field:"rep3", minWidth:60, editor:false, validator:["maxLength:40"], cellEdited:function(cell){
fnReplCell();
}},
{title:"[*4*]", field:"rep4", minWidth:60, editor:false, validator:["maxLength:40"], cellEdited:function(cell){
fnReplCell();
}},
],
validationFailed:function(cell, value, parameters){ // 유효성 체크 함수 - 아직 잘 모르겠음
//take action on validation fail
var valid = cell.isValid();
var fieldNm = cell.getField();
var cellVal = cell.getValue();
var returnVal = "";
if(!valid){
if(fieldNm == "name"){
alert("받는사람 이름은 최대 12글자까지만 입력 가능합니다.");
cell.setValue(strMaxLengthSubstring(cellVal, 11)); //스크립트 함수가 0부터 시작이므로 원하는 글자수 -1을 해줘야한다.
cell.clearValidation();
}else if(fieldNm == "phone"){
alert("휴대폰번호는 하이픈(-)을 제외한 숫자만 정확히 입력해 주세요.");
}else{
alert("치환문자를 정확히 입력해 주세요. 40글자 이내로 입력 가능합니다.");
cell.setValue(strMaxLengthSubstring(cellVal, 39));
cell.clearValidation();
}
//해당 셀 데이터 삭제
//cell.setValue("");
}
return value % parameters.phone;
},
});
// Tabulator 초기화
tableAddr = new Tabulator(".callAddr_box", {
height: "255px",
layout: "fitColumns",
headerHozAlign: "center",
validationMode: "highlight",
placeholder: "주소록 그룹을 선택해 주세요.",
resizableColumns: false,
progressiveLoad:"scroll",
columns: [
{formatter: "rowSelection", clipboard: false, hozAlign: "center", headerSort: false},
// {formatter: "rowSelection", titleFormatter: "rowSelection", clipboard: false, hozAlign: "center", headerSort: false, cellClick: function(e, cell) {
// cell.getRow().toggleSelect();
// }
// },
{formatter: "rownum", align: "center", title: "No", hozAlign: "center", headerHozAlign: "center", width: 60},
{title: "그룹명", hozAlign: "center", field: "addrGroupNm", editor: false, width: 100, validator: ["required", "minLength:2", "maxLength:40"]},
{title: "이름", hozAlign: "center", field: "name", editor: false, width: 100, validator: ["maxLength:12"]},
{title: "휴대폰번호", hozAlign: "center", field: "phone", editor: false, width: 100, validator: ["required", "minLength:10", "maxLength:11"]},
{title: "[*1*]", hozAlign: "center", field: "rep1", editor: false, width: 84, validator: ["maxLength:40"]},
{title: "[*2*]", hozAlign: "center", field: "rep2", editor: false, width: 84, validator: ["maxLength:40"]},
{title: "[*3*]", hozAlign: "center", field: "rep3", editor: false, width: 84, validator: ["maxLength:40"]},
{title: "[*4*]", hozAlign: "center", field: "rep4", editor: false, width: 84, validator: ["maxLength:40"]},
],
validationFailed: function(cell, value, parameters) {
var valid = cell.isValid();
var fieldNm = cell.getField();
if (!valid) {
if (fieldNm == "addrName") {
alert("받는사람 이름은 최대 12글자까지만 입력 가능합니다.");
} else if (fieldNm == "addrPhone") {
alert("휴대폰번호는 하이픈(-)을 제외한 숫자만 정확히 입력해 주세요.");
} else if (fieldNm == "addrGroupNm") {
alert("그룹명을 정확히 입력해 주세요. 2 ~ 40글자 이내로 입력 가능합니다.");
} else {
alert("치환문자를 정확히 입력해 주세요. 100글자 이내로 입력 가능합니다.");
}
cell.setValue("");
}
console.log('parameters : ', parameters);
return value % parameters.addrPhone;
},
});
/*
* 20240823
* 미리보기 스크립트
*/
// 현재 위치
var currentIndex = 0;
// 제일 이전
$('#btnFirst').on('click', function(){
currentIndex = 0;
updateButtons(currentIndex );
fn_previewText(currentIndex);
});
// 이전
$('#btnPrev').on('click', function(){
if (currentIndex > 0) {
currentIndex--;
updateButtons(currentIndex );
fn_previewText(currentIndex);
}
});
// 다음
$('#btnNext').on('click', function(){
var dataLength = tableL.getData().length;
if (currentIndex < dataLength - 1) {
currentIndex++;
updateButtons(currentIndex );
fn_previewText(currentIndex);
}
});
// 제일 다음
$('#btnLast').on('click', function(){
var dataLength = tableL.getData().length;
currentIndex = dataLength - 1;
updateButtons(currentIndex );
fn_previewText(currentIndex);
});
updateButtons(currentIndex);
});
/*
* 버튼 disabled 스크립트
*/
function updateButtons(currentIndex ) {
var dataLength = tableL.getData().length;
console.log('dataLength ', dataLength);
console.log('currentIndex ', currentIndex);
if (currentIndex <= 0) {
$('#btnPrev').attr('disabled', true);
$('#btnFirst').attr('disabled', true);
} else {
$('#btnPrev').attr('disabled', false);
$('#btnFirst').attr('disabled', false);
}
if (currentIndex >= dataLength - 1) {
$('#btnNext').attr('disabled', true);
$('#btnLast').attr('disabled', true);
} else {
$('#btnNext').attr('disabled', false);
$('#btnLast').attr('disabled', false);
}
}
/*
* 미리보기 데이터 치환
*/
function fn_previewText(rowIndex){
var smsText = $('#smsTxtArea').val()
// 데이터 가져오기
var data = tableL.getData();
// 특정 인덱스(예: 1)로 행을 선택하여 치환
var row = data[rowIndex]; // 인덱스 1의 행을 선택
// 이름 치환
smsText = smsText.replace(/\[\*이름\*\]/g, row.name !== undefined && row.name !== null ? row.name : '[*이름*]');
// rep1, rep2, rep3, rep4 치환
smsText = smsText.replace(/\[\*1\*\]/g, row.rep1 !== undefined && row.rep1 !== null ? row.rep1 : '[*1*]');
smsText = smsText.replace(/\[\*2\*\]/g, row.rep2 !== undefined && row.rep2 !== null ? row.rep2 : '[*2*]');
smsText = smsText.replace(/\[\*3\*\]/g, row.rep3 !== undefined && row.rep3 !== null ? row.rep3 : '[*3*]');
smsText = smsText.replace(/\[\*4\*\]/g, row.rep4 !== undefined && row.rep4 !== null ? row.rep4 : '[*4*]');
// 결과 출력 또는 다른 곳에 사용
console.log(smsText);
$('.realtime').text(smsText);
}
var tableErrorData = [];
var totRows = 0; // 좌측 받는사람 총 갯수
@ -853,34 +1077,6 @@ $(document).ready(function (){
});
/* //받는사람 중복 삭제
$('.duple_del').click(function(){
//기존 연락처 모두 불러오기
var data = tableL.getRows();
var tableData = [];
var dpCnt = 0;
var totLen = tableL.getRows().length;
for(var i=0; i < totLen; i++){
tableData.push({phone: data[i].getData().phone.trim(), name: data[i].getData().name});
}
var removeDuplData = dupliPhoneData(tableData);
tableL.setData(removeDuplData);
//총 받는사람 수 계산
totRows = tableL.getRows().length;
updateTotCnt(totRows);
//결제 금액 구하기
totalPriceSum(totRows);
}); */
//주소록 불러오기 버튼 클릭시
$('.popupAddr').click(function(){
@ -3223,12 +3419,12 @@ $(document).on('click', '#hdnLink', function() {
})
</script>
<div class="loading_layer">
<div class="loading_container">
<div class="bar"></div>
<div class="text">Loading</div>
</div>
<div class="loading_layer">
<div class="loading_container">
<div class="bar"></div>
<div class="text">Loading</div>
</div>
</div>
<form id="sentListForm" name="sentListForm" method="post">
<input type="hidden" name="pageType" value=""/>
@ -3393,8 +3589,86 @@ $(document).on('click', '#hdnLink', function() {
<input type="hidden" name="_dontcare">
</form>
</div>
</div><!--// 후보자등록 팝업 -->
</div>
<!--// 후보자등록 팝업 -->
<!-- 주소록 불러오기 -->
<div class="tooltip-wrap">
<div class="popup-com import_layer popup06" tabindex="0" data-tooltip-con="popup06" data-focus="popup06" data-focus-prev="popup06-close" style="width: 1000px">
<div class="popup_heading">
<p><span>주소록 불러오기</p>
<button type="button" onClick="javascript:addrClose(); return false;">
<img src="/publish/images/content/layerPopup_close.png" alt="팝업 닫기"></button>
</div>
<div class="layer_in">
<div class="titBox titBox_pad">
<p>- 주소록 수정 및 변경은 <span>[주소록 관리]</span>에서만 가능합니다.</p>
<button type="button" class="adr_admin" onClick="location.href='/web/mjon/addr/selectAddrList.do'">주소록 관리</button>
</div>
<div class="adr_wrap">
<form id="searchAddrGrpForm" name="searchAddrGrpForm" method="post" style="display: flex; justify-content: space-between;">
<input type="hidden" id="searchAddrGrpId" name="searchAddrGrpId" value=""/>
<input type="hidden" id="type" name="type" value="all"/>
<input type="hidden" id="searchKeyword" name="searchKeyword" value=""/>
<input type="hidden" name="searchCondition" id="searchCondition" value="0" />
<div class="adr_pop_left">
<div class="adr_left_search">
<label for="searchKeyword" class="label">그룹명 검색</label>
<input type="text" name="searchGrpKeyword" id="searchGrpKeyword" placeholder="그룹명 검색" onfocus="this.placeholder=''" onblur="this.placeholder='그룹명 검색'" class="inputLight">
<button type="button" onClick="javascrit:fnAddrGrpSearch(); return false;"><img src="/publish/images/popup/search.png" alt="검색"></button>
</div>
<div class="adr_pop_box">
<div id="addrGroupLoad">
</div>
</div>
<!-- <div class="popup_btn">
<button type="button" class="btnType" onClick="javascript:fnSelectAddrGrpList(); return false;">선택 그룹 추가</button>
</div> -->
</div>
<div class="adr_pop_right">
<div class="clearfix">
<div class="btnWrap_last">
<label for="searchAddrCondition" class="label">카테고리 선택</label>
<select id="searchAddrCondition" name="searchAddrCondition" class="selType2">
<option value='0'>전체</option>
<option value='1'>그룹명</option>
<option value='2'>이름</option>
<option value='3'>핸드폰번호</option>
</select>
<label for="searchAddrKeyword" class="label">검색어 입력</label>
<input type="text" id="searchAddrKeyword" name="searchAddrKeyword" placeholder="검색어를 입력하세요" onfocus="this.placeholder=''" onblur="this.placeholder='검색어를 입력하세요'" >
<button type="button" class="btnType btnType17" onClick="javascrit:fnAddrSearch(); return false;">검색</button>
</div>
<!-- table -->
<div class="adr_excel adr_pop_list2 callAddr_box">
</div>
<!--// table -->
</div>
<div class="popup_btn_wrap2">
<button type="button" onClick="javascript:addrToList(); return false;">추가</button>
<button type="button" onClick="javascript:addrClose(); return false;">닫기</button>
</div>
<%-- 주소록 레이어 팝업 닫기 실행 코드 --%>
<input type="hidden" name="btnAddrClose" id="btnAddrClose" class="tooltip-close closeAddr" data-focus="popup06-close" />
</div>
</form>
</div>
</div>
</div>
</div>
<!--// 주소록 불러오기 -->
<!-- 엑셀 불러오기 -->
<form id="excelForm" name="excelForm" method="post">
<div class="tooltip-wrap">
<div class="popup-com adr_layer popup02" tabindex="0" data-tooltip-con="popup02" data-focus="popup02" data-focus-prev="popup02-close" style="width: 1000px;">
<%@include file="/WEB-INF/jsp/web/msgdata/include/msgDataIncludeExcel.jsp" %>
</div>
</div>
</form>
<!--// 엑셀 불러오기 -->
<!-- 전송내역 팝업 -->
<div class="tooltip-wrap">
<div class="popup-com history_layer popup03" tabindex="0" data-tooltip-con="popup03" data-focus="popup03" data-focus-prev="popup03-close">
<div class="popup_heading">
@ -3467,107 +3741,9 @@ $(document).on('click', '#hdnLink', function() {
</div><!--// 자주보내는 번호 -->
</div>
</div>
</div><!--// 전송내역 팝업 -->
<!-- 엑셀 불러오기 -->
<form id="excelForm" name="excelForm" method="post">
<div class="tooltip-wrap">
<div class="popup-com import_layer popup02" tabindex="0" data-tooltip-con="popup02" data-focus="popup02" data-focus-prev="popup02-close">
<div class="popup_heading">
<p><span>엑셀</span> 불러오기</p>
<button type="button" class="tooltip-close" data-focus="popup02-close"><img src="/publish/images/content/layerPopup_close.png" alt="팝업 닫기"></button>
</div>
<div class="layer_in">
<!-- 엑셀파일 불러오기 -->
<div class="hascont">
<div class="titBox">
<p>- 최대 2만 건까지 등록할 수 있습니다.</p>
<p>- [엑셀 불러오기]시 문서의 A, B, C, D열을 불러옵니다.(지원하는 파일 형식 : xls, xlsx)</p>
<p>- 이름 : 20byte, [*1*]~[*4*] : 40byte까지 입력 가능합니다.</p>
<p>- 휴대폰 항목은 숫자, 하이픈(-)만 인식하며, 번호 앞에 0이 생략되어도 정상 등록됩니다.
</p>
<%-- <button type="button" class="excel_btn" onclick="location.href='/cmm/fms/FileDown.do?atchFileId=FILE_000000000011651&fileSn=1'"><i></i>샘플파일 다운로드</button> --%>
<button type="button" class="excel_btn" onclick="location.href='/download/msg/엑셀주소록_등록양식.xlsx'"><i class="downroad"></i>샘플파일 다운로드</button>
</div>
<div class="attachedFile">
<label for="" class="attachedFile_label">첨부파일</label>
<input type="text" id="excelNm" readonly>
<input type="file" id="excelFile" accept=".xls, .xlsx" onchange="excelExport(event); return false;" style="display:none"/>
<button type="button" class="btnType btnType6 c3">찾아보기</button>
<p><span class="vMiddle">*</span> 첨부된 파일은 <span class="c_e40000">[추가]버튼을 클릭</span>하셔야 받는 사람에 등록됩니다.</p>
</div>
</div><!--// 엑셀파일 불러오기 -->
<div class="popup_btn_wrap2">
<button type="button" class="tooltip-close" data-focus="popup02-close" data-focus-next="popup02" id="excelAdd">추가</button>
<button type="button" class="tooltip-close" data-focus="popup02-close" data-focus-next="popup02">닫기</button>
</div>
</div>
</div>
</div><!--// 엑셀 불러오기 -->
</form>
<!-- 주소록 불러오기 -->
<div class="tooltip-wrap">
<div class="popup-com import_layer popup06" tabindex="0" data-tooltip-con="popup06" data-focus="popup06" data-focus-prev="popup06-close" style="width: 1000px">
<div class="popup_heading">
<p><span>주소록 불러오기</p>
<button type="button" onClick="javascript:addrClose(); return false;">
<img src="/publish/images/content/layerPopup_close.png" alt="팝업 닫기"></button>
</div>
<div class="layer_in">
<div class="titBox titBox_pad">
<p>- 주소록 수정 및 변경은 <span>[주소록 관리]</span>에서만 가능합니다.</p>
<button type="button" class="adr_admin" onClick="location.href='/web/mjon/addr/selectAddrList.do'">주소록 관리</button>
</div>
<div class="adr_wrap">
<form id="searchAddrGrpForm" name="searchAddrGrpForm" method="post" style="display: flex; justify-content: space-between;">
<input type="hidden" id="searchAddrGrpId" name="searchAddrGrpId" value=""/>
<input type="hidden" id="type" name="type" value="all"/>
<input type="hidden" id="searchKeyword" name="searchKeyword" value=""/>
<input type="hidden" name="searchCondition" id="searchCondition" value="0" />
<div class="adr_pop_left">
<div class="adr_left_search">
<label for="searchKeyword" class="label">그룹명 검색</label>
<input type="text" name="searchGrpKeyword" id="searchGrpKeyword" placeholder="그룹명 검색" onfocus="this.placeholder=''" onblur="this.placeholder='그룹명 검색'" class="inputLight">
<button type="button" onClick="javascrit:fnAddrGrpSearch(); return false;"><img src="/publish/images/popup/search.png" alt="검색"></button>
</div>
<div class="adr_pop_box">
<div id="addrGroupLoad">
</div>
</div>
<!-- <div class="popup_btn">
<button type="button" class="btnType" onClick="javascript:fnSelectAddrGrpList(); return false;">선택 그룹 추가</button>
</div> -->
</div>
<div class="adr_pop_right">
<div class="clearfix">
<div class="btnWrap_last">
<label for="searchAddrCondition" class="label">카테고리 선택</label>
<select id="searchAddrCondition" name="searchAddrCondition" class="selType2">
<option value='0'>전체</option>
<option value='1'>그룹명</option>
<option value='2'>이름</option>
<option value='3'>핸드폰번호</option>
</select>
<label for="searchAddrKeyword" class="label">검색어 입력</label>
<input type="text" id="searchAddrKeyword" name="searchAddrKeyword" placeholder="검색어를 입력하세요" onfocus="this.placeholder=''" onblur="this.placeholder='검색어를 입력하세요'" >
<button type="button" class="btnType btnType17" onClick="javascrit:fnAddrSearch(); return false;">검색</button>
</div>
<!-- table -->
<div class="adr_excel adr_pop_list2 callAddr_box">
</div>
<!--// table -->
</div>
<div class="popup_btn_wrap2">
<button type="button" onClick="javascript:addrToList(); return false;">추가</button>
<button type="button" onClick="javascript:addrClose(); return false;">닫기</button>
</div>
<%-- 주소록 레이어 팝업 닫기 실행 코드 --%>
<input type="hidden" name="btnAddrClose" id="btnAddrClose" class="tooltip-close closeAddr" data-focus="popup06-close" />
</div>
</form>
</div>
</div>
</div>
</div><!--// 주소록 불러오기 -->
</div>
<!--// 전송내역 팝업 -->
<!-- 주소록에 등록 data-tooltip:duplication_layer -->
<div class="tooltip-wrap">
<div class="popup-com addressregi_layer" tabindex="0" data-tooltip-con="addressregi_layer" data-focus="addressregi_layer" data-focus-prev="addressregi_layer-close" style="width: 680px;">
@ -3740,9 +3916,10 @@ $(document).on('click', '#hdnLink', function() {
<button type="button" class="tooltip-close" data-focus="candidate_popup03-close" data-focus-next="candidate_popup03">닫기</button>
</div>
</div>
</div><!--// 선거문자 이용안내 팝업 -->
</div>
<!--// 선거문자 이용안내 팝업 -->
<!-- 이벤트 잔여 캐시 정보 표시 팝업 -->
<!-- 이벤트 잔여 캐시 정보 표시 팝업 -->
<div class="tooltip-wrap">
<div class="popup-com event_cash_popup popup07" tabindex="0" data-tooltip-con="popup07" data-focus="popup07" data-focus-prev="popup07-close">
<div class="popup_heading">
@ -4334,21 +4511,25 @@ $(document).on('click', '#hdnLink', function() {
</div>
</div>
</div>
<!-- </div> --><!--// tab content1 -->
</form>
<form id="latestMsgForm" name="latestMsgForm" method="post">
<input type="hidden" id="userId" name="userId" value="${LoginVO.id}"/>
</form>
<form id="addMyMsgForm" name="addMyMsgForm" method="post">
<input type="hidden" id="msgId" name="msgId" value=""/>
<input type="hidden" id="pageType1" name="pageType" value=""/>
</form>
<form name="popForm" id="popForm" method="post">
<input type="hidden"id="pageType2" name="pageType" value=""/>
</form>
<form name="goToCustomForm" id="goToCustomForm" method="post" action="/web/mjon/custom/selectMsgCustomView.do">
<input type="hidden" id="pageType3" name="pageType" value="msgcampain"/>
</form>
<form name="testSendForm" id="testSendForm" method="post">
<input type="hidden" name="msgKind" value="C"/>
<input type="hidden" name="msgpreview" value=""/>