업무데이터 포함 클립보드 복사

This commit is contained in:
daekuk1
2026-02-09 14:22:37 +09:00
parent 98b236f9f5
commit 2a6de5f9ea
@@ -203,6 +203,22 @@
layoutInfo = json.standardHeader;
bzwkdatatntInfo = json.BZWKDATACTNT;
// bzwkdatatntInfoLength 파싱 및 패딩 처리
let bzwkdatatntInfoLength = 0;
try {
bzwkdatatntInfoLength = parseInt(layoutInfo[layoutInfo.length - 2].value, 10);
if (isNaN(bzwkdatatntInfoLength)) {
bzwkdatatntInfoLength = 0;
}
} catch (e) {
bzwkdatatntInfoLength = 0;
}
// bzwkdatatntInfo 패딩 적용
if (bzwkdatatntInfoLength > 0 && bzwkdatatntInfo) {
bzwkdatatntInfo = padByteString(bzwkdatatntInfo, bzwkdatatntInfoLength);
}
if((isInboundPart && isInboundWithoutNet) || (isOutboundPart && isOutboundWithoutNet)){
selectHttpLog(url, prcsDate, json.EAISVCSERNO.trim(), logPrcssSerno);
}else{
@@ -792,8 +808,21 @@ $(document).ready(function() {
const jexcelGrid = $('#grid1').get(0).jexcel;
const data = jexcelGrid.getData();
let paddedValues = "";
for (let row of data) {
paddedValues += row[5].padEnd(row[4], " ");
// 마지막 요소 전까지 처리
for (let i = 0; i < data.length - 1; i++) {
paddedValues += data[i][5].padEnd(data[i][4], " ");
}
// 마지막 요소 전에 bzwkdatatntInfo 추가
if (bzwkdatatntInfo) {
paddedValues += bzwkdatatntInfo;
}
// 마지막 요소 추가
if (data.length > 0) {
const lastRow = data[data.length - 1];
paddedValues += lastRow[5].padEnd(lastRow[4], " ");
}
navigator.clipboard.writeText(paddedValues);//클립보드로 복사
@@ -876,7 +905,39 @@ $(document).ready(function() {
// console.log("변환 완료:", parsedList);
}
/**
* 문자열의 바이트 수 계산 (한글 2바이트, 영문/숫자 1바이트)
*/
function getByteLength(str) {
let byteCount = 0;
for (let i = 0; i < str.length; i++) {
const charCode = str.charCodeAt(i);
byteCount += (charCode >= 0xAC00 && charCode <= 0xD7A3) ? 2 : 1;
}
return byteCount;
}
/**
* 문자열을 주어진 바이트 수만큼 패딩
* @param {string} str - 원본 문자열
* @param {number} targetBytes - 목표 바이트 수
* @param {string} position - 'left' 또는 'right' (기본: 'right')
* @param {string} padChar - 패딩 문자 (기본: 공백)
* @returns {string} - 패딩된 문자열
*/
function padByteString(str, targetBytes, position = 'right', padChar = ' ') {
const currentBytes = getByteLength(str);
if (currentBytes >= targetBytes) {
return str; // 이미 목표 바이트 이상이면 그대로 반환
}
const paddingBytes = targetBytes - currentBytes;
const padding = padChar.repeat(paddingBytes);
return position === 'left' ? padding + str : str + padding;
}
});
</script>