From fd954c80a058579cf4f7d1b348a784aa587c628d Mon Sep 17 00:00:00 2001 From: sky121113 Date: Thu, 18 Jun 2026 13:44:22 +0800 Subject: [PATCH] =?UTF-8?q?[FEAT]=20=E5=88=B7=E5=8D=A1=E6=A9=9F=E7=8B=80?= =?UTF-8?q?=E6=85=8B=E9=A1=AF=E7=A4=BA=E9=99=90=E5=9F=BA=E7=A4=8E=E7=89=88?= =?UTF-8?q?=E5=95=9F=E7=94=A8=E6=A9=9F=E5=8F=B0=EF=BC=8C=E4=B8=A6=E5=8A=A0?= =?UTF-8?q?=E6=A9=9F=E5=8F=B0=E6=97=A5=E8=AA=8C=E6=9F=A5=E8=A9=A2=E7=B4=A2?= =?UTF-8?q?=E5=BC=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Machine 新增 show_card_terminal 取值器:僅 shopping_mode=basic 且 card_terminal_enabled 的機台才呈現刷卡機燈號與日誌分頁(購物車模式或未啟用刷卡機者隱藏)。 2. 機台列表頁:刷卡機狀態燈號與「刷卡機日誌」分頁改以 show_card_terminal 控制顯示;openLogPanel 多帶 cardTerminalEnabled 參數,分頁不可見時自動退回機台狀態分頁。 3. 列表狀態欄文案調整:欄位標頭由「Sub-machine Status」改為「Hardware Status」,下位機燈號標籤改顯示「Sub-machine」,與新增的刷卡機燈號並列更清楚。 4. 新增 migration:machine_logs 加複合索引 (machine_id, type, is_resolved, level),加速列表頁逐台的狀態未解決日誌查詢(正式環境資料量大,建議離峰執行)。 5. CardTerminalStatusTest 新增 show_card_terminal 顯示條件測試(基礎版啟用才顯示、未啟用或非基礎版皆不顯示)。 6. 新增三語系 key(Hardware Status、Sub-machine),zh_TW/en/ja 對齊並 ksort 排序。 Co-Authored-By: Claude Opus 4.8 (1M context) --- app/Models/Machine/Machine.php | 10 +++++++ ...dd_status_lookup_index_to_machine_logs.php | 30 +++++++++++++++++++ lang/en.json | 2 ++ lang/ja.json | 2 ++ lang/zh_TW.json | 4 ++- .../views/admin/machines/index.blade.php | 30 ++++++++++++------- tests/Feature/CardTerminalStatusTest.php | 26 ++++++++++++++++ 7 files changed, 93 insertions(+), 11 deletions(-) create mode 100644 database/migrations/2026_06_18_000001_add_status_lookup_index_to_machine_logs.php diff --git a/app/Models/Machine/Machine.php b/app/Models/Machine/Machine.php index f446325..369d505 100644 --- a/app/Models/Machine/Machine.php +++ b/app/Models/Machine/Machine.php @@ -512,6 +512,16 @@ class Machine extends Model $this->attributes['card_terminal_enabled'] = (bool) $value; } + /** + * 是否需要在後台呈現刷卡機狀態燈號與日誌分頁。 + * 僅「基礎版(shopping_mode=basic)」且「刷卡機支付已啟用」的機台才有意義; + * 購物車模式或未啟用刷卡機的機台不顯示。 + */ + public function getShowCardTerminalAttribute(): bool + { + return $this->shopping_mode === 'basic' && $this->card_terminal_enabled; + } + public function getScanPayEsunEnabledAttribute(): bool { return (bool) ($this->settings['scan_pay_esun_enabled'] ?? ($this->attributes['scan_pay_esun_enabled'] ?? false)); diff --git a/database/migrations/2026_06_18_000001_add_status_lookup_index_to_machine_logs.php b/database/migrations/2026_06_18_000001_add_status_lookup_index_to_machine_logs.php new file mode 100644 index 0000000..18a5bb6 --- /dev/null +++ b/database/migrations/2026_06_18_000001_add_status_lookup_index_to_machine_logs.php @@ -0,0 +1,30 @@ +index(['machine_id', 'type', 'is_resolved', 'level'], 'machine_logs_status_lookup_index'); + }); + } + + public function down(): void + { + Schema::table('machine_logs', function (Blueprint $table) { + $table->dropIndex('machine_logs_status_lookup_index'); + }); + } +}; diff --git a/lang/en.json b/lang/en.json index bb6fac5..4fa8aa9 100644 --- a/lang/en.json +++ b/lang/en.json @@ -905,6 +905,7 @@ "Hardware & Network": "Hardware & Network", "Hardware & Slots": "Hardware & Slots", "Hardware Peripheral Settings": "Hardware Peripheral Settings", + "Hardware Status": "Hardware Status", "HashIV": "HashIV", "HashKey": "HashKey", "Heartbeat": "Heartbeat", @@ -2042,6 +2043,7 @@ "Sub Account Roles": "Sub Account Roles", "Sub Accounts": "Sub Accounts", "Sub-actions": "Sub-actions", + "Sub-machine": "Sub-machine", "Sub-machine Status": "Sub-machine Status", "Sub-machine Status Request": "Sub-machine Status Request", "Submachine Alert": "Submachine Alert", diff --git a/lang/ja.json b/lang/ja.json index 1700291..6d150b6 100644 --- a/lang/ja.json +++ b/lang/ja.json @@ -905,6 +905,7 @@ "Hardware & Network": "ハードウェア・ネットワーク", "Hardware & Slots": "ハードウェア・スロット", "Hardware Peripheral Settings": "ハードウェア周辺機器設定", + "Hardware Status": "ハードウェア状態", "HashIV": "HashIV", "HashKey": "HashKey", "Heartbeat": "ハートビート", @@ -2042,6 +2043,7 @@ "Sub Account Roles": "サブアカウントロール", "Sub Accounts": "サブアカウント", "Sub-actions": "サブアクション", + "Sub-machine": "サブマシン", "Sub-machine Status": "Sub-machine Status", "Sub-machine Status Request": "下位機ステータスリクエスト", "Submachine Alert": "下位機アラート", diff --git a/lang/zh_TW.json b/lang/zh_TW.json index 1b10223..4c8880d 100644 --- a/lang/zh_TW.json +++ b/lang/zh_TW.json @@ -285,7 +285,7 @@ "Card Reader Seconds": "刷卡機秒數", "Card Side Background": "左側卡片背景圖", "Card System": "刷卡機系統", - "Card Terminal": "刷卡機端", + "Card Terminal": "刷卡機", "Card Terminal Logs": "刷卡機日誌", "Card Terminal Status": "刷卡機狀態", "Card Terminal System": "刷卡機系統", @@ -905,6 +905,7 @@ "Hardware & Network": "硬體與網路", "Hardware & Slots": "硬體與貨道", "Hardware Peripheral Settings": "硬體周邊設定", + "Hardware Status": "硬體狀態", "HashIV": "HashIV", "HashKey": "HashKey", "Heartbeat": "心跳狀態", @@ -2042,6 +2043,7 @@ "Sub Account Roles": "子帳號角色", "Sub Accounts": "子帳號", "Sub-actions": "子項目", + "Sub-machine": "下位機", "Sub-machine Status": "下位機狀態", "Sub-machine Status Request": "下位機狀態回傳", "Submachine Alert": "下位機告警", diff --git a/resources/views/admin/machines/index.blade.php b/resources/views/admin/machines/index.blade.php index e8a071a..8947f87 100644 --- a/resources/views/admin/machines/index.blade.php +++ b/resources/views/admin/machines/index.blade.php @@ -43,6 +43,7 @@ currentMachineSn: '', currentMachineName: '', currentMachineAmbientTempEnabled: false, + currentMachineCardTerminalEnabled: false, logs: [], loading: false, inventoryLoading: false, @@ -87,11 +88,16 @@ }); }, - async openLogPanel(id, sn, name, ambientTempEnabled = false) { + async openLogPanel(id, sn, name, ambientTempEnabled = false, cardTerminalEnabled = false) { this.currentMachineId = id; this.currentMachineSn = sn; this.currentMachineName = name; this.currentMachineAmbientTempEnabled = ambientTempEnabled === true || ambientTempEnabled === 1 || ambientTempEnabled === '1' || ambientTempEnabled === 'true'; + this.currentMachineCardTerminalEnabled = cardTerminalEnabled === true || cardTerminalEnabled === 1 || cardTerminalEnabled === '1' || cardTerminalEnabled === 'true'; + // 若刷卡機分頁不可見且當前正停在該分頁,退回機台狀態分頁 + if (!this.currentMachineCardTerminalEnabled && this.activeTab === 'card_terminal') { + this.activeTab = 'status'; + } this.slots = []; this.showLogPanel = true; this.activeTab = 'status'; @@ -520,7 +526,7 @@ {{ __('Temperature') }} - {{ __('Sub-machine Status') }} + {{ __('Hardware Status') }} {{ __('APP Version') }} @@ -537,7 +543,7 @@ + @click="openLogPanel('{{ $machine->id }}', '{{ $machine->serial_no }}', '{{ addslashes($machine->name) }}', {{ $machine->ambient_temp_monitoring_enabled ? 1 : 0 }}, {{ $machine->show_card_terminal ? 1 : 0 }})">
@@ -641,7 +647,6 @@ @php $hStatus = $machine->hardware_status; - $ctStatus = $machine->card_terminal_status; @endphp
{{-- 下位機 --}} @@ -654,13 +659,15 @@ $hStatus === 'error' ? 'text-rose-500' : ($hStatus === 'warning' ? 'text-amber-500' : 'text-slate-400') }} uppercase tracking-widest"> - {{ $hStatus === 'error' ? __('Error') : ($hStatus === 'warning' ? __('Warning') : __('Normal')) }} + {{ __('Sub-machine') }} @if($machine->latest_hardware_log_time && $hStatus !== 'normal') {{ $machine->latest_hardware_log_time->diffForHumans() }} @endif
- {{-- 刷卡機 (信用卡/電子票證/手機支付共用同一台) --}} + {{-- 刷卡機 (信用卡/電子票證/手機支付共用同一台):僅基礎版且啟用刷卡機才顯示 --}} + @if($machine->show_card_terminal) + @php $ctStatus = $machine->card_terminal_status; @endphp
-

{{ $machine->name }} @if($machine->has_login_warning) @@ -836,7 +844,7 @@ {{ __('Edit') }}