[BO] 임가 현황 - 임가 등록 작업 중 (5)

This commit is contained in:
kangsunlee
2025-06-15 22:08:17 +09:00
parent 9723b58aa9
commit cfd7d94744
43 changed files with 1341 additions and 216 deletions

View File

@@ -110,7 +110,7 @@ var ajaxUtil = {
/**
* ajax 공통 처리
*/
_ajaxMethod : function (url, jsonObj, successCallback, errorCallback, method, dataType, async) {
_ajaxMethod : function (url, jsonObj, successCallback, errorCallback, method, dataType, options = {}, async) {
if (typeof ENV != 'undefined' && typeof ENV.submitted == 'boolean') {
ENV.submitted = true;
}
@@ -148,21 +148,31 @@ var ajaxUtil = {
kri.logger.error('statusCode: 403');
},
422:function(rstData, status) {
console.log(rstData)
$(rstData.responseJSON).each((idx, oj) => {
// TODO : form id? or body
let target = $('body').find('[name=' + oj.field + ']');
target.addClass('is-invalid');
target.parent().find('.invalid-feedback').text(oj.defaultMessage);
});
if ($('.invalid-feedback').length === 0) {
let fieldErrors = rstData.responseJSON != null ? rstData.responseJSON : null;
if (fieldErrors != null && fieldErrors.length > 0) {
ajaxUtil._alert(fieldErrors[0].defaultMessage, '유효성 체크');
console.log(rstData);
// options type : 1. alert, 2. field
if (options.handle422Type === 'alert') {
if (typeof errorCallback !== 'undefined') {
errorCallback(422, rstData); // 호출한 쪽에서 alert 처리
}
return;
}
if (options.handle422Type === 'field' || !options.handle422Type) {
$(rstData.responseJSON).each((idx, oj) => {
// TODO : form id? or body
let target = $('body').find('[name=' + oj.field + ']');
target.addClass('is-invalid');
target.parent().find('.invalid-feedback').text(oj.defaultMessage);
});
if ($('.invalid-feedback').length === 0) {
let fieldErrors = rstData.responseJSON != null ? rstData.responseJSON : null;
if (fieldErrors != null && fieldErrors.length > 0) {
ajaxUtil._alert(fieldErrors[0].defaultMessage, '유효성 체크');
}
}
}
},
500:function(rstData){