fix: 로트 배분 모달 필요량 0 표시 버그 수정

문제:
- 원산지 선택에서 "수동 배분" 선택 시 필요량이 0으로 표시
- loadOriginOptions 함수 호출 시점의 requiredQty를 그대로 사용

해결:
- 모달 열기 시점에 현재 행의 실제 필요량 재계산
- gramsPerCheop × cheopTotal로 실시간 계산
- 디버깅 로그 추가로 값 확인 가능

이제 첩수나 용량이 변경된 후에도 정확한 필요량이 모달에 표시됩니다.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
시골약사 2026-02-17 02:23:37 +00:00
parent 7d2b458e31
commit 3f4b9c816a
2 changed files with 88 additions and 2 deletions

View File

@ -1871,8 +1871,13 @@ $(document).ready(function() {
const row = $(this).closest('tr');
if (selectedValue === 'manual') {
// 수동 배분 모달 열기
openLotAllocationModal(herbId, requiredQty, row, response.data);
// 현재 행의 실제 필요량 재계산
const gramsPerCheop = parseFloat(row.find('.grams-per-cheop').val()) || 0;
const cheopTotal = parseFloat($('#cheopTotal').val()) || 0;
const actualRequiredQty = gramsPerCheop * cheopTotal;
// 수동 배분 모달 열기 (재계산된 필요량 사용)
openLotAllocationModal(herbId, actualRequiredQty, row, response.data);
} else {
// 기존 자동/원산지 선택 - lot_assignments 제거
row.removeAttr('data-lot-assignments');
@ -2552,6 +2557,15 @@ $(document).ready(function() {
// 로트 배분 모달 열기
window.openLotAllocationModal = function(herbId, requiredQty, row, data) {
// 디버깅: 전달받은 필요량 확인
console.log('로트 배분 모달 열기:', {
herbId: herbId,
requiredQty: requiredQty,
herbName: data.herb_name,
gramsPerCheop: row.find('.grams-per-cheop').val(),
cheopTotal: $('#cheopTotal').val()
});
currentLotAllocation = {
herbId: herbId,
requiredQty: requiredQty,

72
test_lot_modal.html Normal file
View File

@ -0,0 +1,72 @@
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<title>로트 배분 모달 테스트</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
</head>
<body>
<div class="container mt-5">
<h2>로트 배분 필요량 테스트</h2>
<div class="card mt-3">
<div class="card-body">
<h5 class="card-title">시나리오 테스트</h5>
<div class="row mt-3">
<div class="col-md-3">
<label>첩당 용량 (g)</label>
<input type="number" class="form-control" id="testGramsPerCheop" value="2.2" step="0.1">
</div>
<div class="col-md-3">
<label>총 첩수</label>
<input type="number" class="form-control" id="testCheopTotal" value="10" step="1">
</div>
<div class="col-md-3">
<label>계산된 필요량</label>
<input type="text" class="form-control" id="calculatedQty" readonly>
</div>
<div class="col-md-3">
<button class="btn btn-primary mt-4" onclick="calculateAndShow()">계산 및 확인</button>
</div>
</div>
<div id="result" class="mt-3"></div>
</div>
</div>
</div>
<script>
function calculateAndShow() {
const gramsPerCheop = parseFloat($('#testGramsPerCheop').val()) || 0;
const cheopTotal = parseFloat($('#testCheopTotal').val()) || 0;
const requiredQty = gramsPerCheop * cheopTotal;
$('#calculatedQty').val(requiredQty.toFixed(1) + 'g');
$('#result').html(`
<div class="alert alert-info">
<h6>계산 결과:</h6>
<ul>
<li>첩당 용량: ${gramsPerCheop}g</li>
<li>총 첩수: ${cheopTotal}첩</li>
<li><strong>필요량: ${requiredQty.toFixed(1)}g</strong></li>
</ul>
<p class="mb-0 mt-2">
<strong>테스트:</strong> 2.2g × 10첩 = 22g가 모달에 정상적으로 전달되어야 합니다.
</p>
</div>
`);
}
// 초기 계산
$(document).ready(function() {
calculateAndShow();
$('#testGramsPerCheop, #testCheopTotal').on('input', calculateAndShow);
});
</script>
</body>
</html>