diff --git a/WebContent/WEB-INF/view/contractMgmt/estimateList_new.jsp b/WebContent/WEB-INF/view/contractMgmt/estimateList_new.jsp
index b83babe..389ac82 100644
--- a/WebContent/WEB-INF/view/contractMgmt/estimateList_new.jsp
+++ b/WebContent/WEB-INF/view/contractMgmt/estimateList_new.jsp
@@ -194,6 +194,13 @@ $(document).ready(function(){
fn_search();
});
+// 콤마 추가 함수
+function addComma(num) {
+ if(!num) return '';
+ var regexp = /\B(?=(\d{3})+(?!\d))/g;
+ return num.toString().replace(regexp, ',');
+}
+
var columns = [
{title:'EST_OBJID' ,field:'EST_OBJID' ,visible:false},
{headerHozAlign : 'center', hozAlign : 'center', width : '90', title : '영업번호', field : 'CONTRACT_NO', frozen:true,
@@ -288,11 +295,19 @@ var columns = [
}
},
// {headerHozAlign : 'center', hozAlign : 'center', width : '100', title : '견적단가', field : 'EST_PRICE' },
- {headerHozAlign : 'center', hozAlign : 'center', width : '130', title : '견적공급가액', field : 'EST_SUPPLY_PRICE',
- formatter:"money", formatterParams:{thousand:",", symbolAfter:"p", precision:false,},
+ {headerHozAlign : 'center', hozAlign : 'center', width : '130', title : '견적공급가액', field : 'EST_TOTAL_AMOUNT',
+ formatter: function(cell, formatterParams, onRendered){
+ var value = fnc_checkNull(cell.getValue());
+ if(value === '' || value === '0') return '';
+ return addComma(value);
+ }
},
- {headerHozAlign : 'center', hozAlign : 'center', width : '150', title : '견적원화환산공급가액', field : 'EXC_EST_SUPPLY_PRICE',
- formatter:"money", formatterParams:{thousand:",", symbolAfter:"p", precision:false,},
+ {headerHozAlign : 'center', hozAlign : 'center', width : '150', title : '견적원화환산공급가액', field : 'EST_TOTAL_AMOUNT_KRW',
+ formatter: function(cell, formatterParams, onRendered){
+ var value = fnc_checkNull(cell.getValue());
+ if(value === '' || value === '0') return '';
+ return addComma(value);
+ }
},
{headerHozAlign : 'center', hozAlign : 'center', width : '80', title : '견적환종', field : 'CONTRACT_CURRENCY_NAME' },
{headerHozAlign : 'center', hozAlign : 'center', width : '80', title : '견적환율', field : 'EXCHANGE_RATE' },
diff --git a/WebContent/WEB-INF/view/contractMgmt/estimateRegistFormPopup.jsp b/WebContent/WEB-INF/view/contractMgmt/estimateRegistFormPopup.jsp
index b65a108..0766ebb 100644
--- a/WebContent/WEB-INF/view/contractMgmt/estimateRegistFormPopup.jsp
+++ b/WebContent/WEB-INF/view/contractMgmt/estimateRegistFormPopup.jsp
@@ -380,6 +380,7 @@
}
var item = {
+ objId: $row.find(".item-objid").val(), // 기존 품목 OBJID (수정 시 유지)
partObjId: $row.find(".item-part-objid").val(),
partNo: $row.find(".item-part-no").val() ? $row.find(".item-part-no").val().trim() : "",
partName: $row.find(".item-part-name").val() ? $row.find(".item-part-name").val().trim() : "",
@@ -439,6 +440,7 @@
(function() {
var itemId = 'item_' + itemCounter++;
// 대소문자 모두 시도
+ var savedItemObjId = "<%= item.get("OBJID") != null ? item.get("OBJID") : (item.get("objid") != null ? item.get("objid") : "") %>";
var savedPartObjId = "<%= item.get("PART_OBJID") != null ? item.get("PART_OBJID") : (item.get("part_objid") != null ? item.get("part_objid") : "") %>";
var savedPartNo = "<%= item.get("PART_NO") != null ? item.get("PART_NO") : (item.get("part_no") != null ? item.get("part_no") : "") %>";
var savedPartName = "<%= item.get("PART_NAME") != null ? item.get("PART_NAME") : (item.get("part_name") != null ? item.get("part_name") : "") %>";
@@ -455,6 +457,7 @@
html += '';
+ html += '';
html += '';
html += '';
html += '';
@@ -1147,6 +1150,7 @@
html += '';
+ html += '';
html += '';
html += '';
html += '';
diff --git a/WebContent/WEB-INF/view/contractMgmt/estimateTemplate1.jsp b/WebContent/WEB-INF/view/contractMgmt/estimateTemplate1.jsp
index e6f86b7..e13c313 100644
--- a/WebContent/WEB-INF/view/contractMgmt/estimateTemplate1.jsp
+++ b/WebContent/WEB-INF/view/contractMgmt/estimateTemplate1.jsp
@@ -222,6 +222,8 @@ textarea {
// 전역 변수로 저장 (데이터 로드 시 설정됨)
var g_contractObjId = "<%=objId%>";
var g_templateObjId = "<%=templateObjId%>";
+var g_exchangeRate = 1; // 환율 (기본값 1)
+var g_currencyName = "KRW"; // 통화명 (기본값 원화)
$(function(){
@@ -256,6 +258,7 @@ $(function(){
// 금액 자동 계산
$(document).on("change keyup", ".item-qty, .item-price", function(){
fn_calculateAmount($(this).closest("tr"));
+ fn_calculateTotal(); // 합계 재계산
});
// 콤마 자동 추가 (동적 요소 포함)
@@ -284,6 +287,9 @@ $(function(){
// 데이터 로드
if("<%=objId%>" !== "" && "<%=objId%>" !== "-1") {
fn_loadData();
+ } else {
+ // 초기 로드 시 합계 계산
+ fn_calculateTotal();
}
});
@@ -298,6 +304,32 @@ function fn_calculateAmount(row) {
}
}
+// 합계 계산 (금액 컬럼의 총합)
+function fn_calculateTotal() {
+ var total = 0;
+
+ // 품목 행만 순회 (계 행, 원화환산 행, 비고 행 제외)
+ $("#itemsTableBody tr").not(".total-row, .total-krw-row, .remarks-row").each(function(){
+ var amount = $(this).find(".item-amount").val() || "0";
+ // 콤마와 ₩ 기호 제거 후 숫자로 변환
+ amount = amount.replace(/,/g, "").replace(/₩/g, "");
+ var numAmount = parseInt(amount) || 0;
+ total += numAmount;
+ });
+
+ // 합계 행에 표시
+ $("#totalAmount").text(addComma(total));
+
+ // 원화환산 금액 계산 및 표시
+ fn_calculateTotalKRW(total);
+}
+
+// 원화환산 공급가액 계산
+function fn_calculateTotalKRW(total) {
+ var totalKRW = total * g_exchangeRate;
+ $("#totalAmountKRW").text(addComma(Math.round(totalKRW)));
+}
+
// 콤마 추가
function addComma(num) {
var regexp = /\B(?=(\d{3})+(?!\d))/g;
@@ -306,10 +338,9 @@ function addComma(num) {
// 행 추가 함수
function fn_addItemRow() {
- // 비고 행 제외하고 마지막 품목 행 찾기
- var $lastRow = $("#itemsTableBody tr").not(":last");
- var lastRowIndex = $lastRow.length;
- var nextNo = lastRowIndex + 1;
+ // 계 행, 원화환산 행, 비고 행 제외하고 품목 행 개수 계산
+ var itemRows = $("#itemsTableBody tr").not(".total-row, .total-krw-row, .remarks-row");
+ var nextNo = itemRows.length + 1;
// 새 행 생성
var newRow = '
' +
@@ -323,8 +354,11 @@ function fn_addItemRow() {
' | ' +
'
';
- // 비고 행 바로 위에 추가 (이벤트는 이미 document에 바인딩되어 있으므로 별도 바인딩 불필요)
- $("#itemsTableBody tr:last").before(newRow);
+ // 계 행 바로 위에 추가
+ $(".total-row").before(newRow);
+
+ // 합계 재계산
+ fn_calculateTotal();
}
// 데이터 로드
@@ -338,6 +372,10 @@ function fn_loadData() {
dataType: "json",
success: function(data) {
if(data && data.estimate) {
+ // 환율 정보 저장
+ g_exchangeRate = parseFloat(data.estimate.EXCHANGE_RATE || "1");
+ g_currencyName = data.estimate.CONTRACT_CURRENCY_NAME || "KRW";
+
// 데이터 바인딩
$("#executor").val(data.estimate.EXECUTOR || "");
$("#recipient").val(data.estimate.RECIPIENT || "");
@@ -362,7 +400,33 @@ function fn_loadData() {
itemsHtml += ' | ';
itemsHtml += '';
}
+
+ // 계 행 추가
+ itemsHtml += '';
+ itemsHtml += '| 계 | ';
+ itemsHtml += '0 | ';
+ itemsHtml += ' | ';
+ itemsHtml += '
';
+
+ // 원화환산 공급가액 행 추가
+ itemsHtml += '';
+ itemsHtml += '| 원화환산 공급가액 (KRW) | ';
+ itemsHtml += '0 | ';
+ itemsHtml += ' | ';
+ itemsHtml += '
';
+
+ // 비고 행 추가
+ itemsHtml += '';
+
$("#itemsTableBody").html(itemsHtml);
+
+ // 합계 계산
+ fn_calculateTotal();
}
// 비고 로드
@@ -397,6 +461,10 @@ function fn_loadTemplateData(templateObjId){
g_contractObjId = contractObjId;
}
+ // 환율 정보 저장
+ g_exchangeRate = parseFloat(template.EXCHANGE_RATE || template.exchange_rate || template.exchangeRate || "1");
+ g_currencyName = template.CONTRACT_CURRENCY_NAME || template.contract_currency_name || template.contractCurrencyName || "KRW";
+
// 대문자/소문자 모두 지원
var executor = template.EXECUTOR || template.executor || "";
var recipient = template.RECIPIENT || template.recipient || "";
@@ -446,6 +514,31 @@ function fn_loadTemplateData(templateObjId){
row.append(' | ');
$("#itemsTableBody").append(row);
});
+
+ // 계 행 추가
+ var totalRow = $("");
+ totalRow.append('| 계 | ');
+ totalRow.append('0 | ');
+ totalRow.append(' | ');
+ $("#itemsTableBody").append(totalRow);
+
+ // 원화환산 공급가액 행 추가
+ var totalKRWRow = $("
");
+ totalKRWRow.append('| 원화환산 공급가액 (KRW) | ');
+ totalKRWRow.append('0 | ');
+ totalKRWRow.append(' | ');
+ $("#itemsTableBody").append(totalKRWRow);
+
+ // 비고 행 추가
+ var remarksRow = $("
-
+
+
+ | 계 |
+ 0 |
+ |
+
+
+
+ | 원화환산 공급가액 (KRW) |
+ 0 |
+ |
+
+
+