浏览代码

입력 값 체크 공통 적용

juney 2 年之前
父节点
当前提交
2bdc6363ba

+ 8 - 8
src/main/webapp/app/oper/OPER03010.html

@@ -118,13 +118,13 @@
118 118
 											<label class="col-xs-2 itp_lb">사업자번호 *</label>
119 119
 											<div class="col-xs-4 itp_ip">
120 120
 												<div class="col-xs-7 itp_in">
121
-													<input type="text" id="ITP_FORM_OPER03010_DETAIL_BSNS_REG_NO" data-check-required="empty,number" class="form-control itp_input" name="bsnsRegNo" value="">
121
+													<input type="text" id="ITP_FORM_OPER03010_DETAIL_BSNS_REG_NO" data-check-required="empty,number" data-key-up="regNo" class="form-control itp_input" name="bsnsRegNo" value="">
122 122
 												</div>
123 123
 											</div>
124 124
 											<label class="col-xs-2 itp_lb">법인번호</label>
125 125
 											<div class="col-xs-4 itp_ip">
126 126
 												<div class="col-xs-6 itp_in">
127
-													<input type="text" id="ITP_FORM_OPER03010_DETAIL_CORP_REG_NO" class="form-control itp_input" name="corpRegNo" value="">
127
+													<input type="text" id="ITP_FORM_OPER03010_DETAIL_CORP_REG_NO" data-key-up="regNo" class="form-control itp_input" name="corpRegNo" value="">
128 128
 												</div>
129 129
 												<div class="col-xs-3 itp_in">
130 130
 
@@ -148,7 +148,7 @@
148 148
 											<label class="col-xs-2 itp_lb">전화번호 *</label>
149 149
 											<div class="col-xs-4 itp_ip">
150 150
 												<div class="col-xs-7 itp_in">
151
-													<input type="text" id="ITP_FORM_OPER03010_DETAIL_TEL_NO" data-check-required="empty" class="form-control itp_input" name="rprstTelNo" value="">
151
+													<input type="text" id="ITP_FORM_OPER03010_DETAIL_TEL_NO" data-check-required="empty" data-key-up="tel" class="form-control itp_input" name="rprstTelNo" value="">
152 152
 												</div>
153 153
 											</div>
154 154
 											<label class="col-xs-2 itp_lb" style="border-top:none;">가맹점 로고</label>
@@ -158,10 +158,10 @@
158 158
 											</div>
159 159
 										</div>
160 160
 										<div class="form-group">
161
-											<label class="col-xs-2 itp_lb">FAX *</label>
161
+											<label class="col-xs-2 itp_lb">FAX</label>
162 162
 											<div class="col-xs-4 itp_ip">
163 163
 												<div class="col-xs-7 itp_in">
164
-													<input type="text" id="ITP_FORM_OPER03010_DETAIL_FAX_NO" data-check-required="empty" class="form-control itp_input" name="rprstFaxNo" value="">
164
+													<input type="text" id="ITP_FORM_OPER03010_DETAIL_FAX_NO" data-key-up="tel" class="form-control itp_input" name="rprstFaxNo" value="">
165 165
 												</div>
166 166
 											</div>
167 167
 											<label class="col-xs-2 itp_lb"style="border-top:none;"></label>
@@ -206,7 +206,7 @@
206 206
 											<label class="col-xs-2 itp_lb">대표자연락처 *</label>
207 207
 											<div class="col-xs-4 itp_ip">
208 208
 												<div class="col-xs-7 itp_in">
209
-													<input type="text" id="ITP_FORM_OPER03010_DETAIL_OWNER_TEL_NO" data-check-required="empty" class="form-control itp_input" name="ownerTelNo" value="">
209
+													<input type="text" id="ITP_FORM_OPER03010_DETAIL_OWNER_TEL_NO" data-check-required="empty" data-key-up="tel" class="form-control itp_input" name="ownerTelNo" value="">
210 210
 												</div>
211 211
 											</div>
