[PROMOTE] 晉升 dev 至 demo 環境
1. [FIX] 修正機台設定公司篩選下拉選單兩項問題:選取後自動觸發 AJAX 篩選、重設按鈕透過 HSSelect.setValue() 正確清除 Preline 下拉選單 UI、調整 Preline autoInit 與 Alpine initTree 初始化順序以 requestAnimationFrame 確保 DOM 更新完畢後才執行 Alpine。 2. [FIX] 補強公司篩選下拉選單 AJAX 後選中狀態顯示:option 元素補上 server-side selected 屬性、fetchTabContent 完成後主動呼叫 HSSelect.setValue() 強制同步顯示文字。
This commit is contained in:
commit
43989ada2d
@ -230,10 +230,11 @@
|
|||||||
|
|
||||||
<!-- 公司篩選下拉選單 (僅 System Admin 可見) -->
|
<!-- 公司篩選下拉選單 (僅 System Admin 可見) -->
|
||||||
@if(auth()->user()->isSystemAdmin())
|
@if(auth()->user()->isSystemAdmin())
|
||||||
<div class="w-full md:w-64 relative focus-within:z-[20]">
|
<div class="w-full md:w-64 relative focus-within:z-[20]"
|
||||||
|
@change="$el.closest('form').dispatchEvent(new Event('submit'))">
|
||||||
<x-searchable-select name="filter_company_id" :placeholder="__('All Companies')" :selected="request('filter_company_id')">
|
<x-searchable-select name="filter_company_id" :placeholder="__('All Companies')" :selected="request('filter_company_id')">
|
||||||
@foreach($allCompanies as $c)
|
@foreach($allCompanies as $c)
|
||||||
<option value="{{ $c->id }}" data-title="{{ $c->name }}">{{ $c->name }}</option>
|
<option value="{{ $c->id }}" data-title="{{ $c->name }}" {{ (string)request('filter_company_id') === (string)$c->id ? 'selected' : '' }}>{{ $c->name }}</option>
|
||||||
@endforeach
|
@endforeach
|
||||||
</x-searchable-select>
|
</x-searchable-select>
|
||||||
</div>
|
</div>
|
||||||
@ -244,7 +245,19 @@
|
|||||||
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24" stroke-width="2.5"><path stroke-linecap="round" stroke-linejoin="round" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"/></svg>
|
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24" stroke-width="2.5"><path stroke-linecap="round" stroke-linejoin="round" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"/></svg>
|
||||||
</button>
|
</button>
|
||||||
<button type="button"
|
<button type="button"
|
||||||
@click="$el.closest('form').querySelector('input[name=search_machine]').value=''; @if(auth()->user()->isSystemAdmin()) $el.closest('form').querySelector('select[name=filter_company_id]').value=''; @endif $el.closest('form').dispatchEvent(new Event('submit'));"
|
@click="
|
||||||
|
const form = $el.closest('form');
|
||||||
|
form.querySelector('input[name=search_machine]').value = '';
|
||||||
|
@if(auth()->user()->isSystemAdmin())
|
||||||
|
const nativeSel = form.querySelector('select[name=filter_company_id]');
|
||||||
|
if (nativeSel) {
|
||||||
|
nativeSel.value = ' ';
|
||||||
|
const inst = window.HSSelect?.getInstance(nativeSel);
|
||||||
|
if (inst) inst.setValue(' ');
|
||||||
|
}
|
||||||
|
@endif
|
||||||
|
form.dispatchEvent(new Event('submit'));
|
||||||
|
"
|
||||||
class="p-2.5 rounded-xl bg-slate-100 dark:bg-slate-800 text-slate-500 hover:bg-slate-200 dark:hover:bg-slate-700 transition-all" title="{{ __('Reset') }}">
|
class="p-2.5 rounded-xl bg-slate-100 dark:bg-slate-800 text-slate-500 hover:bg-slate-200 dark:hover:bg-slate-700 transition-all" title="{{ __('Reset') }}">
|
||||||
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24" stroke-width="2.5"><path stroke-linecap="round" stroke-linejoin="round" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"/></svg>
|
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24" stroke-width="2.5"><path stroke-linecap="round" stroke-linejoin="round" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"/></svg>
|
||||||
</button>
|
</button>
|
||||||
@ -1265,8 +1278,18 @@
|
|||||||
if (newContent && container) {
|
if (newContent && container) {
|
||||||
container.innerHTML = newContent.innerHTML;
|
container.innerHTML = newContent.innerHTML;
|
||||||
window.history.pushState({}, '', url);
|
window.history.pushState({}, '', url);
|
||||||
|
// 先讓 Preline (HSSelect 等) 初始化完成,再由 Alpine 接管
|
||||||
if (window.HSStaticMethods?.autoInit) window.HSStaticMethods.autoInit();
|
if (window.HSStaticMethods?.autoInit) window.HSStaticMethods.autoInit();
|
||||||
if (window.Alpine?.initTree) window.Alpine.initTree(container);
|
// Re-sync company filter HSSelect display after AJAX DOM replacement.
|
||||||
|
const filterSelect = container.querySelector('select[name="filter_company_id"]');
|
||||||
|
if (filterSelect) {
|
||||||
|
const selectedValue = (filterSelect.value ?? '').trim();
|
||||||
|
const hsSelect = window.HSSelect?.getInstance(filterSelect);
|
||||||
|
if (hsSelect) hsSelect.setValue(selectedValue || ' ');
|
||||||
|
}
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
if (window.Alpine?.initTree) window.Alpine.initTree(container);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('AJAX Load Failed:', e);
|
console.error('AJAX Load Failed:', e);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user