liyinglin 2 years ago
parent d2003b18e8
commit a5a8e7002f

@ -11,7 +11,7 @@ class AskSubmitForm extends Form
{
public function buildForm()
{
// $this->add("project_id", Field::SELECT, ["label" => "所属项目/医院", "empty_value" => "请选择", "choices" => (new Project())->get()->pluck("name", "id")->toArray()]);
$this->add("project_id", Field::SELECT, ["label" => "所属项目/医院", "empty_value" => "请选择", "choices" => (new Project())->get()->pluck("name", "id")->toArray()]);
$this->add("visit", Field::TEXT, ["label" => "拜访人员", "rules" => "required"]);
$this->add("date", Field::DATE, ["label" => "考核日期", "rules" => "required"]);
$this->add("department", Field::TEXT, ["label" => "科室", "rules" => "required"]);
@ -43,5 +43,4 @@ class AskSubmitForm extends Form
}
}

@ -317,7 +317,11 @@ class ProjectController extends CommonController
public function askSubmitCreate(FormBuilder $formBuilder)
{
dd(auth()->user());
$project_ids = auth()->user()->project_ids;
if ($project_ids) {
$project_ids = explode(',', $project_ids);
}
$form = $formBuilder->create(AskSubmitForm::class, [
"method" => "POST",
"id" => "fm",
@ -325,10 +329,12 @@ class ProjectController extends CommonController
]);
$form->modify("project_id", "select", [
"label" => "所属项目/医院", "empty_value" => "请选择",
"choices" => (new ParamedicLevel())->whereIn("project_id", $vo->project_id)->get()->pluck("name", "id")->toArray()
"choices" => (new ParamedicLevel())->where(function ($query) use ($project_ids) {
if ($project_ids) {
$query->whereIn("project_id", $project_ids);
}
})->get()->pluck("name", "id")->toArray()
]);
return view($this->bladePath . ".asksubmit_create", compact("form"));
}

Loading…
Cancel
Save