212 212
 											<label class="col-xs-2 itp_lb">계약기간 *</label>
@@ -226,13 +226,13 @@
226 226
 											<label class="col-xs-2 itp_lb">주소 *</label>
227 227
 											<div class="col-xs-10 itp_ip">
228 228
 												<div class="col-xs-1 itp_in">
229
-													<input type="text" id="ITP_FORM_OPER03010_DETAIL_ZIPNO" data-check-required="empty" data-alert-required="ONLYCHK" class="form-control itp_input" name="zipNo" value="" maxlength="6" readonly placeholder="우편번호">
229
+													<input type="text" id="ITP_FORM_OPER03010_DETAIL_ZIPNO" data-check-required="empty" data-alert-required="ONLYCHK" data-alert-msg="address" class="form-control itp_input" name="zipNo" value="" maxlength="6" readonly placeholder="우편번호">
230 230
 												</div>
231 231
 												<div class="col-xs-1 itp_in">
232 232
 													<button type="button" id="ITP_FORM_OPER03010_DETAIL_ADRES_SCH" class="btn btn-primary btn-sm SHOW" style="margin: -1px 0px 0px 3px;">&nbsp;&nbsp;주소검색&nbsp;&nbsp;</button>
233 233
 												</div>
234 234
 												<div class="col-xs-4 itp_in" style="margin-right: 5px; margin-left:20px;">
235
-													<input type="text" id="ITP_FORM_OPER03010_DETAIL_ADRES" data-check-required="empty" data-alert-required="ONLYCHK" class="form-control itp_input" name="addr1" value="" readonly placeholder="기본주소">
235
+													<input type="text" id="ITP_FORM_OPER03010_DETAIL_ADRES" data-check-required="empty" data-alert-required="ONLYCHK" data-alert-msg="address" class="form-control itp_input" name="addr1" value="" readonly placeholder="기본주소">
236 236
 												</div>
237 237
 												<div class="col-xs-4 itp_in">
238 238
 													<input type="text" id="ITP_FORM_OPER03010_DETAIL_ADRES_DTL" data-check-required="empty" class="form-control itp_input" name="addr2" value="" placeholder="상세주소">

+ 2 - 2
src/main/webapp/app/oper/OPER03011.html

@@ -221,13 +221,13 @@
221 221
 											<label class="col-xs-2 itp_lb">주소 *</label>
222 222
 											<div class="col-xs-10 itp_ip">
223 223
 												<div class="col-xs-1 itp_in">
224
-													<input type="text" id="ITP_FORM_OPER03011_DETAIL_ZIPNO" data-check-required="empty" data-alert-required="ONLYCHK" class="form-control itp_input" name="zipNo" value="" maxlength="6" readonly placeholder="우편번호">
224
+													<input type="text" id="ITP_FORM_OPER03011_DETAIL_ZIPNO" data-check-required="empty" data-alert-required="ONLYCHK" data-alert-msg="address" class="form-control itp_input" name="zipNo" value="" maxlength="6" readonly placeholder="우편번호">
225 225
 												</div>
226 226
 												<div class="col-xs-1 itp_in">
227 227
 													<button type="button" id="ITP_FORM_OPER03011_DETAIL_ADRES_SCH" class="btn btn-primary btn-sm SHOW" style="margin: -1px 0px 0px 3px;">&nbsp;&nbsp;주소검색&nbsp;&nbsp;</button>
228 228
 												</div>
229 229
 												<div class="col-xs-4 itp_in" style="margin-right: 5px; margin-left:20px;">
230
-													<input type="text" id="ITP_FORM_OPER03011_DETAIL_ADRES" data-check-required="empty" data-alert-required="ONLYCHK" class="form-control itp_input" name="addr1" value="" readonly placeholder="기본주소">
230
+													<input type="text" id="ITP_FORM_OPER03011_DETAIL_ADRES" data-check-required="empty" data-alert-required="ONLYCHK" data-alert-msg="address" class="form-control itp_input" name="addr1" value="" readonly placeholder="기본주소">
231 231
 												</div>
