문자전송 > 엑셀불러오기 완료 ( TODO:오류번호검사, 오류검사, 설명문구, 샘플파일 등등 은 cs팀에서 결정하고

알려준다합니다.)
This commit is contained in:
hylee 2024-08-14 12:03:46 +09:00
parent a985ce5d6d
commit 9079e3fe7b
4 changed files with 251 additions and 97 deletions

View File

@ -1030,7 +1030,6 @@ function setAddrDupliClose() {
</div>
</div>
<!-- // 중복전화번호 팝업 -->
-->
<form name="addrMemoForm" name="addrMemoForm" method="post">
<input type="hidden" name="addrCheck" />
<input type="hidden" name="addrComment" />

View File

@ -32,7 +32,6 @@ function addPhoneInfo_advc(tableAddr){
var addrData = tableAddr.getData().map((row, index) => ({
no: index+1,
name: row.addrName,
phone: removeDash(row.addrPhone),
rep1: row.addrRep1,

View File

@ -54,13 +54,44 @@ $(document).ready(function(){
$("#excelFile").on("change", function(event) {
var fileInfo = event.target.files;
if(fileInfo.length > 0){
excelFileChange(fileInfo[0]);
}
console.log('fileInfo.length : ', fileInfo.length);
if(fileInfo.length > 0){
excelFileChange(fileInfo[0]);
} else {
fn_loadRemoveActive(); // 파일이 선택되지 않은 경우 로딩 상태 제거
$(this).val(''); // 파일 선택 초기화
}
});
$(document).on('click', '#btnAddrMassClose', function() {
// 대량등록 닫기
setAddrMassClose();
});
$(document).on('click', '#closeBtn', function() {
// 대량등록 닫기
setAddrMassClose();
});
// 엑셀등록 닫기
function setAddrMassClose() {
$tableExcel.clearData();
$("#excelRowTotCnt").text(0); //총건수 수정
$("#excelRowDupCnt").text(0); //중복건수 수정
dupliPhoneDataRealList.length = 0; // 중복 휴대폰번호 초기화
addrMassDupliSaveList = null;
$("#btnAddrMassDupli").hide();
$('#tableExcelDupliBtn').hide();
// $("#btnAddrMassSaveDupli").hide();
// $('#closeBtn').click();
}
//#############################################################################################
//파일업로드 드래그앤 드롭
//#############################################################################################
@ -75,7 +106,7 @@ $(document).ready(function(){
e.preventDefault();
});
$(document).on("drop",".upload_area",function(e){
// fn_loadAddActive();
fn_loadAddActive();
e.preventDefault();
var files = e.originalEvent.dataTransfer.files;
excelFileChange(files[0]);
@ -103,95 +134,157 @@ $(document).ready(function(){
//타이틀 select 선택 이벤트
$('.field-selector').on('change', function() {
fn_loadAddActive();
var selectedFields = [];
var isDuplicate = false;
if($tableExcel.getData().length < 1){
alert('데이터 입력 후 선택해 주세요.');
$(this).val("");
fn_loadRemoveActive();
return false;
}
// 중복체크
$('.field-selector').each(function() {
var selectedField = $(this).val();
if (selectedField) {
if (selectedFields.includes(selectedField)) {
alert("중복된 필드를 선택할 수 없습니다.");
$(this).val(""); // 중복 필드를 선택한 경우 빈 값으로 초기화
isDuplicate = true;
return false; // 반복문 종료
}
selectedFields.push(selectedField);
setTimeout(() => { // 파일 읽기 완료 후 실행되도록 함
var selectedFields = [];
var isDuplicate = false;
if($tableExcel.getData().length < 1){
alert('데이터 입력 후 선택해 주세요.');
$(this).val("");
fn_loadRemoveActive();
return false;
}
});
// 중복체크
$('.field-selector').each(function() {
var selectedField = $(this).val();
if (selectedField) {
if (selectedFields.includes(selectedField)) {
alert("중복된 필드를 선택할 수 없습니다.");
$(this).val(""); // 중복 필드를 선택한 경우 빈 값으로 초기화
isDuplicate = true;
return false; // 반복문 종료
}
selectedFields.push(selectedField);
}
});
//
updateTableFields($tableExcel);
// 필드가 휴대폰이면 열 중복체크
if($(this).val() == 'addrPhoneNo'){
fn_phoneDupl($tableExcel);
}
fn_loadRemoveActive();
//
updateTableFields($tableExcel);
// 필드가 휴대폰이면 열 중복체크
if($(this).val() == 'addrPhoneNo'){
fn_phoneDupl($tableExcel);
}
fn_loadRemoveActive();
}, 0); // 지연 없이 즉시 실행되도록 0ms 지연을 설정
});
// 받는사람 선택삭제 버튼 처리해주기
$('#in_select_del').click(function(){
// 받는사람 선택삭제 버튼 처리해주기
$('#in_select_del').click(function(){
if($tableExcel == null || $tableExcel == ""){
if(tableL == null || tableL == ""){
alert("받는사람을 추가해 주세요.");
return false;
}
var selectedData = $tableExcel.getSelectedRows();
if(selectedData == "" || selectedData == null){
alert("삭제할 연락처를 선택해주세요.");
return false;
}else{ // 선택한 Row 데이터 삭제하기
if(confirm("선택하신 받는 사람을 삭제하시겠습니까?")){
// 선택 데이터 삭제
selectedData.forEach(row => row.delete());
totRows = $tableExcel.getRows().length;
$("#excelRowTotCnt").text(totRows);
alert("받는사람을 추가해 주세요.");
return false;
}
var selectedData = tableL.getSelectedRows();
if(selectedData == "" || selectedData == null){
alert("삭제할 연락처를 선택해주세요.");
return false;
}else{ // 선택한 Row 데이터 삭제하기
if(confirm("선택하신 받는 사람을 삭제하시겠습니까?")){
// 선택 데이터 삭제
selectedData.forEach(row => row.delete());
totRows = tableL.getRows().length;
updateTotCnt(totRows);
var smsTxtArea = $('#smsTxtArea').val();
//일괄변환 문구 결제금액 처리
if(smsTxtArea.indexOf("[*이름*]") > -1
|| smsTxtArea.indexOf("[*1*]") > -1
|| smsTxtArea.indexOf("[*2*]") > -1
|| smsTxtArea.indexOf("[*3*]") > -1
|| smsTxtArea.indexOf("[*4*]") > -1){
fnReplCell();
}else{
//결제 금액 구하기
totalPriceSum(totRows);
}
}
}
}
});
// 추가버튼
$('#btnAddrMassReg').click(function(){
if($tableExcel.getData().length < 1){
alert("한 개 이상의 연락처를 입력하세요");
return false;
}
// else if (selectedData.length > 20000) {
// alert("2만줄 이상의 업로드는 데이터 부하로 업로드 할수 없습니다.");
// return false;
// }
// tableExcel 그룹의 select 요소들을 확인
// var isPhoneSelected = false;
// var isNameSelected = false;
var columns = $tableExcel.getColumns();
var isAddrPhoneNoSelected = columns.some(column => column.getField() === 'addrPhoneNo');
if (!isAddrPhoneNoSelected) {
// isPhoneSelected = true;
alert('휴대폰이 선택되지 않았습니다.');
return false;
}
console.log('$tableExcel : ' ,$tableExcel);
var addrData = $tableExcel.getData().map((row, index) => ({
name: row.addrNm,
phone: removeDash(row.addrPhoneNo),
rep1: row.addrInfo1,
rep2: row.addrInfo2,
rep3: row.addrInfo3,
rep4: row.addrInfo4,
}));
tableL.setData(addrData);
var totRows = tableL.getRows().length;
updateTotCnt(totRows); //전체 데이터 갯수 구하기
console.log('totRows : ', totRows);
var smsTxtArea = $('#smsTxtArea').val();
if(smsTxtArea.indexOf("[*이름*]") > -1
|| smsTxtArea.indexOf("[*1*]") > -1
|| smsTxtArea.indexOf("[*2*]") > -1
|| smsTxtArea.indexOf("[*3*]") > -1
|| smsTxtArea.indexOf("[*4*]") > -1){
});
fnReplCell();
}else{
//결제 금액 구하기
totalPriceSum(totRows);
}
setAddrMassClose();
});
//받는사람 전체삭제 버튼 처리
$('#allDel').click(function(){
var data = $tableExcel.getRows();
$tableExcel.clearData();
$("#excelRowTotCnt").text(0); //총건수 수정
$("#excelRowDupCnt").text(0); //중복건수 수정
dupliPhoneDataRealList.length = 0; // 중복 휴대폰번호 초기화
// select box 초기화
$('.field-selector').each(function() { $(this).val(''); });
});
});
@ -285,8 +378,8 @@ function updateTable(tableData) {
]);
$tableExcel.setData(tableData).then(() => {
// rowTotCnt 업데이트
document.getElementById("rowTotCnt").innerText = tableData.length;
// excelRowTotCnt 업데이트
document.getElementById("excelRowTotCnt").innerText = tableData.length;
});
fn_loadRemoveActive();
@ -366,7 +459,7 @@ function fn_phoneDupl($objTabul) {
alert('휴대폰 형식에 맞지 않는 데이터가 있습니다.\n 확인해 주세요');
}
$("#rowDupCnt").text(dupliPhoneDataRealList.length);
$("#excelRowDupCnt").text(dupliPhoneDataRealList.length);
if (dupliPhoneDataRealList.length > 0) {
// alert("중복된 휴대폰 번호가 있습니다: \n" + duplicatePhones.join(", "));
@ -380,14 +473,45 @@ function fn_phoneDupl($objTabul) {
// 고유한 데이터만 남기고 테이블 업데이트
$objTabul.setData(rowsToKeep);
$("#rowTotCnt").text(rowsToKeep.length);
$("#excelRowTotCnt").text(rowsToKeep.length);
}
function fn_dupliPopupShow(){
$("#tableExcelDupliBtn").show();
}
function makeAddrMassDupliPop(dupliPhoneDataRealList) {
var sHtml = "";
sHtml += "<div class='' style='overflow-x:auto; height:350px;'>";
sHtml += "<table class='tType4'>";
sHtml += " <colgroup>";
sHtml += " <col style='width:auto' />";
sHtml += " </colgroup>";
sHtml += " <thead>";
sHtml += " <tr>";
sHtml += " <th>중복 휴대폰번호 (" + numberWithCommas(dupliPhoneDataRealList.length) + "개)</th>";
sHtml += " </tr>";
sHtml += " </thead>";
sHtml += " <tbody>";
for (var i = 0; i < dupliPhoneDataRealList.length; i++) {
sHtml += " <tr>";
sHtml += " <td>" + dupliPhoneDataRealList[i] + "</td>";
sHtml += " </tr>";
}
sHtml += " </tbody>";
sHtml += " </table>";
sHtml += " </div>";
$("#addrMassDupli_layer").html(sHtml);
fn_dupliPopupShow();
}
function fn_dupliPopupShow(){
$('#tableExcelDupliBtn').show()
$('#tableExcelDupliBtn').show();
}
//한국의 핸드폰 번호 형식 검사 함수
@ -399,6 +523,9 @@ function isValidKoreanPhoneNumber(phone) {
return valid;
}
// 상단 설명 더보기
function popMore(e){
$(e).closest(".pop_more_cont").toggleClass("pop_more_click");
@ -414,9 +541,26 @@ function popMore(e){
</script>
<!-- 중복전화번호 data-tooltip:addrMassDupli_layer -->
<div class="tooltip-wrap">
<div class="popup-com addrMassDupli_layer" tabindex="0" data-tooltip-con="addrMassDupli_layer" data-focus="addrMassDupli_layer" data-focus-prev="addrMassDupli_layer-close" style="width: 270px; height: 500px;">
<div class="popup_heading">
<p>중복 휴대폰번호</p>
<button type="button" class="tooltip-close" data-focus="addrMassDupli_layer-close" onclick="setAddrDupliClose();"><img src="/publish/images/content/layerPopup_close.png" alt="팝업 닫기"></button>
</div>
<div class="layer_in" style="padding:20px 0px;" id="addrMassDupli_layer">
</div>
<div class="popup_btn_wrap2" style="margin-top: 0px;">
<button type="button" class="tooltip-close" data-focus="addrMassDupli_layer-close" data-focus-next="addrMassDupli_layer">닫기</button>
</div>
</div>
</div>
<!--// 중복전화번호 팝업 -->
<div class="popup_heading">
<p>주소록 대량등록</p>
<button type="button" class="tooltip-close" data-focus="popup02-close"><img src="/publish/images/content/layerPopup_close.png" alt="팝업 닫기"></button>
<p>엑셀 불러오기</p>
<button type="button" class="tooltip-close" id="closeBtn" data-focus="popup02-close"><img src="/publish/images/content/layerPopup_close.png" alt="팝업 닫기"></button>
</div>
<div class="layer_in" style="padding: 25px 30px;">
<!-- <div class="list_tab_wrap2"> -->
@ -459,7 +603,7 @@ function popMore(e){
</colgroup>
<tbody>
<tr>
<th>그룹 선택</th>
<!-- <th>그룹 선택</th>
<td>
<label for="" class="label">그룹 선택</label>
<select id="addrGrpIdInfo" name="addrGrpIdInfo">
@ -468,17 +612,25 @@ function popMore(e){
<input type="text" id="addrGrpNm" name="addrGrpNm" placeholder="새 그룹명을 입력해주세요." onfocus="this.placeholder=''" onblur="this.placeholder='새 그룹명을 입력해주세요.'"class="inputLight" style="width: 300px;">
<input type="file" id="excelFile" accept=".xls, .xlsx, .txt" style="display:none"/>
<button type="button" class="excel_btn2 btnType c3"><i class="uproad"></i>엑셀, TXT파일 업로드</button>
</td> -->
<td colspan="2" style="padding:20px 0;">
<div class="file_upload_wrap" style="width:100%;display:flex;">
<div class="file_add upload_area">
<p><img src="/publish/images/content/file_add.png" alt="파일 붙여넣기">마우스로 엑셀, TXT파일을 여기에 끌어다 놓으세요</p>
</div>
<input type="file" id="excelFile" accept=".xls, .xlsx, .txt" style="display:none"/>
<button type="button" class="excel_btn2 btnType c3"><i class="uproad"></i>엑셀, TXT파일 업로드</button>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<div class="file_add upload_area">
<p><img src="/publish/images/content/file_add.png" alt="파일 붙여넣기">마우스로 엑셀, TXT파일을 여기에 끌어다 놓으세요</p>
</div>
<div class="excel_middle2">
<p>
총 <span class="c_e40000 fwBold" id="rowTotCnt">0</span>건 / 중복 <span class="c_002c9a fwBold" id="rowDupCnt">0</span>건
총 <span class="c_e40000 fwBold" id="excelRowTotCnt">0</span>건 / 중복 <span class="c_002c9a fwBold" id="excelRowDupCnt">0</span>건
&nbsp;
<button type="button" class="btnType btnType6" data-tooltip="addrMassDupli_layer" id="tableExcelDupliBtn">중복번호</button>
<!-- &nbsp; -->
@ -594,7 +746,7 @@ function popMore(e){
<div class="excel_middle">
<div class="select_btnWrap clearfix">
<div>
<button type="button" id="all_del"><i class="remove_img"></i>전체삭제</button>
<button type="button" id="allDel"><i class="remove_img"></i>전체삭제</button>
<button type="button" id="in_select_del"><i class="remove_img"></i>선택삭제</button>
<button type="button" id="chkVali_del"><i class="remove_img"></i>오류번호삭제</button>
<button type="button" id="check_validity">오류 검사 <i></i></button>
@ -618,7 +770,7 @@ function popMore(e){
</div>
</div>
<div class="popup_btn_wrap2" style="margin: 0 auto 30px auto;">
<button type="button" id="btnAddrMassReg">등록</button>
<button type="button" id="btnAddrMassReg">추가</button>
<button type="button" id="btnAddrMassClose" class="tooltip-close" data-focus="adr_popup01-close" data-focus-next="popup02">닫기</button>
</div>

View File

@ -1195,7 +1195,11 @@
.layer_in .popup_search_type1 button { width:63px;}
.layer_in .gorup_join_cont .input_right.type1 {padding:0 0 0 30px; font-size:17px; font-weight:300;}
/* 주소록 대량등록 */
.file_upload_wrap{position:relative;display:flex;justify-content:space-between;align-items:center;}
.file_upload_wrap .file_add.upload_area{display:flex;width:78%;margin:0;align-items:center;justify-content:center;}
.file_upload_wrap .file_add.upload_area p{display:block;}
.file_upload_wrap .btnType.c3{position:unset;height:82px;}
/* ie */