💄 Updating the UI and style files.

This commit is contained in:
Wisp X 2022-01-20 17:13:43 +08:00
parent 0b4fd797a3
commit 031c0f76ee
4 changed files with 52 additions and 7 deletions

View File

@ -6,6 +6,7 @@ use App\Http\Controllers\Controller;
use App\Models\Group;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\View\View;
class GroupController extends Controller
@ -18,9 +19,29 @@ class GroupController extends Controller
return view('admin.group.index', compact('groups'));
}
public function add(): View
{
return view('admin.group.create');
}
public function edit(Request $request): View
{
$group = Group::query()->findOrFail($request->route('id'));
return view('admin.group.edit', compact('group'));
}
public function create(): Response
{
}
public function update(): Response
{
}
public function delete(Request $request): Response
{
}
}

View File

@ -13,7 +13,7 @@
@foreach($groups as $group)
<tr data-id="{{ $group->id }}">
<td class="px-6 py-4 whitespace-nowrap">{{ $group->id }}</td>
<td class="px-6 py-4 whitespace-nowrap">{{ $group->name }}</td>
<td class="px-6 py-4 whitespace-nowrap name">{{ $group->name }}</td>
<td class="px-6 py-4 whitespace-nowrap">
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full {{ $group->is_default ? 'text-green-800' : 'text-red-800' }}">
<i class="text-lg fas fa-{{ $group->is_default ? 'check-circle' : 'times-circle' }}"></i>
@ -30,15 +30,36 @@
</x-table>
@if($groups->isEmpty())
<x-no-data message="没有找到任何角色组"/>
@else
<div class="mt-4">
{{ $groups->links() }}
</div>
@endif
<div class="mt-4">
{{ $groups->links() }}
</div>
</div>
@push('scripts')
<script>
$('[data-operate="del"]').click(function () {
$('[data-operate="delete"]').click(function () {
Swal.fire({
title: `确认删除角色组${$(this).closest('tr').find('td.name').text()}吗?`,
text: "⚠️注意,删除该角色组后,该角色组下属的用户会被重置为系统默认组。",
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: '确认删除',
}).then((result) => {
if (result.isConfirmed) {
let id = $(this).closest('tr').data('id');
axios.delete(`/groups/${id}`).then(response => {
if (response.data.status) {
history.go(0);
} else {
toastr.error(response.data.message);
}
});
}
})
});
</script>
@endpush

View File

@ -45,8 +45,11 @@ Route::group(['middleware' => ['auth']], function () {
Route::group(['prefix' => 'admin', 'middleware' => ['auth.admin']], function () {
Route::group(['prefix' => 'groups'], function () {
Route::get('', [AdminGroupController::class, 'index'])->name('admin.groups');
Route::get('create', fn () => view('admin.group.create'))->name('admin.group.create');
Route::get('{id}/edit', [AdminGroupController::class, 'edit'])->name('admin.group.edit');
Route::get('create', [AdminGroupController::class, 'add'])->name('admin.group.add');
Route::post('create', [AdminGroupController::class, 'create'])->name('admin.group.create');
Route::get('{id}', [AdminGroupController::class, 'edit'])->name('admin.group.edit');
Route::put('{id}', [AdminGroupController::class, 'update'])->name('admin.group.update');
Route::delete('{id}', [AdminGroupController::class, 'delete'])->name('admin.group.delete');
});
});