feat: RMR시험 입력 시 심도 중복 오류 방지 건

main
thkim 2025-09-09 17:07:48 +09:00
parent 3a5e036b5a
commit b92e55b6f0
1 changed files with 82 additions and 4 deletions

View File

@ -32,6 +32,43 @@ function fn_setGridCombo() {
}
//kendoGrid에서 중복된 행을 빨간색으로 흔드는 함수
function highlightDuplicateRows(grid, indices) {
var trs = grid.tbody.find("tr");
for (var i = 0; i < indices.length; i++) {
var rowIndex = indices[i];
var rowElement = trs[rowIndex];
// CSS 클래스 추가
kendoJQuery(rowElement).addClass("k-row-duplicate-shake");
}
// 2초 후 클래스 제거
setTimeout(function() {
kendoJQuery(".k-row-duplicate-shake").removeClass("k-row-duplicate-shake");
}, 2000);
}
//중복 강조를 위한 CSS 추가
function fn_addHighlightStyles() {
var style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = `
@keyframes shake {
10%, 90% { transform: translate3d(-1px, 0, 0); }
20%, 80% { transform: translate3d(2px, 0, 0); }
30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
40%, 60% { transform: translate3d(4px, 0, 0); }
}
.k-row-duplicate-shake {
background-color: #ffcccc !important;
animation: shake 0.5s;
animation-iteration-count: infinite;
}
`;
document.head.appendChild(style);
}
// Data 저장.
function fn_save(rUrl){
// ----------------------- kendoGrid XML 구조저장 시작 -----------------------
@ -53,6 +90,47 @@ function fn_save(rUrl){
return false;
}
}
// 심도(depthFrom, depthTo) 중복 체크
var seenDepths = {};
var duplicateIndices = [];
for(var i=0; i<data.length; i++){
var row = data[i];
var depthFrom = row.depthFrom;
var depthTo = row.depthTo;
// 심도 값을 기반으로 고유 키 생성
var key = depthFrom + '-' + depthTo;
if (seenDepths[key]) {
// 중복된 값을 발견하면 인덱스 저장
if (seenDepths[key].first) {
duplicateIndices.push(seenDepths[key].index);
seenDepths[key].first = false;
}
duplicateIndices.push(i);
}
seenDepths[key] = { index: i, first: true };
}
if (duplicateIndices.length > 0) {
// 중복된 값을 포함하여 알림 메시지 생성
var duplicatedValues = "";
var uniqueDuplicates = new Set();
for (var i = 0; i < duplicateIndices.length; i++) {
var row = data[duplicateIndices[i]];
var value = "From: " + row.depthFrom + ", To: " + row.depthTo;
uniqueDuplicates.add(value);
}
duplicatedValues = Array.from(uniqueDuplicates).join(", ");
alert("심도 데이터에 중복이 있습니다: " + duplicatedValues + ". 중복을 확인 후 다시 저장해 주십시오. 일부만 저장하고 싶은 경우 윗부분만 입력하시고 나머지 행은 -버튼으로 제거해주세요.");
// 중복된 행을 시각적으로 강조
highlightDuplicateRows(grid, duplicateIndices);
return false;
}
//숫자 체크
var rowInfo = {
@ -192,9 +270,6 @@ function fn_save(rUrl){
//kendoGrid submitAll
function fn_submitAll(strUrl, rUrl, strData, frm) {
document.getElementById("dataAll").value = "<changedData>"+strData+"</changedData>";
var $form = $(frm);
@ -204,6 +279,8 @@ function fn_submitAll(strUrl, rUrl, strData, frm) {
frm.submit();
}
//행추가
function fn_add(){
@ -497,7 +574,8 @@ function fn_grid_refresh(){
fn_kendoGrid();
fn_setGridCombo();
fn_addHighlightStyles(); // 새로운 CSS 함수 호출
var grid = kendoJQuery("#kictGrid").data("kendoGrid");
var dataSource = grid.dataSource;