feat: OTC 라벨 프리셋 삭제 기능 + 디버깅 로그 추가
This commit is contained in:
parent
b71d511c7a
commit
c154537c87
@ -191,6 +191,11 @@
|
|||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
.btn-print:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(99,102,241,0.3); }
|
.btn-print:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(99,102,241,0.3); }
|
||||||
|
.btn-delete {
|
||||||
|
background: #fee2e2;
|
||||||
|
color: #dc2626;
|
||||||
|
}
|
||||||
|
.btn-delete:hover { background: #fecaca; }
|
||||||
|
|
||||||
/* 미리보기 */
|
/* 미리보기 */
|
||||||
.preview-container {
|
.preview-container {
|
||||||
@ -334,6 +339,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
<button type="button" class="btn btn-print" onclick="printLabel()">🖨️ 인쇄</button>
|
<button type="button" class="btn btn-print" onclick="printLabel()">🖨️ 인쇄</button>
|
||||||
|
<button type="button" class="btn btn-delete" onclick="deleteLabel()">🗑️ 삭제</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
@ -503,21 +509,27 @@
|
|||||||
usage_tip: document.getElementById('usageTip').value
|
usage_tip: document.getElementById('usageTip').value
|
||||||
};
|
};
|
||||||
|
|
||||||
|
console.log('저장 payload:', payload);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await fetch('/api/admin/otc-labels', {
|
const res = await fetch('/api/admin/otc-labels', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify(payload)
|
body: JSON.stringify(payload)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log('저장 응답 status:', res.status);
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
|
console.log('저장 응답 data:', data);
|
||||||
|
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
showToast('저장 완료!', 'success');
|
showToast('저장 완료!', 'success');
|
||||||
loadLabelList();
|
loadLabelList();
|
||||||
} else {
|
} else {
|
||||||
showToast(data.error, 'error');
|
showToast(data.error || '알 수 없는 오류', 'error');
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
console.error('저장 오류:', err);
|
||||||
showToast('저장 오류: ' + err.message, 'error');
|
showToast('저장 오류: ' + err.message, 'error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -559,6 +571,43 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 삭제
|
||||||
|
async function deleteLabel() {
|
||||||
|
if (!currentBarcode) {
|
||||||
|
showToast('삭제할 프리셋이 없습니다', 'error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!confirm(`"${currentDrugName}" 프리셋을 삭제하시겠습니까?`)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const res = await fetch(`/api/admin/otc-labels/${currentBarcode}`, {
|
||||||
|
method: 'DELETE'
|
||||||
|
});
|
||||||
|
const data = await res.json();
|
||||||
|
|
||||||
|
if (data.success) {
|
||||||
|
showToast('삭제 완료!', 'success');
|
||||||
|
// 폼 초기화
|
||||||
|
currentBarcode = '';
|
||||||
|
currentDrugName = '';
|
||||||
|
document.getElementById('barcode').value = '';
|
||||||
|
document.getElementById('displayName').value = '';
|
||||||
|
document.getElementById('effect').value = '';
|
||||||
|
document.getElementById('dosageInstruction').value = '';
|
||||||
|
document.getElementById('usageTip').value = '';
|
||||||
|
document.getElementById('previewContainer').innerHTML = '<div class="preview-placeholder">미리보기를 클릭하면 라벨이 표시됩니다</div>';
|
||||||
|
loadLabelList();
|
||||||
|
} else {
|
||||||
|
showToast(data.error || '삭제 실패', 'error');
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
showToast('삭제 오류: ' + err.message, 'error');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 목록 로드
|
// 목록 로드
|
||||||
async function loadLabelList() {
|
async function loadLabelList() {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user