input('plan_id'); $taskName = $request->input('task_name'); if (empty($planId)) { return $this->response() ->error('请选择清理计划'); } if (empty($taskName)) { return $this->response() ->error('请输入任务名称'); } // 调用服务创建任务 $result = CleanupService::createTaskFromPlan($planId, $taskName); if (!$result['success']) { return $this->response() ->error('创建失败:' . $result['message']); } $task = $result['data']; return $this->response() ->success('任务创建成功!') ->detail(" 任务ID:{$task['id']}
任务名称:{$task['task_name']}
关联计划:{$task['plan_name']}
包含表数:{$task['total_tables']}
状态:待执行 ") ->refresh(); } catch (\Exception $e) { return $this->response() ->error('创建失败:' . $e->getMessage()); } } /** * 确认对话框 */ public function confirm() { $plans = CleanupPlan::where('is_enabled', 1)->pluck('plan_name', 'id')->toArray(); return [ '创建清理任务', '请选择清理计划并输入任务名称。', [ 'plan_id' => [ 'type' => 'select', 'label' => '清理计划', 'options' => $plans, 'required' => true, ], 'task_name' => [ 'type' => 'text', 'label' => '任务名称', 'placeholder' => '请输入任务名称', 'required' => true, ] ] ]; } }