123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220 |
- <?php
- namespace App\Admin\Controllers;
- use App\Facades\RemoteSsoFacade;
- use App\Models\FourActivity;
- use Encore\Admin\Controllers\AdminController;
- use Encore\Admin\Facades\Admin;
- use Encore\Admin\Form;
- use Encore\Admin\Grid;
- use Encore\Admin\Show;
- use Illuminate\Database\Eloquent\Builder;
- /**
- * 四进活动相关控制器操作
- */
- class FourActivityController extends AdminController
- {
- /**
- * 访问标题
- * @var string
- */
- protected $title = '四进活动';
- /**
- * 远程oss首页
- * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
- */
- public function ssoIndex()
- {
- $indexUrl = "/admin/activities";
- $thirdOpenid = Admin::user()->third_openid;
- $menuResult = RemoteSsoFacade::getUserMenuWebsiteData($thirdOpenid);
- // if (isset($menuResult["menu"])){
- // foreach ($menuResult["menu"] as &$val){
- // if($val["id"]==1000000000000016){
- // $val["menu_url"]=admin_url("activities");
- // }
- // }
- // }
- return view('admin/sso/index', ['menuResult' => $menuResult,"indexUrl"=>$indexUrl]);
- }
- /**
- * Make a grid builder.
- *
- * @return Grid
- */
- protected function grid()
- {
- $user = Admin::user();
- $grid = new Grid(new FourActivity());
- //权限
- $grid->actions(function ($actions) use ($user) {
- // 没有`delete-image`权限的角色不显示删除按钮
- if (!$user->can('delete-activite')) {
- $actions->disableDelete();
- }
- });
- $grid->model()->where(function(Builder $query) use ($user){
- if ($user->username != "admin"){
- $query->where("creator","=",$user->getAuthIdentifier());
- }
- }
- );
- $grid->filter(function($filter){
- $filter->disableIdFilter();
- // $filter->where(function($query){
- // $query->where('activity_range_id=' . $_GET['activity_range_id']);
- // },'hidden');
- // 在这里添加字段过滤器
- $filter->like('title', '主题');
- $filter->equal('type', '活动类型')->select(
- FourActivity::TYPE_MAP
- );
- $filter->equal('activities_type', '四进类型')->select(
- FourActivity::ACTIVITIES_TYPE_MAP
- );
- $filter->expand();
- });
- $grid->column('id', __('ID'));
- $grid->column('title', __('主题'));
- $grid->column('type', __('活动类型'))->using(
- FourActivity::TYPE_MAP
- );
- $grid->column('activities_type', __('四进类型'))->using(
- FourActivity::ACTIVITIES_TYPE_MAP
- );
- $grid->column('active_time', __('活动时间'));
- $grid->column('place', __('活动地点'));
- // $grid->column('content', __('活动内容'));
- // $grid->column('ext', __('附件资料'));
- // $grid->column('creater', __('创建者'));
- // $grid->column('updater', __('修改者'));
- $grid->column('created_at', __('创建时间'));
- $grid->column('updated_at', __('修改时间'));
- return $grid;
- }
- /**
- * Make a show builder.
- *
- * @param mixed $id
- * @return Show
- */
- protected function detail($id)
- {
- $show = new Show(FourActivity::findOrFail($id));
- $show->field('id', __('Id'));
- $show->field('title', __('主题'));
- $show->field('type', __('活动类型'))->using(FourActivity::TYPE_MAP);
- $show->field('activities_type', __('四进类型'))->using(FourActivity::ACTIVITIES_TYPE_MAP);
- $show->field('active_time', __('活动时间'));
- $show->field('content', __('活动内容'));
- $show->field('place', __('活动地点'));
- $show->field('audience_crowd', __('受众人群'))->using(FourActivity::AUDIENCE_CROWD_MAP);
- $show->field('mode', __('方式'))->using(FourActivity::MODE_MAP);
- $show->field('anchor', __('讲者/主持'));
- $show->field('educational_materials', __('发放宣教材料(份)'));
- $show->field('publicity_board', __('宣传栏(期)'));
- $show->field('filling_people', __('填表人'));
- $show->field('filling_time', __('填表时间'));
- $show->field('member_num', __('受宣人次数'));
- $show->field('planned_number', __('计划人数'));
- $show->field('actual_number', __('实到人数'));
- return $show;
- }
- /**
- * Make a form builder.
- *
- * @return Form
- */
- protected function form()
- {
- $form = new Form(new FourActivity());
- $form->radio("type","活动类型")
- ->options(FourActivity::TYPE_MAP)
- ->when("in",array(FourActivity::TYPE_SCIENCE_POPULARIZATION_BASE,FourActivity::TYPE_PROMOTION_ACTIVITIES),function (Form $form) {
- $form->select('activities_type', __('四进类型'))->options(function(){
- return FourActivity::ACTIVITIES_TYPE_MAP;
- });
- $form->datetime('active_time', __('活动时间'));
- $form->text('place', __('活动地点'));
- $form->select('audience_crowd', __('受众人群'))->options(function(){
- return FourActivity::AUDIENCE_CROWD_MAP;
- });
- $form->text('title', __('主题'));
- $form->text('anchor', __('讲者/主持'));
- $form->text('educational_materials', __('发放宣教材料(份)'));
- $form->text('publicity_board', __('宣传栏(期)'));
- $form->text('member_num', __('受宣人次数'));
- $form->text('planned_number', __('计划人数'));
- $form->text('actual_number', __('实到人数'));
- $form->text('filling_people', __('填表人'));
- $form->datetime('filling_time', __('填表时间'));
- $form->select('mode', __('方式'))->options(function(){
- return FourActivity::MODE_MAP;
- })->when("in",array(
- FourActivity::MODE_HEALTH_EDUCATION_LECTURE,
- FourActivity::MODE_TRAIN,
- FourActivity::MODE_GROUP_DISCUSSION_AND_DISCUSSION
- ),function (Form $form) {
- //开展讲座、培训,需同步提交通知、课件、签到表及现场照片
- $form->html("<p style='color: red'>备注:需同步提交通知、课件、签到表及现场照片</p>");
- })->when("in",array(
- FourActivity::MODE_HEALTH_PROMOTION_ACTIVITIES,
- ),function (Form $form) {
- //开展健康宣传活动,需同步提交活动照片、活动总结
- $form->html("<p style='color: red'>备注:需同步提交活动照片、活动总结</p>");
- })->when("in",array_values(array_diff(array_keys(FourActivity::MODE_MAP),array(
- FourActivity::MODE_HEALTH_EDUCATION_LECTURE,
- FourActivity::MODE_TRAIN,
- FourActivity::MODE_GROUP_DISCUSSION_AND_DISCUSSION,
- FourActivity::MODE_HEALTH_PROMOTION_ACTIVITIES
- )
- )),function (Form $form) {
- //其它形式活动根据实际情况提交影像资料
- $form->html("<p style='color: red'>备注:需要根据实际情况提交影像资料</p>");
- });
- //多文件
- $form->multipleFile('ext', __('附件资料'))->removable();
- $form->textarea('content', __('活动内容'));
- })
- ->when("=",FourActivity::TYPE_FEATURED_SERVICES,function (Form $form){
- $form->text('title', __('项目名称'));
- // $form->text('place', __('活动地点'));
- //申报书、任务书、结题报告书和其他
- $form->file('declaration_form', __('申报书'))->removable();
- $form->html("<a style='color: red' onclick='window.open(this.href); return false;' href='https://cydsyy-api.qingerai.com/vendor/excel/附件:2024年朝阳区精神卫生特色服务项目申报书.doc'><button class='btn btn-warning'>下载申报书模版</button></a>");
- $form->file('task_book', __('任务书'))->removable();
- $form->html("<a style='color: red' onclick='window.open(this.href); return false;' href='https://cydsyy-api.qingerai.com/vendor/excel/附件2特色项目任务书.doc'><button class='btn btn-warning'>下载任务书模版</button></a>");
- $form->file('final_report', __('结题报告书'))->removable();
- $form->html("<a style='color: red' onclick='window.open(this.href); return false;' href='https://cydsyy-api.qingerai.com/vendor/excel/附件3:朝阳区特色项目结题报告书.doc'><button class='btn btn-warning'>下载结题报告书模版</button></a>");
- $form->multipleFile('ext', __('其他'))->removable();
- })
- ->when("=",FourActivity::TYPE_FEATURED_REPORT_RECEIPT,function (Form $form){
- $form->text('title', __('回执名称'));
- // $form->text('place', __('活动地点'));
- $form->file('return_receipt', __('回执单'))->removable();
- $form->html("<a style='color: red' onclick='window.open(this.href); return false;' href='https://cydsyy-api.qingerai.com/vendor/excel/回执单.xlsx'><button class='btn btn-warning'>下载回执单模版</button></a>");
- $form->multipleFile('ext', __('其他'))->removable();
- })
- ->required();
- $form->tools(function (Form\Tools $tools) {
- // 去掉`列表`按钮
- $tools->disableList();
- // // 去掉`删除`按钮
- // $tools->disableDelete();
- // // 去掉`查看`按钮
- // $tools->disableView();
- });
- return $form;
- }
- }
|