From 89d93c92edd98e8e6452b4feee5bc9853e6ad2ca Mon Sep 17 00:00:00 2001 From: lkddi Date: Sun, 1 Mar 2026 11:28:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=9F=E8=83=BD=EF=BC=9A=E8=81=8C=E5=8A=A1?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E5=86=85=E8=81=94=E7=BC=96=E8=BE=91=20+=20?= =?UTF-8?q?=E5=85=A8=E5=B1=80=E5=A5=96=E5=8A=B1=E9=85=8D=E7=BD=AE=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 职务列表三列内联编辑(失焦/回车自动保存,无需打开编辑弹窗): - 人数上限:PATCH max_persons - 单次上限:PATCH max_reward - 单日上限:PATCH daily_reward_limit 保存成功显示短暂绿色 ✓,失败显示红色错误提示 全局奖励接收次数配置改为 AJAX 自动保存,失焦/回车触发, 无需保存按钮(原表单已移除) 新增接口: - PATCH /admin/positions/{position}/patch(quickPatch) - POST /admin/positions/reward-config(saveRewardConfig,兼容 JSON + 重定向) --- .../Controllers/Admin/PositionController.php | 29 ++- .../views/admin/positions/index.blade.php | 177 ++++++++++++++---- routes/web.php | 1 + 3 files changed, 168 insertions(+), 39 deletions(-) diff --git a/app/Http/Controllers/Admin/PositionController.php b/app/Http/Controllers/Admin/PositionController.php index 62c919f..74bc0b4 100644 --- a/app/Http/Controllers/Admin/PositionController.php +++ b/app/Http/Controllers/Admin/PositionController.php @@ -72,13 +72,35 @@ class PositionController extends Controller return redirect()->route('admin.positions.index')->with('success', "职务【{$data['name']}】创建成功!"); } + /** + * 快速补丁:仅更新职务的数值限额字段(内联编辑专用) + * + * 允许修改的字段:max_persons / max_reward / daily_reward_limit。 + * 只接受 JSON AJAX 请求,只更新提交的字段,其余字段保持不变。 + * + * @param Position $position 目标职务 + */ + public function quickPatch(Request $request, Position $position): \Illuminate\Http\JsonResponse + { + $data = $request->validate([ + 'max_persons' => 'sometimes|nullable|integer|min:1|max:9999', + 'max_reward' => 'sometimes|nullable|integer|min:0|max:999999', + 'daily_reward_limit' => 'sometimes|nullable|integer|min:0|max:999999', + ]); + + // 用 fill+save 确保 null 值(不限)也能正确写入 + $position->fill($data)->save(); + + return response()->json(['status' => 'success']); + } + /** * 保存全局奖励金币接收次数上限 * * 控制每位用户单日内可从所有职务持有者处累计接收奖励的最高次数。 * 0 表示不限制,保存到 sysparam 表中(key: reward_recipient_daily_max)。 */ - public function saveRewardConfig(Request $request): RedirectResponse + public function saveRewardConfig(Request $request): \Illuminate\Http\JsonResponse|RedirectResponse { $request->validate([ 'reward_recipient_daily_max' => 'required|integer|min:0|max:9999', @@ -98,6 +120,11 @@ class PositionController extends Controller $label = $value === '0' ? '不限' : "{$value} 次"; + // AJAX 请求返回 JSON,普通表单提交返回重定向 + if ($request->expectsJson()) { + return response()->json(['status' => 'success', 'message' => "全局接收次数上限已更新为:{$label}"]); + } + return redirect()->route('admin.positions.index') ->with('success', "全局接收次数上限已更新为:{$label}"); } diff --git a/resources/views/admin/positions/index.blade.php b/resources/views/admin/positions/index.blade.php index 80e39e5..8cfcc18 100644 --- a/resources/views/admin/positions/index.blade.php +++ b/resources/views/admin/positions/index.blade.php @@ -101,30 +101,61 @@ {{ session('error') }} @endif - {{-- 全局奖励接收上限配置卡片 --}} -
-
+ {{-- 全局奖励接收上限配置卡片(失焦/回车自动保存) --}} +
+

🪙 全局奖励接收上限

每位用户单日内可从所有职务持有者处累计接收奖励金币的最高次数。 设为 0 表示不限制。 - 当前配置:{{ $globalRecipientDailyMax > 0 ? $globalRecipientDailyMax . ' 次' : '不限' }}

-
- @csrf +
- - 次(0=不限) - - + + 次(0=不限) + {{-- 状态反馈 --}} + 保存中… + ✓ 已保存 + +
@@ -170,32 +201,44 @@ Lv.{{ $pos->level }} - {{ $pos->max_persons ?? '不限' }} + {{-- 人数上限:内联编辑 --}} + + + + + {{ $pos->active_user_positions_count }} 人 - - @if ($pos->max_reward === null) - 不限 - @elseif ($pos->max_reward === 0) - 禁止 - @else - {{ number_format($pos->max_reward) }} - @endif + {{-- 单次奖励上限:内联编辑 --}} + + + + - - @if ($pos->daily_reward_limit === null) - 不限 - @elseif ($pos->daily_reward_limit === 0) - 禁止 - @else - {{ number_format($pos->daily_reward_limit) }} - @endif + {{-- 单日发放总上限:内联编辑 --}} + + + + @if (count($appointableIds) > 0) @@ -229,8 +272,9 @@ @endif @if (Auth::id() === 1) -
+ @csrf @method('DELETE')
@@ -359,3 +404,59 @@
@endsection + +@push('scripts') + +@endsection diff --git a/routes/web.php b/routes/web.php index 4e53884..f803f1b 100644 --- a/routes/web.php +++ b/routes/web.php @@ -191,6 +191,7 @@ Route::middleware(['chat.auth', 'chat.has_position'])->prefix('admin')->name('ad Route::get('/positions', [\App\Http\Controllers\Admin\PositionController::class, 'index'])->name('positions.index'); Route::put('/departments/{department}', [\App\Http\Controllers\Admin\DepartmentController::class, 'update'])->name('departments.update'); Route::put('/positions/{position}', [\App\Http\Controllers\Admin\PositionController::class, 'update'])->name('positions.update'); + Route::patch('/positions/{position}/patch', [\App\Http\Controllers\Admin\PositionController::class, 'quickPatch'])->name('positions.quick_patch'); Route::post('/positions/reward-config', [\App\Http\Controllers\Admin\PositionController::class, 'saveRewardConfig'])->name('positions.reward_config'); // 大卡片通知广播(仅超级管理员,安全隔离:普通用户无此接口)