@@ -201,11 +201,11 @@ const confirmModalMessage = ref("");
const confirmText = ref("Ya, Konfirmasi");
const cancelText = ref("Batal");
-// Barcode generator (Code128)
-const barcodeUrl = computed(() => {
+// QR Code generator
+const qrCodeUrl = computed(() => {
if (selectedItem.value) {
const data = selectedItem.value.kode_item;
- return `https://barcode.tec-it.com/barcode.ashx?data=${encodeURIComponent(data)}&code=Code128&dpi=96`;
+ return `https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=${encodeURIComponent(data)}`;
}
return "";
});
@@ -333,53 +333,56 @@ const handleConfirmAction = async () => {
// Fungsi utilitas
const printQR = () => {
- if (barcodeUrl.value) {
+ if (qrCodeUrl.value && selectedItem.value) {
const printWindow = window.open('', '_blank');
+ const itemCode = selectedItem.value.kode_item;
+
printWindow.document.write(`
-
-

+
+
- ${selectedItem.value.kode_item}
+
${itemCode}
+
${selectedItem.value.produk?.nama || ''}
+
${selectedItem.value.produk?.berat || ''}g
`);
+
printWindow.document.close();
+
+ const img = printWindow.document.getElementById("qr-img");
+ img.onload = () => {
+ printWindow.focus();
+ printWindow.print();
+ };
}
};
diff --git a/resources/js/components/CreateItemModal.vue b/resources/js/components/CreateItemModal.vue
index 63551ff..0bda8e4 100644
--- a/resources/js/components/CreateItemModal.vue
+++ b/resources/js/components/CreateItemModal.vue
@@ -102,11 +102,9 @@ const createdItem = ref(null);
// QR Code generator - berdasarkan logika dari brankas list
const qrCodeUrl = computed(() => {
if (createdItem.value && props.product) {
- const itemId = createdItem.value.kode_item || createdItem.value.id;
- const data = `${itemId}`;
-
- // Barcode Code128
- return `https://barcode.tec-it.com/barcode.ashx?data=${encodeURIComponent(data)}&code=Code128&dpi=96`;
+ const kode_item = createdItem.value.kode_item;
+ const data = kode_item;
+ return `https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=${encodeURIComponent(data)}`;
}
return "";
});
@@ -198,6 +196,10 @@ const printItem = () => {
display: inline-block;
margin: 20px;
}
+ .qr-img {
+ width: 200px;
+ height: 200px;
+ }
.item-info {
margin-top: 10px;
font-size: 14px;
@@ -206,7 +208,7 @@ const printItem = () => {
-

+
${itemCode}
${props.product.nama}
@@ -216,8 +218,14 @@ const printItem = () => {