[FEAT] 依據環境溫度監測啟用狀態動態顯示日誌 Tab

1. 在 machines/index.blade.php 的 Alpine x-data 中新增 currentMachineAmbientTempEnabled 屬性。
2. 修改 openLogPanel 方法以傳入機台的環境溫度監測啟用狀態。
3. 於機台列表所有呼叫 openLogPanel 處帶入 ambient_temp_monitoring_enabled。
4. 在「環境溫度回傳」Tab 的按鈕上加入 x-show 與 x-cloak,使該 Tab 僅在機台啟用監測時顯示,避免非必要 Tab 的干擾與界面閃爍。
This commit is contained in:
sky121113 2026-06-04 13:13:20 +08:00
parent 7ceb7644f0
commit 06d93889b3

View File

@ -42,6 +42,7 @@
},
currentMachineSn: '',
currentMachineName: '',
currentMachineAmbientTempEnabled: false,
logs: [],
loading: false,
inventoryLoading: false,
@ -86,10 +87,11 @@
});
},
async openLogPanel(id, sn, name) {
async openLogPanel(id, sn, name, ambientTempEnabled = false) {
this.currentMachineId = id;
this.currentMachineSn = sn;
this.currentMachineName = name;
this.currentMachineAmbientTempEnabled = ambientTempEnabled === true || ambientTempEnabled === 1 || ambientTempEnabled === '1' || ambientTempEnabled === 'true';
this.slots = [];
this.showLogPanel = true;
this.activeTab = 'status';
@ -474,7 +476,7 @@
<tr
class="group hover:bg-slate-50/50 dark:hover:bg-white/[0.02] transition-colors duration-200">
<td class="px-6 py-6 cursor-pointer group"
@click="openLogPanel('{{ $machine->id }}', '{{ $machine->serial_no }}', '{{ addslashes($machine->name) }}')">
@click="openLogPanel('{{ $machine->id }}', '{{ $machine->serial_no }}', '{{ addslashes($machine->name) }}', {{ $machine->ambient_temp_monitoring_enabled ? 1 : 0 }})">
<div class="flex items-center gap-3">
<div
class="w-12 h-12 rounded-2xl bg-slate-100 dark:bg-slate-800 flex items-center justify-center text-slate-400 border border-slate-200 dark:border-slate-700 group-hover:bg-cyan-500 group-hover:text-white transition-all duration-300 overflow-hidden shadow-sm">
@ -621,7 +623,7 @@
</svg>
</button>
<button type="button"
@click="openLogPanel('{{ $machine->id }}', '{{ $machine->serial_no }}', '{{ addslashes($machine->name) }}')"
@click="openLogPanel('{{ $machine->id }}', '{{ $machine->serial_no }}', '{{ addslashes($machine->name) }}', {{ $machine->ambient_temp_monitoring_enabled ? 1 : 0 }})"
class="p-2.5 rounded-xl bg-slate-50 dark:bg-slate-800 text-slate-400 hover:text-cyan-500 hover:bg-cyan-500/5 dark:hover:bg-cyan-500/10 border border-transparent hover:border-cyan-500/20 transition-all duration-200"
title="{{ __('View Logs') }}">
<svg class="w-4 h-4 stroke-[2.5]" fill="none" stroke="currentColor"
@ -661,7 +663,7 @@
@endif
</div>
<div class="min-w-0">
<h3 @click="openLogPanel('{{ $machine->id }}', '{{ $machine->serial_no }}', '{{ addslashes($machine->name) }}')"
<h3 @click="openLogPanel('{{ $machine->id }}', '{{ $machine->serial_no }}', '{{ addslashes($machine->name) }}', {{ $machine->ambient_temp_monitoring_enabled ? 1 : 0 }})"
class="text-base font-extrabold text-slate-800 dark:text-slate-100 hover:text-cyan-600 dark:hover:text-cyan-400 transition-colors tracking-tight cursor-pointer flex items-center gap-2 min-w-0">
<span class="truncate">{{ $machine->name }}</span>
@if($machine->has_login_warning)
@ -749,8 +751,8 @@
{{ __('Edit') }}
</button>
<button type="button"
@click="openLogPanel('{{ $machine->id }}', '{{ $machine->serial_no }}', '{{ addslashes($machine->name) }}')"
class="flex-1 flex items-center justify-center gap-2 py-3 rounded-xl bg-slate-50 dark:bg-slate-800 text-slate-500 dark:text-slate-400 font-bold text-xs hover:bg-cyan-500 hover:text-white transition-all duration-300 border border-slate-200/50 dark:border-slate-700/50">
@click="openLogPanel('{{ $machine->id }}', '{{ $machine->serial_no }}', '{{ addslashes($machine->name) }}', {{ $machine->ambient_temp_monitoring_enabled ? 1 : 0 }})"
class="flex-1 flex items-center justify-center gap-2 py-3 rounded-xl bg-slate-50 dark:bg-slate-800 text-slate-500 dark:text-slate-400 font-bold text-xs hover:bg-cyan-500 hover:text-white transition-all duration-300 border border-slate-200/50 dark:border-slate-700/50">
<svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2.5"
d="M2.036 12.322a1.012 1.012 0 0 1 0-.644C3.67 8.5 7.652 6 12 6c4.348 0 8.332 2.5 9.964 5.678a1.012 1.012 0 0 1 0 .644C20.33 15.5 16.348 18 12 18c-4.348 0-8.332-2.5-9.964-5.678z" />
@ -926,8 +928,10 @@
{{ __('Sub-machine Status Request') }}
</button>
<button @click="activeTab = 'ambient_temp'"
x-show="currentMachineAmbientTempEnabled"
:class="{'border-cyan-500 text-cyan-600 dark:text-cyan-400': activeTab === 'ambient_temp', 'border-transparent text-slate-500 hover:text-slate-700 hover:border-slate-300 dark:hover:text-slate-300': activeTab !== 'ambient_temp'}"
class="whitespace-nowrap py-4 px-1 border-b-2 font-bold text-[13px] sm:text-sm transition duration-300">
class="whitespace-nowrap py-4 px-1 border-b-2 font-bold text-[13px] sm:text-sm transition duration-300"
x-cloak>
{{ __('Ambient Temperature Log') }}
</button>