WuYongJie 9595267ee7
Some checks failed
Tests / PHP 8.1 (push) Has been cancelled
Tests / PHP 8.2 (push) Has been cancelled
Tests / PHP 8.3 (push) Has been cancelled
chore: 导入 Akaunting 初始源码与团队协作规则
2026-07-20 18:20:25 +08:00

83 lines
4.7 KiB
PHP

<x-layouts.admin>
<x-slot name="title">用户管理</x-slot>
<x-slot name="buttons">
<a href="{{ route('system-settings.users.create') }}" class="inline-flex items-center gap-2 rounded-lg bg-green px-5 py-2 text-sm text-white hover:bg-green-700">
<span class="material-icons-outlined text-lg">person_add</span>
新增用户
</a>
</x-slot>
<x-slot name="content">
<div class="my-6">
@include('system_settings.partials.navigation')
<div class="mb-4 rounded-lg border-l-4 border-purple bg-lilac-100 px-4 py-3 text-sm text-gray-700">
@if (\App\Utilities\SystemAccess::isSuperAdmin())
超级管理员可管理所有用户和用户类型。
@else
普通管理员只能新增、修改和删除普通用户。
@endif
</div>
@if ($errors->any())
<div class="mb-4 rounded-lg bg-red-50 px-4 py-3 text-sm text-red-700">
@foreach ($errors->all() as $error)<p>{{ $error }}</p>@endforeach
</div>
@endif
<div class="overflow-x-auto rounded-xl border border-gray-200 bg-white">
<table class="min-w-full divide-y divide-gray-200 text-sm">
<thead class="bg-gray-50 text-left text-gray-500">
<tr>
<th class="px-5 py-3">姓名</th>
<th class="px-5 py-3">邮箱</th>
<th class="px-5 py-3">用户类型</th>
<th class="px-5 py-3">状态</th>
<th class="px-5 py-3 text-right">操作</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-100">
@forelse ($users as $managedUser)
@php $roleName = \App\Utilities\SystemAccess::roleName($managedUser); @endphp
<tr>
<td class="px-5 py-4 font-semibold text-gray-800">
{{ $managedUser->name }}
@if ($managedUser->id === user()->id)
<span class="ml-2 rounded-full bg-lilac-100 px-2 py-0.5 text-xs text-purple">当前账号</span>
@endif
</td>
<td class="px-5 py-4 text-gray-600">{{ $managedUser->email }}</td>
<td class="px-5 py-4 text-gray-600">{{ $roleLabels[$roleName] ?? ($managedUser->roles->first()?->display_name ?? '-') }}</td>
<td class="px-5 py-4">
<span @class([
'rounded-full px-2.5 py-1 text-xs font-semibold',
'bg-green-100 text-green-700' => $managedUser->enabled,
'bg-gray-100 text-gray-500' => ! $managedUser->enabled,
])>{{ $managedUser->enabled ? '启用' : '停用' }}</span>
</td>
<td class="px-5 py-4 text-right whitespace-nowrap">
@if (\App\Utilities\SystemAccess::canManageUser(user(), $managedUser))
<a href="{{ route('system-settings.users.edit', $managedUser->id) }}" class="mr-4 text-purple hover:underline">修改</a>
@if ($managedUser->id !== user()->id)
<form method="POST" action="{{ route('system-settings.users.destroy', $managedUser->id) }}" class="inline" onsubmit="return confirm('确定删除该用户吗?')">
@csrf
@method('DELETE')
<button type="submit" class="text-red-600 hover:underline">删除</button>
</form>
@endif
@else
<span class="text-gray-400">-</span>
@endif
</td>
</tr>
@empty
<tr><td colspan="5" class="px-5 py-12 text-center text-gray-400">暂无用户</td></tr>
@endforelse
</tbody>
</table>
</div>
</div>
</x-slot>
</x-layouts.admin>