- commit 충돌 해결
- 기존 flatView function 삭제 후 pretty 버튼 추가
This commit is contained in:
@@ -38,6 +38,7 @@
|
|||||||
let fullMessageData;
|
let fullMessageData;
|
||||||
let layoutInfo = [];
|
let layoutInfo = [];
|
||||||
let bzwkdatatntInfo;
|
let bzwkdatatntInfo;
|
||||||
|
var isPrettyView = false;
|
||||||
|
|
||||||
var eaiSvcCode = "";
|
var eaiSvcCode = "";
|
||||||
|
|
||||||
@@ -388,10 +389,6 @@
|
|||||||
|
|
||||||
$('#btn_pretty_body').click(function(){
|
$('#btn_pretty_body').click(function(){
|
||||||
const syntax = $('#selectBodySyntax').val();
|
const syntax = $('#selectBodySyntax').val();
|
||||||
|
|
||||||
// FLAT view를 위해 생성된 데이터 -> 기존 업무데이터
|
|
||||||
bodyCodeEditor.setValue(bzwkdatatntInfo);
|
|
||||||
|
|
||||||
const value = bodyCodeEditor.getValue();
|
const value = bodyCodeEditor.getValue();
|
||||||
let prettyValue = value;
|
let prettyValue = value;
|
||||||
if(syntax === 'JSN'){
|
if(syntax === 'JSN'){
|
||||||
@@ -431,7 +428,6 @@
|
|||||||
$('#btn_pretty_body').css('display', 'block');
|
$('#btn_pretty_body').css('display', 'block');
|
||||||
bodyCodeEditor.setOption("mode", "application/json");
|
bodyCodeEditor.setOption("mode", "application/json");
|
||||||
}else if(syntax === 'XML'){
|
}else if(syntax === 'XML'){
|
||||||
$('#btn_pretty_body').css('display', 'block');
|
|
||||||
$('#btn_pretty_body').css('display', 'block');
|
$('#btn_pretty_body').css('display', 'block');
|
||||||
bodyCodeEditor.setOption("mode", "application/xml");
|
bodyCodeEditor.setOption("mode", "application/xml");
|
||||||
}else{
|
}else{
|
||||||
@@ -842,77 +838,105 @@ $(document).ready(function() {
|
|||||||
alert('전체 전문 복사되었습니다.')
|
alert('전체 전문 복사되었습니다.')
|
||||||
});
|
});
|
||||||
|
|
||||||
// FLAT 데이터를 전문정보로 잘라서 JSON / XML VIEW 로 볼 수 있는 버튼
|
$('#btn_pretty_print').click(function () {
|
||||||
$('#btn_convert_view').click(function() {
|
|
||||||
var type = $('select[id=selectBodySyntax]').val();
|
var $button = $(this);
|
||||||
|
|
||||||
if (!fullMessageData || !layoutInfo) {
|
// Pretty View → 원본 복구
|
||||||
alert("데이터가 없습니다.");
|
if (typeof isPrettyView !== 'undefined' && isPrettyView) {
|
||||||
|
|
||||||
|
var originalData = (typeof bzwkdatatntInfo !== 'undefined')
|
||||||
|
? bzwkdatatntInfo
|
||||||
|
: "";
|
||||||
|
|
||||||
|
if (typeof bodyCodeEditor !== 'undefined') {
|
||||||
|
bodyCodeEditor.setValue(originalData);
|
||||||
|
}
|
||||||
|
|
||||||
|
isPrettyView = false;
|
||||||
|
$button.text("PRETTY_PRINT");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
parserCommon(fullMessageData, layoutInfo, type);
|
var intrefaceId = ($("input[name=eaiSvcName]").val() || "").trim();
|
||||||
});
|
var logProcessNo = ($("input[name=logPrcssSerno]").val() || "").trim();
|
||||||
|
var bizData = (typeof bzwkdatatntInfo !== 'undefined')
|
||||||
|
? bzwkdatatntInfo
|
||||||
|
: "";
|
||||||
|
|
||||||
function parserCommon(flatData, layoutInfo, type) {
|
var error = false;
|
||||||
var cursor = 0;
|
|
||||||
var parsedList = [];
|
|
||||||
|
|
||||||
layoutInfo.forEach(function(field) {
|
var errContent = ($("textarea[name=eaiErrCtnt]").val() || "").trim();
|
||||||
var fieldLen = field.length;
|
if (errContent.length > 0) {
|
||||||
|
error = true;
|
||||||
if (fieldLen > 0) {
|
|
||||||
var rawValue = flatData.substring(cursor, cursor + fieldLen);
|
|
||||||
|
|
||||||
parsedList.push({
|
|
||||||
engName: field.name,
|
|
||||||
korName: field.desc || field.name,
|
|
||||||
value: rawValue // trim 금지.
|
|
||||||
});
|
|
||||||
|
|
||||||
cursor += fieldLen;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// CodeMirror 에디터에 값 세팅
|
|
||||||
var finalString = "";
|
|
||||||
|
|
||||||
if (type == "JSN") {
|
|
||||||
|
|
||||||
var jsonResult = {};
|
|
||||||
|
|
||||||
parsedList.forEach(function(item) {
|
|
||||||
jsonResult[item.engName] = {
|
|
||||||
"한글명": item.korName,
|
|
||||||
"값": item.value
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
finalString = JSON.stringify(jsonResult, null, 4);
|
|
||||||
|
|
||||||
} else if (type == "XML") {
|
|
||||||
|
|
||||||
var xmlResult = "<Root>\n";
|
|
||||||
|
|
||||||
parsedList.forEach(function(item) {
|
|
||||||
var cleanTagName = item.korName.replace(/[^a-zA-Z0-9가-힣]/g, "");
|
|
||||||
if (!cleanTagName) cleanTagName = item.engName;
|
|
||||||
|
|
||||||
xmlResult += "\t<" + cleanTagName + ">" + item.value + "</" + cleanTagName + ">\n";
|
|
||||||
});
|
|
||||||
xmlResult += "</Root>";
|
|
||||||
|
|
||||||
finalString = xmlResult;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
finalString = flatData;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bodyCodeEditor.setValue(finalString);
|
if (!intrefaceId || !logProcessNo || !bizData) {
|
||||||
$('#selectBodySyntax').val(type).trigger('change');
|
alert("필수값이 누락되어 조회가 불가능합니다.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// console.log("변환 완료:", parsedList);
|
$.ajax({
|
||||||
}
|
type: "POST",
|
||||||
|
url: url,
|
||||||
|
dataType: "json",
|
||||||
|
data: {
|
||||||
|
cmd: "DETAIL_PRETTY_VIEW",
|
||||||
|
intrefaceId: intrefaceId,
|
||||||
|
logProcessNo: logProcessNo,
|
||||||
|
bizData: bizData
|
||||||
|
},
|
||||||
|
|
||||||
|
success: function (response) {
|
||||||
|
|
||||||
|
var xmlString = response.result;
|
||||||
|
|
||||||
|
if (xmlString) {
|
||||||
|
|
||||||
|
if (typeof bodyCodeEditor !== 'undefined') {
|
||||||
|
bodyCodeEditor.setValue(xmlString);
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#selectBodySyntax')
|
||||||
|
.val('XML')
|
||||||
|
.trigger('change');
|
||||||
|
|
||||||
|
isPrettyView = true;
|
||||||
|
$button.text("업무데이터 보기");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
alert("변환된 데이터 내용이 없습니다.");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
error: function (xhr, status, error) {
|
||||||
|
|
||||||
|
console.error("AJAX Error:", xhr);
|
||||||
|
|
||||||
|
var errorMsg = "처리 중 오류가 발생했습니다.";
|
||||||
|
|
||||||
|
if (xhr.responseJSON) {
|
||||||
|
|
||||||
|
var errResponse = xhr.responseJSON;
|
||||||
|
|
||||||
|
if (errResponse.result) {
|
||||||
|
errorMsg = errResponse.result;
|
||||||
|
}
|
||||||
|
else if (errResponse.message) {
|
||||||
|
errorMsg = errResponse.message;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
// JSON 파싱 실패 대비
|
||||||
|
else if (xhr.responseText) {
|
||||||
|
errorMsg = xhr.responseText;
|
||||||
|
}
|
||||||
|
|
||||||
|
alert(errorMsg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user