Compare commits

..

No commits in common. "bd07755a0f601dc65069e17e59ea98bd2d308af4" and "e4e98e3f980d2b2e1a1a47886bc036bbf6200569" have entirely different histories.

4 changed files with 35 additions and 80 deletions

View File

@ -340,50 +340,40 @@ const printQR = () => {
<head> <head>
<title>Print QR Code - ${selectedItem.value.kode_item}</title> <title>Print QR Code - ${selectedItem.value.kode_item}</title>
<style> <style>
@page {
size: 60mm 50mm;
margin: 1mm;
}
body { body {
font-family: Arial, sans-serif; font-family: Arial, sans-serif;
text-align: center; text-align: center;
margin: 0; padding: 20px;
padding: 0;
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
} }
.qr-container { .qr-container {
text-align: center; border: 2px solid #ccc;
} padding: 20px;
.qr-img { display: inline-block;
width: 40mm; margin: 20px;
height: 40mm;
margin-bottom: 2mm;
} }
.item-info { .item-info {
font-size: 14pt; margin-top: 10px;
font-weight: bold; font-size: 14px;
} }
</style> </style>
</head> </head>
<body> <body>
<div class="qr-container"> <div class="qr-container">
<img class="qr-img" src="${qrCodeUrl.value}" alt="QR Code" <img src="${qrCodeUrl.value}" alt="QR Code" style="width: 200px; height: 200px;" />
onload="window.print()" />
<div class="item-info"> <div class="item-info">
${selectedItem.value.kode_item} <div style="font-weight: bold; margin-bottom: 5px;">${selectedItem.value.kode_item}</div>
<div>${selectedItem.value.produk.nama}</div>
<div style="color: #666; margin-top: 5px;">${selectedItem.value.produk.berat}g</div>
</div> </div>
</div> </div>
</body> </body>
</html> </html>
`); `);
printWindow.document.close(); printWindow.document.close();
printWindow.print();
} }
}; };
const handleImageError = (event) => { const handleImageError = (event) => {
event.target.style.display = 'none'; event.target.style.display = 'none';
}; };

View File

@ -87,7 +87,7 @@ const props = defineProps({
}); });
// Emits // Emits
const emit = defineEmits(['close','itemAdded']); const emit = defineEmits(['close']);
// State // State
const selectedNampan = ref(''); const selectedNampan = ref('');
@ -147,17 +147,15 @@ const createItem = async () => {
} }
const response = await axios.post('/api/item', payload, { const response = await axios.post('/api/item', payload, {
headers: { headers: {
Authorization: `Bearer ${localStorage.getItem("token")}`, Authorization: `Bearer ${localStorage.getItem("token")}`,
}, },
}); });;
success.value = true; success.value = true;
createdItem.value = response.data.data; createdItem.value = response.data.data
console.log('Item created:', createdItem); console.log('Item created:', createdItem);
emit('itemAdded'); // 🔔 penting
loadNampanList(); loadNampanList();
} catch (error) { } catch (error) {
console.error('Error creating item:', error); console.error('Error creating item:', error);
@ -167,7 +165,6 @@ const createItem = async () => {
} }
}; };
const addNewItem = () => { const addNewItem = () => {
success.value = false; success.value = false;
selectedNampan.value = ''; selectedNampan.value = '';

View File

@ -185,57 +185,40 @@ const printQR = () => {
<head> <head>
<title>Print QR Code - ${selectedItem.value.kode_item}</title> <title>Print QR Code - ${selectedItem.value.kode_item}</title>
<style> <style>
@page {
size: 60mm 50mm;
margin: 1mm;
}
* {
margin: 0;
padding: 0;
}
body { body {
font-family: Arial, sans-serif; font-family: Arial, sans-serif;
display: flex; text-align: center;
align-items: center; padding: 20px;
justify-content: center;
height: 100vh;
width: 100vw;
} }
.qr-container { .qr-container {
text-align: center; border: 2px solid #ccc;
width: 100%; padding: 20px;
display: inline-block;
margin: 20px;
} }
.qr-img { .item-info {
width: 40mm; margin-top: 10px;
height: 40mm; font-size: 14px;
margin-bottom: 2mm;
}
.kode-item {
font-weight: bold;
font-size: 14pt;
} }
</style> </style>
</head> </head>
<body> <body>
<div class="qr-container"> <div class="qr-container">
<img id="qr-img" class="qr-img" src="${qrCodeUrl.value}" alt="QR Code" /> <img src="${qrCodeUrl.value}" alt="QR Code" style="width: 200px; height: 200px;" />
<div class="kode-item">${selectedItem.value.kode_item}</div> <div class="item-info">
<div style="font-weight: bold; margin-bottom: 5px;">${selectedItem.value.kode_item}</div>
<div>${selectedItem.value.produk.nama}</div>
<div style="color: #666; margin-top: 5px;">${selectedItem.value.produk.berat}g</div>
</div>
</div> </div>
</body> </body>
</html> </html>
`); `);
printWindow.document.close(); printWindow.document.close();
printWindow.print();
const img = printWindow.document.getElementById("qr-img");
img.onload = () => {
printWindow.focus();
printWindow.print();
};
} }
}; };
const showDeleteConfirm = ref(false); const showDeleteConfirm = ref(false);
const confirmDelete = async () => { const confirmDelete = async () => {

View File

@ -1,13 +1,7 @@
<template> <template>
<mainLayout> <mainLayout>
<!-- Modal Buat Item --> <!-- Modal Buat Item -->
<CreateItemModal <CreateItemModal :isOpen="creatingItem" :product="detail" @close="closeItemModal" />
:isOpen="creatingItem"
:product="detail"
@close="closeItemModal"
@itemAdded="handleItemAdded"
/>
<!-- Modal Konfirmasi Hapus Produk --> <!-- Modal Konfirmasi Hapus Produk -->
<ConfirmDeleteModal :isOpen="deleting" @cancel="deleting = false" @confirm="deleteProduk" title="Hapus Produk" <ConfirmDeleteModal :isOpen="deleting" @cancel="deleting = false" @confirm="deleteProduk" title="Hapus Produk"
@ -274,15 +268,6 @@ function formatNumber(num) {
return new Intl.NumberFormat().format(num || 0); return new Intl.NumberFormat().format(num || 0);
} }
function handleItemAdded() {
if (detail.value) {
detail.value.items_count++;
}
creatingItem.value = false;
}
// Hapus produk // Hapus produk
async function deleteProduk() { async function deleteProduk() {
try { try {