迁移房间后台表单事件

This commit is contained in:
2026-04-25 13:25:27 +08:00
parent 4751a5578e
commit 4815d201f6
3 changed files with 96 additions and 12 deletions
+5 -12
View File
@@ -11,7 +11,7 @@
</div>
{{-- 新增房间按钮 --}}
@if (auth()->id() === 1)
<button onclick="document.getElementById('create-room-form').classList.toggle('hidden')"
<button type="button" data-room-create-toggle
class="px-4 py-2 bg-indigo-600 text-white rounded-md text-sm font-bold hover:bg-indigo-700 transition shadow-sm">
+ 新增房间
</button>
@@ -20,7 +20,8 @@
{{-- 新增房间表单(默认隐藏) --}}
@if (auth()->id() === 1)
<div id="create-room-form" class="hidden border-b border-gray-200 bg-indigo-50 p-6">
<div id="create-room-form" class="hidden border-b border-gray-200 bg-indigo-50 p-6"
@if ($errors->any()) data-room-create-open @endif>
<h3 class="text-sm font-bold text-indigo-800 mb-4"> 创建新房间</h3>
<form action="{{ route('admin.rooms.store') }}" method="POST">
@csrf
@@ -67,7 +68,7 @@
class="px-5 py-2 bg-indigo-600 text-white rounded-md font-bold hover:bg-indigo-700 shadow-sm transition text-sm">
确认创建
</button>
<button type="button" onclick="document.getElementById('create-room-form').classList.add('hidden')"
<button type="button" data-room-create-close
class="px-4 py-2 bg-gray-200 text-gray-700 rounded-md font-bold hover:bg-gray-300 transition text-sm">
取消
</button>
@@ -75,14 +76,6 @@
</form>
</div>
@endif
{{-- 新增房间表单展开时自动滚到顶部校验错误 --}}
@if ($errors->any())
<script>
document.getElementById('create-room-form').classList.remove('hidden');
</script>
@endif
<div class="p-6">
<div class="space-y-4">
@foreach ($rooms as $room)
@@ -169,7 +162,7 @@
@unless ($room->room_keep)
<form action="{{ route('admin.rooms.destroy', $room->id) }}" method="POST"
class="inline"
onsubmit="return confirm('确定要删除房间「{{ $room->room_name }}」吗?此操作不可撤销!')">
data-room-delete-confirm="确定要删除房间「{{ $room->room_name }}」吗?此操作不可撤销!">
@csrf
@method('DELETE')
<button type="submit"