232 232
 												<div class="col-xs-4 itp_in">
233 233
 													<input type="text" id="ITP_FORM_OPER03011_DETAIL_ADRES_DTL" data-check-required="empty" class="form-control itp_input" name="addr2" value="" placeholder="상세주소">

+ 46 - 13
src/main/webapp/js/app/config.js

@@ -2968,19 +2968,52 @@ var itp_fn_set_timeout = {
2968 2968
 };
2969 2969
 
2970 2970
 var itp_fn_is_valid = (formId) => {
2971
-	var isValid = false;
2972
-	$(formId).find('input, select, checkbox, textarea').each(function(k) {
2973
-		if($(this).data('check-required')) {
2974
-			var arry = $(this).data('check-required').split(',');
2975
-			var alertMsg = $(this).data('alert-required');
2976
-			isValid = itp_fn_form_validate(formId, '#' + $(this).attr('id'), arry, undefined, alertMsg);
2977
-			if(!isValid) {
2978
-				if(alertMsg && alertMsg.length > 0) {
2979
-					itp_fn_modal_alert($(this).data('alert-msg'));
2971
+};
2972
+
2973
+// 2022-11-02 수발주 추가
2974
+let itp_fn_form_event = {
2975
+	onKeyup: function(formId) {
2976
+		$(formId).find('input[data-key-up]').on('keyup', function() {
2977
+			let value = '';
2978
+			let arry = $(this).data('key-up').split(',');
2979
+			if ($.inArray('number', arry) > -1) {
2980
+				value = $(this).val().replace(/[^0-9]/g, "");
2981
+			}
2982
+			if ($.inArray('comma', arry) > -1) {
2983
+				value = $(this).val().replace(/[^0-9]/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",");
2984
+			}
2985
+			if ($.inArray('regNo', arry) > -1) {
2986
+				value = $(this).val().replace(/[^0-9]/g, "")
2987
+					.replace(/(^[0-9]{3}|^0[0-9]{2})([0-9]+)?([0-9]{5})$/,"$1-$2-$3")
2988
+			}
2989
+			if ($.inArray('tel', arry) > -1) {
2990
+				value = ($(this).val().startsWith('0')) ? $(this).val().replace(/[^0-9]/g, "")
2991
+					.replace(/(^02|^0505|^1[0-9]{3}|^0[0-9]{2})([0-9]+)?([0-9]{4})$/,"$1-$2-$3")
2992
+					.replace("--", "-") : '';
2993
+			}
2994
+			$(this).val(value);
2995
+		});
2996
+	},
2997
+	removeChar: function(formId) {
2998
+		$(formId).find('input[data-key-up]').each(function() {
2999
+			$(this).val($(this).val().replace(/[^0-9]/g, ""));
3000
+		});
3001
+	},
3002
+	isValid: function(formId) {
3003
+		var isValid = false;
3004
+		$(formId).find('input, select, checkbox, textarea').each(function(k) {
3005
+			if($(this).data('check-required')) {
3006
+				var arry = $(this).data('check-required').split(',');
3007
+				var alertMsg = $(this).data('alert-required');
3008
+				isValid = itp_fn_form_validate(formId, '#' + $(this).attr('id'), arry, undefined, alertMsg);
3009
+				if(!isValid) {
3010
+					if(alertMsg && alertMsg.length > 0) {
3011
+						itp_fn_modal_alert($(this).data('alert-msg'));
3012
+					}
3013
+					return false;
2980 3014
 				}
2981
-				return false;
2982 3015
 			}
2983
-		}
2984
-	});
2985
-	return isValid;
3016
+		});
3017
+		return isValid;
3018
+	}
2986 3019
 };

+ 13 - 19
src/main/webapp/js/app/oper/ITP_OPER03010.js

@@ -159,6 +159,7 @@ let pageObj = {
159 159
 	ui: {
160 160
 		init: function () {
161 161
 			this.view();
162
+			this.form();
162 163
 			this.grid();
163 164
 			this.ready();
164 165
 		},
@@ -175,6 +176,16 @@ let pageObj = {
175 176
 
176 177
 			// 조회일자 지정
177 178
 			$('#ITP_TAB_OPER03010 .input-group.date').datepicker(ITP_DATE_LANGUAGE);
179
+
180
+			// form alert message 주입
181
+			$('input[data-alert-required="ONLYCHK"]').each(function() {
182
+				if($(this).data('alert-msg') === 'address') {
183
+					$(this).data('alert-msg', ITP_MSG_LOCALE.message.form.emptyAddr);
184
+				}
185
+			});
186
+		},
187
+		form: function() {
188
+			itp_fn_form_event.onKeyup('#ITP_FORM_OPER03010_DETAIL');
178 189
 		},
179 190
 		grid: function() {
180 191
 			itp_fn_jqgrid_resize(OPER03010_GRID_ID, OPER03010_GRID_LIST, 'lg');
@@ -427,7 +438,6 @@ let listObj = {
427 438
 		reload : function() {
428 439
 			var _this = this;
429 440
 			$(OPER03010_GRID_EMPTY).off('click').on('click', function() {
430
-				_this.itp_fn_OPER03010_empty.back();
431 441
 				pageObj.itp_OPER03010_param.gridSize = $.jgrid.defaults.rowNum;
432 442
 				$(OPER03010_GRID_ID).setGridParam({'postData': JSON.stringify(pageObj.itp_OPER03010_param)}).trigger('reloadGrid');
433 443
 			});
@@ -577,26 +587,10 @@ let createObj = {
577 587
 		},
578 588
 		save: function() {
579 589
 			const formId = '#ITP_FORM_OPER03010_DETAIL';
590
+			itp_fn_form_event.removeChar('#ITP_FORM_OPER03010_DETAIL');
580 591
 			itp_fn_form_clear_validate(null, formId);
581
-			// var vali_cmpyCd = itp_fn_form_validate(formId, formId + '_CMPY_CD', ['empty'], undefined);
582
-			// var vali_cmpyStatCd = itp_fn_form_validate(formId, formId + '_CMPY_STAT_CD', ['empty'], undefined);
583
-			// var vali_cmpyTypeCd = itp_fn_form_validate(formId, formId + '_CMPY_TYPE_CD', ['empty'], undefined);
584
-			// var vali_cmpyNm = itp_fn_form_validate(formId, formId + '_CMPY_NM', ['empty'], undefined);
585
-			// var vali_bossNm = itp_fn_form_validate(formId, formId + '_BOSS_NM', ['empty'], undefined);
586
-			// var vali_mainTel = itp_fn_form_validate(formId, formId + '_MAIN_TEL', ['empty'], undefined);
587
-			// var vali_mainEmail = itp_fn_form_validate(formId, formId + 'MAIN_EMAIL', ['empty'], undefined);
588
-
589
-			var isValid = false;
590
-			$(formId).find('input, select, checkbox, textarea').each(function(k) {
591
-				if($(this).data('check-required')) {
592
-					var arry = $(this).data('check-required').split(',');
593
-					isValid = itp_fn_form_validate(formId, '#' + $(this).attr('id'), arry, undefined);
594
-					if(!isValid) return false;
595
-				}
596
-			});
597 592
 
598
-			// if (vali_cmpyCd && vali_cmpyStatCd && vali_cmpyTypeCd && vali_cmpyNm && vali_bossNm && vali_mainTel && vali_mainEmail) {
599
-			if (isValid) {
593
+			if (itp_fn_form_event.isValid(formId)) {
600 594
 
601 595
 				if($('#ITP_FORM_OPER03010_DETAIL_CMPY_ZIPNO').val() === '' || $('#ITP_FORM_OPER03010_DETAIL_CMPY_ADRES').val() === '') {
602 596
 					itp_fn_modal_alert('주소 검색을 통해 회사 주소를 입력하세요.');

+ 12 - 7
src/main/webapp/js/app/oper/ITP_OPER03011.js

@@ -130,6 +130,13 @@ let pageObj = {
130 130
 
131 131
 			// 조회일자 지정
132 132
 			$('#ITP_TAB_OPER03011 .input-group.date').datepicker(ITP_DATE_LANGUAGE);
133
+
134
+			// form alert message 주입
135
+			$('input[data-alert-required="ONLYCHK"]').each(function() {
136
+				if($(this).data('alert-msg') === 'address') {
137
+					$(this).data('alert-msg', ITP_MSG_LOCALE.message.form.emptyAddr);
138
+				}
139
+			});
133 140
 		},
134 141
 		grid: function() {
135 142
 		},
@@ -192,8 +199,6 @@ let pageObj = {
192 199
 			$('#ITP_FORM_OPER03011_DETAIL_AFFL_SHOP_KEY').prop('readonly', true);
193 200
 			$('#ITP_BTN_OPER03011_DETAIL_AFFL_SHOP_KEY').prop('disabled', true);
194 201
 
195
-			$('input[id=ITP_FORM_OPER03011_DETAIL_ADRES]').data('alert-msg', ITP_MSG_LOCALE.message.form.emptyAddr);
196
-			$('input[id=ITP_FORM_OPER03011_DETAIL_ADRES_DTL]').data('alert-msg', ITP_MSG_LOCALE.message.form.emptyAddr);
197 202
 		} else if(mode === 'VIEW') { // 보기
198 203
 			$('#ITP_AJAX_OPER03011_VIEW_CONTAINER').show();
199 204
 			fn_show_btn_auth_array(['#ITP_BTN_OPER03011_MODIFY']);
@@ -352,12 +357,12 @@ let modifyObj = {
352 357
 			itp_fn_form_clear_validate(null, formId);
353 358
 
354 359
 			// if (vali_cmpyCd && vali_cmpyStatCd && vali_cmpyTypeCd && vali_cmpyNm && vali_bossNm && vali_mainTel && vali_mainEmail) {
355
-			if (itp_fn_is_valid(formId)) {
360
+			if (itp_fn_form_event.isValid(formId)) {
356 361
 
357
-				if($('#ITP_FORM_OPER03011_DETAIL_CMPY_ZIPNO').val() === '' || $('#ITP_FORM_OPER03011_DETAIL_CMPY_ADRES').val() === '') {
358
-					itp_fn_modal_alert('주소 검색을 통해 회사 주소를 입력하세요.');
359
-					return;
360
-				}
362
+				// if($('#ITP_FORM_OPER03011_DETAIL_CMPY_ZIPNO').val() === '' || $('#ITP_FORM_OPER03011_DETAIL_CMPY_ADRES').val() === '') {
363
+				// 	itp_fn_modal_alert('주소 검색을 통해 회사 주소를 입력하세요.');
364
+				// 	return;
365
+				// }
361 366
 
362 367
 				if (ITP_FORM_OPER03011_DETAIL_IS_DUPLICATE) {
363 368
 					itp_fn_modal_duplicate('회사코드 중복체크를 해주세요.', formId + '_AFFL_SHOP_ID');

+ 14 - 10
src/main/webapp/js/app/stinfo/ITP_STINFO06010.js

@@ -266,9 +266,14 @@ let pageObj = {
266 266
 		} else if(mode == 'ADD') { // 등록
267 267
 			itp_fn_form_clear_validate(null, '#ITP_FORM_STINFO07010_DETAIL');
268 268
 
269
-			$('#ITP_AJAX_STINFO06010_DETAIL_CONTAINER').show();
270
-			fn_show_btn_auth_array(['#ITP_BTN_STINFO06010_SRH', '#ITP_BTN_STINFO06010_CANCELLIST', '#ITP_BTN_STINFO06010_SAVE']);
269
+			$('#ITP_FORM_STINFO06010_DETAIL').find('input, textarea, select, checkbox').each(function(i, elem) {
270
+				$(this).attr('id') === 'ITP_FORM_STINFO06010_DETAIL_VIEW_CD' ? $(this).val('C') : $(this).val('');
271
+				if(elem.type === 'select') {
272
+					$(this).val('').prop('selected', true);
273
+				}
274
+			});
271 275
 
276
+			$('#ITP_AJAX_STINFO06010_DETAIL_CONTAINER').show();
272 277
 			fn_show_btn_auth_array(['#ITP_BTN_STINFO06010_CANCELLIST', '#ITP_BTN_STINFO06010_SAVE']);
273 278
 
274 279
 			$('#ITP_BTN_STINFO06010_DETAIL_SEARCH_STORE').removeAttr('disabled');
@@ -277,7 +282,6 @@ let pageObj = {
277 282
 			$('#ITP_FORM_STINFO06010_DETAIL_BRAND_ID').val(fn_make_user_info.get('brandId'));
278 283
 		} else if(mode == 'MODIFY') { // 수정
279 284
 			$('#ITP_AJAX_STINFO06010_DETAIL_CONTAINER').show();
280
-			fn_show_btn_auth_array(['#ITP_BTN_STINFO06010_SRH', '#ITP_BTN_STINFO06010_CANCELLIST', '#ITP_BTN_STINFO06010_SAVE', '#ITP_BTN_STINFO06010_RESET_PW']);
281 285
 			if(fn_make_user_info.get('authTpCd') === '50') {
282 286
 				fn_show_btn_auth_array(['#ITP_BTN_STINFO06010_CANCELLIST']);
283 287
 			} else {
@@ -504,25 +508,25 @@ let createObj = {
504 508
 			const formId = '#ITP_FORM_STINFO06010_DETAIL';
505 509
 			var isValid = true;
506 510
 			if(pageObj.screenMode === 'ADD') {
507
-				isValid = itp_fn_is_valid(formId)
511
+				isValid = itp_fn_form_event.isValid(formId)
508 512
 			}
509 513
 			if (isValid) {
510 514
 				itp_fn_grid_save_rows(STINFO06010_DETAIL_GRID_ID);
511 515
 
512 516
 				var rows = $(STINFO06010_DETAIL_GRID_ID).getRowData();
513 517
 				let param = {};
514
-				// var gridInsertData = [];
518
+				var gridInsertData = [];
515 519
 				var gridUpdateData = [];
516 520
 				var changeRows = createObj.changeRows(rows);
517 521
 				$.each(changeRows, function (index, item) {
518 522
 					if(pageObj.screenMode === 'ADD') {
519 523
 						item['contSttDt'] = $('#ITP_FORM_STINFO06010_DETAIL_FROM_DT').val();
520 524
 						item['contEndDt'] = $('#ITP_FORM_STINFO06010_DETAIL_TO_DT').val();
521
-						gridUpdateData.push(item);
525
+						gridInsertData.push(item);
522 526
 					} else {
523
-						if(item.viewCd === 'C' || item.viewCd === 'U') {
524
-							// 	gridInsertData.push(item);
525
-							// } else if(item.viewCd === 'U') {
527
+						if(item.viewCd === 'C') {
528
+							gridInsertData.push(item);
529
+						} else if(item.viewCd === 'U') {
526 530
 							gridUpdateData.push(item);
527 531
 						}
528 532
 					}
@@ -530,7 +534,7 @@ let createObj = {
530 534
 				param['viewCd'] = 'U';
531 535
 				param['brandId'] = fn_make_user_info.get('brandId');
532 536
 				param['storeId'] = $('#ITP_FORM_STINFO06010_DETAIL_STORE_ID').val();
533
-				// param['gridInsertData'] = gridInsertData;
537
+				param['gridInsertData'] = gridInsertData;
534 538
 				param['gridUpdateData'] = gridUpdateData;
535 539
 				console.log(JSON.stringify(param));
536 540
 				var searhFn = function() {