diff --git a/static/app.js b/static/app.js
index 672ab18..f1ad19f 100644
--- a/static/app.js
+++ b/static/app.js
@@ -254,7 +254,7 @@ $(document).ready(function() {
`);
} else {
- compounds.forEach(compound => {
+ compounds.forEach((compound, index) => {
// 상태 뱃지
let statusBadge = '';
switch(compound.status) {
@@ -271,8 +271,13 @@ $(document).ready(function() {
statusBadge = '대기';
}
+ const detailRowId = `compound-detail-${compound.compound_id}`;
+
tbody.append(`
-
+
+ |
+
+ |
${compound.compound_date || '-'} |
${compound.formula_name || '직접조제'} |
${compound.je_count || 0} |
@@ -282,20 +287,59 @@ $(document).ready(function() {
${formatCurrency(compound.sell_price_total || 0)} |
${statusBadge} |
${compound.prescription_no || '-'} |
-
-
+ |
+
+
+
+
+
+
+ 구성 약재
+
+
+ 재고 소비 내역
+
+
+
+
+
|
`);
});
- // 상세보기 버튼 이벤트
- $('.view-compound-detail').on('click', function() {
- const compoundId = $(this).data('id');
- viewCompoundDetail(compoundId);
+ // 행 클릭 이벤트 - 상세 정보 토글
+ $('.compound-row').on('click', function() {
+ const compoundId = $(this).data('compound-id');
+ const detailRow = $(`#compound-detail-${compoundId}`);
+ const icon = $(this).find('.toggle-icon');
+
+ if (detailRow.is(':visible')) {
+ // 닫기
+ detailRow.slideUp();
+ icon.removeClass('bi-chevron-down').addClass('bi-chevron-right');
+ } else {
+ // 열기 - 다른 모든 행 닫기
+ $('.collapse-row').slideUp();
+ $('.toggle-icon').removeClass('bi-chevron-down').addClass('bi-chevron-right');
+
+ // 현재 행 열기
+ detailRow.slideDown();
+ icon.removeClass('bi-chevron-right').addClass('bi-chevron-down');
+
+ // 상세 정보 로드
+ loadCompoundDetailInline(compoundId);
+ }
});
}
@@ -311,6 +355,70 @@ $(document).ready(function() {
});
}
+ // 환자 처방 내역 모달 내에서 조제 상세 정보 로드 (인라인)
+ function loadCompoundDetailInline(compoundId) {
+ $.get(`/api/compounds/${compoundId}`, function(response) {
+ if (response.success && response.data) {
+ const data = response.data;
+
+ // 구성 약재 테이블
+ let ingredientsHtml = '| 약재명 | 보험코드 | 첩당용량 | 총용량 |
';
+
+ if (data.ingredients && data.ingredients.length > 0) {
+ data.ingredients.forEach(ing => {
+ ingredientsHtml += `
+
+ | ${ing.herb_name} |
+ ${ing.insurance_code || '-'} |
+ ${ing.grams_per_cheop}g |
+ ${ing.total_grams}g |
+
+ `;
+ });
+ } else {
+ ingredientsHtml += '| 약재 정보가 없습니다 |
';
+ }
+ ingredientsHtml += '
';
+
+ $(`#ingredients-${compoundId}`).html(ingredientsHtml);
+
+ // 재고 소비 내역 테이블
+ let consumptionsHtml = '| 약재명 | 원산지 | 도매상 | 사용량 | 단가 | 원가 |
';
+
+ if (data.consumptions && data.consumptions.length > 0) {
+ let totalCost = 0;
+ data.consumptions.forEach(con => {
+ totalCost += con.cost_amount || 0;
+ consumptionsHtml += `
+
+ | ${con.herb_name} |
+ ${con.origin_country || '-'} |
+ ${con.supplier_name || '-'} |
+ ${con.quantity_used}g |
+ ${formatCurrency(con.unit_cost_per_g)}/g |
+ ${formatCurrency(con.cost_amount)} |
+
+ `;
+ });
+ consumptionsHtml += `
+
+ | 총 원가: |
+ ${formatCurrency(totalCost)} |
+
+ `;
+ } else {
+ consumptionsHtml += '| 재고 소비 내역이 없습니다 |
';
+ }
+ consumptionsHtml += '
';
+
+ $(`#consumptions-${compoundId}`).html(consumptionsHtml);
+ }
+ }).fail(function() {
+ $(`#ingredients-${compoundId}`).html('데이터를 불러오는데 실패했습니다.
');
+ $(`#consumptions-${compoundId}`).html('데이터를 불러오는데 실패했습니다.
');
+ });
+ }
+
// 처방 목록 로드
function loadFormulas() {
$.get('/api/formulas', function(response) {
@@ -847,7 +955,21 @@ $(document).ready(function() {
// 비고
$('#detailNotes').text(data.notes || '');
- // 모달 표시
+ // 부모 모달(환자 처방 내역)을 임시로 숨기고 조제 상세 모달 열기
+ const parentModal = $('#patientCompoundsModal');
+ const wasParentOpen = parentModal.hasClass('show');
+
+ if (wasParentOpen) {
+ // 부모 모달 숨기기 (DOM에서 제거하지 않음)
+ parentModal.modal('hide');
+
+ // 조제 상세 모달이 닫힐 때 부모 모달 다시 열기
+ $('#compoundDetailModal').off('hidden.bs.modal').on('hidden.bs.modal', function() {
+ parentModal.modal('show');
+ });
+ }
+
+ // 조제 상세 모달 열기
$('#compoundDetailModal').modal('show');
}
}).fail(function() {
diff --git a/templates/index.html b/templates/index.html
index 18c03fd..5a7da18 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -1088,9 +1088,10 @@
처방 내역
-
+
+ |
조제일 |
처방명 |
제수 |
@@ -1100,11 +1101,10 @@
판매가 |
상태 |
처방전번호 |
- 작업 |
-
+