[FIX] 修復商品報表篩選 UI 邏輯與選項選取狀態

1. 調整商品報表篩選區塊順序,將「公司篩選」移至「商品篩選」前方,符合依公司過濾商品的操作邏輯。
2. 修復 <x-searchable-select> 在透過 slot 傳入選項時,無法正確綁定 selected 狀態的問題,手動於 <option> 標籤中補上選取狀態判斷。
This commit is contained in:
sky121113 2026-05-18 15:51:45 +08:00
parent e4c63bbf38
commit 46e8bdfaae

View File

@ -138,29 +138,29 @@
</div> </div>
</div> </div>
<!-- Product Selection -->
<div class="w-full sm:w-48 relative focus-within:z-[30]">
<x-searchable-select name="product_id" id="product_id" :placeholder="__('All Products (ALL)')" :selected="$selectedProductId"
@change="selectedProductId = ($event.target.value && $event.target.value.trim() !== '') ? $event.target.value.trim() : 'ALL'; fetchData()">
@foreach($products as $p)
<option value="{{ $p->id }}" data-title="{{ $p->name }}{{ $p->barcode ? ' (' . $p->barcode . ')' : '' }}">
{{ $p->name }}{{ $p->barcode ? ' (' . $p->barcode . ')' : '' }}
</option>
@endforeach
</x-searchable-select>
</div>
<!-- Company Selection (Super Admin only) --> <!-- Company Selection (Super Admin only) -->
@if(auth()->user()->isSystemAdmin()) @if(auth()->user()->isSystemAdmin())
<div class="w-full sm:w-48 relative focus-within:z-[30]"> <div class="w-full sm:w-48 relative focus-within:z-[30]">
<x-searchable-select name="company_id" id="company_id" :placeholder="__('All Companies')" :selected="$selectedCompanyId" <x-searchable-select name="company_id" id="company_id" :placeholder="__('All Companies')" :selected="$selectedCompanyId"
@change="companyChanged($event.target.value)"> @change="companyChanged($event.target.value)">
@foreach($companies as $c) @foreach($companies as $c)
<option value="{{ $c->id }}" data-title="{{ $c->name }}">{{ $c->name }}</option> <option value="{{ $c->id }}" {{ (string)$selectedCompanyId === (string)$c->id ? 'selected' : '' }} data-title="{{ $c->name }}">{{ $c->name }}</option>
@endforeach @endforeach
</x-searchable-select> </x-searchable-select>
</div> </div>
@endif @endif
<!-- Product Selection -->
<div class="w-full sm:w-48 relative focus-within:z-[30]">
<x-searchable-select name="product_id" id="product_id" :placeholder="__('All Products (ALL)')" :selected="$selectedProductId"
@change="selectedProductId = ($event.target.value && $event.target.value.trim() !== '') ? $event.target.value.trim() : 'ALL'; fetchData()">
@foreach($products as $p)
<option value="{{ $p->id }}" {{ (string)$selectedProductId === (string)$p->id ? 'selected' : '' }} data-title="{{ $p->name }}{{ $p->barcode ? ' (' . $p->barcode . ')' : '' }}">
{{ $p->name }}{{ $p->barcode ? ' (' . $p->barcode . ')' : '' }}
</option>
@endforeach
</x-searchable-select>
</div>
</div> </div>
</div> </div>