rowData[key] = typeof row[idx] === 'string' ? row[idx].trim() : row[idx]; // 문자열인지 확인하고 trim() 적용
row[idx]; // 문자열인지 확인하고 trim() 적용
@58357b78915e623f0005df61173572692e142ede
--- src/main/webapp/WEB-INF/jsp/web/addr/AddrList.jsp
+++ src/main/webapp/WEB-INF/jsp/web/addr/AddrList.jsp
... | ... | @@ -28,6 +28,16 @@ |
| 28 | 28 |
// addrMassTab(1); |
| 29 | 29 |
|
| 30 | 30 |
// 중복 휴대폰번호 버튼 노출여부 |
| 31 |
+ |
|
| 32 |
+ |
|
| 33 |
+ // excel 오류정보 테스트 |
|
| 34 |
+ $('#errorExcelBtn').click(function(){
|
|
| 35 |
+ if($tableError.getDataCount()<1){
|
|
| 36 |
+ alert('오류 정보가 없습니다.');
|
|
| 37 |
+ return false; |
|
| 38 |
+ } |
|
| 39 |
+ $tableError.download("xlsx", "error_data.xlsx");
|
|
| 40 |
+ }); |
|
| 31 | 41 |
}); |
| 32 | 42 |
|
| 33 | 43 |
// 메인 화면 좌측메뉴 최신화 |
... | ... | @@ -213,7 +223,8 @@ |
| 213 | 223 |
//location.reload(); |
| 214 | 224 |
listAddrGrp(); |
| 215 | 225 |
addrGroupLoadAjax(); |
| 216 |
- addrLoadAjax(); |
|
| 226 |
+ addrLoadAjax(); |
|
| 227 |
+ errorPopClean(); // 에러 팝업 초기화 |
|
| 217 | 228 |
} |
| 218 | 229 |
|
| 219 | 230 |
// 주소록 그룹 중복체크 |
... | ... | @@ -651,6 +662,7 @@ |
| 651 | 662 |
|
| 652 | 663 |
<div id="adrPopup_tab1"> |
| 653 | 664 |
|
| 665 |
+ |
|
| 654 | 666 |
<!-- 수신거부 대량등록 data-tooltip:adr_popup01 --> |
| 655 | 667 |
<form id="addrMassForm" name="addrMassForm" method="post"> |
| 656 | 668 |
<input type="hidden" id="phoneList" name="phoneList" value=""/> |
... | ... | @@ -694,6 +706,39 @@ |
| 694 | 706 |
</div> |
| 695 | 707 |
</div> |
| 696 | 708 |
</form> |
| 709 |
+ |
|
| 710 |
+ |
|
| 711 |
+ |
|
| 712 |
+<!-- 주소록 상세 결과 팝업 data-tooltip:adr_popup14 --> |
|
| 713 |
+ <div class="tooltip-wrap"> |
|
| 714 |
+ <div class="popup-com adr_layer adr_popup14" tabindex="0" data-tooltip-con="adr_popup14" data-focus="adr_popup14" data-focus-prev="adr_popu14-close" style="width: 450px;"> |
|
| 715 |
+ <div class="popup_heading"> |
|
| 716 |
+ <p>주소록 상세 결과</p> |
|
| 717 |
+ <button type="button" class="tooltip-close" data-focus="adr_popup14-close"><img src="/publish/images/content/layerPopup_close.png" alt="팝업 닫기"></button> |
|
| 718 |
+ </div> |
|
| 719 |
+ <div class="layer_in" style="padding:30px 20px;"> |
|
| 720 |
+ <div class="table_top"> |
|
| 721 |
+ <p> |
|
| 722 |
+ 총 <span class="c_e40000" id="errorPopTotCnt">0</span>건 |
|
| 723 |
+ / 중복 <span class="c_002c9a" id="errorPopDupCnt">0</span>건 |
|
| 724 |
+ / 오류 <span class="c_002c9a" id="errorPopErrorCnt">0</span>건</p> |
|
| 725 |
+ <button type="button" class="excel_btn btnType" id="errorExcelBtn"><i class="downroad"></i>엑셀 다운로드</button> |
|
| 726 |
+ </div> |
|
| 727 |
+ <div class="tb_wrap adr_list" id="tabulator_error"> |
|
| 728 |
+ <!-- $tableError 참고 --> |
|
| 729 |
+ </div> |
|
| 730 |
+ <ul class="cf_text_ul"> |
|
| 731 |
+ <li>*중복번호는 하나의 번호만 등록됩니다.</li> |
|
| 732 |
+ <li>*휴대폰 형식에 맞지 않는 데이터는 삭제 후 업로드 됩니다.</li> |
|
| 733 |
+ <li>ex) 발송불가 특수문자, 자릿수 오류 등</li> |
|
| 734 |
+ </ul> |
|
| 735 |
+ <div class="popup_btn_wrap2"> |
|
| 736 |
+ <button type="button">저장</button> |
|
| 737 |
+ <button type="button" class="tooltip-close" data-focus="adr_popup14-close" data-focus-next="adr_popup14">닫기</button> |
|
| 738 |
+ </div> |
|
| 739 |
+ </div> |
|
| 740 |
+ </div> |
|
| 741 |
+ </div> |
|
| 697 | 742 |
|
| 698 | 743 |
</div> |
| 699 | 744 |
<!--// 주소록 대량등록 팝업 --> |
--- src/main/webapp/WEB-INF/jsp/web/addr/include/addrListforExcel.jsp
+++ src/main/webapp/WEB-INF/jsp/web/addr/include/addrListforExcel.jsp
... | ... | @@ -314,6 +314,7 @@ |
| 314 | 314 |
//파일 드래그앤드롭 종료 |
| 315 | 315 |
|
| 316 | 316 |
function excelFileChange(file) {
|
| 317 |
+ errorPopClean(); // 에러 popup 초기화 |
|
| 317 | 318 |
if (file) {
|
| 318 | 319 |
fn_loadAddActive(); |
| 319 | 320 |
var reader = new FileReader(); |
... | ... | @@ -354,7 +355,8 @@ |
| 354 | 355 |
data.forEach((row, index) => {
|
| 355 | 356 |
var rowData = {};
|
| 356 | 357 |
keys.forEach((key, idx) => { // index 변수명 변경 (내부와 외부에서 사용되므로 충돌 방지)
|
| 357 |
- rowData[key] = row[idx] ? row[idx].trim() : ""; // 각 컬럼에 대해 기본값을 설정 |
|
| 358 |
+ console.log('row[idx] : ', row[idx]);
|
|
| 359 |
+ rowData[key] = typeof row[idx] === 'string' ? row[idx].trim() : row[idx]; // 문자열인지 확인하고 trim() 적용 |
|
| 358 | 360 |
}); |
| 359 | 361 |
tableData.push(rowData); |
| 360 | 362 |
|
... | ... | @@ -495,6 +497,7 @@ |
| 495 | 497 |
} */ |
| 496 | 498 |
|
| 497 | 499 |
</script> |
| 500 |
+ |
|
| 498 | 501 |
<!-- 엑셀입력 --> |
| 499 | 502 |
<div class="popCont current pop_more_cont" id="popCont_1"> |
| 500 | 503 |
<div class="titBox"> |
... | ... | @@ -549,13 +552,17 @@ |
| 549 | 552 |
</div> |
| 550 | 553 |
<div class="excel_middle2"> |
| 551 | 554 |
<p> |
| 552 |
- 총 <span class="c_e40000 fwBold" id="rowTotCnt">0</span>건 / 중복 <span class="c_002c9a fwBold" id="rowDupCnt">0</span>건 |
|
| 555 |
+ 총 <span class="c_e40000 fwBold" id="rowTotCnt">0</span>건 |
|
| 556 |
+ / 중복 <span class="c_002c9a fwBold" id="rowDupCnt">0</span>건 |
|
| 557 |
+ / 오류 <span class="c_002c9a fwBold" id="rowErrorCnt">0</span>건 |
|
| 558 |
+ <button type="button" class="btn_list_detail" data-tooltip="adr_popup14"><img src="/publish/images/search.png"></button> |
|
| 559 |
+ </p> |
|
| 560 |
+<!-- <p>총 <span class="c_e40000">171</span>건 / 중복 <span class="c_002c9a">9</span>건 / 오류 <span class="c_002c9a">9</span>건 <button type="button" class="btn_list_detail"><img src="/publish/images/search.png"></button></p> --> |
|
| 553 | 561 |
|
| 554 | 562 |
<!-- <button type="button" class="btnType btnType6" data-tooltip="addrMassDupli_layer" onclick="GetAddrMassDupli()" id="btnAddrMassDupli">중복번호</button> --> |
| 555 |
- <button type="button" class="btnType btnType6" data-tooltip="addrMassDupli_layer" id="tableExcelDupliBtn">중복번호</button> |
|
| 563 |
+<!-- <button type="button" class="btnType btnType6" data-tooltip="addrMassDupli_layer" id="tableExcelDupliBtn">중복번호</button> --> |
|
| 556 | 564 |
<!-- --> |
| 557 | 565 |
<!-- <button type="button" class="btnType btnType6" data-tooltip="addrMassSaveDupli_layer" onclick="GetAddrMassSaveDupli()" id="btnAddrMassSaveDupli">중복번호</button> --> |
| 558 |
- </p> |
|
| 559 | 566 |
<!-- <button type="button" class="btnType btnType6 addCallToF">번호추가</button> --> |
| 560 | 567 |
</div> |
| 561 | 568 |
|
--- src/main/webapp/WEB-INF/jsp/web/msgdata/MsgDataSMLView.jsp
+++ src/main/webapp/WEB-INF/jsp/web/msgdata/MsgDataSMLView.jsp
... | ... | @@ -7,6 +7,8 @@ |
| 7 | 7 |
|
| 8 | 8 |
<script type="text/javascript" src="<c:url value='/publish/js/content.js'/>"></script> |
| 9 | 9 |
<script type="text/javascript" src="<c:url value='/js/txtSpecialReplace.js?date=202304250003'/>"></script> |
| 10 |
+<!-- 주소록 유효성 체크 공통유틸로 인해 추가 --> |
|
| 11 |
+<script type="text/javascript" src="<c:url value='/js/web/addr/event.js?date=202409021440'/>"></script> |
|
| 10 | 12 |
|
| 11 | 13 |
<% pageContext.setAttribute("newLineChar", "\r\n"); %>
|
| 12 | 14 |
<script type="text/javascript"> |
... | ... | @@ -1059,48 +1061,6 @@ |
| 1059 | 1061 |
|
| 1060 | 1062 |
}); |
| 1061 | 1063 |
|
| 1062 |
- // 유효한 번호인지 확인하는 함수 |
|
| 1063 |
- function isValidPhoneNumber(phone) {
|
|
| 1064 |
- // 숫자만 추출 |
|
| 1065 |
- const numberOnly = phone.replace(/\D/g, ''); |
|
| 1066 |
- |
|
| 1067 |
- // 유효한 형식 체크 |
|
| 1068 |
- return ( |
|
| 1069 |
- (numberOnly.startsWith("010") && numberOnly.length === 11) || // 010으로 시작하고 11자리
|
|
| 1070 |
- (/^01[1-9]/.test(numberOnly) && numberOnly.length === 10) || // 011~019로 시작하고 10자리 |
|
| 1071 |
- (numberOnly.startsWith("050") && numberOnly.length === 12) // 050X로 시작하고 12자리
|
|
| 1072 |
- ); |
|
| 1073 |
- } |
|
| 1074 |
- |
|
| 1075 |
- function formatPhoneNumber(phone) {
|
|
| 1076 |
- // 숫자만 남기기 |
|
| 1077 |
- let cleanedPhone = phone.replace(/\D/g, ''); // 모든 숫자가 아닌 문자 제거 |
|
| 1078 |
- console.log('cleanedPhone : ', cleanedPhone);
|
|
| 1079 |
- |
|
| 1080 |
- // 앞에 0이 추가된 경우 처리 |
|
| 1081 |
- if (cleanedPhone.length === 10 && cleanedPhone.startsWith("10")) {
|
|
| 1082 |
- // 10으로 시작하는 10자리 번호는 앞에 0을 추가하여 11자리로 만듦 |
|
| 1083 |
- cleanedPhone = "0" + cleanedPhone; |
|
| 1084 |
- }else if (cleanedPhone.length === 9 && (cleanedPhone.startsWith("11") || cleanedPhone.startsWith("16") || cleanedPhone.startsWith("19"))) {
|
|
| 1085 |
- // 11, 16, 19로 시작하는 9자리 번호는 앞에 0을 추가하여 10자리로 만듦 |
|
| 1086 |
- cleanedPhone = "0" + cleanedPhone; |
|
| 1087 |
- } |
|
| 1088 |
- |
|
| 1089 |
- // 번호 형식 변환 |
|
| 1090 |
- if (cleanedPhone.startsWith("010") && cleanedPhone.length === 11) {
|
|
| 1091 |
- // 010-1234-5678 형식 |
|
| 1092 |
- return cleanedPhone.substring(0, 3) + '-' + cleanedPhone.substring(3, 7) + '-' + cleanedPhone.substring(7); |
|
| 1093 |
- } else if ((/^01[1-9]/.test(cleanedPhone)) && cleanedPhone.length === 10) {
|
|
| 1094 |
- // 01X-123-5678 형식 |
|
| 1095 |
- return cleanedPhone.substring(0, 3) + '-' + cleanedPhone.substring(3, 6) + '-' + cleanedPhone.substring(6); |
|
| 1096 |
- } else if (cleanedPhone.startsWith("050") && cleanedPhone.length === 12) {
|
|
| 1097 |
- // 050X-1234-5678 형식 |
|
| 1098 |
- return cleanedPhone.substring(0, 4) + '-' + cleanedPhone.substring(4, 8) + '-' + cleanedPhone.substring(8); |
|
| 1099 |
- } |
|
| 1100 |
- |
|
| 1101 |
- // 원본 반환 (표준 형식으로 변환되지 않으면) |
|
| 1102 |
- return phone; |
|
| 1103 |
- } |
|
| 1104 | 1064 |
|
| 1105 | 1065 |
|
| 1106 | 1066 |
|
--- src/main/webapp/js/web/addr/event.js
+++ src/main/webapp/js/web/addr/event.js
... | ... | @@ -41,7 +41,7 @@ |
| 41 | 41 |
}); |
| 42 | 42 |
|
| 43 | 43 |
|
| 44 |
- // |
|
| 44 |
+ // 데이터 넣기 |
|
| 45 | 45 |
updateTableFields($objTabul, group); |
| 46 | 46 |
|
| 47 | 47 |
// 필드가 휴대폰이면 열 중복체크 |
... | ... | @@ -57,53 +57,136 @@ |
| 57 | 57 |
* @ 핸드폰 중복 데이터 |
| 58 | 58 |
* */ |
| 59 | 59 |
function fn_phoneDupl($objTabul) {
|
| 60 |
- var data = $objTabul.getData(); |
|
| 61 |
- var uniquePhones = new Set(); |
|
| 62 |
- var dupliPhoneDataRealList = []; |
|
| 63 |
- var rowsToKeep = []; |
|
| 64 |
- var rowsToDelete = []; |
|
| 65 |
- var phoneNumberChk = false; |
|
| 60 |
+ |
|
| 61 |
+ $tableError.clearData(); |
|
| 62 |
+ |
|
| 63 |
+ var tabulNm = fn_utils_getTabulatorNm(); |
|
| 64 |
+ var tabluC = '.'+tabulNm |
|
| 65 |
+ |
|
| 66 |
+ var data = $objTabul.getData(); |
|
| 67 |
+ var phoneNumberChk = false; |
|
| 68 |
+ var existingNumbers = new Set(); // 배열에서 Set으로 변경 |
|
| 69 |
+ |
|
| 70 |
+ console.log('입력된 번호들 : ', data);
|
|
| 66 | 71 |
|
| 67 | 72 |
|
| 68 |
- var tabulNm = fn_utils_getTabulatorNm(); |
|
| 69 |
- var tabluC = '.'+tabulNm |
|
| 70 |
- |
|
| 71 |
- data.forEach((row, index) => {
|
|
| 73 |
+ let errorCount = 0; // 중복 번호 개수를 저장할 변수 |
|
| 74 |
+ let duplicateCount = 0; // 중복 번호 개수를 저장할 변수 |
|
| 72 | 75 |
|
| 73 |
- if (!isValidKoreanPhoneNumber(row.addrPhoneNo)) {
|
|
| 74 |
- phoneNumberChk = true |
|
| 75 |
- return false; |
|
| 76 |
- } |
|
| 77 |
- |
|
| 78 |
- if (uniquePhones.has(row.addrPhoneNo)) {
|
|
| 79 |
- dupliPhoneDataRealList.push(row.addrPhoneNo); |
|
| 80 |
- rowsToDelete.push(index); // 중복된 행의 인덱스를 기록 |
|
| 81 |
- } else {
|
|
| 82 |
- uniquePhones.add(row.addrPhoneNo); |
|
| 83 |
- rowsToKeep.push(row); // 고유한 데이터만 추가 |
|
| 84 |
- } |
|
| 85 |
- }); |
|
| 86 |
- |
|
| 87 |
- if(phoneNumberChk){
|
|
| 88 |
- alert('휴대폰 형식에 맞지 않는 데이터가 있습니다.\n 확인해 주세요');
|
|
| 89 |
- } |
|
| 76 |
+ // 각 번호를 테이블에 추가 (중복 검사 및 포맷팅 포함) |
|
| 77 |
+ for (let i = data.length - 1; i >= 0; i--) {
|
|
| 78 |
+// console.log('index : ', index);
|
|
| 79 |
+// console.log('existingNumbers : ', existingNumbers);
|
|
| 90 | 80 |
|
| 91 |
- $(tabluC+" #rowDupCnt").text(dupliPhoneDataRealList.length); |
|
| 81 |
+ let row = data[i]; |
|
| 82 |
+ var number = row.addrPhoneNo; |
|
| 83 |
+ const formattedNumber = formatPhoneNumber(number); // 번호 표준화 |
|
| 84 |
+// console.log('number : ', number)
|
|
| 85 |
+// console.log('formattedNumber : ', formattedNumber)
|
|
| 86 |
+ const cleanedNumber = formattedNumber.replace(/[^0-9]/g, ''); // 숫자만 남김 |
|
| 87 |
+ if (!existingNumbers.has(cleanedNumber)) { // 중복 번호 체크
|
|
| 88 |
+ if (isValidPhoneNumber(formattedNumber)) { // 유효성 검사
|
|
| 89 |
+// $tableError.addRow({ phone: formattedNumber }); // 표준화된 번호로 추가
|
|
| 90 |
+// console.log('formattedNumber : ', formattedNumber);
|
|
| 91 |
+ |
|
| 92 |
+// console.log('통과 : ', row.addrPhoneNo, " : ", cleanedNumber);
|
|
| 93 |
+ row.addrPhoneNo = formattedNumber ; |
|
| 94 |
+ existingNumbers.add(cleanedNumber); // 추가된 번호를 기존 목록에 추가 |
|
| 95 |
+ } else {
|
|
| 96 |
+ // 오류 : 유효성 통과 못함 |
|
| 97 |
+// console.log('오류 : ', formattedNumber, ' : ',cleanedNumber);
|
|
| 98 |
+ errorCount++; |
|
| 99 |
+ $tableError.addRow({
|
|
| 100 |
+ name: row.addrNm, // 이름 |
|
| 101 |
+ phone: row.addrPhoneNo, // 폰번호 |
|
| 102 |
+ result: "오류" // 결과 메시지 추가 |
|
| 103 |
+ }); |
|
| 104 |
+ data.splice(i, 1); // 유효하지 않은 행 삭제 |
|
| 105 |
+ } |
|
| 106 |
+ } else {
|
|
| 107 |
+ // 중복 |
|
| 108 |
+// console.log('중복 : ', row.addrPhoneNo);
|
|
| 109 |
+ duplicateCount++; // 중복 번호가 발견될 때마다 카운트를 증가 |
|
| 110 |
+ $tableError.addRow({
|
|
| 111 |
+ name: row.addrNm, // 이름 |
|
| 112 |
+ phone: row.addrPhoneNo, // 폰번호 |
|
| 113 |
+ result: "중복" // 결과 메시지 추가 |
|
| 114 |
+ }); |
|
| 115 |
+ data.splice(i, 1); // 유효하지 않은 행 삭제 |
|
| 116 |
+ } |
|
| 117 |
+ }; |
|
| 92 | 118 |
|
| 93 |
- if (dupliPhoneDataRealList.length > 0) {
|
|
| 119 |
+ // 중복 카운트 |
|
| 120 |
+ $(tabluC+" #rowDupCnt").text(duplicateCount); |
|
| 121 |
+ // 에러 카운트 |
|
| 122 |
+ $(tabluC+" #rowErrorCnt").text(errorCount); |
|
| 123 |
+ |
|
| 124 |
+ // popup 영역 |
|
| 125 |
+ // 중복 카운트 |
|
| 126 |
+ $("#errorPopDupCnt").text(duplicateCount);
|
|
| 127 |
+ // 에러 카운트 |
|
| 128 |
+ $("#errorPopErrorCnt").text(errorCount);
|
|
| 129 |
+ // |
|
| 130 |
+ $("#errorPopTotCnt").text(duplicateCount+errorCount);
|
|
| 131 |
+ |
|
| 132 |
+ // 수정된 데이터로 테이블 업데이트 |
|
| 133 |
+ $objTabul.setData(data); |
|
| 134 |
+ |
|
| 135 |
+ // 중복 번호 개수를 #rowDupCnt 요소에 표시 |
|
| 136 |
+ $("#rowDupCnt").text(duplicateCount);
|
|
| 137 |
+ |
|
| 138 |
+ $(tabluC+" #rowTotCnt").text($objTabul.getDataCount()); |
|
| 139 |
+ |
|
| 140 |
+ } |
|
| 141 |
+ |
|
| 142 |
+ function fn_phoneDupl_old($objTabul) {
|
|
| 143 |
+ var data = $objTabul.getData(); |
|
| 144 |
+ var uniquePhones = new Set(); |
|
| 145 |
+ var dupliPhoneDataRealList = []; |
|
| 146 |
+ var rowsToKeep = []; |
|
| 147 |
+ var rowsToDelete = []; |
|
| 148 |
+ var phoneNumberChk = false; |
|
| 149 |
+ |
|
| 150 |
+ |
|
| 151 |
+ var tabulNm = fn_utils_getTabulatorNm(); |
|
| 152 |
+ var tabluC = '.'+tabulNm |
|
| 153 |
+ |
|
| 154 |
+ data.forEach((row, index) => {
|
|
| 155 |
+ |
|
| 156 |
+ if (!isValidKoreanPhoneNumber(row.addrPhoneNo)) {
|
|
| 157 |
+ phoneNumberChk = true |
|
| 158 |
+ return false; |
|
| 159 |
+ } |
|
| 160 |
+ |
|
| 161 |
+ if (uniquePhones.has(row.addrPhoneNo)) {
|
|
| 162 |
+ dupliPhoneDataRealList.push(row.addrPhoneNo); |
|
| 163 |
+ rowsToDelete.push(index); // 중복된 행의 인덱스를 기록 |
|
| 164 |
+ } else {
|
|
| 165 |
+ uniquePhones.add(row.addrPhoneNo); |
|
| 166 |
+ rowsToKeep.push(row); // 고유한 데이터만 추가 |
|
| 167 |
+ } |
|
| 168 |
+ }); |
|
| 169 |
+ |
|
| 170 |
+ if(phoneNumberChk){
|
|
| 171 |
+ alert('휴대폰 형식에 맞지 않는 데이터가 있습니다.\n 확인해 주세요');
|
|
| 172 |
+ } |
|
| 173 |
+ |
|
| 174 |
+ $(tabluC+" #rowDupCnt").text(dupliPhoneDataRealList.length); |
|
| 175 |
+ |
|
| 176 |
+ if (dupliPhoneDataRealList.length > 0) {
|
|
| 94 | 177 |
// alert("중복된 휴대폰 번호가 있습니다: \n" + duplicatePhones.join(", "));
|
| 95 |
- makeAddrMassDupliPop(dupliPhoneDataRealList); |
|
| 96 |
- } |
|
| 178 |
+ makeAddrMassDupliPop(dupliPhoneDataRealList); |
|
| 179 |
+ } |
|
| 97 | 180 |
|
| 98 |
- // 중복된 행 삭제 |
|
| 99 |
- rowsToDelete.reverse().forEach(index => {
|
|
| 100 |
- $objTabul.deleteRow(index); |
|
| 101 |
- }); |
|
| 181 |
+ // 중복된 행 삭제 |
|
| 182 |
+ rowsToDelete.reverse().forEach(index => {
|
|
| 183 |
+ $objTabul.deleteRow(index); |
|
| 184 |
+ }); |
|
| 102 | 185 |
|
| 103 |
- // 고유한 데이터만 남기고 테이블 업데이트 |
|
| 104 |
- $objTabul.setData(rowsToKeep); |
|
| 105 |
- $(tabluC+" #rowTotCnt").text(rowsToKeep.length); |
|
| 106 |
- } |
|
| 186 |
+ // 고유한 데이터만 남기고 테이블 업데이트 |
|
| 187 |
+ $objTabul.setData(rowsToKeep); |
|
| 188 |
+ $(tabluC+" #rowTotCnt").text(rowsToKeep.length); |
|
| 189 |
+ } |
|
| 107 | 190 |
|
| 108 | 191 |
//받는사람 전체삭제 버튼 처리 |
| 109 | 192 |
$('.all_del').click(function(){
|
... | ... | @@ -161,7 +244,10 @@ |
| 161 | 244 |
* 데이터테이블 필드값 수정 |
| 162 | 245 |
*/ |
| 163 | 246 |
function updateTableFields($objTabul, group) {
|
| 247 |
+ // 데이터가져오기 |
|
| 164 | 248 |
var currentData = $objTabul.getData(); |
| 249 |
+ |
|
| 250 |
+ // 필드 초기 값 셋팅 |
|
| 165 | 251 |
var columns = [ |
| 166 | 252 |
{formatter: "rowSelection", titleFormatter: "rowSelection", clipboard: false, hozAlign: "center", headerHozAlign: "center", headerSort: false, cellClick: function(e, cell) {
|
| 167 | 253 |
cell.getRow().toggleSelect(); |
... | ... | @@ -170,6 +256,7 @@ |
| 170 | 256 |
]; |
| 171 | 257 |
|
| 172 | 258 |
var fieldMapping = []; |
| 259 |
+ // 초기 후 필드 값 셋팅하기 |
|
| 173 | 260 |
$('[data-group="' + group + '"] .field-selector').each(function(index) {
|
| 174 | 261 |
var selectedField = $(this).val(); |
| 175 | 262 |
// ASCII 문자 코드 사용 - 65=A, 66=B ... |
... | ... | @@ -201,6 +288,7 @@ |
| 201 | 288 |
} |
| 202 | 289 |
}); |
| 203 | 290 |
|
| 291 |
+ // 데이터 셋팅 |
|
| 204 | 292 |
var updatedData = currentData.map(row => {
|
| 205 | 293 |
var newRow = {};
|
| 206 | 294 |
fieldMapping.forEach((field, index) => {
|
... | ... | @@ -258,12 +346,66 @@ |
| 258 | 346 |
$(showId+'DupliBtn').show() |
| 259 | 347 |
} |
| 260 | 348 |
|
| 261 |
-//한국의 핸드폰 번호 형식 검사 함수 |
|
| 262 |
-function isValidKoreanPhoneNumber(phone) {
|
|
| 263 |
- // 하이픈(-)을 제거하고 숫자만 남긴 후 검사 |
|
| 264 |
- var cleaned = phone.replace(/-/g, ''); |
|
| 265 |
- // 010, 011, 016, 017, 018, 019로 시작하고 10~11자리인 경우 유효 |
|
| 266 |
- var valid = /^(010|011|016|017|018|019)\d{7,8}$/.test(cleaned);
|
|
| 267 |
- return valid; |
|
| 349 |
+ |
|
| 350 |
+ |
|
| 351 |
+ |
|
| 352 |
+// 유효한 번호인지 확인하는 함수 |
|
| 353 |
+function isValidPhoneNumber(phone) {
|
|
| 354 |
+ // 숫자만 추출 |
|
| 355 |
+ const numberOnly = phone.replace(/\D/g, ''); |
|
| 356 |
+ |
|
| 357 |
+ // 유효한 형식 체크 |
|
| 358 |
+ return ( |
|
| 359 |
+ (numberOnly.startsWith("010") && numberOnly.length === 11) || // 010으로 시작하고 11자리
|
|
| 360 |
+ (/^01[1-9]/.test(numberOnly) && numberOnly.length === 10) || // 011~019로 시작하고 10자리 |
|
| 361 |
+ (numberOnly.startsWith("050") && numberOnly.length === 12) // 050X로 시작하고 12자리
|
|
| 362 |
+ ); |
|
| 268 | 363 |
} |
| 269 | 364 |
|
| 365 |
+// 유효성 후 포맷 맞추는 함수 |
|
| 366 |
+function formatPhoneNumber(phone) {
|
|
| 367 |
+ // 숫자만 남기기 |
|
| 368 |
+ let cleanedPhone = phone.replace(/\D/g, ''); // 모든 숫자가 아닌 문자 제거 |
|
| 369 |
+// console.log('cleanedPhone : ', cleanedPhone);
|
|
| 370 |
+ |
|
| 371 |
+ // 앞에 0이 추가된 경우 처리 |
|
| 372 |
+ if (cleanedPhone.length === 10 && cleanedPhone.startsWith("10")) {
|
|
| 373 |
+ // 10으로 시작하는 10자리 번호는 앞에 0을 추가하여 11자리로 만듦 |
|
| 374 |
+ cleanedPhone = "0" + cleanedPhone; |
|
| 375 |
+ }else if (cleanedPhone.length === 9 && (cleanedPhone.startsWith("11") || cleanedPhone.startsWith("16") || cleanedPhone.startsWith("19"))) {
|
|
| 376 |
+ // 11, 16, 19로 시작하는 9자리 번호는 앞에 0을 추가하여 10자리로 만듦 |
|
| 377 |
+ cleanedPhone = "0" + cleanedPhone; |
|
| 378 |
+ } |
|
| 379 |
+ |
|
| 380 |
+ // 번호 형식 변환 |
|
| 381 |
+ if (cleanedPhone.startsWith("010") && cleanedPhone.length === 11) {
|
|
| 382 |
+ // 010-1234-5678 형식 |
|
| 383 |
+ return cleanedPhone.substring(0, 3) + '-' + cleanedPhone.substring(3, 7) + '-' + cleanedPhone.substring(7); |
|
| 384 |
+ } else if ((/^01[1-9]/.test(cleanedPhone)) && cleanedPhone.length === 10) {
|
|
| 385 |
+ // 01X-123-5678 형식 |
|
| 386 |
+ return cleanedPhone.substring(0, 3) + '-' + cleanedPhone.substring(3, 6) + '-' + cleanedPhone.substring(6); |
|
| 387 |
+ } else if (cleanedPhone.startsWith("050") && cleanedPhone.length === 12) {
|
|
| 388 |
+ // 050X-1234-5678 형식 |
|
| 389 |
+ return cleanedPhone.substring(0, 4) + '-' + cleanedPhone.substring(4, 8) + '-' + cleanedPhone.substring(8); |
|
| 390 |
+ } |
|
| 391 |
+ |
|
| 392 |
+ // 원본 반환 (표준 형식으로 변환되지 않으면) |
|
| 393 |
+ return phone; |
|
| 394 |
+} |
|
| 395 |
+ |
|
| 396 |
+// 주소록 에러결과 초기화 |
|
| 397 |
+function errorPopClean(){
|
|
| 398 |
+ |
|
| 399 |
+ // popup 영역 |
|
| 400 |
+ $tableError.clearData(); |
|
| 401 |
+ // 중복 카운트 |
|
| 402 |
+ $("#errorPopDupCnt").text(0);
|
|
| 403 |
+ // 에러 카운트 |
|
| 404 |
+ $("#errorPopErrorCnt").text(0);
|
|
| 405 |
+ // |
|
| 406 |
+ $("#errorPopTotCnt").text(0);
|
|
| 407 |
+} |
|
| 408 |
+ |
|
| 409 |
+ |
|
| 410 |
+ |
|
| 411 |
+ |
--- src/main/webapp/js/web/addr/init.js
+++ src/main/webapp/js/web/addr/init.js
... | ... | @@ -18,6 +18,8 @@ |
| 18 | 18 |
var $tableClip = null; //붙여넣기 탭 |
| 19 | 19 |
var $tableSelf = null; //붙여넣기 탭 |
| 20 | 20 |
|
| 21 |
+var $tableError = null; //에러 팝업 영역 |
|
| 22 |
+ |
|
| 21 | 23 |
$(document).ready(function(){
|
| 22 | 24 |
|
| 23 | 25 |
//Tabulator AJAX Data Loading |
... | ... | @@ -129,6 +131,34 @@ |
| 129 | 131 |
}, |
| 130 | 132 |
}); |
| 131 | 133 |
|
| 134 |
+ |
|
| 135 |
+ //Tabulator AJAX Data Loading |
|
| 136 |
+ $tableError = new Tabulator("#tabulator_error", {
|
|
| 137 |
+ height:"255px", |
|
| 138 |
+ width:"100%", |
|
| 139 |
+ layout:"fitColumns", |
|
| 140 |
+ autoColumns:false, |
|
| 141 |
+ headerHozAlign:"center", |
|
| 142 |
+ validationMode:"highlight", |
|
| 143 |
+ clipboard:false, |
|
| 144 |
+ clipboardCopySelector:"table", |
|
| 145 |
+ clipboardPasteAction:"insert", // insert, update, replace |
|
| 146 |
+ placeholder:"Excel 파일을 업로드 해주세요.", //fit columns to width of table (optional) |
|
| 147 |
+ columns:[ //Define Table Columns |
|
| 148 |
+// {formatter:"rowSelection", titleFormatter:"rowSelection",clipboard:false, hozAlign:"center", headerSort:false, cellClick:function(e, cell){
|
|
| 149 |
+// cell.getRow().toggleSelect(); |
|
| 150 |
+// } |
|
| 151 |
+// }, |
|
| 152 |
+// {formatter:"rownum", align:"center" ,title:"No", hozAlign:"center", headerHozAlign:"center", width:40},
|
|
| 153 |
+ {title:"이름", field:"name", hozAlign:"center", headerHozAlign: "center", width:125},
|
|
| 154 |
+ {title:"휴대폰", field:"phone", hozAlign:"center", headerHozAlign: "center", width:158},
|
|
| 155 |
+ {title:"미등록 결과", field:"result", hozAlign:"center", headerHozAlign: "center", width:125}
|
|
| 156 |
+// {title:"이름", field:"name", hozAlign:"center", headerHozAlign: "center", width:125, validator:["maxLength:100", "string"]},
|
|
| 157 |
+// {title:"휴대폰", field:"phone", hozAlign:"center", headerHozAlign: "center", width:125, validator:["maxLength:100", "string"]},
|
|
| 158 |
+// {title:"미등록 결과", field:"result", hozAlign:"center", headerHozAlign: "center", width:125, validator:["maxLength:100", "string"]},
|
|
| 159 |
+ ] |
|
| 160 |
+ }); |
|
| 161 |
+ |
|
| 132 | 162 |
|
| 133 | 163 |
|
| 134 | 164 |
|
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?