Jing Li 2024-05-27 18:52:28 +08:00
parent 1fce3af888
commit 8267ed071c
2 changed files with 24 additions and 10 deletions

View File

@ -173,16 +173,29 @@ class WorkflowController extends AdminController
public function getValueOptions(Request $request)
{
$type = $request->input('type');
$options = [];
if ($type == CheckType::Job->value) {
$options = Keyword::where('parent_key', 'job')->select(['key as value', 'name as label'])->get();
}
if ($type == CheckType::User->value) {
$options = Employee::enable()->select(['id as value', 'name as label'])->get();
}
$options = match (CheckType::tryFrom($request->input('type'))) {
CheckType::Job => Keyword::where('parent_key', 'job')->get(['key', 'name']),
CheckType::User => Employee::enable()->get(['id', 'name']),
default => collect(),
};
return $this->response()->success($options);
return $this->response()->success(
$options->map(function ($item) {
switch (get_class($item)) {
case Keyword::class:
return ['value' => $item->key, 'label' => $item->name];
break;
case Employee::class:
return ['value' => $item->id, 'label' => $item->name];
break;
default:
return $item;
break;
}
})->all()
);
}
public function apply(Request $request)

View File

@ -26,6 +26,7 @@ class TaskController extends Controller
$orderBy = <<<'MySQL'
CASE
WHEN task_status = 1 THEN 100
WHEN task_status = 9 THEN 50
ELSE 0
END
MySQL;
@ -56,7 +57,7 @@ MySQL;
}
)
->orderBy(DB::raw($orderBy), 'DESC')
->orderBy('start_at', 'ASC')
->orderBy('start_at', 'DESC')
->orderBy('end_at', 'ASC')
->simplePaginate($request->query('per_page', 20));