showInfo = AdminFollowShow::query()->where(['user_id' => Admin::user()['id']])->first(); $this->followStatusList = UserFollowStatus::query()->orderByDesc('id')->pluck('name', 'id')->toArray(); $this->lastElement = array_slice($this->followStatusList, -1, 1, true); $this->secondaryCollegeList = SecondaryCollege::query()->whereIn('id', $this->showInfo['secondary_college_id'] ?? [])->pluck("name", "id"); $list = Speciality::query()->whereIn("id", $this->showInfo['speciality_id'] ?? [])->get()->toArray(); foreach ($list as $item) { $college = SecondaryCollege::query()->where("id", $item["secondary_college_id"])->first(); $this->specialityList[$item["id"]] = $item["speciality_name"] . "({$college->name})"; } return $content ->header('新生数据概览') ->description('各项数据统计详情') ->body(function (Row $row) { $row->column(12, function (Column $column) { $getData = [ 'secondary_college_id' => request()->get('secondary_college_id', ''), 'speciality_id' => request()->get('speciality_id', ''), 'follow_id' => request()->get('follow_id', ''), ]; if (empty($getData['secondary_college_id'])) { $getData['secondary_college_id'] = $this->showInfo['secondary_college_id'] ?? ""; } $column->row(function (Row $row) use ($getData) { $row->column(12, $this->table($getData)); }); $column->row(function (Row $row) use ($getData) { $row->column(4, new AllEnrollCollege($getData)); $row->column(4, new AllNewFollowCollege($getData)); }); $column->row(function (Row $row) use ($getData) { $row->column(4, new AllEnrollSpeciality($getData)); $row->column(4, new AllNewFollowSpeciality($getData)); }); Admin::script(<<disableToolbar(); // 禁用 $grid->disablePagination(); // 禁用操作 $grid->disableActions(); // 禁用批量操作 $grid->disableBatchActions(); // 禁用行选择 $grid->disableRowSelector(); // 禁用创建 $grid->disableCreateButton(); $grid->filter(function (Grid\Filter $filter) { $filter->panel(); $filter->expand(); $filter->equal('secondary_college_id', '学院') ->select($this->secondaryCollegeList) ->load('speciality_id', '/api/getSpecialityList') ->ignore() ->width(2); $filter->equal('speciality_id', '专业') ->select($this->specialityList) ->ignore() ->width(3); $filter->equal('follow_id', '回访状态') ->select($this->followStatusList) ->ignore() ->width(2); }); }); } /** * @desc 二级联动:学院下面的专业数据 * @author 何鸠鸠 */ public function getSpecialityList(Request $request): array { $provinceId = $request->get('q'); $list = Speciality::query()->where("secondary_college_id", $provinceId)->get()->toArray(); $select = []; foreach ($list as $item) { $college = SecondaryCollege::query()->where("id", $item["secondary_college_id"])->first(); $select[] = ['id' => $item["id"], 'text' => $item["speciality_name"] . "({$college->name})"]; } return $select; } }