From 888db7ffe7ed812d9ba3e0216517284012420650 Mon Sep 17 00:00:00 2001 From: terrylee Date: Thu, 16 Jul 2026 10:38:44 +0800 Subject: [PATCH] =?UTF-8?q?feat(app-ui):=20UI=E7=B5=84=E5=90=88=E7=B7=A8?= =?UTF-8?q?=E8=BC=AF/=E6=A9=9F=E5=8F=B0=E8=A8=AD=E5=AE=9A=20=E4=B9=9F?= =?UTF-8?q?=E5=8A=A0=E6=AF=8F=E9=A0=81=E7=AD=86=E6=95=B8+=E6=90=9C?= =?UTF-8?q?=E5=B0=8B+=E5=88=86=E9=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 抽共用元件 x-app-list-controls(3頁共用);bundles 依名稱、machines 依名稱/序號搜尋 paginate Co-Authored-By: Claude Opus 4.8 (1M context) --- .../Controllers/Admin/UiElementController.php | 32 +++++++++++++++---- lang/en.json | 2 ++ lang/zh_TW.json | 2 ++ .../admin/app/ui-bundles/index.blade.php | 6 ++++ .../admin/app/ui-elements/index.blade.php | 22 +------------ .../admin/app/ui-machines/index.blade.php | 2 ++ .../components/app-list-controls.blade.php | 29 +++++++++++++++++ 7 files changed, 68 insertions(+), 27 deletions(-) create mode 100644 resources/views/components/app-list-controls.blade.php diff --git a/app/Http/Controllers/Admin/UiElementController.php b/app/Http/Controllers/Admin/UiElementController.php index 6ed6a8f..57b7381 100644 --- a/app/Http/Controllers/Admin/UiElementController.php +++ b/app/Http/Controllers/Admin/UiElementController.php @@ -99,11 +99,19 @@ class UiElementController extends Controller // 頁籤二:UI 組合編輯 // ================================================================== - public function bundles() + public function bundles(Request $request) { - $bundles = UiBundle::orderBy('id')->get(); + $perPage = (int) $request->input('per_page', 10); + $perPage = in_array($perPage, [10, 25, 50, 100], true) ? $perPage : 10; + $search = trim((string) $request->input('search', '')); - return view('admin.app.ui-bundles.index', compact('bundles')); + $query = UiBundle::orderBy('id'); + if ($search !== '') { + $query->where('name', 'like', "%{$search}%"); + } + $bundles = $query->paginate($perPage)->withQueryString(); + + return view('admin.app.ui-bundles.index', compact('bundles', 'perPage', 'search')); } public function storeBundle(Request $request) @@ -186,16 +194,28 @@ class UiElementController extends Controller public function machines(Request $request) { - $machines = Machine::orderBy('name')->paginate(20); - $bundles = UiBundle::orderBy('name')->get(); + $perPage = (int) $request->input('per_page', 25); + $perPage = in_array($perPage, [10, 25, 50, 100], true) ? $perPage : 25; + $search = trim((string) $request->input('search', '')); - // 現有綁定名稱對照 + $query = Machine::orderBy('name'); + if ($search !== '') { + $query->where(function ($q) use ($search) { + $q->where('name', 'like', "%{$search}%") + ->orWhere('serial_no', 'like', "%{$search}%"); + }); + } + $machines = $query->paginate($perPage)->withQueryString(); + + $bundles = UiBundle::orderBy('name')->get(); $bundleNames = $bundles->pluck('name', 'id'); return view('admin.app.ui-machines.index', [ 'machines' => $machines, 'bundles' => $bundles, 'bundleNames' => $bundleNames, + 'perPage' => $perPage, + 'search' => $search, ]); } diff --git a/lang/en.json b/lang/en.json index 06a67c9..f3e1ffc 100644 --- a/lang/en.json +++ b/lang/en.json @@ -2350,6 +2350,8 @@ "No data": "No data", "entries": "entries", "Search name or category...": "Search name or category...", + "Search name...": "Search name...", + "Search machine or serial...": "Search machine or serial...", "Back": "Back", "Rename": "Rename", "Content Settings": "Content Settings", diff --git a/lang/zh_TW.json b/lang/zh_TW.json index 206969e..1aa78cb 100644 --- a/lang/zh_TW.json +++ b/lang/zh_TW.json @@ -2351,6 +2351,8 @@ "No data": "無資料", "entries": "筆", "Search name or category...": "搜尋名稱或類別…", + "Search name...": "搜尋名稱…", + "Search machine or serial...": "搜尋機台名稱或序號…", "Back": "返回", "Rename": "重新命名", "Content Settings": "內容設定", diff --git a/resources/views/admin/app/ui-bundles/index.blade.php b/resources/views/admin/app/ui-bundles/index.blade.php index ee34bec..8970254 100644 --- a/resources/views/admin/app/ui-bundles/index.blade.php +++ b/resources/views/admin/app/ui-bundles/index.blade.php @@ -9,6 +9,8 @@ + +
@@ -48,6 +50,10 @@
+
+ {{ $bundles->links() }} +
+ {{-- 新增組合 Modal --}}
diff --git a/resources/views/admin/app/ui-elements/index.blade.php b/resources/views/admin/app/ui-elements/index.blade.php index 2055969..d1a359f 100644 --- a/resources/views/admin/app/ui-elements/index.blade.php +++ b/resources/views/admin/app/ui-elements/index.blade.php @@ -9,27 +9,7 @@ - {{-- 控制列:每頁筆數 + 搜尋 --}} -
-
- {{ __('Show') }} - - {{ __('entries') }} -
-
- - - - - -
-
+
diff --git a/resources/views/admin/app/ui-machines/index.blade.php b/resources/views/admin/app/ui-machines/index.blade.php index 2812077..e71c224 100644 --- a/resources/views/admin/app/ui-machines/index.blade.php +++ b/resources/views/admin/app/ui-machines/index.blade.php @@ -4,6 +4,8 @@
+ +
diff --git a/resources/views/components/app-list-controls.blade.php b/resources/views/components/app-list-controls.blade.php new file mode 100644 index 0000000..e228174 --- /dev/null +++ b/resources/views/components/app-list-controls.blade.php @@ -0,0 +1,29 @@ +{{-- APP UI元素設定 列表控制列:每頁筆數下拉(左)+ 搜尋欄/重置(右)。一般 GET 表單(非 AJAX)。 + 用法: --}} +@props([ + 'route' => '', + 'perPage' => 10, + 'search' => '', + 'placeholder' => '', +]) + +
+
+ {{ __('Show') }} + + {{ __('entries') }} +
+
+ + + + + +
+