diff --git a/app/Http/Controllers/Admin/RemoteController.php b/app/Http/Controllers/Admin/RemoteController.php index 89fa1ce..bf1f5a3 100644 --- a/app/Http/Controllers/Admin/RemoteController.php +++ b/app/Http/Controllers/Admin/RemoteController.php @@ -53,7 +53,8 @@ class RemoteController extends Controller ->orWhere('serial_no', 'like', "%{$search}%"); })->orWhereHas('user', function ($uq) use ($search) { $uq->where('name', 'like', "%{$search}%"); - }); + })->orWhere('remark', 'like', "%{$search}%") + ->orWhere('note', 'like', "%{$search}%"); }); } @@ -145,7 +146,8 @@ class RemoteController extends Controller $this->machineService->dispatchDispense( Machine::findOrFail($validated['machine_id']), $validated['slot_no'], - auth()->id() + auth()->id(), + $validated['note'] ?? null ); } else { $payload = []; @@ -169,7 +171,7 @@ class RemoteController extends Controller 'command_type' => $validated['command_type'], 'payload' => $payload, 'status' => 'pending', - 'note' => $validated['note'] ?? null, + 'remark' => $validated['note'] ?? null, ]); // 推播 MQTT 指令 diff --git a/app/Models/Machine/RemoteCommand.php b/app/Models/Machine/RemoteCommand.php index 27ba7af..a569bbd 100644 --- a/app/Models/Machine/RemoteCommand.php +++ b/app/Models/Machine/RemoteCommand.php @@ -16,6 +16,8 @@ class RemoteCommand extends Model 'payload', 'status', 'ttl', + 'note', + 'remark', 'executed_at', ]; diff --git a/app/Services/Machine/MachineService.php b/app/Services/Machine/MachineService.php index fc8d1e1..7c74693 100644 --- a/app/Services/Machine/MachineService.php +++ b/app/Services/Machine/MachineService.php @@ -403,9 +403,9 @@ class MachineService /** * 遠端出貨指令下發 (指令模式,不再預扣庫存) */ - public function dispatchDispense(Machine $machine, string $slotNo, ?int $userId = null): RemoteCommand + public function dispatchDispense(Machine $machine, string $slotNo, ?int $userId = null, ?string $remark = null): RemoteCommand { - return DB::transaction(function () use ($machine, $slotNo, $userId) { + return DB::transaction(function () use ($machine, $slotNo, $userId, $remark) { $slot = $machine->slots()->where('slot_no', $slotNo)->lockForUpdate()->firstOrFail(); // 併行檢查:若有 pending 指令,超過 1 分鐘視為逾時可覆蓋 @@ -440,6 +440,7 @@ class MachineService 'user_id' => $userId, 'command_type' => 'dispense', 'status' => 'pending', + 'remark' => $remark, 'payload' => [ 'slot_no' => (string)$slotNo, 'current_stock' => $slot->stock, diff --git a/database/migrations/2026_05_12_170742_add_remark_to_remote_commands_table.php b/database/migrations/2026_05_12_170742_add_remark_to_remote_commands_table.php new file mode 100644 index 0000000..273da52 --- /dev/null +++ b/database/migrations/2026_05_12_170742_add_remark_to_remote_commands_table.php @@ -0,0 +1,28 @@ +string('remark')->nullable()->after('note')->comment('操作備註'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('remote_commands', function (Blueprint $table) { + $table->dropColumn('remark'); + }); + } +}; diff --git a/resources/views/admin/remote/partials/tab-history-index.blade.php b/resources/views/admin/remote/partials/tab-history-index.blade.php index 9d7030c..2f0dc22 100644 --- a/resources/views/admin/remote/partials/tab-history-index.blade.php +++ b/resources/views/admin/remote/partials/tab-history-index.blade.php @@ -129,10 +129,13 @@ 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 text-center whitespace-nowrap"> {{ __('Picked up Time') }} + 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 whitespace-nowrap"> {{ __('Command Type') }} + 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 whitespace-nowrap"> + {{ __('Operation Note') }} + {{ __('Operator') }} @@ -190,22 +193,39 @@ @endif -
+
- @if($item->note) - - @endif
+ +
+ @if($item->remark) + {{ $item->remark }} + @endif + + @if($item->note) +
+ + + + +
+ @endif + + @if(!$item->remark && !$item->note) + - + @endif +
+
- @if($item->note) - - @endif
+ @if($item->remark || $item->note) +
+

{{ __('Operation Note') }}

+
+ @if($item->remark) + {{ $item->remark }} + @endif + @if($item->note) +
+ + + + +
+ @endif +
+
+ @endif

{{ __('Creation Time') }}