--- src/main/webapp/WEB-INF/jsp/web/msgdata/MsgDataSMLView.jsp
+++ src/main/webapp/WEB-INF/jsp/web/msgdata/MsgDataSMLView.jsp
... | ... | @@ -28,28 +28,32 @@ |
| 28 | 28 |
validationMode:"highlight", |
| 29 | 29 |
placeholder:"복사(Ctrl+C)한 내용을 여기에 붙여넣기(Ctrl+V) 해주세요.", //fit columns to width of table (optional) |
| 30 | 30 |
resizableColumns:false, |
| 31 |
+ columnDefaults:{ // 공통설정
|
|
| 32 |
+ hozAlign: "center", |
|
| 33 |
+ headerHozAlign: "center", |
|
| 34 |
+ editor: "input", |
|
| 35 |
+ editor: false |
|
| 36 |
+ }, |
|
| 31 | 37 |
columns:[ //Define Table Columns |
| 32 | 38 |
{formatter:"rowSelection", headerHozAlign:"center", titleFormatter:"rowSelection",clipboard:false, hozAlign:"center", width:5, headerSort:false, cellClick:function(e, cell){
|
| 33 | 39 |
cell.getRow().toggleSelect(); |
| 34 | 40 |
}}, |
| 35 | 41 |
// {formatter:"rownum", align:"center", title:"No", hozAlign:"center", headerHozAlign:"center", field:"No", width:30},
|
| 36 | 42 |
{formatter:"rownum", align:"center" ,title:"No", hozAlign:"center", headerHozAlign:"center", width:40},
|
| 37 |
- {title:"이름", hozAlign:"center", headerHozAlign:"center", field:"name", editor:"input", validator:["maxLength:12"], cellEdited:function(cell){
|
|
| 43 |
+ {title:"이름", field:"name", validator:["maxLength:12"], cellEdited:function(cell){
|
|
| 38 | 44 |
fnReplCell(); |
| 39 | 45 |
}}, |
| 40 |
- {title:"휴대폰", hozAlign:"center", headerHozAlign:"center", field:"phone", editor:"input", width:100, validator:["required","minLength:10", "maxLength:12"], cellEdited:function(cell){
|
|
| 41 |
- fnDuplPhone(); |
|
| 42 |
- }}, |
|
| 43 |
- {title:"[*1*]", hozAlign:"center", headerHozAlign:"center", field:"rep1", editor:"input", minWidth:60, validator:["maxLength:40"], cellEdited:function(cell){
|
|
| 46 |
+ {title:"휴대폰", field:"phone", width:100, validator:["required","minLength:10", "maxLength:12"]},
|
|
| 47 |
+ {title:"[*1*]", field:"rep1", minWidth:60, validator:["maxLength:40"], cellEdited:function(cell){
|
|
| 44 | 48 |
fnReplCell(); |
| 45 | 49 |
}}, |
| 46 |
- {title:"[*2*]", hozAlign:"center", headerHozAlign:"center", field:"rep2", editor:"input", minWidth:60, validator:["maxLength:40"], cellEdited:function(cell){
|
|
| 50 |
+ {title:"[*2*]", field:"rep2", minWidth:60, validator:["maxLength:40"], cellEdited:function(cell){
|
|
| 47 | 51 |
fnReplCell(); |
| 48 | 52 |
}}, |
| 49 |
- {title:"[*3*]", hozAlign:"center", headerHozAlign:"center", field:"rep3", editor:"input", minWidth:60, validator:["maxLength:40"], cellEdited:function(cell){
|
|
| 53 |
+ {title:"[*3*]", field:"rep3", minWidth:60, validator:["maxLength:40"], cellEdited:function(cell){
|
|
| 50 | 54 |
fnReplCell(); |
| 51 | 55 |
}}, |
| 52 |
- {title:"[*4*]", hozAlign:"center", headerHozAlign:"center", field:"rep4", editor:"input", minWidth:60, validator:["maxLength:40"], cellEdited:function(cell){
|
|
| 56 |
+ {title:"[*4*]", field:"rep4", minWidth:60, validator:["maxLength:40"], cellEdited:function(cell){
|
|
| 53 | 57 |
fnReplCell(); |
| 54 | 58 |
}}, |
| 55 | 59 |
|
... | ... | @@ -1083,73 +1087,104 @@ |
| 1083 | 1087 |
$('.addCallToF').click(function(){
|
| 1084 | 1088 |
|
| 1085 | 1089 |
var callToNum = $('#callTo').val();
|
| 1086 |
- if(callToNum == null || callToNum == ""){
|
|
| 1087 |
- |
|
| 1088 |
- alert("받는사람 번호를 입력해 주세요.");
|
|
| 1089 |
- return false; |
|
| 1090 |
- |
|
| 1091 |
- }else if(!checkHpNum(callToNum)){
|
|
| 1092 |
- |
|
| 1093 |
- alert("올바른 전화번호를 입력해 주세요.");
|
|
| 1094 |
- $('#callTo').val("");
|
|
| 1095 |
- return false; |
|
| 1090 |
+ if (callToNum == null || callToNum == "") {
|
|
| 1091 |
+ alert("받는사람 번호를 입력해 주세요.");
|
|
| 1092 |
+ return false; |
|
| 1096 | 1093 |
} |
| 1094 |
+ |
|
| 1095 |
+ const textarea = $('#callTo');
|
|
| 1096 |
+ const numbers = textarea.val().split('\n')
|
|
| 1097 |
+ .map(num => num.trim()) |
|
| 1098 |
+ .filter(num => num !== ""); |
|
| 1099 |
+ |
|
| 1100 |
+ console.log('입력된 번호들 : ', numbers);
|
|
| 1101 |
+ |
|
| 1102 |
+ // 현재 테이블에 있는 데이터 가져오기 |
|
| 1103 |
+ const existingRows = tableL.getData(); |
|
| 1104 |
+ const existingNumbers = new Set(existingRows.map(row => row.phone.replace(/[^0-9]/g, ''))); // 숫자만 남겨서 중복 비교 |
|
| 1105 |
+ |
|
| 1106 |
+ let duplicateCount = 0; // 중복 번호 개수를 저장할 변수 |
|
| 1107 |
+ let invalidNumbers = []; // 유효하지 않은 번호를 저장할 배열 |
|
| 1108 |
+ |
|
| 1109 |
+ // 각 번호를 테이블에 추가 (중복 검사 및 포맷팅 포함) |
|
| 1110 |
+ numbers.forEach(number => {
|
|
| 1111 |
+ const formattedNumber = formatPhoneNumber(number); // 번호 표준화 |
|
| 1112 |
+// console.log('number : ', number)
|
|
| 1113 |
+// console.log('formattedNumber : ', formattedNumber)
|
|
| 1114 |
+ const cleanedNumber = formattedNumber.replace(/[^0-9]/g, ''); // 숫자만 남김 |
|
| 1115 |
+ if (!existingNumbers.has(cleanedNumber)) { // 중복 번호 체크
|
|
| 1116 |
+ if (isValidPhoneNumber(formattedNumber)) { // 유효성 검사
|
|
| 1117 |
+ tableL.addRow({ phone: formattedNumber }); // 표준화된 번호로 추가
|
|
| 1118 |
+ existingNumbers.add(cleanedNumber); // 추가된 번호를 기존 목록에 추가 |
|
| 1119 |
+ } else {
|
|
| 1120 |
+// alert(`유효하지 않은 번호 형식: ${number}`);
|
|
| 1121 |
+ invalidNumbers.push(number); // 유효하지 않은 번호를 배열에 추가 |
|
| 1122 |
+ } |
|
| 1123 |
+ } else {
|
|
| 1124 |
+ duplicateCount++; // 중복 번호가 발견될 때마다 카운트를 증가 |
|
| 1125 |
+ } |
|
| 1126 |
+ }); |
|
| 1127 |
+ |
|
| 1128 |
+ // 중복 번호 개수를 #rowDupCnt 요소에 표시 |
|
| 1129 |
+ $("#rowDupCnt").text(duplicateCount);
|
|
| 1130 |
+ |
|
| 1131 |
+ updateTotCnt(tableL.getRows().length); |
|
| 1097 | 1132 |
|
| 1098 |
- //핸드폰 번호에 '-' 문자 제거하기 |
|
| 1099 |
- callToNum = removeDash(callToNum); |
|
| 1100 |
- |
|
| 1101 |
- //기존 받는사람 연락처 모두 불러오기 |
|
| 1102 |
- var data = tableL.getRows(); |
|
| 1103 |
- var tableData = []; |
|
| 1104 |
- var dpCnt = 0; |
|
| 1105 |
- for(var i=0; i < tableL.getRows().length; i++){
|
|
| 1106 |
- |
|
| 1107 |
- if(callToNum == data[i].getData().phone){
|
|
| 1108 |
- |
|
| 1109 |
- dpCnt++; |
|
| 1110 |
- |
|
| 1111 |
- } |
|
| 1112 |
- |
|
| 1113 |
- } |
|
| 1114 |
- |
|
| 1115 |
- if(dpCnt > 0){
|
|
| 1116 |
- |
|
| 1117 |
- alert("받는사람 리스트에 동일한 연락처가 있습니다.");
|
|
| 1118 |
- $('#callTo').val("");
|
|
| 1119 |
- return false; |
|
| 1120 |
- |
|
| 1121 |
- }else{
|
|
| 1122 |
- |
|
| 1123 |
- tabledata = [{phone: callToNum},];
|
|
| 1124 |
- |
|
| 1125 |
- //빈 row 데이터 삭제하기 |
|
| 1126 |
- var befData = tableL.getRows(); |
|
| 1127 |
- var totLen = tableL.getRows().length; |
|
| 1128 |
- |
|
| 1129 |
- for(var i=0; i < totLen; i++){
|
|
| 1130 |
- |
|
| 1131 |
- tableData.push({phone: data[i].getData().phone.trim(), name: data[i].getData().name});
|
|
| 1132 |
- |
|
| 1133 |
- } |
|
| 1134 |
- |
|
| 1135 |
- //연락처 추가해 주기 |
|
| 1136 |
- addPhoneInfo(tabledata); |
|
| 1137 |
- |
|
| 1138 |
- //tableL.addData(tabledata); |
|
| 1139 |
- |
|
| 1140 |
- //전체 데이터 갯수 구하기 |
|
| 1141 |
- //totRows = tableL.getRows().length; |
|
| 1142 |
- //updateTotCnt(totRows); |
|
| 1143 |
- |
|
| 1144 |
- //결제 금액 구하기 |
|
| 1145 |
- //totalPriceSum(totRows); |
|
| 1146 |
- |
|
| 1147 |
- $('#callTo').val("");
|
|
| 1148 |
- |
|
| 1149 |
- } |
|
| 1133 |
+ // 유효하지 않은 번호가 있으면 alert로 표시 |
|
| 1134 |
+ console.log('invalidNumbers : ', invalidNumbers);
|
|
| 1135 |
+ if (invalidNumbers.length > 0) {
|
|
| 1136 |
+ alert('유효하지 않은 번호 형식: \n'+ invalidNumbers.join('\n'));
|
|
| 1137 |
+ } |
|
| 1138 |
+ // textarea 초기화 |
|
| 1139 |
+ textarea.val(''); // jQuery 객체에서 값을 초기화할 때는 .val('') 사용
|
|
| 1150 | 1140 |
|
| 1151 | 1141 |
}); |
| 1152 | 1142 |
|
| 1143 |
+ // 유효한 번호인지 확인하는 함수 |
|
| 1144 |
+ function isValidPhoneNumber(phone) {
|
|
| 1145 |
+ // 숫자만 추출 |
|
| 1146 |
+ const numberOnly = phone.replace(/\D/g, ''); |
|
| 1147 |
+ |
|
| 1148 |
+ // 유효한 형식 체크 |
|
| 1149 |
+ return ( |
|
| 1150 |
+ (numberOnly.startsWith("010") && numberOnly.length === 11) || // 010으로 시작하고 11자리
|
|
| 1151 |
+ (/^01[1-9]/.test(numberOnly) && numberOnly.length === 10) || // 011~019로 시작하고 10자리 |
|
| 1152 |
+ (numberOnly.startsWith("050") && numberOnly.length === 12) // 050X로 시작하고 12자리
|
|
| 1153 |
+ ); |
|
| 1154 |
+ } |
|
| 1155 |
+ |
|
| 1156 |
+ function formatPhoneNumber(phone) {
|
|
| 1157 |
+ // 숫자만 남기기 |
|
| 1158 |
+ let cleanedPhone = phone.replace(/\D/g, ''); // 모든 숫자가 아닌 문자 제거 |
|
| 1159 |
+ console.log('cleanedPhone : ', cleanedPhone);
|
|
| 1160 |
+ |
|
| 1161 |
+ // 앞에 0이 추가된 경우 처리 |
|
| 1162 |
+ if (cleanedPhone.length === 10 && cleanedPhone.startsWith("10")) {
|
|
| 1163 |
+ // 10으로 시작하는 10자리 번호는 앞에 0을 추가하여 11자리로 만듦 |
|
| 1164 |
+ cleanedPhone = "0" + cleanedPhone; |
|
| 1165 |
+ }else if (cleanedPhone.length === 9 && (cleanedPhone.startsWith("11") || cleanedPhone.startsWith("16") || cleanedPhone.startsWith("19"))) {
|
|
| 1166 |
+ // 11, 16, 19로 시작하는 9자리 번호는 앞에 0을 추가하여 10자리로 만듦 |
|
| 1167 |
+ cleanedPhone = "0" + cleanedPhone; |
|
| 1168 |
+ } |
|
| 1169 |
+ |
|
| 1170 |
+ // 번호 형식 변환 |
|
| 1171 |
+ if (cleanedPhone.startsWith("010") && cleanedPhone.length === 11) {
|
|
| 1172 |
+ // 010-1234-5678 형식 |
|
| 1173 |
+ return cleanedPhone.substring(0, 3) + '-' + cleanedPhone.substring(3, 7) + '-' + cleanedPhone.substring(7); |
|
| 1174 |
+ } else if ((/^01[1-9]/.test(cleanedPhone)) && cleanedPhone.length === 10) {
|
|
| 1175 |
+ // 01X-123-5678 형식 |
|
| 1176 |
+ return cleanedPhone.substring(0, 3) + '-' + cleanedPhone.substring(3, 6) + '-' + cleanedPhone.substring(6); |
|
| 1177 |
+ } else if (cleanedPhone.startsWith("050") && cleanedPhone.length === 12) {
|
|
| 1178 |
+ // 050X-1234-5678 형식 |
|
| 1179 |
+ return cleanedPhone.substring(0, 4) + '-' + cleanedPhone.substring(4, 8) + '-' + cleanedPhone.substring(8); |
|
| 1180 |
+ } |
|
| 1181 |
+ |
|
| 1182 |
+ // 원본 반환 (표준 형식으로 변환되지 않으면) |
|
| 1183 |
+ return phone; |
|
| 1184 |
+ } |
|
| 1185 |
+ |
|
| 1186 |
+ |
|
| 1187 |
+ |
|
| 1153 | 1188 |
|
| 1154 | 1189 |
//받는사람 전체삭제 버튼 처리 |
| 1155 | 1190 |
$('.all_del').click(function(){
|
... | ... | @@ -4094,11 +4129,34 @@ |
| 4094 | 4129 |
<th scope="row" class="vTop">받는사람</th> |
| 4095 | 4130 |
<td class="putText"> |
| 4096 | 4131 |
<div class="clearfix receipt_num"> |
| 4132 |
+<!-- <div class="receipt_num_top"> --> |
|
| 4133 |
+<!-- <label for="callTo" class="label">받는 번호입력</label> --> |
|
| 4134 |
+ |
|
| 4135 |
+<!-- <input type="text" id="callTo" name="callTo" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" placeholder="번호를 입력하세요" |
|
| 4136 |
+ onfocus="this.placeholder=''" onblur="this.placeholder='번호를 입력하세요'" style="width:340px;"> --> |
|
| 4137 |
+ |
|
| 4138 |
+<!-- <button type="button" class="btnType btnType6 addCallToF">번호추가</button> --> |
|
| 4139 |
+<!-- <span><span class="vMiddle">*</span> 중복번호는 한번만 추가됩니다.</span> --> |
|
| 4140 |
+<!-- </div> --> |
|
| 4141 |
+ |
|
| 4097 | 4142 |
<div class="receipt_num_top"> |
| 4098 |
- <label for="callTo" class="label">받는 번호입력</label> |
|
| 4099 |
- <input type="text" id="callTo" name="callTo" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" placeholder="번호를 입력하세요" onfocus="this.placeholder=''" onblur="this.placeholder='번호를 입력하세요'" style="width:340px;"> |
|
| 4100 |
- <button type="button" class="btnType btnType6 addCallToF">번호추가</button> |
|
| 4101 |
- <span><span class="vMiddle">*</span> 중복번호는 한번만 추가됩니다.</span> |
|
| 4143 |
+ <label for="" class="label">받는 번호입력</label> |
|
| 4144 |
+ <!-- <input type="text" placeholder="번호를 입력하세요" onfocus="this.placeholder=''" onblur="this.placeholder='번호를 입력하세요'" style="width:340px;"> --> |
|
| 4145 |
+<!-- oninput="this.value = this.value.replace(/[^0-9.\n]/g, '').replace(/(\..*)\./g, '$1');" --> |
|
| 4146 |
+ <textarea name="callTo" id="callTo" cols="30" rows="10" class="receipt_num" |
|
| 4147 |
+ placeholder="번호를 입력하세요" |
|
| 4148 |
+ onfocus="this.placeholder=''" |
|
| 4149 |
+ onblur="this.placeholder='번호를 입력하세요'" |
|
| 4150 |
+ style="width:340px;"></textarea> |
|
| 4151 |
+ <!-- <button type="button" class="btnType btnType6">번호추가</button> --> |
|
| 4152 |
+ <div class="btn_popup_wrap"> |
|
| 4153 |
+ <button type="button" class="btnType btnType6 btn_add_number addCallToF">번호추가<i class="qmMark"></i></button> |
|
| 4154 |
+ <span style="display:block;margin:10px 0 0 0;"><span class="vMiddle">*</span> 중복번호는 한번만 추가됩니다.</span> |
|
| 4155 |
+ <div class="error_hover_cont send_hover_cont"> |
|
| 4156 |
+ <p>휴대폰 번호 입력 시 해당 휴대폰 번호에 대한 형식이 어긋나거나 휴대폰 번호에 오류가 있는지 등을 검사하는 기능</p> |
|
| 4157 |
+ <span>(예시) 010-1234-0001(O) / 010-12345-0001(X)</span> |
|
| 4158 |
+ </div> |
|
| 4159 |
+ </div> |
|
| 4102 | 4160 |
</div> |
| 4103 | 4161 |
<div class="receipt_num_midde"> |
| 4104 | 4162 |
<div class="listType list01 callList_box"> |
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?