From 8c2be8945d407bfe204ef9fc780f5a985f55c013 Mon Sep 17 00:00:00 2001 From: Yoga Pangestu Date: Thu, 18 Jun 2026 01:25:53 +0700 Subject: [PATCH] feat: enhance order creation and editing with print options and customer creation event handling --- .../Admin/Manage/OrderController.php | 9 ++- .../admin/manage/orders/OrderPosForm.vue | 41 ++++++++++- .../js/pages/admin/manage/orders/Create.vue | 10 ++- .../js/pages/admin/manage/orders/Edit.vue | 9 ++- .../js/pages/admin/manage/orders/Index.vue | 69 ++++++++++++++----- 5 files changed, 114 insertions(+), 24 deletions(-) diff --git a/app/Http/Controllers/Admin/Manage/OrderController.php b/app/Http/Controllers/Admin/Manage/OrderController.php index 429feaf..b665627 100644 --- a/app/Http/Controllers/Admin/Manage/OrderController.php +++ b/app/Http/Controllers/Admin/Manage/OrderController.php @@ -57,7 +57,14 @@ public function store(OrderRequest $request): RedirectResponse $this->flashCreated('Pesanan'); - return redirect()->route('admin.manage.orders.index'); + $params = []; + + if ($request->boolean('print')) { + $params['print'] = 1; + $params['paper_size'] = $request->input('paper_size', '80mm'); + } + + return redirect()->route('admin.manage.orders.index', $params); } public function edit(Order $order): Response|RedirectResponse diff --git a/resources/js/components/admin/manage/orders/OrderPosForm.vue b/resources/js/components/admin/manage/orders/OrderPosForm.vue index f9c5e7c..7899200 100644 --- a/resources/js/components/admin/manage/orders/OrderPosForm.vue +++ b/resources/js/components/admin/manage/orders/OrderPosForm.vue @@ -3,9 +3,9 @@ import { useForm, usePage } from '@inertiajs/vue3'; import { Minus, Plus, Save, Search, ShoppingCart, Trash2 } from '@lucide/vue'; import { computed, ref, watch } from 'vue'; import { toast } from 'vue-sonner'; +import CustomerQuickCreateModal from '@/components/admin/manage/orders/CustomerQuickCreateModal.vue'; import PosCatalogCard from '@/components/admin/manage/PosCatalogCard.vue'; import PosCatalogVariantThumb from '@/components/admin/manage/PosCatalogVariantThumb.vue'; -import CustomerQuickCreateModal from '@/components/admin/manage/orders/CustomerQuickCreateModal.vue'; import { NumberInput } from '@/components/form/number-input'; import { RupiahInput } from '@/components/form/rupiah-input'; import { Button } from '@/components/ui/button'; @@ -24,6 +24,7 @@ import { FieldSet, } from '@/components/ui/field'; import { Input } from '@/components/ui/input'; +import { Label } from '@/components/ui/label'; import { Select, SelectContent, @@ -35,10 +36,10 @@ import { import { Separator } from '@/components/ui/separator'; import { Switch } from '@/components/ui/switch'; import { Textarea } from '@/components/ui/textarea'; +import { useCan } from '@/composables/useCan'; import { OrderChannel } from '@/constants/order-channel'; import { apiFetch } from '@/lib/api'; import { getFirstCoverImage } from '@/lib/catalog-cover'; -import { useCan } from '@/composables/useCan'; import { formErrors } from '@/lib/form'; import { formatRupiah, parseRupiah } from '@/lib/rupiah'; import type { Auth } from '@/types/auth'; @@ -71,6 +72,10 @@ const props = defineProps<{ submitLabel: string; }>(); +const emit = defineEmits<{ + 'customer-created': [customer: { id: number; name: string }]; +}>(); + const isCreateMode = computed(() => props.method === 'post'); const { can } = useCan(); @@ -84,9 +89,11 @@ const isMarketingUser = computed(() => const search = ref(''); const cart = ref([]); const customerFormOpen = ref(false); +const printAfterSave = ref(false); +const selectedPaperSize = ref<'58mm' | '80mm'>('80mm'); function onCustomerCreated(customer: { id: number; name: string }) { - props.customers.push({ value: customer.id, label: customer.name }); + emit('customer-created', customer); form.customer_id = String(customer.id); } @@ -396,6 +403,11 @@ function buildFormData(): FormData { formData.append('discount', parseRupiah(form.discount)); formData.append('notes', form.notes); + if (isCreateMode.value && printAfterSave.value) { + formData.append('print', '1'); + formData.append('paper_size', selectedPaperSize.value); + } + if (props.method === 'put') { cart.value.forEach((item, index) => { formData.append(`items[${index}][product_variant_id]`, String(item.product_variant_id)); @@ -733,6 +745,29 @@ function submit() { + +
+ + +
+
+ Ukuran kertas: +
+ +
+
+
+