feat: 任命/撤销通知系统 + 用户名片UI优化
- 任命/撤销事件增加 type 字段区分类型 - 任命:全屏礼花 + 紫色弹窗 + 紫色系统消息 - 撤销:灰色弹窗 + 灰色系统消息,无礼花 - 消息分发:操作者/被操作者显示在私聊面板,其他人显示在公屏 - 系统消息加随机鼓励语(各5条轮换) - ChatStateService 修复 Redis key 前缀扫描问题(getAllActiveRoomIds) - 用户名片折叠优化:管理员视野、职务履历均可折叠 - 管理操作 + 职务操作合并为「🔧 管理操作」折叠区 - 悄悄话改为「🎁 送礼物」按钮,礼物面板内联展开
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
{{--
|
||||
文件功能:在职期间权限操作日志子页
|
||||
展示某任职记录期间该用户的所有权限操作(任命/撤销/奖励/警告/踢出/禁言/封IP等)
|
||||
|
||||
@author ChatRoom Laravel
|
||||
@version 1.0.0
|
||||
--}}
|
||||
|
||||
@extends('admin.layouts.app')
|
||||
|
||||
@section('title', '权限操作日志 · ' . $userPosition->user->username)
|
||||
|
||||
@section('content')
|
||||
<div class="mb-6">
|
||||
<a href="{{ route('admin.appointments.index') }}" class="text-sm text-indigo-600 hover:underline">← 返回任命管理</a>
|
||||
<h2 class="text-lg font-bold text-gray-800 mt-2">
|
||||
{{ $userPosition->position->icon }} {{ $userPosition->user->username }} · {{ $userPosition->position->name }}
|
||||
</h2>
|
||||
<p class="text-sm text-gray-500 mt-1">权限操作记录(共 {{ $logs->total() }} 条)</p>
|
||||
</div>
|
||||
|
||||
@php
|
||||
$actionColors = [
|
||||
'appoint' => 'bg-green-100 text-green-700',
|
||||
'revoke' => 'bg-red-100 text-red-700',
|
||||
'reward' => 'bg-yellow-100 text-yellow-700',
|
||||
'warn' => 'bg-orange-100 text-orange-700',
|
||||
'kick' => 'bg-red-100 text-red-700',
|
||||
'mute' => 'bg-purple-100 text-purple-700',
|
||||
'banip' => 'bg-gray-200 text-gray-700',
|
||||
'other' => 'bg-gray-100 text-gray-600',
|
||||
];
|
||||
@endphp
|
||||
|
||||
<div class="bg-white rounded-xl shadow-sm border overflow-hidden">
|
||||
<table class="w-full text-sm">
|
||||
<thead class="bg-gray-50 text-gray-600 text-xs">
|
||||
<tr>
|
||||
<th class="px-4 py-3 text-left">操作时间</th>
|
||||
<th class="px-4 py-3 text-center">操作类型</th>
|
||||
<th class="px-4 py-3 text-left">操作对象</th>
|
||||
<th class="px-4 py-3 text-left">目标职务</th>
|
||||
<th class="px-4 py-3 text-center">奖励金额</th>
|
||||
<th class="px-4 py-3 text-left">备注</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-gray-100">
|
||||
@forelse ($logs as $log)
|
||||
@php $colorClass = $actionColors[$log->action_type] ?? 'bg-gray-100 text-gray-600'; @endphp
|
||||
<tr class="hover:bg-gray-50">
|
||||
<td class="px-4 py-3 text-gray-500 text-xs">{{ $log->created_at->format('m-d H:i:s') }}</td>
|
||||
<td class="px-4 py-3 text-center">
|
||||
<span class="text-xs px-2 py-0.5 rounded font-bold {{ $colorClass }}">
|
||||
{{ $log->action_label }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-4 py-3 font-bold text-gray-700">{{ $log->targetUser->username ?? '—' }}</td>
|
||||
<td class="px-4 py-3 text-gray-500">{{ $log->targetPosition?->name ?? '—' }}</td>
|
||||
<td class="px-4 py-3 text-center text-yellow-600 font-bold">
|
||||
{{ $log->amount ? number_format($log->amount) . ' 金币' : '—' }}
|
||||
</td>
|
||||
<td class="px-4 py-3 text-gray-400 text-xs">{{ $log->remark ?? '—' }}</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="6" class="px-4 py-12 text-center text-gray-400">暂无权限操作记录</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="mt-4">{{ $logs->links() }}</div>
|
||||
@endsection
|
||||
@@ -0,0 +1,80 @@
|
||||
{{--
|
||||
文件功能:任职期间登录记录子页
|
||||
展示某个用户在职期间的每次登录时间、在线时长、IP 和房间
|
||||
|
||||
@author ChatRoom Laravel
|
||||
@version 1.0.0
|
||||
--}}
|
||||
|
||||
@extends('admin.layouts.app')
|
||||
|
||||
@section('title', '在职登录日志 · ' . $userPosition->user->username)
|
||||
|
||||
@section('content')
|
||||
<div class="mb-6">
|
||||
<a href="{{ route('admin.appointments.index') }}" class="text-sm text-indigo-600 hover:underline">← 返回任命管理</a>
|
||||
<h2 class="text-lg font-bold text-gray-800 mt-2">
|
||||
{{ $userPosition->position->icon }} {{ $userPosition->user->username }} · {{ $userPosition->position->name }}
|
||||
</h2>
|
||||
<p class="text-sm text-gray-500 mt-1">
|
||||
任命于 {{ $userPosition->appointed_at->format('Y-m-d') }},
|
||||
任命人:{{ $userPosition->appointedBy?->username ?? '系统' }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{{-- 统计摘要 --}}
|
||||
<div class="grid grid-cols-3 gap-4 mb-6">
|
||||
<div class="bg-white rounded-xl p-5 border shadow-sm text-center">
|
||||
<div class="text-2xl font-bold text-indigo-600">{{ $logs->total() }}</div>
|
||||
<div class="text-xs text-gray-500 mt-1">总登录次数</div>
|
||||
</div>
|
||||
<div class="bg-white rounded-xl p-5 border shadow-sm text-center">
|
||||
<div class="text-2xl font-bold text-green-600">
|
||||
{{ gmdate('H', $logs->sum('duration_seconds')) }}h {{ gmdate('i', $logs->sum('duration_seconds')) }}m
|
||||
</div>
|
||||
<div class="text-xs text-gray-500 mt-1">累计在线时长(当前页)</div>
|
||||
</div>
|
||||
<div class="bg-white rounded-xl p-5 border shadow-sm text-center">
|
||||
<div class="text-2xl font-bold text-orange-600">{{ $userPosition->total_rewarded_coins }}</div>
|
||||
<div class="text-xs text-gray-500 mt-1">在职期间发放金币</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bg-white rounded-xl shadow-sm border overflow-hidden">
|
||||
<table class="w-full text-sm">
|
||||
<thead class="bg-gray-50 text-gray-600 text-xs">
|
||||
<tr>
|
||||
<th class="px-4 py-3 text-left">登录时间</th>
|
||||
<th class="px-4 py-3 text-left">退出时间</th>
|
||||
<th class="px-4 py-3 text-center">在线时长</th>
|
||||
<th class="px-4 py-3 text-center">房间</th>
|
||||
<th class="px-4 py-3 text-left">IP 地址</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-gray-100">
|
||||
@forelse ($logs as $log)
|
||||
<tr class="hover:bg-gray-50">
|
||||
<td class="px-4 py-3 text-gray-700">{{ $log->login_at->format('m-d H:i:s') }}</td>
|
||||
<td class="px-4 py-3 text-gray-500">{{ $log->logout_at?->format('m-d H:i:s') ?? '在线中...' }}</td>
|
||||
<td class="px-4 py-3 text-center">
|
||||
@if ($log->duration_seconds)
|
||||
<span
|
||||
class="text-xs bg-blue-100 text-blue-700 px-2 py-0.5 rounded">{{ $log->formatted_duration }}</span>
|
||||
@else
|
||||
<span class="text-xs text-gray-400">—</span>
|
||||
@endif
|
||||
</td>
|
||||
<td class="px-4 py-3 text-center text-gray-500">{{ $log->room_id ? "房间#{$log->room_id}" : '—' }}
|
||||
</td>
|
||||
<td class="px-4 py-3 text-gray-400 font-mono text-xs">{{ $log->ip_address }}</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="5" class="px-4 py-12 text-center text-gray-400">暂无登录记录</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="mt-4">{{ $logs->links() }}</div>
|
||||
@endsection
|
||||
@@ -0,0 +1,62 @@
|
||||
{{--
|
||||
文件功能:历史任职记录页面
|
||||
展示所有已撤销的职务记录(is_active=false),含任命人和撤销人信息
|
||||
|
||||
@author ChatRoom Laravel
|
||||
@version 1.0.0
|
||||
--}}
|
||||
|
||||
@extends('admin.layouts.app')
|
||||
|
||||
@section('title', '历史任职记录')
|
||||
|
||||
@section('content')
|
||||
<div class="mb-6">
|
||||
<a href="{{ route('admin.appointments.index') }}" class="text-sm text-indigo-600 hover:underline">← 返回任命管理</a>
|
||||
<h2 class="text-lg font-bold text-gray-800 mt-2">历史任职记录</h2>
|
||||
<p class="text-sm text-gray-500 mt-1">已撤销的职务记录(共 {{ $history->total() }} 条)</p>
|
||||
</div>
|
||||
|
||||
<div class="bg-white rounded-xl shadow-sm border overflow-hidden">
|
||||
<table class="w-full text-sm">
|
||||
<thead class="bg-gray-50 text-gray-600 text-xs">
|
||||
<tr>
|
||||
<th class="px-4 py-3 text-left">用户</th>
|
||||
<th class="px-4 py-3 text-left">职务</th>
|
||||
<th class="px-4 py-3 text-left">任命人</th>
|
||||
<th class="px-4 py-3 text-center">任命时间</th>
|
||||
<th class="px-4 py-3 text-left">撤销人</th>
|
||||
<th class="px-4 py-3 text-center">撤销时间</th>
|
||||
<th class="px-4 py-3 text-center">在职天数</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-gray-100">
|
||||
@forelse ($history as $up)
|
||||
<tr class="hover:bg-gray-50">
|
||||
<td class="px-4 py-3 font-bold text-gray-800">{{ $up->user->username }}</td>
|
||||
<td class="px-4 py-3">
|
||||
<span class="mr-1">{{ $up->position->icon }}</span>
|
||||
<span style="color: {{ $up->position->department->color }}">{{ $up->position->name }}</span>
|
||||
<span class="text-xs text-gray-400 ml-1">{{ $up->position->department->name }}</span>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-gray-500">{{ $up->appointedBy?->username ?? '系统' }}</td>
|
||||
<td class="px-4 py-3 text-center text-gray-500 text-xs">{{ $up->appointed_at->format('Y-m-d') }}
|
||||
</td>
|
||||
<td class="px-4 py-3 text-gray-500">{{ $up->revokedBy?->username ?? '系统' }}</td>
|
||||
<td class="px-4 py-3 text-center text-gray-500 text-xs">
|
||||
{{ $up->revoked_at?->format('Y-m-d') ?? '—' }}</td>
|
||||
<td class="px-4 py-3 text-center">
|
||||
<span class="text-xs bg-gray-100 text-gray-600 px-2 py-0.5 rounded">{{ $up->duration_days }}
|
||||
天</span>
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="7" class="px-4 py-12 text-center text-gray-400">暂无历史记录</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="mt-4">{{ $history->links() }}</div>
|
||||
@endsection
|
||||
@@ -0,0 +1,250 @@
|
||||
{{--
|
||||
文件功能:后台任命管理页面
|
||||
展示当前所有在职人员,支持新增任命和撤销职务
|
||||
任命时可搜索用户并选择目标职务
|
||||
|
||||
@author ChatRoom Laravel
|
||||
@version 1.0.0
|
||||
--}}
|
||||
|
||||
@extends('admin.layouts.app')
|
||||
|
||||
@section('title', '任命管理')
|
||||
|
||||
@section('content')
|
||||
<div x-data="{
|
||||
showForm: false,
|
||||
username: '',
|
||||
position_id: '',
|
||||
remark: '',
|
||||
searchResults: [],
|
||||
showDropdown: false,
|
||||
searching: false,
|
||||
searchTimer: null,
|
||||
openAppoint() {
|
||||
this.username = '';
|
||||
this.position_id = '';
|
||||
this.remark = '';
|
||||
this.searchResults = [];
|
||||
this.showDropdown = false;
|
||||
this.showForm = true;
|
||||
},
|
||||
async doSearch(val) {
|
||||
this.username = val;
|
||||
clearTimeout(this.searchTimer);
|
||||
if (val.length < 1) {
|
||||
this.searchResults = [];
|
||||
this.showDropdown = false;
|
||||
return;
|
||||
}
|
||||
this.searching = true;
|
||||
this.searchTimer = setTimeout(async () => {
|
||||
const res = await fetch(`{{ route('admin.appointments.search-users') }}?q=${encodeURIComponent(val)}`);
|
||||
this.searchResults = await res.json();
|
||||
this.showDropdown = this.searchResults.length > 0;
|
||||
this.searching = false;
|
||||
}, 250);
|
||||
},
|
||||
selectUser(u) {
|
||||
this.username = u.username;
|
||||
this.showDropdown = false;
|
||||
this.searchResults = [];
|
||||
}
|
||||
}">
|
||||
|
||||
{{-- 头部 --}}
|
||||
<div class="flex justify-between items-center mb-6">
|
||||
<div>
|
||||
<h2 class="text-lg font-bold text-gray-800">任命管理</h2>
|
||||
<p class="text-sm text-gray-500">管理当前所有在职职位人员,执行任命或撤销操作</p>
|
||||
</div>
|
||||
<div class="flex space-x-2">
|
||||
<a href="{{ route('admin.appointments.history') }}"
|
||||
style="background-color:#e5e7eb;color:#374151;padding:0.5rem 1rem;border-radius:0.5rem;font-weight:700;font-size:0.875rem;display:inline-flex;align-items:center;text-decoration:none;"
|
||||
onmouseover="this.style.backgroundColor='#d1d5db'" onmouseout="this.style.backgroundColor='#e5e7eb'">
|
||||
历史记录
|
||||
</a>
|
||||
<button @click="openAppoint()"
|
||||
style="background-color:#f97316;color:#fff;padding:0.5rem 1.25rem;border-radius:0.5rem;font-weight:700;border:none;cursor:pointer;box-shadow:0 1px 2px rgba(0,0,0,.1);"
|
||||
onmouseover="this.style.backgroundColor='#ea580c'" onmouseout="this.style.backgroundColor='#f97316'">
|
||||
+ 新增任命
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (session('success'))
|
||||
<div class="mb-4 px-4 py-3 bg-green-50 border border-green-200 text-green-700 rounded-lg text-sm">
|
||||
{{ session('success') }}</div>
|
||||
@endif
|
||||
@if (session('error'))
|
||||
<div class="mb-4 px-4 py-3 bg-red-50 border border-red-200 text-red-700 rounded-lg text-sm">
|
||||
{{ session('error') }}</div>
|
||||
@endif
|
||||
|
||||
{{-- 在职人员列表 --}}
|
||||
<div class="bg-white rounded-xl shadow-sm border overflow-hidden">
|
||||
<table class="w-full text-sm">
|
||||
<thead class="bg-gray-50 text-gray-600 text-xs">
|
||||
<tr>
|
||||
<th class="px-4 py-3 text-left">用户</th>
|
||||
<th class="px-4 py-3 text-left">部门·职务</th>
|
||||
<th class="px-4 py-3 text-center">等级</th>
|
||||
<th class="px-4 py-3 text-left">任命人</th>
|
||||
<th class="px-4 py-3 text-center">任命时间</th>
|
||||
<th class="px-4 py-3 text-center">在职天数</th>
|
||||
<th class="px-4 py-3 text-right">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-gray-100">
|
||||
@forelse ($activePositions as $up)
|
||||
<tr class="hover:bg-gray-50 transition">
|
||||
<td class="px-4 py-3">
|
||||
<div class="font-bold text-gray-800">{{ $up->user->username }}</div>
|
||||
<div class="text-xs text-gray-400">Lv.{{ $up->user->user_level }}</div>
|
||||
</td>
|
||||
<td class="px-4 py-3">
|
||||
<div class="flex items-center space-x-1">
|
||||
<span class="text-lg">{{ $up->position->icon }}</span>
|
||||
<div>
|
||||
<div class="text-xs text-gray-400">{{ $up->position->department->name }}</div>
|
||||
<div class="font-bold" style="color: {{ $up->position->department->color }}">
|
||||
{{ $up->position->name }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-center">
|
||||
<span class="text-xs bg-orange-100 text-orange-700 px-2 py-0.5 rounded font-mono">
|
||||
Lv.{{ $up->position->level }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-gray-600">{{ $up->appointedBy?->username ?? '系统' }}</td>
|
||||
<td class="px-4 py-3 text-center text-gray-500">
|
||||
{{ $up->appointed_at->format('Y-m-d') }}
|
||||
</td>
|
||||
<td class="px-4 py-3 text-center">
|
||||
<span class="text-xs bg-blue-100 text-blue-700 px-2 py-0.5 rounded">
|
||||
{{ $up->duration_days }} 天
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-right space-x-1">
|
||||
<a href="{{ route('admin.appointments.duty-logs', $up->id) }}"
|
||||
class="text-xs bg-blue-50 text-blue-600 font-bold px-2 py-1 rounded hover:bg-blue-600 hover:text-white transition">
|
||||
登录日志
|
||||
</a>
|
||||
<a href="{{ route('admin.appointments.authority-logs', $up->id) }}"
|
||||
class="text-xs bg-purple-50 text-purple-600 font-bold px-2 py-1 rounded hover:bg-purple-600 hover:text-white transition">
|
||||
操作日志
|
||||
</a>
|
||||
<form action="{{ route('admin.appointments.revoke', $up->id) }}" method="POST"
|
||||
class="inline"
|
||||
onsubmit="return confirm('确定撤销【{{ $up->user->username }}】的【{{ $up->position->name }}】职务?撤销后其等级将归 1。')">
|
||||
@csrf @method('DELETE')
|
||||
<button type="submit"
|
||||
class="text-xs bg-red-50 text-red-600 font-bold px-2 py-1 rounded hover:bg-red-600 hover:text-white transition">
|
||||
撤销职务
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="7" class="px-4 py-12 text-center text-gray-400">暂无在职人员</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
{{-- 新增任命弹窗 --}}
|
||||
<div x-show="showForm" style="display: none;"
|
||||
class="fixed inset-0 z-50 bg-black/60 flex items-center justify-center p-4">
|
||||
<div @click.away="showForm = false" class="bg-white rounded-xl shadow-2xl w-full max-w-md" x-transition>
|
||||
<div
|
||||
style="background-color:#c2410c;padding:1rem 1.5rem;display:flex;justify-content:space-between;align-items:center;border-radius:0.75rem 0.75rem 0 0;">
|
||||
<h3 style="font-weight:700;font-size:1.125rem;color:#fff;margin:0;">新增任命</h3>
|
||||
<button @click="showForm = false"
|
||||
style="color:#fed7aa;background:none;border:none;font-size:1.5rem;cursor:pointer;line-height:1;"
|
||||
onmouseover="this.style.color='#fff'" onmouseout="this.style.color='#fed7aa'">×</button>
|
||||
</div>
|
||||
<div class="p-6">
|
||||
<form action="{{ route('admin.appointments.store') }}" method="POST">
|
||||
@csrf
|
||||
<div class="space-y-4">
|
||||
<div>
|
||||
<label class="block text-xs font-bold text-gray-600 mb-1">用户名</label>
|
||||
<div class="relative">
|
||||
<input type="text" name="username" x-model="username" required
|
||||
placeholder="输入关键字搜索用户..." @input="doSearch($event.target.value)"
|
||||
@blur="setTimeout(() => showDropdown = false, 200)"
|
||||
@focus="if(username.length > 0) doSearch(username)"
|
||||
class="w-full border rounded-md p-2 text-sm" autocomplete="off">
|
||||
{{-- 搜索中指示 --}}
|
||||
<span x-show="searching"
|
||||
class="absolute right-2 top-2.5 text-gray-400 text-xs">搜索中…</span>
|
||||
{{-- 下拉结果 --}}
|
||||
<div x-show="showDropdown" style="display:none;"
|
||||
class="absolute z-50 w-full bg-white border rounded-md shadow-lg mt-1 max-h-48 overflow-y-auto">
|
||||
<template x-for="u in searchResults" :key="u.id">
|
||||
<div @mousedown="selectUser(u)"
|
||||
class="px-3 py-2 hover:bg-orange-50 cursor-pointer flex justify-between items-center">
|
||||
<span class="font-bold text-sm" x-text="u.username"></span>
|
||||
<span class="text-xs text-gray-400" x-text="'Lv.' + u.user_level"></span>
|
||||
</div>
|
||||
</template>
|
||||
<div x-show="searchResults.length === 0 && !searching"
|
||||
class="px-3 py-2 text-xs text-gray-400">无匹配用户(或已有职务)</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-bold text-gray-600 mb-1">目标职务</label>
|
||||
<select name="position_id" x-model="position_id" required
|
||||
class="w-full border rounded-md p-2 text-sm">
|
||||
<option value="">-- 请选择职务 --</option>
|
||||
@foreach ($departments as $dept)
|
||||
<optgroup label="{{ $dept->name }}">
|
||||
@foreach ($dept->positions as $pos)
|
||||
@php
|
||||
$current = $pos->active_user_positions_count ?? 0;
|
||||
$max = $pos->max_persons;
|
||||
$isFull = $max && $current >= $max;
|
||||
$cap = $max
|
||||
? "在职 {$current}/{$max} 人" . ($isFull ? ' ⚠️满' : '')
|
||||
: "在职 {$current} 人·不限额";
|
||||
@endphp
|
||||
<option value="{{ $pos->id }}"
|
||||
{{ $isFull ? 'style=color:#dc2626' : '' }}>
|
||||
{{ $pos->icon }}
|
||||
{{ $pos->name }}(Lv.{{ $pos->level }},{{ $cap }})
|
||||
</option>
|
||||
@endforeach
|
||||
</optgroup>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-bold text-gray-600 mb-1">任命备注(可选)</label>
|
||||
<input type="text" name="remark" x-model="remark" maxlength="255"
|
||||
placeholder="例:表现优秀,特此提拔" class="w-full border rounded-md p-2 text-sm">
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
style="display:flex;justify-content:flex-end;gap:0.75rem;padding-top:1rem;margin-top:1rem;border-top:1px solid #e5e7eb;">
|
||||
<button type="button" @click="showForm = false"
|
||||
style="padding:0.5rem 1rem;border:1px solid #d1d5db;border-radius:0.375rem;font-weight:500;color:#4b5563;background:#fff;cursor:pointer;"
|
||||
onmouseover="this.style.background='#f9fafb'"
|
||||
onmouseout="this.style.background='#fff'">取消</button>
|
||||
<button type="submit"
|
||||
style="padding:0.5rem 1rem;background-color:#f97316;color:#fff;border-radius:0.375rem;font-weight:700;border:none;cursor:pointer;box-shadow:0 1px 2px rgba(0,0,0,.1);"
|
||||
onmouseover="this.style.backgroundColor='#ea580c'"
|
||||
onmouseout="this.style.backgroundColor='#f97316'">
|
||||
确认任命
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
@@ -20,7 +20,7 @@
|
||||
<div class="md:col-span-2">
|
||||
<label class="block text-xs font-bold text-gray-600 mb-1">事件文本
|
||||
<span class="text-gray-400 font-normal">({username} 将被替换为触发者用户名)</span></label>
|
||||
<input type="text" name="text_body" required placeholder="例:🎉 恭喜【{username}】获得 100 经验值!"
|
||||
<input type="text" name="text_body" required placeholder="例:🎉 恭喜【{username}】获得 100 经验値!"
|
||||
class="w-full border-gray-300 rounded-md shadow-sm focus:border-indigo-500 focus:ring-indigo-500 p-2 bg-white border">
|
||||
</div>
|
||||
<div>
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
{{--
|
||||
文件功能:后台开发日志新增/编辑表单(仅 id=1 超级管理员可访问)
|
||||
新增时:可选立即发布 + 通知大厅用户(触发 WebSocket 广播)
|
||||
编辑时:不显示"通知大厅"选项,不更新 published_at
|
||||
|
||||
@extends admin.layouts.app
|
||||
--}}
|
||||
@extends('admin.layouts.app')
|
||||
|
||||
@section('title', $isCreate ? '新增开发日志' : '编辑开发日志')
|
||||
|
||||
@section('content')
|
||||
<div class="flex items-center gap-3 mb-6">
|
||||
<a href="{{ route('admin.changelogs.index') }}" class="text-gray-400 hover:text-gray-600 transition">← 返回列表</a>
|
||||
<h2 class="text-xl font-bold text-gray-800">{{ $isCreate ? '📝 新增开发日志' : '✏️ 编辑开发日志' }}</h2>
|
||||
</div>
|
||||
|
||||
<div class="max-w-3xl bg-white rounded-xl shadow-sm border border-gray-100 p-6">
|
||||
<form action="{{ $isCreate ? route('admin.changelogs.store') : route('admin.changelogs.update', $log->id) }}"
|
||||
method="POST">
|
||||
@csrf
|
||||
@if (!$isCreate)
|
||||
@method('PUT')
|
||||
@endif
|
||||
|
||||
{{-- 版本号 + 类型 --}}
|
||||
<div class="grid grid-cols-2 gap-4 mb-4">
|
||||
<div>
|
||||
<label class="block text-sm font-bold text-gray-700 mb-2">
|
||||
版本号 <span class="text-red-500">*</span>
|
||||
<span class="font-normal text-gray-400 ml-1">(推荐使用日期格式,如 2026-02-28)</span>
|
||||
</label>
|
||||
<input type="text" name="version" value="{{ old('version', $log?->version ?? $todayVersion) }}"
|
||||
required maxlength="30" placeholder="例: 2026-02-28"
|
||||
class="w-full border border-gray-200 rounded-lg p-2.5 text-sm focus:ring-2 focus:ring-indigo-400 outline-none">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-bold text-gray-700 mb-2">类型 <span class="text-red-500">*</span></label>
|
||||
<select name="type"
|
||||
class="w-full border border-gray-200 rounded-lg p-2.5 text-sm focus:ring-2 focus:ring-indigo-400 outline-none">
|
||||
@foreach ($typeOptions as $value => $config)
|
||||
<option value="{{ $value }}" {{ old('type', $log?->type) === $value ? 'selected' : '' }}>
|
||||
{{ $config['label'] }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- 标题 --}}
|
||||
<div class="mb-4">
|
||||
<label class="block text-sm font-bold text-gray-700 mb-2">标题 <span class="text-red-500">*</span></label>
|
||||
<input type="text" name="title" value="{{ old('title', $log?->title) }}" required maxlength="200"
|
||||
placeholder="简洁描述本次更新的重点..."
|
||||
class="w-full border border-gray-200 rounded-lg p-2.5 text-sm focus:ring-2 focus:ring-indigo-400 outline-none">
|
||||
</div>
|
||||
|
||||
{{-- Markdown 内容 --}}
|
||||
<div class="mb-5">
|
||||
<label class="block text-sm font-bold text-gray-700 mb-2">
|
||||
详细内容 <span class="text-red-500">*</span>
|
||||
<span class="font-normal text-gray-400 ml-1">(支持 Markdown 格式)</span>
|
||||
</label>
|
||||
<textarea name="content" required rows="16"
|
||||
placeholder="## 新增功能 - 新增了 AI 聊天机器人功能 - 支持多种 AI 服务商(OpenAI / DeepSeek) ## Bug 修复 - 修复了钓鱼游戏积分计算错误 ## 优化 - 改进了消息加载速度"
|
||||
class="w-full border border-gray-200 rounded-lg p-3 text-sm font-mono resize-y focus:ring-2 focus:ring-indigo-400 outline-none leading-relaxed">{{ old('content', $log?->content) }}</textarea>
|
||||
<p class="text-xs text-gray-400 mt-1">支持 ## 标题、- 列表、`代码` 等 Markdown 格式</p>
|
||||
</div>
|
||||
|
||||
{{-- 发布选项 --}}
|
||||
<div class="bg-gray-50 rounded-xl p-4 mb-5 border border-gray-200">
|
||||
<label class="flex items-center gap-3 cursor-pointer group">
|
||||
<input type="checkbox" name="is_published" value="1"
|
||||
{{ old('is_published', $log?->is_published) ? 'checked' : '' }}
|
||||
class="w-4 h-4 text-indigo-600 rounded focus:ring-indigo-400" id="is_published">
|
||||
<span class="font-bold text-gray-800">立即发布</span>
|
||||
<span class="text-gray-500 text-sm font-normal">(取消勾选则保存为草稿)</span>
|
||||
</label>
|
||||
|
||||
@if ($isCreate)
|
||||
{{-- 新增时显示"通知大厅"选项 --}}
|
||||
<label class="flex items-center gap-3 cursor-pointer mt-3" id="notify-row">
|
||||
<input type="checkbox" name="notify_chat" value="1" checked
|
||||
class="w-4 h-4 text-purple-600 rounded focus:ring-purple-400" id="notify_chat">
|
||||
<span class="font-bold text-gray-800">通知大厅用户</span>
|
||||
<span class="text-gray-500 text-sm font-normal">
|
||||
(发布时在「星光大厅 Room 1」的聊天区广播通知,含可点击链接)
|
||||
</span>
|
||||
</label>
|
||||
@else
|
||||
{{-- 编辑时也可手动触发通知 --}}
|
||||
<label class="flex items-center gap-3 cursor-pointer mt-3" id="notify-row">
|
||||
<input type="checkbox" name="notify_chat" value="1"
|
||||
class="w-4 h-4 text-purple-600 rounded focus:ring-purple-400" id="notify_chat">
|
||||
<span class="font-bold text-gray-800">重新通知大厅用户</span>
|
||||
<span class="text-gray-500 text-sm font-normal">
|
||||
(勾选后保存,将再次向「星光大厅」广播此日志通知)
|
||||
</span>
|
||||
</label>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
{{-- 操作按钮 --}}
|
||||
<div class="flex justify-end gap-3">
|
||||
<a href="{{ route('admin.changelogs.index') }}"
|
||||
class="px-5 py-2 border border-gray-200 rounded-lg text-gray-600 hover:bg-gray-50 font-medium text-sm transition">
|
||||
取消
|
||||
</a>
|
||||
<button type="submit"
|
||||
class="px-6 py-2 bg-indigo-600 text-white rounded-lg font-bold hover:bg-indigo-700 text-sm shadow-sm transition">
|
||||
{{ $isCreate ? '保存日志' : '更新日志' }}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@endsection
|
||||
@@ -0,0 +1,102 @@
|
||||
{{--
|
||||
文件功能:后台开发日志列表页(仅 id=1 超级管理员可访问)
|
||||
展示所有日志(含草稿),支持发布/编辑/删除操作
|
||||
|
||||
@extends admin.layouts.app
|
||||
--}}
|
||||
@extends('admin.layouts.app')
|
||||
|
||||
@section('title', '开发日志管理')
|
||||
|
||||
@section('content')
|
||||
<div class="flex justify-between items-center mb-6">
|
||||
<div>
|
||||
<h2 class="text-xl font-bold text-gray-800">📋 开发日志管理</h2>
|
||||
<p class="text-sm text-gray-500 mt-1">管理版本更新记录,发布后可在大厅消息区通知用户</p>
|
||||
</div>
|
||||
<a href="{{ route('admin.changelogs.create') }}"
|
||||
class="bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded-lg font-bold text-sm shadow transition">
|
||||
+ 新增日志
|
||||
</a>
|
||||
</div>
|
||||
|
||||
{{-- 日志列表 --}}
|
||||
<div class="bg-white rounded-xl shadow-sm border border-gray-100 overflow-hidden">
|
||||
<table class="w-full text-sm">
|
||||
<thead class="bg-gray-50 border-b border-gray-100">
|
||||
<tr class="text-left text-gray-500 text-xs font-bold uppercase tracking-wider">
|
||||
<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">发布时间</th>
|
||||
<th class="px-5 py-3 text-right">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-gray-50">
|
||||
@forelse($logs as $log)
|
||||
<tr class="hover:bg-gray-50 transition-colors">
|
||||
<td class="px-5 py-3 font-mono text-indigo-700 font-bold">v{{ $log->version }}</td>
|
||||
<td class="px-5 py-3 text-gray-800 font-medium">{{ $log->title }}</td>
|
||||
<td class="px-5 py-3">
|
||||
@php
|
||||
$typeConfig = \App\Models\DevChangelog::TYPE_CONFIG[$log->type] ?? null;
|
||||
$colorMap = [
|
||||
'emerald' => 'bg-emerald-100 text-emerald-700',
|
||||
'rose' => 'bg-rose-100 text-rose-700',
|
||||
'blue' => 'bg-blue-100 text-blue-700',
|
||||
'slate' => 'bg-slate-100 text-slate-700',
|
||||
];
|
||||
@endphp
|
||||
<span
|
||||
class="px-2 py-0.5 rounded-full text-xs font-bold {{ $colorMap[$typeConfig['color'] ?? 'slate'] ?? 'bg-slate-100 text-slate-700' }}">
|
||||
{{ $typeConfig['label'] ?? '其他' }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-5 py-3">
|
||||
@if ($log->is_published)
|
||||
<span class="px-2 py-0.5 bg-green-100 text-green-700 rounded-full text-xs font-bold">✅
|
||||
已发布</span>
|
||||
@else
|
||||
<span class="px-2 py-0.5 bg-gray-100 text-gray-500 rounded-full text-xs font-bold">🔒
|
||||
草稿</span>
|
||||
@endif
|
||||
</td>
|
||||
<td class="px-5 py-3 text-gray-400 text-xs">
|
||||
{{ $log->published_at?->format('Y-m-d H:i') ?? '—' }}
|
||||
</td>
|
||||
<td class="px-5 py-3 text-right">
|
||||
<div class="flex items-center justify-end gap-2">
|
||||
<a href="{{ route('admin.changelogs.edit', $log->id) }}"
|
||||
class="text-blue-600 hover:text-blue-800 font-semibold text-xs px-2 py-1 rounded hover:bg-blue-50 transition">
|
||||
编辑
|
||||
</a>
|
||||
<form action="{{ route('admin.changelogs.destroy', $log->id) }}" method="POST"
|
||||
onsubmit="return confirm('确定要删除这条日志吗?');">
|
||||
@csrf @method('DELETE')
|
||||
<button type="submit"
|
||||
class="text-red-600 hover:text-red-800 font-semibold text-xs px-2 py-1 rounded hover:bg-red-50 transition">
|
||||
删除
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="6" class="px-5 py-12 text-center text-gray-400">
|
||||
<p class="text-3xl mb-2">📭</p>
|
||||
<p>还没有任何日志,点击右上角「新增日志」开始吧</p>
|
||||
</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@if ($logs->hasPages())
|
||||
<div class="px-5 py-4 border-t border-gray-100">
|
||||
{{ $logs->links() }}
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
@endsection
|
||||
@@ -0,0 +1,185 @@
|
||||
{{--
|
||||
文件功能:后台部门管理页面
|
||||
提供部门的新增、编辑、删除功能,展示每个部门的职务数量
|
||||
|
||||
@author ChatRoom Laravel
|
||||
@version 1.0.0
|
||||
--}}
|
||||
|
||||
@extends('admin.layouts.app')
|
||||
|
||||
@section('title', '部门管理')
|
||||
|
||||
@section('content')
|
||||
<div x-data="{
|
||||
showForm: false,
|
||||
editing: null,
|
||||
form: { name: '', rank: 80, color: '#1a5276', sort_order: 0, description: '' },
|
||||
|
||||
openCreate() {
|
||||
this.editing = null;
|
||||
this.form = { name: '', rank: 80, color: '#1a5276', sort_order: 0, description: '' };
|
||||
this.showForm = true;
|
||||
},
|
||||
openEdit(dept) {
|
||||
this.editing = dept;
|
||||
this.form = { name: dept.name, rank: dept.rank, color: dept.color, sort_order: dept.sort_order, description: dept.description };
|
||||
this.showForm = true;
|
||||
}
|
||||
}">
|
||||
|
||||
{{-- 头部 --}}
|
||||
<div class="flex justify-between items-center mb-6">
|
||||
<div>
|
||||
<h2 class="text-lg font-bold text-gray-800">部门管理</h2>
|
||||
<p class="text-sm text-gray-500">管理聊天室部门架构,设置位阶、颜色与描述</p>
|
||||
</div>
|
||||
<div class="flex space-x-2">
|
||||
<a href="{{ route('admin.positions.index') }}"
|
||||
style="background-color:#16a34a;color:#fff;padding:0.5rem 1rem;border-radius:0.5rem;font-weight:700;font-size:0.875rem;display:inline-flex;align-items:center;text-decoration:none;box-shadow:0 1px 2px rgba(0,0,0,.1);"
|
||||
onmouseover="this.style.backgroundColor='#15803d'" onmouseout="this.style.backgroundColor='#16a34a'">
|
||||
📋 职务管理 →
|
||||
</a>
|
||||
@if (Auth::id() === 1)
|
||||
<button @click="openCreate()"
|
||||
style="background-color:#4f46e5;color:#fff;padding:0.5rem 1.25rem;border-radius:0.5rem;font-weight:700;border:none;cursor:pointer;box-shadow:0 1px 2px rgba(0,0,0,.1);"
|
||||
onmouseover="this.style.backgroundColor='#4338ca'"
|
||||
onmouseout="this.style.backgroundColor='#4f46e5'">
|
||||
+ 新增部门
|
||||
</button>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (session('success'))
|
||||
<div class="mb-4 px-4 py-3 bg-green-50 border border-green-200 text-green-700 rounded-lg text-sm">
|
||||
{{ session('success') }}
|
||||
</div>
|
||||
@endif
|
||||
@if (session('error'))
|
||||
<div class="mb-4 px-4 py-3 bg-red-50 border border-red-200 text-red-700 rounded-lg text-sm">
|
||||
{{ session('error') }}
|
||||
</div>
|
||||
@endif
|
||||
|
||||
{{-- 部门卡片列表 --}}
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 xl:grid-cols-4 gap-4">
|
||||
@foreach ($departments as $dept)
|
||||
<div class="bg-white rounded-xl shadow-sm border overflow-hidden hover:shadow-md transition">
|
||||
<div class="h-2" style="background-color: {{ $dept->color }}"></div>
|
||||
<div class="p-5">
|
||||
<div class="flex items-center justify-between mb-3">
|
||||
<span class="font-bold text-lg" style="color: {{ $dept->color }}">{{ $dept->name }}</span>
|
||||
<span class="text-xs bg-gray-100 px-2 py-0.5 rounded text-gray-500">位阶
|
||||
{{ $dept->rank }}</span>
|
||||
</div>
|
||||
<div class="space-y-1.5 text-sm">
|
||||
<div class="flex justify-between">
|
||||
<span class="text-gray-500">职务数量</span>
|
||||
<span class="font-bold text-indigo-600">{{ $dept->positions_count }} 个</span>
|
||||
</div>
|
||||
<div class="flex justify-between">
|
||||
<span class="text-gray-500">排序</span>
|
||||
<span class="font-bold">{{ $dept->sort_order }}</span>
|
||||
</div>
|
||||
@if ($dept->description)
|
||||
<p class="text-gray-400 text-xs pt-1">{{ $dept->description }}</p>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
@php $superLvl = (int) \App\Models\Sysparam::getValue('superlevel', '100'); @endphp
|
||||
@if (Auth::user()->user_level >= $superLvl)
|
||||
<div class="border-t bg-gray-50 px-5 py-3 flex justify-end space-x-2">
|
||||
<button
|
||||
@click="openEdit({
|
||||
id: {{ $dept->id }},
|
||||
name: '{{ addslashes($dept->name) }}',
|
||||
rank: {{ $dept->rank }},
|
||||
color: '{{ $dept->color }}',
|
||||
sort_order: {{ $dept->sort_order }},
|
||||
description: '{{ addslashes($dept->description ?? '') }}',
|
||||
requestUrl: '{{ route('admin.departments.update', $dept->id) }}'
|
||||
})"
|
||||
class="text-xs bg-indigo-50 text-indigo-600 font-bold px-3 py-1.5 rounded hover:bg-indigo-600 hover:text-white transition">
|
||||
编辑
|
||||
</button>
|
||||
@if (Auth::id() === 1)
|
||||
<form action="{{ route('admin.departments.destroy', $dept->id) }}" method="POST"
|
||||
onsubmit="return confirm('确定删除部门【{{ $dept->name }}】?该操作会同时删除该部门所有职务(有在职人员时拒绝删除)。')">
|
||||
@csrf @method('DELETE')
|
||||
<button type="submit"
|
||||
class="text-xs bg-red-50 text-red-600 font-bold px-3 py-1.5 rounded hover:bg-red-600 hover:text-white transition">
|
||||
删除
|
||||
</button>
|
||||
</form>
|
||||
@endif
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
|
||||
@if ($departments->isEmpty())
|
||||
<div class="text-center py-16 text-gray-400">
|
||||
<p class="text-lg">暂无部门,点击右上角「新增部门」创建</p>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
{{-- 新增/编辑弹窗 --}}
|
||||
<div x-show="showForm" style="display: none;"
|
||||
class="fixed inset-0 z-50 bg-black/60 flex items-center justify-center p-4">
|
||||
<div @click.away="showForm = false" class="bg-white rounded-xl shadow-2xl w-full max-w-md" x-transition>
|
||||
<div class="bg-indigo-900 px-6 py-4 flex justify-between items-center rounded-t-xl text-white">
|
||||
<h3 class="font-bold text-lg" x-text="editing ? '编辑部门:' + editing.name : '新增部门'"></h3>
|
||||
<button @click="showForm = false" class="text-gray-400 hover:text-white text-xl">×</button>
|
||||
</div>
|
||||
<div class="p-6">
|
||||
<form :action="editing ? editing.requestUrl : '{{ route('admin.departments.store') }}'" method="POST">
|
||||
@csrf
|
||||
<template x-if="editing"><input type="hidden" name="_method" value="PUT"></template>
|
||||
|
||||
<div class="grid grid-cols-2 gap-4">
|
||||
<div class="col-span-2">
|
||||
<label class="block text-xs font-bold text-gray-600 mb-1">部门名称</label>
|
||||
<input type="text" name="name" x-model="form.name" required maxlength="50"
|
||||
class="w-full border rounded-md p-2 text-sm">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-bold text-gray-600 mb-1">位阶(0~99,越大越高)</label>
|
||||
<input type="number" name="rank" x-model="form.rank" required min="0"
|
||||
max="99" class="w-full border rounded-md p-2 text-sm">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-bold text-gray-600 mb-1">排序</label>
|
||||
<input type="number" name="sort_order" x-model="form.sort_order" required min="0"
|
||||
class="w-full border rounded-md p-2 text-sm">
|
||||
</div>
|
||||
<div class="col-span-2">
|
||||
<label class="block text-xs font-bold text-gray-600 mb-1">展示颜色</label>
|
||||
<div class="flex items-center space-x-2">
|
||||
<input type="color" name="color" x-model="form.color"
|
||||
class="w-10 h-8 border rounded cursor-pointer">
|
||||
<input type="text" x-model="form.color" maxlength="10"
|
||||
class="flex-1 border rounded-md p-2 text-sm font-mono">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-span-2">
|
||||
<label class="block text-xs font-bold text-gray-600 mb-1">部门描述(可选)</label>
|
||||
<input type="text" name="description" x-model="form.description" maxlength="255"
|
||||
class="w-full border rounded-md p-2 text-sm">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-end space-x-3 pt-4 mt-4 border-t">
|
||||
<button type="button" @click="showForm = false"
|
||||
class="px-4 py-2 border rounded font-medium text-gray-600 hover:bg-gray-50">取消</button>
|
||||
<button type="submit"
|
||||
class="px-4 py-2 bg-indigo-600 text-white rounded font-bold hover:bg-indigo-700 shadow-sm"
|
||||
x-text="editing ? '保存修改' : '创建部门'"></button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
@@ -0,0 +1,187 @@
|
||||
{{--
|
||||
文件功能:后台用户反馈管理页面(仅 id=1 超级管理员可访问)
|
||||
列表展示所有用户提交的 Bug 报告和功能建议
|
||||
支持按类型+状态筛选,可直接修改状态(Ajax)和填写官方回复
|
||||
|
||||
@extends admin.layouts.app
|
||||
--}}
|
||||
@extends('admin.layouts.app')
|
||||
|
||||
@section('title', '用户反馈管理')
|
||||
|
||||
@section('content')
|
||||
<div class="flex justify-between items-center mb-6">
|
||||
<div>
|
||||
<h2 class="text-xl font-bold text-gray-800">
|
||||
💬 用户反馈管理
|
||||
@if ($pendingCount > 0)
|
||||
<span class="ml-2 text-sm bg-orange-100 text-orange-700 font-bold px-2 py-0.5 rounded-full">
|
||||
{{ $pendingCount }} 条待处理
|
||||
</span>
|
||||
@endif
|
||||
</h2>
|
||||
<p class="text-sm text-gray-500 mt-1">管理用户提交的 Bug 报告和功能建议,修改状态后前台实时更新</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- 筛选栏 --}}
|
||||
<div class="flex flex-wrap gap-3 mb-5" x-data="{
|
||||
type: '{{ $currentType ?? '' }}',
|
||||
status: '{{ $currentStatus ?? '' }}',
|
||||
go() {
|
||||
const params = new URLSearchParams();
|
||||
if (this.type) params.set('type', this.type);
|
||||
if (this.status) params.set('status', this.status);
|
||||
window.location.href = '/admin/feedback?' + params.toString();
|
||||
}
|
||||
}">
|
||||
<select x-model="type" @change="go()"
|
||||
class="border border-gray-200 rounded-lg px-3 py-2 text-sm focus:ring-2 focus:ring-indigo-400 outline-none bg-white">
|
||||
<option value="">所有类型</option>
|
||||
<option value="bug">🐛 Bug报告</option>
|
||||
<option value="suggestion">💡 功能建议</option>
|
||||
</select>
|
||||
<select x-model="status" @change="go()"
|
||||
class="border border-gray-200 rounded-lg px-3 py-2 text-sm focus:ring-2 focus:ring-indigo-400 outline-none bg-white">
|
||||
<option value="">所有状态</option>
|
||||
@foreach ($statusConfig as $key => $config)
|
||||
<option value="{{ $key }}">{{ $config['icon'] }} {{ $config['label'] }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
@if ($currentType || $currentStatus)
|
||||
<a href="{{ route('admin.feedback.index') }}"
|
||||
class="px-3 py-2 text-sm text-gray-500 hover:text-gray-700 border border-gray-200 rounded-lg bg-white hover:bg-gray-50 transition">
|
||||
✕ 清除筛选
|
||||
</a>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
{{-- 反馈列表 --}}
|
||||
<div class="space-y-3">
|
||||
@forelse($feedbacks as $feedback)
|
||||
<div class="bg-white rounded-xl border border-gray-100 shadow-sm overflow-hidden" x-data="{
|
||||
expanded: false,
|
||||
status: '{{ $feedback->status }}',
|
||||
remark: @js($feedback->admin_remark ?? ''),
|
||||
saving: false,
|
||||
async updateStatus() {
|
||||
this.saving = true;
|
||||
const res = await fetch('/admin/feedback/{{ $feedback->id }}', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': document.querySelector('meta[name=csrf-token]').content,
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
'X-HTTP-Method-Override': 'PUT',
|
||||
},
|
||||
body: JSON.stringify({ status: this.status, admin_remark: this.remark, _method: 'PUT' }),
|
||||
});
|
||||
const data = await res.json();
|
||||
this.saving = false;
|
||||
if (data.status !== 'success') alert('保存失败');
|
||||
}
|
||||
}">
|
||||
{{-- 卡片头部 --}}
|
||||
<div class="px-5 py-4 flex items-start gap-4">
|
||||
{{-- 赞同数 --}}
|
||||
<div class="shrink-0 text-center">
|
||||
<div class="text-2xl font-black text-indigo-600">{{ $feedback->votes_count }}</div>
|
||||
<div class="text-xs text-gray-400">赞同</div>
|
||||
</div>
|
||||
{{-- 类型+状态+标题 --}}
|
||||
<div class="flex-1 min-w-0">
|
||||
<div class="flex items-center gap-2 flex-wrap mb-1">
|
||||
@php
|
||||
$typeConfig = \App\Models\FeedbackItem::TYPE_CONFIG[$feedback->type] ?? null;
|
||||
@endphp
|
||||
<span
|
||||
class="px-2 py-0.5 rounded text-xs font-bold {{ $feedback->type === 'bug' ? 'bg-rose-100 text-rose-700' : 'bg-blue-100 text-blue-700' }}">
|
||||
{{ $typeConfig['label'] ?? '' }}
|
||||
</span>
|
||||
{{-- 状态下拉(Ajax 即时保存) --}}
|
||||
<select x-model="status" @change="updateStatus()"
|
||||
class="border border-gray-200 rounded px-2 py-0.5 text-xs font-bold focus:ring-1 focus:ring-indigo-400 outline-none cursor-pointer"
|
||||
:disabled="saving">
|
||||
@foreach ($statusConfig as $key => $config)
|
||||
<option value="{{ $key }}"
|
||||
{{ $feedback->status === $key ? 'selected' : '' }}>
|
||||
{{ $config['icon'] }} {{ $config['label'] }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
<span class="text-gray-400 text-xs">💬 {{ $feedback->replies_count }}</span>
|
||||
<span x-show="saving" class="text-xs text-indigo-500 animate-pulse">保存中...</span>
|
||||
</div>
|
||||
<h4 class="font-bold text-gray-800 text-sm">{{ $feedback->title }}</h4>
|
||||
<p class="text-gray-400 text-xs mt-1">
|
||||
by {{ $feedback->username }} · {{ $feedback->created_at->diffForHumans() }}
|
||||
</p>
|
||||
</div>
|
||||
{{-- 展开按钮 --}}
|
||||
<button @click="expanded = !expanded"
|
||||
class="shrink-0 text-indigo-600 hover:text-indigo-800 text-sm font-bold border border-indigo-200 hover:border-indigo-400 px-3 py-1.5 rounded-lg transition">
|
||||
<span x-text="expanded ? '收起 ▲' : '展开 ▽'"></span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{{-- 展开详情 --}}
|
||||
<div x-show="expanded" x-transition.opacity class="border-t border-gray-100">
|
||||
{{-- 原始描述 --}}
|
||||
<div class="px-5 py-4 bg-gray-50 text-sm text-gray-700 leading-relaxed">
|
||||
<p class="font-bold text-gray-500 text-xs mb-2">用户描述</p>
|
||||
<p class="whitespace-pre-wrap">{{ $feedback->content }}</p>
|
||||
</div>
|
||||
|
||||
{{-- 所有补充评论 --}}
|
||||
@if ($feedback->replies->count() > 0)
|
||||
<div class="px-5 py-3 border-t border-gray-100 space-y-2">
|
||||
<p class="text-xs font-bold text-gray-500 mb-2">用户补充 ({{ $feedback->replies->count() }} 条)</p>
|
||||
@foreach ($feedback->replies as $reply)
|
||||
<div
|
||||
class="rounded-lg px-3 py-2 text-sm {{ $reply->is_admin ? 'bg-indigo-50 border border-indigo-200' : 'bg-gray-50' }}">
|
||||
<div class="flex items-center gap-2 mb-1">
|
||||
<span
|
||||
class="font-bold {{ $reply->is_admin ? 'text-indigo-700' : 'text-gray-700' }}">{{ $reply->username }}</span>
|
||||
@if ($reply->is_admin)
|
||||
<span
|
||||
class="text-xs bg-indigo-200 text-indigo-800 px-1.5 rounded font-bold">开发者</span>
|
||||
@endif
|
||||
<span
|
||||
class="text-gray-400 text-xs">{{ $reply->created_at->diffForHumans() }}</span>
|
||||
</div>
|
||||
<p class="text-gray-700 whitespace-pre-wrap">{{ $reply->content }}</p>
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
@endif
|
||||
|
||||
{{-- 官方回复+保存区 --}}
|
||||
<div class="px-5 py-4 border-t border-gray-100 bg-indigo-50/40">
|
||||
<p class="text-xs font-bold text-indigo-800 mb-2">🛡️ 官方回复(公开显示给所有用户)</p>
|
||||
<textarea x-model="remark" rows="3" placeholder="填写官方处理说明、修复进度或拒绝原因..."
|
||||
class="w-full border border-indigo-200 rounded-lg p-2.5 text-sm resize-none focus:ring-2 focus:ring-indigo-400 outline-none bg-white"></textarea>
|
||||
<div class="flex justify-end mt-2">
|
||||
<button @click="updateStatus()" :disabled="saving"
|
||||
class="bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded-lg text-xs font-bold disabled:opacity-50 transition">
|
||||
<span x-text="saving ? '保存中...' : '保存状态+回复'"></span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@empty
|
||||
<div class="bg-white rounded-xl border border-gray-100 py-16 text-center text-gray-400">
|
||||
<p class="text-4xl mb-3">💬</p>
|
||||
<p class="font-bold text-lg">暂无用户反馈</p>
|
||||
<p class="text-sm mt-1">等待用户从前台提交问题和建议</p>
|
||||
</div>
|
||||
@endforelse
|
||||
</div>
|
||||
|
||||
{{-- 分页 --}}
|
||||
@if ($feedbacks->hasPages())
|
||||
<div class="mt-6">
|
||||
{{ $feedbacks->links() }}
|
||||
</div>
|
||||
@endif
|
||||
@endsection
|
||||
@@ -18,6 +18,8 @@
|
||||
<p class="text-xs text-slate-400 mt-2">飘落流星 控制台</p>
|
||||
</div>
|
||||
<nav class="flex-1 px-4 py-6 space-y-2 overflow-y-auto">
|
||||
|
||||
{{-- ──────── 所有有职务的人都可见 ──────── --}}
|
||||
<a href="{{ route('admin.dashboard') }}"
|
||||
class="block px-4 py-3 rounded-md transition {{ request()->routeIs('admin.dashboard') ? 'bg-indigo-600 font-bold' : 'hover:bg-white/10' }}">
|
||||
📊 仪表盘
|
||||
@@ -26,38 +28,76 @@
|
||||
class="block px-4 py-3 rounded-md transition {{ request()->routeIs('admin.currency-stats.*') ? 'bg-indigo-600 font-bold' : 'hover:bg-white/10' }}">
|
||||
📈 积分流水统计
|
||||
</a>
|
||||
@if (Auth::id() === 1)
|
||||
<a href="{{ route('admin.system.edit') }}"
|
||||
class="block px-4 py-3 rounded-md transition {{ request()->routeIs('admin.system.*') ? 'bg-indigo-600 font-bold' : 'hover:bg-white/10' }}">
|
||||
⚙️ 聊天室参数设置
|
||||
</a>
|
||||
<a href="{{ route('admin.smtp.edit') }}"
|
||||
class="block px-4 py-3 rounded-md transition {{ request()->routeIs('admin.smtp.*') ? 'bg-indigo-600 font-bold' : 'hover:bg-white/10' }}">
|
||||
📧 邮件 SMTP 配置
|
||||
</a>
|
||||
@endif
|
||||
<a href="{{ route('admin.users.index') }}"
|
||||
class="block px-4 py-3 rounded-md transition {{ request()->routeIs('admin.users.*') ? 'bg-indigo-600 font-bold' : 'hover:bg-white/10' }}">
|
||||
👥 用户管理
|
||||
</a>
|
||||
<a href="{{ route('admin.rooms.index') }}"
|
||||
class="block px-4 py-3 rounded-md transition {{ request()->routeIs('admin.rooms.*') ? 'bg-indigo-600 font-bold' : 'hover:bg-white/10' }}">
|
||||
🏠 房间管理
|
||||
</a>
|
||||
<a href="{{ route('admin.autoact.index') }}"
|
||||
class="block px-4 py-3 rounded-md transition {{ request()->routeIs('admin.autoact.*') ? 'bg-indigo-600 font-bold' : 'hover:bg-white/10' }}">
|
||||
🎲 随机事件
|
||||
</a>
|
||||
<a href="{{ route('admin.vip.index') }}"
|
||||
class="block px-4 py-3 rounded-md transition {{ request()->routeIs('admin.vip.*') ? 'bg-indigo-600 font-bold' : 'hover:bg-white/10' }}">
|
||||
👑 VIP 会员等级
|
||||
{{-- ──────── 部门职务任命系统 ──────── --}}
|
||||
<div class="border-t border-white/10 my-2"></div>
|
||||
<a href="{{ route('admin.appointments.index') }}"
|
||||
class="block px-4 py-3 rounded-md transition {{ request()->routeIs('admin.appointments.*') ? 'bg-indigo-600 font-bold' : 'hover:bg-white/10' }}">
|
||||
🎖️ 任命管理
|
||||
</a>
|
||||
|
||||
@if (Auth::id() === 1)
|
||||
<a href="{{ route('admin.ai-providers.index') }}"
|
||||
class="block px-4 py-3 rounded-md transition {{ request()->routeIs('admin.ai-providers.*') ? 'bg-indigo-600 font-bold' : 'hover:bg-white/10' }}">
|
||||
🤖 AI 厂商配置
|
||||
{{-- superlevel 及以上:可查看(只读标注)以下模块;id=1 可编辑 --}}
|
||||
@php $superLvl = (int) \App\Models\Sysparam::getValue('superlevel', '100'); @endphp
|
||||
@if (Auth::user()->user_level >= $superLvl)
|
||||
@php $ro = Auth::id() !== 1 ? ' <span style="font-size:10px;opacity:.45;font-weight:normal;">(只读)</span>' : ''; @endphp
|
||||
<div class="border-t border-white/10 my-2"></div>
|
||||
<p class="px-4 text-xs text-slate-500 uppercase tracking-widest mb-1">
|
||||
{{ Auth::id() === 1 ? '站长功能' : '查看' }}</p>
|
||||
|
||||
<a href="{{ route('admin.system.edit') }}"
|
||||
class="block px-4 py-3 rounded-md transition {{ request()->routeIs('admin.system.*') ? 'bg-indigo-600 font-bold' : 'hover:bg-white/10' }}">
|
||||
{!! '⚙️ 聊天室参数' . $ro !!}
|
||||
</a>
|
||||
<a href="{{ route('admin.rooms.index') }}"
|
||||
class="block px-4 py-3 rounded-md transition {{ request()->routeIs('admin.rooms.*') ? 'bg-indigo-600 font-bold' : 'hover:bg-white/10' }}">
|
||||
{!! '🏠 房间管理' . $ro !!}
|
||||
</a>
|
||||
<a href="{{ route('admin.autoact.index') }}"
|
||||
class="block px-4 py-3 rounded-md transition {{ request()->routeIs('admin.autoact.*') ? 'bg-indigo-600 font-bold' : 'hover:bg-white/10' }}">
|
||||
{!! '🎲 随机事件' . $ro !!}
|
||||
</a>
|
||||
<a href="{{ route('admin.vip.index') }}"
|
||||
class="block px-4 py-3 rounded-md transition {{ request()->routeIs('admin.vip.*') ? 'bg-indigo-600 font-bold' : 'hover:bg-white/10' }}">
|
||||
{!! '👑 VIP 会员等级' . $ro !!}
|
||||
</a>
|
||||
<a href="{{ route('admin.departments.index') }}"
|
||||
class="block px-4 py-3 rounded-md transition {{ request()->routeIs('admin.departments.*') ? 'bg-indigo-600 font-bold' : 'hover:bg-white/10' }}">
|
||||
{!! '🏛️ 部门管理' . $ro !!}
|
||||
</a>
|
||||
<a href="{{ route('admin.positions.index') }}"
|
||||
class="block px-4 py-3 rounded-md transition {{ request()->routeIs('admin.positions.*') ? 'bg-indigo-600 font-bold' : 'hover:bg-white/10' }}">
|
||||
{!! '📋 职务管理' . $ro !!}
|
||||
</a>
|
||||
|
||||
{{-- 以下纯写操作:仅 id=1 可见 --}}
|
||||
@if (Auth::id() === 1)
|
||||
<div class="border-t border-white/10 my-2"></div>
|
||||
<p class="px-4 text-xs text-slate-500 uppercase tracking-widest mb-1">系统配置</p>
|
||||
<a href="{{ route('admin.smtp.edit') }}"
|
||||
class="block px-4 py-3 rounded-md transition {{ request()->routeIs('admin.smtp.*') ? 'bg-indigo-600 font-bold' : 'hover:bg-white/10' }}">
|
||||
📧 邮件 SMTP 配置
|
||||
</a>
|
||||
<a href="{{ route('admin.ai-providers.index') }}"
|
||||
class="block px-4 py-3 rounded-md transition {{ request()->routeIs('admin.ai-providers.*') ? 'bg-indigo-600 font-bold' : 'hover:bg-white/10' }}">
|
||||
🤖 AI 厂商配置
|
||||
</a>
|
||||
<a href="{{ route('admin.changelogs.index') }}"
|
||||
class="block px-4 py-3 rounded-md transition {{ request()->routeIs('admin.changelogs.*') ? 'bg-indigo-600 font-bold' : 'hover:bg-white/10' }}">
|
||||
📋 开发日志
|
||||
</a>
|
||||
<a href="{{ route('admin.feedback.index') }}"
|
||||
class="flex items-center justify-between px-4 py-3 rounded-md transition {{ request()->routeIs('admin.feedback.*') ? 'bg-indigo-600 font-bold' : 'hover:bg-white/10' }}">
|
||||
<span>💬 用户反馈</span>
|
||||
@php $pendingFeedback = \App\Models\FeedbackItem::pending()->count(); @endphp
|
||||
@if ($pendingFeedback > 0)
|
||||
<span
|
||||
class="bg-orange-500 text-white text-xs px-1.5 py-0.5 rounded-full font-bold">{{ $pendingFeedback }}</span>
|
||||
@endif
|
||||
</a>
|
||||
@endif
|
||||
@endif
|
||||
</nav>
|
||||
<div class="p-4 border-t border-white/10">
|
||||
|
||||
@@ -0,0 +1,298 @@
|
||||
{{--
|
||||
文件功能:后台职务管理页面
|
||||
按部门分组展示所有职务,支持新增/编辑/删除职务
|
||||
编辑时可通过多选框配置该职务可任命的目标职务列表(任命白名单)
|
||||
|
||||
@author ChatRoom Laravel
|
||||
@version 1.0.0
|
||||
--}}
|
||||
|
||||
@extends('admin.layouts.app')
|
||||
|
||||
@section('title', '职务管理')
|
||||
|
||||
@section('content')
|
||||
<div x-data="{
|
||||
showForm: false,
|
||||
editing: null,
|
||||
selectedIds: [],
|
||||
form: {
|
||||
department_id: '',
|
||||
name: '',
|
||||
icon: '🎖️',
|
||||
rank: 50,
|
||||
level: 60,
|
||||
max_persons: 1,
|
||||
max_reward: '',
|
||||
sort_order: 0
|
||||
},
|
||||
|
||||
openCreate() {
|
||||
this.editing = null;
|
||||
this.selectedIds = [];
|
||||
this.form = { department_id: '', name: '', icon: '🎖️', rank: 50, level: 60, max_persons: 1, max_reward: '', sort_order: 0 };
|
||||
this.showForm = true;
|
||||
},
|
||||
openEdit(pos, appointableIds) {
|
||||
this.editing = pos;
|
||||
this.selectedIds = appointableIds;
|
||||
this.form = {
|
||||
department_id: pos.department_id,
|
||||
name: pos.name,
|
||||
icon: pos.icon || '',
|
||||
rank: pos.rank,
|
||||
level: pos.level,
|
||||
max_persons: pos.max_persons || '',
|
||||
max_reward: pos.max_reward || '',
|
||||
sort_order: pos.sort_order,
|
||||
};
|
||||
this.showForm = true;
|
||||
},
|
||||
toggleId(id) {
|
||||
if (this.selectedIds.includes(id)) {
|
||||
this.selectedIds = this.selectedIds.filter(i => i !== id);
|
||||
} else {
|
||||
this.selectedIds.push(id);
|
||||
}
|
||||
},
|
||||
isSelected(id) {
|
||||
return this.selectedIds.includes(id);
|
||||
}
|
||||
}">
|
||||
|
||||
{{-- 头部 --}}
|
||||
<div class="flex justify-between items-center mb-6">
|
||||
<div>
|
||||
<h2 class="text-lg font-bold text-gray-800">职务管理</h2>
|
||||
<p class="text-sm text-gray-500">管理各部门职务,配置等级、图标、人数上限和任命权限</p>
|
||||
</div>
|
||||
<div class="flex space-x-2">
|
||||
<a href="{{ route('admin.departments.index') }}"
|
||||
style="background-color:#e5e7eb;color:#374151;padding:0.5rem 1rem;border-radius:0.5rem;font-weight:700;font-size:0.875rem;display:inline-flex;align-items:center;text-decoration:none;"
|
||||
onmouseover="this.style.backgroundColor='#d1d5db'" onmouseout="this.style.backgroundColor='#e5e7eb'">
|
||||
← 部门管理
|
||||
</a>
|
||||
<a href="{{ route('admin.appointments.index') }}"
|
||||
style="background-color:#f97316;color:#fff;padding:0.5rem 1rem;border-radius:0.5rem;font-weight:700;font-size:0.875rem;display:inline-flex;align-items:center;text-decoration:none;box-shadow:0 1px 2px rgba(0,0,0,.1);"
|
||||
onmouseover="this.style.backgroundColor='#ea580c'" onmouseout="this.style.backgroundColor='#f97316'">
|
||||
🎖️ 任命管理 →
|
||||
</a>
|
||||
@if (Auth::id() === 1)
|
||||
<button @click="openCreate()"
|
||||
style="background-color:#4f46e5;color:#fff;padding:0.5rem 1.25rem;border-radius:0.5rem;font-weight:700;border:none;cursor:pointer;box-shadow:0 1px 2px rgba(0,0,0,.1);"
|
||||
onmouseover="this.style.backgroundColor='#4338ca'"
|
||||
onmouseout="this.style.backgroundColor='#4f46e5'">
|
||||
+ 新增职务
|
||||
</button>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (session('success'))
|
||||
<div class="mb-4 px-4 py-3 bg-green-50 border border-green-200 text-green-700 rounded-lg text-sm">
|
||||
{{ session('success') }}</div>
|
||||
@endif
|
||||
@if (session('error'))
|
||||
<div class="mb-4 px-4 py-3 bg-red-50 border border-red-200 text-red-700 rounded-lg text-sm">
|
||||
{{ session('error') }}</div>
|
||||
@endif
|
||||
|
||||
{{-- 按部门分组展示职务 --}}
|
||||
@foreach ($departments as $dept)
|
||||
<div class="mb-8">
|
||||
<div class="flex items-center space-x-3 mb-3">
|
||||
<div class="w-3 h-3 rounded-full" style="background-color: {{ $dept->color }}"></div>
|
||||
<h3 class="font-bold text-base" style="color: {{ $dept->color }}">{{ $dept->name }}</h3>
|
||||
<span class="text-xs text-gray-400">位阶 {{ $dept->rank }}</span>
|
||||
</div>
|
||||
|
||||
<div class="bg-white rounded-xl shadow-sm border overflow-hidden">
|
||||
<table class="w-full text-sm">
|
||||
<thead class="bg-gray-50 text-gray-600 text-xs">
|
||||
<tr>
|
||||
<th class="px-4 py-3 text-left">图标</th>
|
||||
<th class="px-4 py-3 text-left">职务名</th>
|
||||
<th class="px-4 py-3 text-center">位阶</th>
|
||||
<th class="px-4 py-3 text-center">等级</th>
|
||||
<th class="px-4 py-3 text-center">人数上限</th>
|
||||
<th class="px-4 py-3 text-center">当前在职</th>
|
||||
<th class="px-4 py-3 text-center">奖励上限</th>
|
||||
<th class="px-4 py-3 text-center">任命权</th>
|
||||
@php $superLvl = (int) \App\Models\Sysparam::getValue('superlevel', '100'); @endphp
|
||||
@if (Auth::user()->user_level >= $superLvl)
|
||||
<th class="px-4 py-3 text-right">操作</th>
|
||||
@endif
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-gray-100">
|
||||
@forelse ($dept->positions as $pos)
|
||||
@php $appointableIds = $pos->appointablePositions->pluck('id')->toArray(); @endphp
|
||||
<tr class="hover:bg-gray-50 transition">
|
||||
<td class="px-4 py-3 text-xl">{{ $pos->icon }}</td>
|
||||
<td class="px-4 py-3 font-bold">{{ $pos->name }}</td>
|
||||
<td class="px-4 py-3 text-center">
|
||||
<span
|
||||
class="text-xs bg-indigo-100 text-indigo-700 px-2 py-0.5 rounded font-mono">{{ $pos->rank }}</span>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-center">
|
||||
<span
|
||||
class="text-xs bg-orange-100 text-orange-700 px-2 py-0.5 rounded font-mono">Lv.{{ $pos->level }}</span>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-center text-gray-600">{{ $pos->max_persons ?? '不限' }}</td>
|
||||
<td class="px-4 py-3 text-center">
|
||||
<span
|
||||
class="{{ $pos->active_user_positions_count >= ($pos->max_persons ?? 999) ? 'text-red-600 font-bold' : 'text-indigo-600' }}">
|
||||
{{ $pos->active_user_positions_count }} 人
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-center text-gray-600">
|
||||
{{ $pos->max_reward ? number_format($pos->max_reward) . '金币' : '不限' }}
|
||||
</td>
|
||||
<td class="px-4 py-3 text-center">
|
||||
@if (count($appointableIds) > 0)
|
||||
<span
|
||||
class="text-xs bg-green-100 text-green-700 px-2 py-0.5 rounded">{{ count($appointableIds) }}
|
||||
个职务</span>
|
||||
@else
|
||||
<span class="text-xs text-gray-400">无</span>
|
||||
@endif
|
||||
</td>
|
||||
<td class="px-4 py-3 text-right space-x-1">
|
||||
@php $superLvl = (int) \App\Models\Sysparam::getValue('superlevel', '100'); @endphp
|
||||
@if (Auth::user()->user_level >= $superLvl)
|
||||
<button
|
||||
@click="openEdit({
|
||||
id: {{ $pos->id }},
|
||||
department_id: {{ $pos->department_id }},
|
||||
name: '{{ addslashes($pos->name) }}',
|
||||
icon: '{{ $pos->icon }}',
|
||||
rank: {{ $pos->rank }},
|
||||
level: {{ $pos->level }},
|
||||
max_persons: {{ $pos->max_persons ?? 'null' }},
|
||||
max_reward: {{ $pos->max_reward ?? 'null' }},
|
||||
sort_order: {{ $pos->sort_order }},
|
||||
requestUrl: '{{ route('admin.positions.update', $pos->id) }}'
|
||||
}, {{ json_encode($appointableIds) }})"
|
||||
class="text-xs bg-indigo-50 text-indigo-600 font-bold px-2 py-1 rounded hover:bg-indigo-600 hover:text-white transition">
|
||||
编辑
|
||||
</button>
|
||||
@endif
|
||||
@if (Auth::id() === 1)
|
||||
<form action="{{ route('admin.positions.destroy', $pos->id) }}" method="POST"
|
||||
class="inline" onsubmit="return confirm('确定删除职务【{{ $pos->name }}】?')">
|
||||
@csrf @method('DELETE')
|
||||
<button type="submit"
|
||||
class="text-xs bg-red-50 text-red-600 font-bold px-2 py-1 rounded hover:bg-red-600 hover:text-white transition">
|
||||
删除
|
||||
</button>
|
||||
</form>
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="9" class="px-4 py-6 text-center text-gray-400">该部门暂无职务</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
|
||||
{{-- 新增/编辑弹窗 --}}
|
||||
<div x-show="showForm" style="display: none;"
|
||||
class="fixed inset-0 z-50 bg-black/60 flex items-center justify-center p-4">
|
||||
<div @click.away="showForm = false"
|
||||
class="bg-white rounded-xl shadow-2xl w-full max-w-2xl max-h-[92vh] overflow-y-auto" x-transition>
|
||||
<div class="bg-indigo-900 px-6 py-4 flex justify-between items-center rounded-t-xl text-white sticky top-0">
|
||||
<h3 class="font-bold text-lg" x-text="editing ? '编辑职务:' + editing.name : '新增职务'"></h3>
|
||||
<button @click="showForm = false" class="text-gray-400 hover:text-white text-xl">×</button>
|
||||
</div>
|
||||
<div class="p-6">
|
||||
<form :action="editing ? editing.requestUrl : '{{ route('admin.positions.store') }}'" method="POST">
|
||||
@csrf
|
||||
<template x-if="editing"><input type="hidden" name="_method" value="PUT"></template>
|
||||
|
||||
<div class="grid grid-cols-2 gap-4 mb-4">
|
||||
<div class="col-span-2">
|
||||
<label class="block text-xs font-bold text-gray-600 mb-1">所属部门</label>
|
||||
<select name="department_id" x-model="form.department_id" required
|
||||
class="w-full border rounded-md p-2 text-sm">
|
||||
<option value="">-- 请选择部门 --</option>
|
||||
@foreach ($departments as $dept)
|
||||
<option value="{{ $dept->id }}">{{ $dept->name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-bold text-gray-600 mb-1">职务名称</label>
|
||||
<input type="text" name="name" x-model="form.name" required maxlength="50"
|
||||
class="w-full border rounded-md p-2 text-sm">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-bold text-gray-600 mb-1">图标(Emoji)</label>
|
||||
<input type="text" name="icon" x-model="form.icon" maxlength="10"
|
||||
class="w-full border rounded-md p-2 text-sm">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-bold text-gray-600 mb-1">位阶(0~99,跨全局排序)</label>
|
||||
<input type="number" name="rank" x-model="form.rank" required min="0"
|
||||
max="99" class="w-full border rounded-md p-2 text-sm">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-bold text-gray-600 mb-1">等级(user_level,1~100)</label>
|
||||
<input type="number" name="level" x-model="form.level" required min="1"
|
||||
max="100" class="w-full border rounded-md p-2 text-sm">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-bold text-gray-600 mb-1">人数上限(空=不限)</label>
|
||||
<input type="number" name="max_persons" x-model="form.max_persons" min="1"
|
||||
class="w-full border rounded-md p-2 text-sm" placeholder="留空不限">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-bold text-gray-600 mb-1">单次奖励上限金币(空=不限)</label>
|
||||
<input type="number" name="max_reward" x-model="form.max_reward" min="0"
|
||||
class="w-full border rounded-md p-2 text-sm" placeholder="留空不限">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-bold text-gray-600 mb-1">排序</label>
|
||||
<input type="number" name="sort_order" x-model="form.sort_order" required
|
||||
min="0" class="w-full border rounded-md p-2 text-sm">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- 任命白名单多选 --}}
|
||||
<div class="border rounded-lg p-4 bg-gray-50">
|
||||
<h4 class="text-xs font-bold text-gray-700 mb-2">
|
||||
任命权限白名单
|
||||
<span class="font-normal text-gray-400 ml-1">(勾选后此职务持有者可将用户任命到以下职务;不勾选则该职务无任命权)</span>
|
||||
</h4>
|
||||
<div class="grid grid-cols-2 gap-1 max-h-52 overflow-y-auto">
|
||||
@foreach ($allPositions as $ap)
|
||||
<label
|
||||
class="flex items-center space-x-2 cursor-pointer hover:bg-white rounded p-1.5 text-sm"
|
||||
:class="isSelected({{ $ap->id }}) ? 'bg-indigo-50 text-indigo-700 font-bold' :
|
||||
'text-gray-700'">
|
||||
<input type="checkbox" name="appointable_ids[]" value="{{ $ap->id }}"
|
||||
:checked="isSelected({{ $ap->id }})"
|
||||
@change="toggleId({{ $ap->id }})" class="rounded text-indigo-600">
|
||||
<span>{{ $ap->department->name }}·{{ $ap->name }}</span>
|
||||
</label>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-end space-x-3 pt-4 mt-4 border-t">
|
||||
<button type="button" @click="showForm = false"
|
||||
class="px-4 py-2 border rounded font-medium text-gray-600 hover:bg-gray-50">取消</button>
|
||||
<button type="submit"
|
||||
class="px-4 py-2 bg-indigo-600 text-white rounded font-bold hover:bg-indigo-700 shadow-sm"
|
||||
x-text="editing ? '保存修改' : '创建职务'"></button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
@@ -97,7 +97,7 @@
|
||||
@unless ($room->room_keep)
|
||||
<form action="{{ route('admin.rooms.destroy', $room->id) }}" method="POST"
|
||||
class="inline"
|
||||
onsubmit="return confirm('确定要删除房间「{{ $room->room_name }}」吗?此操作不可撤销!')">
|
||||
onsubmit="return confirm('确定要删除房间「{{ $room->room_name }}」吗?此操作不可撑销!')">
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<button type="submit"
|
||||
|
||||
@@ -4,10 +4,6 @@
|
||||
|
||||
@section('content')
|
||||
|
||||
@php
|
||||
// 管理员级别 = 最高等级 + 1,后台编辑最高可设到管理员级别
|
||||
$adminLevel = (int) \App\Models\Sysparam::getValue('maxlevel', '15') + 1;
|
||||
@endphp
|
||||
<div class="bg-white rounded-xl shadow-sm border border-gray-100 overflow-hidden mb-6" x-data="userEditor()">
|
||||
<div class="p-6 border-b border-gray-100 bg-gray-50 flex items-center justify-between">
|
||||
<form action="{{ route('admin.users.index') }}" method="GET" class="flex gap-2">
|
||||
@@ -54,6 +50,7 @@
|
||||
等级<span class="text-indigo-500">{{ $arrow('user_level') }}</span>
|
||||
</a>
|
||||
</th>
|
||||
<th class="p-4">职务</th>
|
||||
<th class="p-4">
|
||||
<a href="{{ $sortLink('exp_num') }}" class="hover:text-indigo-600 flex items-center gap-1">
|
||||
经验<span class="text-indigo-500">{{ $arrow('exp_num') }}</span>
|
||||
@@ -95,6 +92,17 @@
|
||||
LV.{{ $user->user_level }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="p-4">
|
||||
@if ($user->activePosition)
|
||||
@php $pos = $user->activePosition->position; @endphp
|
||||
<div class="text-xs text-gray-400">{{ $pos->department->name }}</div>
|
||||
<div class="font-bold text-sm" style="color: {{ $pos->department->color }}">
|
||||
{{ $pos->icon }} {{ $pos->name }}
|
||||
</div>
|
||||
@else
|
||||
<span class="text-gray-300 text-xs">—</span>
|
||||
@endif
|
||||
</td>
|
||||
<td class="p-4 text-sm font-mono text-gray-600">
|
||||
{{ number_format($user->exp_num ?? 0) }}
|
||||
</td>
|
||||
@@ -111,7 +119,6 @@
|
||||
@click="editingUser = {
|
||||
id: {{ $user->id }},
|
||||
username: '{{ addslashes($user->username) }}',
|
||||
user_level: {{ $user->user_level }},
|
||||
exp_num: {{ $user->exp_num ?? 0 }},
|
||||
jjb: {{ $user->jjb ?? 0 }},
|
||||
meili: {{ $user->meili ?? 0 }},
|
||||
@@ -172,26 +179,6 @@
|
||||
@csrf @method('PUT')
|
||||
|
||||
<div class="grid grid-cols-2 gap-4">
|
||||
{{-- 等级 --}}
|
||||
<div>
|
||||
<label class="block text-xs font-bold text-gray-600 mb-1">
|
||||
等级
|
||||
<span class="text-gray-400 font-normal">
|
||||
(最高 <span x-text="adminLevel"></span> 级)
|
||||
</span>
|
||||
</label>
|
||||
<input type="number" name="user_level" x-model="editingUser.user_level" required
|
||||
min="0" :max="adminLevel"
|
||||
:readonly="{{ Auth::id() }} !== 1 && editingUser.id !== {{ Auth::id() }}"
|
||||
class="w-full border-gray-300 rounded-md shadow-sm focus:ring-indigo-500 focus:border-indigo-500 p-2 border text-sm"
|
||||
:class="{
|
||||
'bg-gray-100 cursor-not-allowed': {{ Auth::id() }} !== 1 && editingUser
|
||||
.id !==
|
||||
{{ Auth::id() }}
|
||||
}"
|
||||
:title="{{ Auth::id() }} !== 1 && editingUser.id !== {{ Auth::id() }} ?
|
||||
'仅系统创始人可修改他人等级' : ''">
|
||||
</div>
|
||||
{{-- 经验 --}}
|
||||
<div>
|
||||
<label class="block text-xs font-bold text-gray-600 mb-1">经验值</label>
|
||||
@@ -285,7 +272,6 @@
|
||||
Alpine.data('userEditor', () => ({
|
||||
showEditModal: false,
|
||||
editingUser: {},
|
||||
adminLevel: {{ $adminLevel }},
|
||||
editToast: false,
|
||||
editToastOk: true,
|
||||
editToastMsg: '',
|
||||
|
||||
Reference in New Issue
Block a user