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'); // 大卡片通知广播(仅超级管理员,安全隔离:普通用户无此接口)