[PROMOTE] dev -> demo: 取貨碼列表以商品為主顯示
1. [FIX] 取貨碼列表改以商品為主:綁商品碼直接顯示商品名、不再顯示空貨道;綁貨道碼(舊)維持反查商品名並保留貨道號。 2. pickupCodes 查詢補 product eager load 避免 N+1,標題改為「商品」。
This commit is contained in:
commit
1ace7da140
@ -376,7 +376,7 @@ class SalesController extends Controller
|
||||
// 1. 取貨碼列表 (list)
|
||||
if (!$isAjax || $tab === 'list') {
|
||||
// 僅顯示目前帳號可存取機台的取貨碼(機台授權以 machine_user 為準,whereHas 會套用 Machine 的 machine_access 全域 scope)
|
||||
$query = PickupCode::with(['machine.slots.product', 'creator', 'order'])
|
||||
$query = PickupCode::with(['machine.slots.product', 'product', 'creator', 'order'])
|
||||
->whereHas('machine')
|
||||
->latest();
|
||||
|
||||
|
||||
@ -80,7 +80,7 @@
|
||||
</th>
|
||||
<th
|
||||
class="px-6 py-4 text-xs font-bold text-slate-500 dark:text-slate-400 uppercase tracking-[0.15em] border-b border-slate-100 dark:border-slate-800">
|
||||
{{ __('Product / Slot') }}
|
||||
{{ __('Product') }}
|
||||
</th>
|
||||
<th
|
||||
class="px-6 py-4 text-xs font-bold text-slate-500 dark:text-slate-400 uppercase tracking-[0.15em] border-b border-slate-100 dark:border-slate-800">
|
||||
@ -125,15 +125,25 @@
|
||||
</td>
|
||||
<td class="px-6 py-6">
|
||||
@php
|
||||
$slot = $code->machine?->slots->where('slot_no', $code->slot_no)->first();
|
||||
$productName = $slot ? ($slot->product?->name ?? __('Empty')) : __('Empty');
|
||||
// 綁商品碼(新):直接取 product 名稱,不顯示貨道。
|
||||
// 綁貨道碼(舊,向後相容):由貨道反查商品,並保留貨道資訊。
|
||||
if ($code->product_id) {
|
||||
$productName = $code->product?->name ?? __('Empty');
|
||||
$slotLabel = null;
|
||||
} else {
|
||||
$slot = $code->machine?->slots->where('slot_no', $code->slot_no)->first();
|
||||
$productName = $slot ? ($slot->product?->name ?? __('Empty')) : __('Empty');
|
||||
$slotLabel = $code->slot_no;
|
||||
}
|
||||
@endphp
|
||||
<div class="text-sm font-black text-cyan-600 dark:text-cyan-400 mb-0.5">{{
|
||||
$productName
|
||||
}}</div>
|
||||
@if($slotLabel)
|
||||
<div class="text-xs font-bold text-slate-400 uppercase tracking-widest">{{
|
||||
__('Slot')
|
||||
}}: {{ $code->slot_no }}</div>
|
||||
}}: {{ $slotLabel }}</div>
|
||||
@endif
|
||||
</td>
|
||||
<td class="px-6 py-6 whitespace-nowrap">
|
||||
<div class="text-sm font-black text-slate-600 dark:text-slate-300">
|
||||
@ -281,19 +291,24 @@
|
||||
<div
|
||||
class="grid grid-cols-2 gap-y-4 mb-6 border-y border-slate-100 dark:border-slate-800/50 py-4">
|
||||
<div>
|
||||
@php
|
||||
if ($code->product_id) {
|
||||
$prodMobile = $code->product?->name ?? __('Empty');
|
||||
$slotMobileLabel = null;
|
||||
} else {
|
||||
$slotMobile = $code->machine?->slots->where('slot_no', $code->slot_no)->first();
|
||||
$prodMobile = $slotMobile ? ($slotMobile->product?->name ?? __('Empty')) : __('Empty');
|
||||
$slotMobileLabel = $code->slot_no;
|
||||
}
|
||||
@endphp
|
||||
<p
|
||||
class="text-[10px] font-black text-slate-400 dark:text-slate-500 uppercase tracking-widest mb-1">
|
||||
{{ __('Slot') }}</p>
|
||||
{{ __('Product') }}</p>
|
||||
<p class="text-sm font-bold text-slate-700 dark:text-slate-300">
|
||||
{{ $code->slot_no }}
|
||||
@php
|
||||
$slotMobile = $code->machine?->slots->where('slot_no',
|
||||
$code->slot_no)->first();
|
||||
$prodMobile = $slotMobile ? ($slotMobile->product?->name ?? __('Empty')) :
|
||||
__('Empty');
|
||||
@endphp
|
||||
<span class="ml-1 text-cyan-600 dark:text-cyan-400">({{ $prodMobile
|
||||
}})</span>
|
||||
<span class="text-cyan-600 dark:text-cyan-400">{{ $prodMobile }}</span>
|
||||
@if($slotMobileLabel)
|
||||
<span class="ml-1 text-[10px] text-slate-400">{{ __('Slot') }}: {{ $slotMobileLabel }}</span>
|
||||
@endif
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user