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