|
|
|
|
@@ -264,6 +264,10 @@ textarea {
|
|
|
|
|
font-size: inherit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.item-amount {
|
|
|
|
|
pointer-events: none;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
textarea {
|
|
|
|
|
resize: vertical;
|
|
|
|
|
min-height: 25px;
|
|
|
|
|
@@ -323,11 +327,12 @@ $(function(){
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 초기 로드는 $(document).ready에서 처리하므로 주석 처리
|
|
|
|
|
// templateObjId가 있으면 기존 데이터 로드
|
|
|
|
|
var templateObjId = "<%=templateObjId%>";
|
|
|
|
|
if(templateObjId && templateObjId !== ""){
|
|
|
|
|
fn_loadTemplateData(templateObjId);
|
|
|
|
|
}
|
|
|
|
|
// var templateObjId = "<%=templateObjId%>";
|
|
|
|
|
// if(templateObjId && templateObjId !== ""){
|
|
|
|
|
// fn_loadTemplateData(templateObjId);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// 인쇄 버튼
|
|
|
|
|
$("#btnPrint").click(function(){
|
|
|
|
|
@@ -351,55 +356,62 @@ $(function(){
|
|
|
|
|
fn_addItemRow();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 금액 자동 계산
|
|
|
|
|
// 계 행 삭제 버튼
|
|
|
|
|
$(document).on("click", ".btn-delete-total-row", function(){
|
|
|
|
|
if(confirm("계 행을 삭제하시겠습니까?")) {
|
|
|
|
|
$(".total-row").hide();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 금액 자동 계산 (수량, 단가 변경 시)
|
|
|
|
|
$(document).on("change keyup", ".item-qty, .item-price", function(){
|
|
|
|
|
fn_calculateAmount($(this).closest("tr"));
|
|
|
|
|
fn_calculateTotal(); // 합계 재계산
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 금액 필드 직접 수정 시에도 합계 재계산
|
|
|
|
|
$(document).on("change keyup", ".item-amount", function(){
|
|
|
|
|
fn_calculateTotal(); // 합계 재계산
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 콤마 자동 추가 (동적 요소 포함)
|
|
|
|
|
$(document).on("blur", ".item-price, .item-amount", function(){
|
|
|
|
|
var val = $(this).val().replace(/,/g, "").replace(/₩/g, "");
|
|
|
|
|
// 단가 입력 완료 시 콤마 자동 추가
|
|
|
|
|
$(document).on("blur", ".item-price", function(){
|
|
|
|
|
var val = $(this).val().replace(/,/g, "");
|
|
|
|
|
if(!isNaN(val) && val !== "") {
|
|
|
|
|
$(this).val(addComma(val));
|
|
|
|
|
}
|
|
|
|
|
fn_calculateTotal(); // blur 시에도 합계 재계산
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 단가 입력 시 실시간 콤마 처리
|
|
|
|
|
// 단가 입력 시 숫자만 입력 가능하도록 제한 및 실시간 콤마 처리
|
|
|
|
|
$(document).on("input", ".item-price", function(){
|
|
|
|
|
var val = $(this).val().replace(/,/g, "");
|
|
|
|
|
var cursorPos = this.selectionStart;
|
|
|
|
|
var commasBefore = ($(this).val().substring(0, cursorPos).match(/,/g) || []).length;
|
|
|
|
|
var originalVal = $(this).val();
|
|
|
|
|
var commasBefore = (originalVal.substring(0, cursorPos).match(/,/g) || []).length;
|
|
|
|
|
|
|
|
|
|
if(!isNaN(val) && val !== "") {
|
|
|
|
|
// 콤마 제거 후 숫자가 아닌 문자 제거
|
|
|
|
|
var val = originalVal.replace(/,/g, "").replace(/[^0-9]/g, "");
|
|
|
|
|
|
|
|
|
|
// 값 설정 (빈 문자열 포함)
|
|
|
|
|
if(val !== "") {
|
|
|
|
|
$(this).val(addComma(val));
|
|
|
|
|
// 커서 위치 조정
|
|
|
|
|
var commasAfter = ($(this).val().substring(0, cursorPos).match(/,/g) || []).length;
|
|
|
|
|
var newPos = cursorPos + (commasAfter - commasBefore);
|
|
|
|
|
this.setSelectionRange(newPos, newPos);
|
|
|
|
|
} else {
|
|
|
|
|
$(this).val("");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 수량 입력 시 숫자만 입력 가능하도록 제한
|
|
|
|
|
$(document).on("input", ".item-qty", function(){
|
|
|
|
|
var val = $(this).val().replace(/[^0-9]/g, "");
|
|
|
|
|
$(this).val(val);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 데이터 로드
|
|
|
|
|
if("<%=objId%>" !== "" && "<%=objId%>" !== "-1") {
|
|
|
|
|
fn_loadData();
|
|
|
|
|
} else {
|
|
|
|
|
// 새 견적서 작성 시 기본 행의 셀렉트박스 초기화
|
|
|
|
|
fn_initItemDescSelect('default_item_1');
|
|
|
|
|
fn_initItemDescSelect('default_item_2');
|
|
|
|
|
|
|
|
|
|
// 초기 로드 시 합계 계산
|
|
|
|
|
fn_calculateTotal();
|
|
|
|
|
|
|
|
|
|
// 새로 등록 시 명시적으로 작성중 상태 설정
|
|
|
|
|
g_apprStatus = "작성중";
|
|
|
|
|
fn_controlButtons();
|
|
|
|
|
if("<%=templateObjId%>" !== "" && "<%=templateObjId%>" !== "-1") {
|
|
|
|
|
// 저장된 견적서 수정: 견적서 데이터 로드
|
|
|
|
|
fn_loadTemplateData("<%=templateObjId%>");
|
|
|
|
|
} else if("<%=objId%>" !== "" && "<%=objId%>" !== "-1") {
|
|
|
|
|
// 처음 견적서 작성: 영업정보의 품목 데이터 로드
|
|
|
|
|
fn_loadContractItems("<%=objId%>");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
@@ -427,6 +439,7 @@ function fn_controlButtons() {
|
|
|
|
|
|
|
|
|
|
// 삭제 버튼 숨김
|
|
|
|
|
$(".btn-delete-row").hide();
|
|
|
|
|
$(".btn-delete-total-row").hide(); // 계 삭제 버튼도 숨김
|
|
|
|
|
} else {
|
|
|
|
|
console.log("결재완료 아님 - 입력 필드 활성화");
|
|
|
|
|
// 결재완료가 아닌 경우 버튼 표시
|
|
|
|
|
@@ -446,6 +459,7 @@ function fn_controlButtons() {
|
|
|
|
|
|
|
|
|
|
// 삭제 버튼 표시
|
|
|
|
|
$(".btn-delete-row").show();
|
|
|
|
|
$(".btn-delete-total-row").show(); // 계 삭제 버튼도 표시
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -456,7 +470,8 @@ function fn_calculateAmount(row) {
|
|
|
|
|
|
|
|
|
|
var amount = parseInt(qty) * parseInt(price);
|
|
|
|
|
if(!isNaN(amount)) {
|
|
|
|
|
row.find(".item-amount").val(addComma(amount));
|
|
|
|
|
var currencySymbol = getCurrencySymbol();
|
|
|
|
|
row.find(".item-amount").val(currencySymbol + addComma(amount));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -467,8 +482,8 @@ function fn_calculateTotal() {
|
|
|
|
|
// 품목 행만 순회 (계 행, 원화환산 행, 비고 행, 참조사항 행, 회사명 행 제외)
|
|
|
|
|
$("#itemsTableBody tr").not(".total-row, .total-krw-row, .remarks-row, .notes-row, .footer-row").each(function(){
|
|
|
|
|
var amount = $(this).find(".item-amount").val() || "0";
|
|
|
|
|
// 콤마와 통화 기호 제거 후 숫자로 변환
|
|
|
|
|
amount = amount.replace(/,/g, "").replace(/₩/g, "").replace(/\$/g, "").replace(/€/g, "").replace(/¥/g, "");
|
|
|
|
|
// 모든 비숫자 문자 제거 (통화 기호, 콤마 등)
|
|
|
|
|
amount = amount.replace(/[^0-9]/g, "");
|
|
|
|
|
var numAmount = parseInt(amount) || 0;
|
|
|
|
|
total += numAmount;
|
|
|
|
|
});
|
|
|
|
|
@@ -613,6 +628,159 @@ function fn_addItemRow() {
|
|
|
|
|
fn_calculateTotal();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 영업정보의 품목 데이터 로드
|
|
|
|
|
function fn_loadContractItems(contractObjId) {
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: "/contractMgmt/getContractItemList.do",
|
|
|
|
|
type: "POST",
|
|
|
|
|
data: {
|
|
|
|
|
contractObjId: contractObjId
|
|
|
|
|
},
|
|
|
|
|
dataType: "json",
|
|
|
|
|
success: function(data) {
|
|
|
|
|
console.log("품목 데이터:", data); // 디버깅용
|
|
|
|
|
|
|
|
|
|
if(data && data.result === "success" && data.items && data.items.length > 0) {
|
|
|
|
|
// 환율 정보 설정
|
|
|
|
|
if(data.exchangeRate) {
|
|
|
|
|
g_exchangeRate = parseFloat(data.exchangeRate);
|
|
|
|
|
}
|
|
|
|
|
if(data.currencyName) {
|
|
|
|
|
g_currencyName = data.currencyName;
|
|
|
|
|
}
|
|
|
|
|
console.log("환율 정보:", g_exchangeRate, g_currencyName);
|
|
|
|
|
|
|
|
|
|
// 고객사 정보 설정
|
|
|
|
|
if(data.customerObjId && data.customerObjId !== "") {
|
|
|
|
|
// 데이터 로드 중 플래그 설정
|
|
|
|
|
window.isLoadingData = true;
|
|
|
|
|
|
|
|
|
|
$("#recipient").val(data.customerObjId).trigger('change');
|
|
|
|
|
|
|
|
|
|
// 담당자 목록 로드
|
|
|
|
|
fn_loadCustomerContact(data.customerObjId);
|
|
|
|
|
|
|
|
|
|
// 플래그 해제
|
|
|
|
|
setTimeout(function() {
|
|
|
|
|
window.isLoadingData = false;
|
|
|
|
|
}, 100);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 기존 테이블 초기화
|
|
|
|
|
$("#itemsTableBody").empty();
|
|
|
|
|
|
|
|
|
|
// 품목 HTML 생성
|
|
|
|
|
var itemsHtml = "";
|
|
|
|
|
for(var i = 0; i < data.items.length; i++) {
|
|
|
|
|
var item = data.items[i];
|
|
|
|
|
console.log("품목 " + (i+1) + ":", item); // 각 품목 디버깅
|
|
|
|
|
|
|
|
|
|
var itemId = 'contract_item_' + i;
|
|
|
|
|
var partNo = item.PART_NO || item.part_no || '';
|
|
|
|
|
var partName = item.PART_NAME || item.part_name || '';
|
|
|
|
|
var quantity = item.QUANTITY || item.quantity || '';
|
|
|
|
|
var partObjId = item.PART_OBJID || item.part_objid || '';
|
|
|
|
|
|
|
|
|
|
console.log("추출된 값 - partName:", partName, ", partObjId:", partObjId, ", quantity:", quantity);
|
|
|
|
|
|
|
|
|
|
itemsHtml += '<tr id="' + itemId + '">';
|
|
|
|
|
itemsHtml += '<td>' + (i + 1) + '</td>';
|
|
|
|
|
itemsHtml += '<td class="text-left editable">';
|
|
|
|
|
itemsHtml += '<select class="item-desc-select" style="width:100%;">';
|
|
|
|
|
if(partName) {
|
|
|
|
|
itemsHtml += '<option value="' + partObjId + '" selected>' + partName + '</option>';
|
|
|
|
|
}
|
|
|
|
|
itemsHtml += '</select>';
|
|
|
|
|
itemsHtml += '<input type="hidden" class="item-desc" value="' + partName + '">';
|
|
|
|
|
itemsHtml += '<input type="hidden" class="item-part-objid" value="' + partObjId + '">';
|
|
|
|
|
itemsHtml += '</td>';
|
|
|
|
|
itemsHtml += '<td class="text-left editable"><textarea class="item-spec"></textarea></td>';
|
|
|
|
|
itemsHtml += '<td class="editable"><input type="text" class="item-qty" value="' + quantity + '"></td>';
|
|
|
|
|
itemsHtml += '<td class="editable"><input type="text" class="item-unit" value="EA"></td>';
|
|
|
|
|
itemsHtml += '<td class="text-right editable"><input type="text" class="item-price" value=""></td>';
|
|
|
|
|
itemsHtml += '<td class="text-right editable"><input type="text" class="item-amount" value="" readonly></td>';
|
|
|
|
|
itemsHtml += '<td class="editable"><input type="text" class="item-note" value=""></td>';
|
|
|
|
|
itemsHtml += '</tr>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 계 행 추가
|
|
|
|
|
itemsHtml += '<tr class="total-row">';
|
|
|
|
|
itemsHtml += '<td colspan="6" style="text-align: center; font-weight: bold; background-color: #f0f0f0;">계</td>';
|
|
|
|
|
itemsHtml += '<td class="text-right" style="font-weight: bold; background-color: #f0f0f0;"><span id="totalAmount">0</span></td>';
|
|
|
|
|
itemsHtml += '<td style="background-color: #f0f0f0; text-align: center;"><button type="button" class="btn-delete-total-row" style="padding: 2px 8px; font-size: 9pt; cursor: pointer;">삭제</button></td>';
|
|
|
|
|
itemsHtml += '</tr>';
|
|
|
|
|
|
|
|
|
|
// 원화환산 공급가액 행 추가 (숨김)
|
|
|
|
|
itemsHtml += '<tr class="total-krw-row" style="display: none;">';
|
|
|
|
|
itemsHtml += '<td colspan="6" style="text-align: center; font-weight: bold; background-color: #e8f4f8;">원화환산 공급가액 (KRW)</td>';
|
|
|
|
|
itemsHtml += '<td class="text-right" style="font-weight: bold; background-color: #e8f4f8;"><span id="totalAmountKRW">0</span></td>';
|
|
|
|
|
itemsHtml += '<td style="background-color: #e8f4f8;"></td>';
|
|
|
|
|
itemsHtml += '</tr>';
|
|
|
|
|
|
|
|
|
|
// 비고 행 추가
|
|
|
|
|
itemsHtml += '<tr class="remarks-row">';
|
|
|
|
|
itemsHtml += '<td colspan="8" style="height: 100px; vertical-align: top; padding: 10px; text-align: left;">';
|
|
|
|
|
itemsHtml += '<div style="font-weight: bold; margin-bottom: 10px; text-align: left;"><비고></div>';
|
|
|
|
|
itemsHtml += '<textarea id="note_remarks" style="width: 100%; height: 70px; border: none; resize: none; font-family: inherit; font-size: 10pt; text-align: left;"></textarea>';
|
|
|
|
|
itemsHtml += '</td>';
|
|
|
|
|
itemsHtml += '</tr>';
|
|
|
|
|
|
|
|
|
|
// 참조사항 행 추가
|
|
|
|
|
itemsHtml += '<tr class="notes-row">';
|
|
|
|
|
itemsHtml += '<td colspan="8" style="vertical-align: top; padding: 10px; text-align: left; border: 1px solid #000;">';
|
|
|
|
|
itemsHtml += '<div style="font-weight: bold; margin-bottom: 10px; text-align: left;"><참조사항></div>';
|
|
|
|
|
itemsHtml += '<div class="editable" style="margin-bottom: 5px;"><input type="text" id="note1" value="1. 견적유효기간: 일" style="width: 100%; border: none; background: transparent; font-size: 10pt;"></div>';
|
|
|
|
|
itemsHtml += '<div class="editable" style="margin-bottom: 5px;"><input type="text" id="note2" value="2. 납품기간: 발주 후 1주 이내" style="width: 100%; border: none; background: transparent; font-size: 10pt;"></div>';
|
|
|
|
|
itemsHtml += '<div class="editable" style="margin-bottom: 5px;"><input type="text" id="note3" value="3. VAT 별도" style="width: 100%; border: none; background: transparent; font-size: 10pt;"></div>';
|
|
|
|
|
itemsHtml += '<div class="editable" style="margin-bottom: 5px;"><input type="text" id="note4" value="4. 결제 조건 : 기존 결제조건에 따름." style="width: 100%; border: none; background: transparent; font-size: 10pt;"></div>';
|
|
|
|
|
itemsHtml += '</td>';
|
|
|
|
|
itemsHtml += '</tr>';
|
|
|
|
|
|
|
|
|
|
// 하단 회사명 행 추가
|
|
|
|
|
itemsHtml += '<tr class="footer-row">';
|
|
|
|
|
itemsHtml += '<td colspan="8" style="text-align: right; padding: 15px; font-size: 10pt; font-weight: bold; border: none;">';
|
|
|
|
|
itemsHtml += '㈜알피에스';
|
|
|
|
|
itemsHtml += '</td>';
|
|
|
|
|
itemsHtml += '</tr>';
|
|
|
|
|
|
|
|
|
|
// HTML 삽입
|
|
|
|
|
$("#itemsTableBody").html(itemsHtml);
|
|
|
|
|
|
|
|
|
|
// 셀렉트박스 초기화
|
|
|
|
|
for(var i = 0; i < data.items.length; i++) {
|
|
|
|
|
var itemId = 'contract_item_' + i;
|
|
|
|
|
fn_initItemDescSelect(itemId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 합계 계산
|
|
|
|
|
fn_calculateTotal();
|
|
|
|
|
|
|
|
|
|
// 결재상태에 따라 버튼 제어
|
|
|
|
|
g_apprStatus = "작성중";
|
|
|
|
|
fn_controlButtons();
|
|
|
|
|
} else {
|
|
|
|
|
// 품목이 없으면 기본 행 표시
|
|
|
|
|
fn_initItemDescSelect('default_item_1');
|
|
|
|
|
fn_initItemDescSelect('default_item_2');
|
|
|
|
|
fn_calculateTotal();
|
|
|
|
|
g_apprStatus = "작성중";
|
|
|
|
|
fn_controlButtons();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
error: function(xhr, status, error) {
|
|
|
|
|
console.error("품목 데이터 로드 오류:", xhr, status, error);
|
|
|
|
|
Swal.fire("품목 데이터를 불러오는데 실패했습니다.");
|
|
|
|
|
|
|
|
|
|
// 오류 시 기본 행 표시
|
|
|
|
|
fn_initItemDescSelect('default_item_1');
|
|
|
|
|
fn_initItemDescSelect('default_item_2');
|
|
|
|
|
fn_calculateTotal();
|
|
|
|
|
g_apprStatus = "작성중";
|
|
|
|
|
fn_controlButtons();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 데이터 로드
|
|
|
|
|
function fn_loadData() {
|
|
|
|
|
$.ajax({
|
|
|
|
|
@@ -692,12 +860,12 @@ function fn_loadData() {
|
|
|
|
|
itemsHtml += '</tr>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 계 행 추가
|
|
|
|
|
itemsHtml += '<tr class="total-row">';
|
|
|
|
|
itemsHtml += '<td colspan="6" style="text-align: center; font-weight: bold; background-color: #f0f0f0;">계</td>';
|
|
|
|
|
itemsHtml += '<td class="text-right" style="font-weight: bold; background-color: #f0f0f0;"><span id="totalAmount">0</span></td>';
|
|
|
|
|
itemsHtml += '<td style="background-color: #f0f0f0;"></td>';
|
|
|
|
|
itemsHtml += '</tr>';
|
|
|
|
|
// 계 행 추가
|
|
|
|
|
itemsHtml += '<tr class="total-row">';
|
|
|
|
|
itemsHtml += '<td colspan="6" style="text-align: center; font-weight: bold; background-color: #f0f0f0;">계</td>';
|
|
|
|
|
itemsHtml += '<td class="text-right" style="font-weight: bold; background-color: #f0f0f0;"><span id="totalAmount">0</span></td>';
|
|
|
|
|
itemsHtml += '<td style="background-color: #f0f0f0; text-align: center;"><button type="button" class="btn-delete-total-row" style="padding: 2px 8px; font-size: 9pt; cursor: pointer;">삭제</button></td>';
|
|
|
|
|
itemsHtml += '</tr>';
|
|
|
|
|
|
|
|
|
|
// 원화환산 공급가액 행 추가 (숨김)
|
|
|
|
|
itemsHtml += '<tr class="total-krw-row" style="display: none;">';
|
|
|
|
|
@@ -843,6 +1011,9 @@ function fn_loadTemplateData(templateObjId){
|
|
|
|
|
if(recipient && recipient !== "") {
|
|
|
|
|
// OBJID로 셀렉트박스 선택
|
|
|
|
|
$("#recipient").val(recipient).trigger('change');
|
|
|
|
|
|
|
|
|
|
// 담당자 목록 로드 (저장된 수신인도 함께 전달)
|
|
|
|
|
fn_loadCustomerContact(recipient, contactPerson);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 플래그 해제
|
|
|
|
|
@@ -883,9 +1054,12 @@ function fn_loadTemplateData(templateObjId){
|
|
|
|
|
var note = item.NOTE || item.note || '';
|
|
|
|
|
var partObjId = item.PART_OBJID || item.part_objid || '';
|
|
|
|
|
|
|
|
|
|
// 단가와 금액에 콤마 추가
|
|
|
|
|
// 통화 기호 가져오기
|
|
|
|
|
var currencySymbol = getCurrencySymbol();
|
|
|
|
|
|
|
|
|
|
// 단가와 금액에 콤마 및 통화 기호 추가
|
|
|
|
|
var unitPriceFormatted = unitPrice ? addComma(unitPrice) : '';
|
|
|
|
|
var amountFormatted = amount ? addComma(amount) : '';
|
|
|
|
|
var amountFormatted = amount ? (currencySymbol + addComma(amount)) : '';
|
|
|
|
|
|
|
|
|
|
itemsHtml += '<tr id="' + itemId + '">';
|
|
|
|
|
itemsHtml += '<td>' + (i + 1) + '</td>';
|
|
|
|
|
@@ -908,12 +1082,12 @@ function fn_loadTemplateData(templateObjId){
|
|
|
|
|
itemsHtml += '</tr>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 계 행 추가
|
|
|
|
|
itemsHtml += '<tr class="total-row">';
|
|
|
|
|
itemsHtml += '<td colspan="6" style="text-align: center; font-weight: bold; background-color: #f0f0f0;">계</td>';
|
|
|
|
|
itemsHtml += '<td class="text-right" style="font-weight: bold; background-color: #f0f0f0;"><span id="totalAmount">0</span></td>';
|
|
|
|
|
itemsHtml += '<td style="background-color: #f0f0f0;"></td>';
|
|
|
|
|
itemsHtml += '</tr>';
|
|
|
|
|
// 계 행 추가
|
|
|
|
|
itemsHtml += '<tr class="total-row">';
|
|
|
|
|
itemsHtml += '<td colspan="6" style="text-align: center; font-weight: bold; background-color: #f0f0f0;">계</td>';
|
|
|
|
|
itemsHtml += '<td class="text-right" style="font-weight: bold; background-color: #f0f0f0;"><span id="totalAmount">0</span></td>';
|
|
|
|
|
itemsHtml += '<td style="background-color: #f0f0f0; text-align: center;"><button type="button" class="btn-delete-total-row" style="padding: 2px 8px; font-size: 9pt; cursor: pointer;">삭제</button></td>';
|
|
|
|
|
itemsHtml += '</tr>';
|
|
|
|
|
|
|
|
|
|
// 원화환산 공급가액 행 추가 (숨김)
|
|
|
|
|
itemsHtml += '<tr class="total-krw-row" style="display: none;">';
|
|
|
|
|
@@ -1006,6 +1180,14 @@ function fn_loadTemplateData(templateObjId){
|
|
|
|
|
// 합계 계산
|
|
|
|
|
fn_calculateTotal();
|
|
|
|
|
|
|
|
|
|
// 계 행 표시 여부 복원
|
|
|
|
|
var showTotalRow = template.SHOW_TOTAL_ROW || template.show_total_row || "Y";
|
|
|
|
|
if(showTotalRow === "N") {
|
|
|
|
|
$(".total-row").hide();
|
|
|
|
|
} else {
|
|
|
|
|
$(".total-row").show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 결재상태에 따라 버튼 제어
|
|
|
|
|
fn_controlButtons();
|
|
|
|
|
|
|
|
|
|
@@ -1027,27 +1209,42 @@ function fn_loadTemplateData(templateObjId){
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 저장
|
|
|
|
|
// 고객사 담당자 정보 로드
|
|
|
|
|
function fn_loadCustomerContact(customerObjId) {
|
|
|
|
|
// 고객사 담당자 목록 로드
|
|
|
|
|
function fn_loadCustomerContact(customerObjId, selectedContact) {
|
|
|
|
|
if(!customerObjId || customerObjId === "") {
|
|
|
|
|
$("#contact_person").val("");
|
|
|
|
|
$("#contact_person").empty().append('<option value="">담당자 선택</option>');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: "/contractMgmt/getCustomerContactInfo.do",
|
|
|
|
|
url: "/contractMgmt/getCustomerManagerList.do",
|
|
|
|
|
type: "POST",
|
|
|
|
|
data: { customerObjId: customerObjId },
|
|
|
|
|
dataType: "json",
|
|
|
|
|
success: function(data) {
|
|
|
|
|
if(data && data.contactPerson) {
|
|
|
|
|
$("#contact_person").val(data.contactPerson + " 귀하");
|
|
|
|
|
$("#contact_person").empty();
|
|
|
|
|
$("#contact_person").append('<option value="">담당자 선택</option>');
|
|
|
|
|
|
|
|
|
|
if(data && data.managers && data.managers.length > 0) {
|
|
|
|
|
for(var i = 0; i < data.managers.length; i++) {
|
|
|
|
|
var manager = data.managers[i];
|
|
|
|
|
if(manager.name && manager.name !== "") {
|
|
|
|
|
$("#contact_person").append('<option value="' + manager.name + ' 귀하">' + manager.name + ' 귀하</option>');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$("#contact_person").val("구매 담당자님 귀하");
|
|
|
|
|
$("#contact_person").append('<option value="구매 담당자님 귀하">구매 담당자님 귀하</option>');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 저장된 수신인이 있으면 선택
|
|
|
|
|
if(selectedContact && selectedContact !== "") {
|
|
|
|
|
$("#contact_person").val(selectedContact);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
error: function() {
|
|
|
|
|
$("#contact_person").val("구매 담당자님 귀하");
|
|
|
|
|
$("#contact_person").empty();
|
|
|
|
|
$("#contact_person").append('<option value="">담당자 선택</option>');
|
|
|
|
|
$("#contact_person").append('<option value="구매 담당자님 귀하">구매 담당자님 귀하</option>');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
@@ -1066,10 +1263,10 @@ function fn_save() {
|
|
|
|
|
part_objid: row.find(".item-part-objid").val() || "", // part_objid 추가
|
|
|
|
|
description: row.find(".item-desc").val() || "",
|
|
|
|
|
specification: row.find(".item-spec").val() || "",
|
|
|
|
|
quantity: quantity.replace(/,/g, ""), // 콤마 제거
|
|
|
|
|
quantity: quantity.replace(/[^0-9]/g, ""), // 숫자만 추출
|
|
|
|
|
unit: row.find(".item-unit").val() || "",
|
|
|
|
|
unit_price: unitPrice.replace(/,/g, ""), // 콤마 제거
|
|
|
|
|
amount: amount.replace(/,/g, "").replace(/₩/g, ""), // 콤마와 ₩ 제거
|
|
|
|
|
unit_price: unitPrice.replace(/[^0-9]/g, ""), // 숫자만 추출
|
|
|
|
|
amount: amount.replace(/[^0-9]/g, ""), // 숫자만 추출
|
|
|
|
|
note: row.find(".item-note").val() || ""
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
@@ -1090,6 +1287,9 @@ function fn_save() {
|
|
|
|
|
// 디버깅: 품목 데이터 확인
|
|
|
|
|
console.log("저장할 품목 데이터:", items);
|
|
|
|
|
|
|
|
|
|
// 계 행 표시 여부 확인
|
|
|
|
|
var showTotalRow = $(".total-row").is(":visible") ? "Y" : "N";
|
|
|
|
|
|
|
|
|
|
var formData = {
|
|
|
|
|
objId: contractObjId,
|
|
|
|
|
template_type: "1",
|
|
|
|
|
@@ -1107,6 +1307,7 @@ function fn_save() {
|
|
|
|
|
note2: $("#note2").val(),
|
|
|
|
|
note3: $("#note3").val(),
|
|
|
|
|
note4: $("#note4").val(),
|
|
|
|
|
show_total_row: showTotalRow, // 계 행 표시 여부
|
|
|
|
|
items: JSON.stringify(items)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
@@ -1189,7 +1390,9 @@ function fn_save() {
|
|
|
|
|
<tr>
|
|
|
|
|
<td class="label">수신인</td>
|
|
|
|
|
<td class="editable">
|
|
|
|
|
<input type="text" id="contact_person" value="구매 담당자님 귀하" readonly style="background-color: #f5f5f5;">
|
|
|
|
|
<select id="contact_person" style="width: 100%; border: none; font-size: 9pt; padding: 2px;">
|
|
|
|
|
<option value="">담당자 선택</option>
|
|
|
|
|
</select>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
@@ -1258,12 +1461,12 @@ function fn_save() {
|
|
|
|
|
<td class="text-right editable"><input type="text" class="item-amount" value="" readonly></td>
|
|
|
|
|
<td class="editable"><input type="text" class="item-note" value=""></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<!-- 계 행 -->
|
|
|
|
|
<tr class="total-row">
|
|
|
|
|
<td colspan="6" style="text-align: center; font-weight: bold; background-color: #f0f0f0;">계</td>
|
|
|
|
|
<td class="text-right" style="font-weight: bold; background-color: #f0f0f0;"><span id="totalAmount">0</span></td>
|
|
|
|
|
<td style="background-color: #f0f0f0;"></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<!-- 계 행 -->
|
|
|
|
|
<tr class="total-row">
|
|
|
|
|
<td colspan="6" style="text-align: center; font-weight: bold; background-color: #f0f0f0;">계</td>
|
|
|
|
|
<td class="text-right" style="font-weight: bold; background-color: #f0f0f0;"><span id="totalAmount">0</span></td>
|
|
|
|
|
<td style="background-color: #f0f0f0; text-align: center;"><button type="button" class="btn-delete-total-row" style="padding: 2px 8px; font-size: 9pt; cursor: pointer;">삭제</button></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<!-- 원화환산 공급가액 행 (숨김) -->
|
|
|
|
|
<tr class="total-krw-row" style="display: none;">
|
|
|
|
|
<td colspan="6" style="text-align: center; font-weight: bold; background-color: #e8f4f8;">원화환산 공급가액 (KRW)</td>
|
|
|
|
|
|