[FIX] 修正 IoT 管理介面分頁持久化與實作 B055 遠端出貨 API
All checks were successful
star-cloud-deploy-demo / deploy-demo (push) Successful in 3m58s
All checks were successful
star-cloud-deploy-demo / deploy-demo (push) Successful in 3m58s
1. 視圖持久化優化:將 index/stock 視圖切換從 x-if 改為 x-show,解決 HSSelect 在切換分頁後失效的問題。 2. 變數存取安全:為所有 selectedMachine 屬性存取補上可選鏈 (?.) 保護,防止 x-show 模式下的 null 錯誤。 3. UI 體驗提升:放大「指令中心」與「庫存管理」歷史紀錄的時間字體至 15px 並加粗顯示。 4. API 功能實作:在 routes/api.php 與 MachineController 中實作 B055 遠端指令出貨控制端點。 5. 文件同步:更新 SKILL.md 技術規格文件,明確定義 B055 的請求與回應格式。 6. 樣式調整:修改 app.css 優化奢華風 UI 字體與間距細節。
This commit is contained in:
@@ -17,7 +17,49 @@ class RemoteController extends Controller
|
||||
{
|
||||
$machines = Machine::withCount(['slots'])->orderBy('last_heartbeat_at', 'desc')->orderBy('id', 'desc')->get();
|
||||
$selectedMachine = null;
|
||||
$history = RemoteCommand::where('command_type', '!=', 'reload_stock')->with(['machine', 'user'])->latest()->limit(50)->get();
|
||||
|
||||
$historyQuery = RemoteCommand::where('command_type', '!=', 'reload_stock')
|
||||
->with(['machine', 'user']);
|
||||
|
||||
if ($request->filled('search')) {
|
||||
$search = $request->input('search');
|
||||
$historyQuery->where(function($q) use ($search) {
|
||||
$q->whereHas('machine', function($mq) use ($search) {
|
||||
$mq->where('name', 'like', "%{$search}%")
|
||||
->orWhere('serial_no', 'like', "%{$search}%");
|
||||
})->orWhereHas('user', function($uq) use ($search) {
|
||||
$uq->where('name', 'like', "%{$search}%");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// 時間區間過濾 (created_at)
|
||||
if ($request->filled('start_date') || $request->filled('end_date')) {
|
||||
try {
|
||||
if ($request->filled('start_date')) {
|
||||
$start = \Illuminate\Support\Carbon::parse($request->input('start_date'));
|
||||
$historyQuery->where('created_at', '>=', $start);
|
||||
}
|
||||
if ($request->filled('end_date')) {
|
||||
$end = \Illuminate\Support\Carbon::parse($request->input('end_date'));
|
||||
$historyQuery->where('created_at', '<=', $end);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
// 忽略解析錯誤
|
||||
}
|
||||
}
|
||||
|
||||
// 指令類型過濾
|
||||
if ($request->filled('command_type')) {
|
||||
$historyQuery->where('command_type', $request->input('command_type'));
|
||||
}
|
||||
|
||||
// 狀態過濾
|
||||
if ($request->filled('status')) {
|
||||
$historyQuery->where('status', $request->input('status'));
|
||||
}
|
||||
|
||||
$history = $historyQuery->latest()->paginate($request->input('per_page', 10));
|
||||
|
||||
if ($request->has('machine_id')) {
|
||||
$selectedMachine = Machine::with(['slots.product', 'commands' => function($query) {
|
||||
@@ -112,7 +154,44 @@ class RemoteController extends Controller
|
||||
}
|
||||
])->orderBy('last_heartbeat_at', 'desc')->orderBy('id', 'desc')->get();
|
||||
|
||||
$history = RemoteCommand::where('command_type', 'reload_stock')->with(['machine', 'user'])->latest()->limit(50)->get();
|
||||
$historyQuery = RemoteCommand::with(['machine', 'user']);
|
||||
|
||||
$historyQuery->where('command_type', 'reload_stock');
|
||||
|
||||
if ($request->filled('search')) {
|
||||
$search = $request->input('search');
|
||||
$historyQuery->where(function($q) use ($search) {
|
||||
$q->whereHas('machine', function($mq) use ($search) {
|
||||
$mq->where('name', 'like', "%{$search}%")
|
||||
->orWhere('serial_no', 'like', "%{$search}%");
|
||||
})->orWhereHas('user', function($uq) use ($search) {
|
||||
$uq->where('name', 'like', "%{$search}%");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// 時間區間過濾 (created_at)
|
||||
if ($request->filled('start_date') || $request->filled('end_date')) {
|
||||
try {
|
||||
if ($request->filled('start_date')) {
|
||||
$start = \Illuminate\Support\Carbon::parse($request->input('start_date'));
|
||||
$historyQuery->where('created_at', '>=', $start);
|
||||
}
|
||||
if ($request->filled('end_date')) {
|
||||
$end = \Illuminate\Support\Carbon::parse($request->input('end_date'));
|
||||
$historyQuery->where('created_at', '<=', $end);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
// 忽略解析錯誤
|
||||
}
|
||||
}
|
||||
|
||||
// 狀態過濾
|
||||
if ($request->filled('status')) {
|
||||
$historyQuery->where('status', $request->input('status'));
|
||||
}
|
||||
|
||||
$history = $historyQuery->latest()->paginate($request->input('per_page', 10));
|
||||
|
||||
$selectedMachine = null;
|
||||
if ($request->has('machine_id')) {
|
||||
|
||||
Reference in New Issue
Block a user