건설현장 입력 여러사업 등록 처리, 사업명 중복 체크 보완

main
유지인 2025-07-14 15:15:23 +09:00
parent 8004401036
commit f310066eee
6 changed files with 171 additions and 101 deletions

View File

@ -92,7 +92,7 @@ public class ProjectListController {
jsonObject.put("resultCode", "The name already exists."); jsonObject.put("resultCode", "The name already exists.");
jsonObject.put("message", "해당 사업명이 이미 있습니다. 다른 사업명으로 입력해 주세요. code 2"); jsonObject.put("message", "해당 사업명이 이미 있습니다. 다른 사업명으로 입력해 주세요. code 2");
} }
} else if( false && 0 < arrConstNameByProjectNameFromTempConstructSiteInfo.size() ) { } else if( 0 < arrConstNameByProjectNameFromTempConstructSiteInfo.size() ) {
jsonObject.put("result", "false"); jsonObject.put("result", "false");
jsonObject.put("resultCode", "The name already exists."); jsonObject.put("resultCode", "The name already exists.");
jsonObject.put("message", "해당 사업명이 이미 있습니다. 다른 사업명으로 입력해 주세요. code 3"); jsonObject.put("message", "해당 사업명이 이미 있습니다. 다른 사업명으로 입력해 주세요. code 3");

View File

@ -312,16 +312,35 @@ if (request.getSession().getAttribute("CLS") == null || "2".equals(request.getSe
console.log(tableDataElements); console.log(tableDataElements);
for (var i = 0; i < tableDataElements.length; i++) {
let duplChkEle = tableDataElements[i].querySelector('.input-box[id*="const-name"]') // 엑셀양식 로드시 사업명 중복 체크해야 하는 대상 엘리먼트
let result = projNmDuplChkResult(duplChkEle)
if (result.result == 'false') {
duplChkEle.focus();
shakeAndHighlight(duplChkEle, result.msg)
return;
} else {
// 중복체크 통과시 border 초기화
}
}
// 사업명 중복 체크 통과시 등록처리호출
addDrillingInput(tableDataElements)
});
});
// 사업 등록 처리
function addDrillingInput(tableDataElements) {
const cid = getQueryString('CID');
var dataIndexValue; var dataIndexValue;
var jsonData = new Array(); var jsonData = new Array();
for (var i = 0; i < tableDataElements.length; i++) { for (var i = 0; i < tableDataElements.length; i++) {
let duplChkEle = document.querySelectorAll('.input-box[id*="const-name"]'); // 엑셀양식 로드시 사업명 중복 체크해야 하는 대상 엘리먼트
for (let i = 0 ; i < duplChkEle.length; i++) {
duplicateCheckProjectName(duplChkEle[i])
}
var jsonItem = {}; var jsonItem = {};
dataIndexValue = tableDataElements[i].getAttribute('data-index'); dataIndexValue = tableDataElements[i].getAttribute('data-index');
@ -386,7 +405,6 @@ if (request.getSession().getAttribute("CLS") == null || "2".equals(request.getSe
jsonData.push(jsonItem); jsonData.push(jsonItem);
} }
if (cid) { if (cid) {
xhr.open('POST', '/drilling/input/modify.do', true); xhr.open('POST', '/drilling/input/modify.do', true);
} else { } else {
@ -403,8 +421,13 @@ if (request.getSession().getAttribute("CLS") == null || "2".equals(request.getSe
console.log(xhr.responseText); console.log(xhr.responseText);
const obj = JSON.parse(xhr.responseText); const obj = JSON.parse(xhr.responseText);
if (obj.resultCode == 100) {
if(confirm(obj.message)) {
window.location.href='/drilling/inquiry.do';
}
} else {
alert(obj.message); alert(obj.message);
// window.location.href='/drilling/inquiry.do'; }
} else if (xhr.readyState === 4) { } else if (xhr.readyState === 4) {
// 요청 실패 시 처리 // 요청 실패 시 처리
console.error('요청 실패:', xhr.status); console.error('요청 실패:', xhr.status);
@ -412,10 +435,7 @@ if (request.getSession().getAttribute("CLS") == null || "2".equals(request.getSe
}; };
xhr.send(JSON.stringify(jsonData)); xhr.send(JSON.stringify(jsonData));
}); }
});
function isValid(index) { function isValid(index) {
// 사업명 // 사업명

View File

@ -6832,6 +6832,9 @@ ul.faq-q > li textarea {
resize: none; resize: none;
margin: 0; margin: 0;
} }
.drilling .drilling .input-box.error {
border: 2px solid red;
}
.drilling .check-box { .drilling .check-box {
padding-left: 0px; padding-left: 0px;
cursor: pointer; cursor: pointer;

File diff suppressed because one or more lines are too long

View File

@ -5189,6 +5189,9 @@ ul.faq-q > li textarea {
resize: none; resize: none;
margin: 0 ; margin: 0 ;
} }
.drilling .input-box.error {
border: 2px solid red;
}
.check-box { .check-box {
padding-left: 0px; padding-left: 0px;
cursor: pointer; cursor: pointer;

View File

@ -1857,10 +1857,11 @@ function fn_openClipReport(table,project,hole,sample,etc1,etc2,gbn){
function shakeAndHighlight(targetEle, message) { function shakeAndHighlight(targetEle, message) {
var originalStyle = targetEle.style.border; // 원래 스타일 저장 // var originalStyle = targetEle.style.border; // 원래 스타일 저장
// 빨간색 테두리 설정 // 빨간색 테두리 설정
targetEle.style.border = "2px solid red"; // targetEle.style.border = "2px solid red";
targetEle.classList.add("error");
// 흔들리는 애니메이션 추가 // 흔들리는 애니메이션 추가
targetEle.classList.add("shake-animation"); targetEle.classList.add("shake-animation");
@ -1882,7 +1883,9 @@ function shakeAndHighlight(targetEle, message) {
// 3초 후 원래 스타일로 복원 // 3초 후 원래 스타일로 복원
setTimeout(function() { setTimeout(function() {
targetEle.style.border = originalStyle; // targetEle.style.border = originalStyle;
targetEle.classList.remove("error");
targetEle.classList.remove("shake-animation"); targetEle.classList.remove("shake-animation");
//targetEle.focus(); //targetEle.focus();
showSnackbar(); showSnackbar();
@ -2035,3 +2038,44 @@ function duplicateCheckProjectName( projectNameInput, projectCode ) {
} }
}); });
} }
/**
* 프로젝트 중복 체크
* 동기처리
* 응답 받은 호출한 부분에서 처리
*/
function projNmDuplChkResult( projectNameInput, projectCode) {
if( typeof projectCode === 'undefined' || projectCode ==="null") {
projectCode = null;
}
projectName = projectNameInput.value;
let result = {result:"false", msg: ''};
$.ajax({
type : "GET",
data : {
projectName : projectName,
projectCode : projectCode,
isProjectNameChecking : "true"
},
url : "/project-duplicate-check.json",
dataType : "json",
async: false,
success : function( json ){
resultData = json.result;
if(resultData == "false"){
// shakeAndHighlight(projectNameInput, json.message);
result.result = "false";
result.msg= json.message;
} else {
result.result = "true";
}
},
error: function(xhr, option, error){
alert(xhr.status); // 오류코드
alert(error); // 오류내용
}
});
return result;
}