調整包廂Status 功能介面改維護 20250729
This commit is contained in:
parent
eb465425f7
commit
04c9f016bf
@ -21,7 +21,7 @@ class CheckRoomOnlineStatus extends Command
|
||||
$threshold = $now->subMinutes(10);
|
||||
|
||||
// 所有房間
|
||||
$rooms = Room::with('branch')->where('is_online',1)->get();
|
||||
$rooms = Room::with('branch')->get();
|
||||
|
||||
foreach ($rooms as $room) {
|
||||
$branch = optional($room->branch);
|
||||
|
@ -8,7 +8,7 @@ use App\Enums\Traits\HasLabels;
|
||||
* @OA\Schema(
|
||||
* schema="RoomStatus",
|
||||
* type="string",
|
||||
* enum={"active", "closed", "fire", "maintenance"},
|
||||
* enum={"active", "closed", "fire", "maintain", "error"},
|
||||
* example="error"
|
||||
* )
|
||||
*/
|
||||
@ -18,6 +18,7 @@ enum RoomStatus: string {
|
||||
case Active = 'active';
|
||||
case Closed = 'closed';
|
||||
case Fire ='fire';
|
||||
case Maintain ='maintain';
|
||||
case Error = 'error';
|
||||
|
||||
// 返回對應的顯示文字
|
||||
@ -27,6 +28,7 @@ enum RoomStatus: string {
|
||||
self::Active => __('enums.room.status.Active'),
|
||||
self::Closed => __('enums.room.status.Closed'),
|
||||
self::Fire => __('enums.room.status.Fire'),
|
||||
self::Maintain => __('enums.room.status.Maintain'),
|
||||
self::Error => __('enums.room.status.Error'),
|
||||
};
|
||||
}
|
||||
|
@ -264,6 +264,7 @@ class RoomControlController extends Controller
|
||||
|
||||
$suffix = substr($room->name, -3) ?: $room->name;
|
||||
$signal = match ($validated['command']) {
|
||||
'maintain' => 'O',
|
||||
'active' => 'O',
|
||||
'closed' => 'X',
|
||||
'fire' => 'F',
|
||||
|
@ -10,7 +10,7 @@ use Illuminate\Foundation\Http\FormRequest;
|
||||
* required={"branch_name", "room_name", "command"},
|
||||
* @OA\Property(property="branch_name", type="string", example="測試"),
|
||||
* @OA\Property(property="room_name", type="string", example="pc102"),
|
||||
* @OA\Property(property="command", type="string", enum={"active", "closed", "fire", "maintenance"}, example="active"),
|
||||
* @OA\Property(property="command", type="string", enum={"active", "closed", "fire", "maintain"}, example="active"),
|
||||
* @OA\Property(property="started_at", type="string", nullable=true, example="2025-05-19 09:31:00"),
|
||||
* @OA\Property(property="ended_at", type="string", nullable=true, example="2025-05-19 09:31:00")
|
||||
* )
|
||||
@ -27,7 +27,7 @@ class SendRoomSwitchCommandRequest extends ApiRequest
|
||||
return [
|
||||
'branch_name' =>'required|string|exists:branches,name',
|
||||
'room_name' => 'required|string',
|
||||
'command' => 'required|string',
|
||||
'command' => 'required|in:active,closed,fire,maintain,error',
|
||||
'started_at' => 'nullable|date_format:Y-m-d H:i:s',
|
||||
'ended_at' => 'nullable|date_format:Y-m-d H:i:s',
|
||||
];
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire\Forms;
|
||||
namespace App\Livewire\Grids;
|
||||
|
||||
use App\Models\Room;
|
||||
use App\Models\Branch;
|
||||
@ -11,7 +11,7 @@ use Illuminate\Database\Eloquent\Collection;
|
||||
|
||||
|
||||
|
||||
class RoomGridForm extends Component
|
||||
class RoomGrid extends Component
|
||||
{
|
||||
public $branchName="";
|
||||
public array $roomTypes;
|
||||
@ -35,7 +35,7 @@ class RoomGridForm extends Component
|
||||
$floors = $rooms->pluck('floor')->unique()->sort()->values()->toArray();
|
||||
}
|
||||
|
||||
return view('livewire.forms.room-grid-form', [
|
||||
return view('livewire.grids.room-grid', [
|
||||
'rooms' => $rooms,
|
||||
'floors' => $floors,
|
||||
]);
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire\Forms\Modals;
|
||||
namespace App\Livewire\Modals;
|
||||
|
||||
use App\Models\Room;
|
||||
use App\Models\Branch;
|
||||
@ -37,7 +37,7 @@ class RoomDetailModal extends Component
|
||||
}
|
||||
public function startNotify()
|
||||
{
|
||||
$data = $this->buildNotifyData('active', now(), null);
|
||||
$data = $this->buildNotifyData('maintain', null, null);
|
||||
$this->send($data);
|
||||
}
|
||||
|
||||
@ -86,7 +86,7 @@ class RoomDetailModal extends Component
|
||||
$this->sendErrorNotification('api', 'API token is missing.');
|
||||
return false;
|
||||
}
|
||||
$apiClient = new ApiClient($this->branch->external_ip,$token);
|
||||
$apiClient = new ApiClient(config('app.url'),$token);
|
||||
$response = $apiClient->post('/api/room/sendSwitch', $data);
|
||||
if ($response->failed()) {
|
||||
$this->sendErrorNotification('api', 'API request failed: ' . $response->body());
|
||||
@ -113,6 +113,6 @@ class RoomDetailModal extends Component
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.forms.modals.room-detail-modal');
|
||||
return view('livewire.modals.room-detail-modal');
|
||||
}
|
||||
}
|
@ -224,7 +224,7 @@ final class RoomTable extends PowerGridComponent
|
||||
->slot('包廂設定')
|
||||
->icon('solid-cog')
|
||||
->class('inline-flex items-center gap-1 px-3 py-1 rounded ')
|
||||
->dispatchTo('forms.modals.room-detail-modal', 'openModal', ['roomId' => $row->id]);
|
||||
->dispatchTo('modals.room-detail-modal', 'openModal', ['roomId' => $row->id]);
|
||||
}
|
||||
return $actions;
|
||||
}
|
||||
|
@ -72,7 +72,10 @@ class ApiClient
|
||||
|
||||
protected function withDefaultHeaders(): PendingRequest
|
||||
{
|
||||
$request = Http::connectTimeout($this->connectTimeout)
|
||||
$request = Http::withOptions([
|
||||
'verify' => false, // ✅ 關閉憑證驗證
|
||||
])
|
||||
->connectTimeout($this->connectTimeout)
|
||||
->timeout($this->timeout)
|
||||
->withHeaders([
|
||||
'Accept' => 'application/json',
|
||||
|
@ -20,7 +20,7 @@ return new class extends Migration
|
||||
$table->string('internal_ip')->nullable()->comment('內部 IP');
|
||||
$table->unsignedSmallInteger('port')->nullable()->comment('通訊 Port');
|
||||
$table->tinyInteger('is_online')->default(0)->comment('連線狀態');
|
||||
$table->enum('status', ['active', 'closed','fire', 'error'])->default('error')->comment('狀態'); // :啟用中 / 已結束
|
||||
$table->enum('status', ['active', 'closed','fire', 'error','maintain'])->default('error')->comment('狀態'); // :啟用中 / 已結束
|
||||
$table->dateTime('started_at')->nullable()->comment('開始時間'); //
|
||||
$table->dateTime('ended_at')->nullable()->comment('結束時間'); //
|
||||
$table->timestamps();
|
||||
|
@ -15,7 +15,7 @@ return new class extends Migration
|
||||
$table->id();
|
||||
$table->foreignId('room_id')->nullable();
|
||||
$table->foreignId('user_id')->nullable(); // 操作者,可為 null(系統)
|
||||
$table->enum('status', ['active', 'closed','fire', 'error', 'maintenance']);
|
||||
$table->enum('status', ['active', 'closed','fire', 'error', 'maintain']);
|
||||
$table->text('message')->nullable(); // 可填異常原因或操作說明
|
||||
$table->timestamps();
|
||||
});
|
||||
|
@ -13,5 +13,6 @@ return [
|
||||
'room.status.Active' => '已占用',
|
||||
'room.status.Closed' => '可用',
|
||||
'room.status.Fire' => '火災',
|
||||
'room.status.Error' => '維修',
|
||||
'room.status.Maintain' => '維護',
|
||||
'room.status.Error' => '異常',
|
||||
];
|
@ -18,7 +18,7 @@ return [
|
||||
'ended_at' =>'結束於',
|
||||
'created_at' =>'建立於',
|
||||
'active' => '正常',
|
||||
'error' => '維修',
|
||||
'error' => '關機',
|
||||
|
||||
'select_type' =>'選擇型別',
|
||||
|
||||
|
@ -3,12 +3,12 @@
|
||||
$statusColors = [
|
||||
RoomStatus::Active->value => 'green-600',
|
||||
RoomStatus::Closed->value => 'gray-600',
|
||||
RoomStatus::Error->value => 'red-600',
|
||||
RoomStatus::Maintain->value => 'red-600',
|
||||
];
|
||||
@endphp
|
||||
|
||||
<div class="border p-2 rounded shadow-md h-32 relative cursor-pointer bg-amber-50"
|
||||
wire:click="$dispatchTo('forms.modals.room-detail-modal','openModal', { roomId: {{ $room->id }} })">
|
||||
wire:click="$dispatchTo('modals.room-detail-modal','openModal', { roomId: {{ $room->id }} })">
|
||||
{{-- 房間名稱 + 線上狀態圓點 --}}
|
||||
<div class="font-bold flex items-center gap-1">
|
||||
<span class="w-2.5 h-2.5 rounded-full inline-block
|
||||
|
@ -1,4 +1,4 @@
|
||||
|
||||
<x-layouts.admin>
|
||||
<livewire:forms.room-grid-form />
|
||||
<livewire:grids.room-grid />
|
||||
</x-layouts.admin>
|
@ -3,5 +3,5 @@
|
||||
<x-wireui:notifications/>
|
||||
<livewire:tables.room-table/>
|
||||
<livewire:forms.room-form />
|
||||
<livewire:forms.modals.room-detail-modal />
|
||||
<livewire:modals.room-detail-modal />
|
||||
</x-layouts.admin>
|
@ -46,5 +46,5 @@
|
||||
</div>
|
||||
</div>
|
||||
<x-wireui:notifications/>
|
||||
<livewire:forms.modals.room-detail-modal />
|
||||
<livewire:modals.room-detail-modal />
|
||||
</x-wireui:card>
|
Loading…
x
Reference in New Issue
Block a user