FourActivityController.php 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Facades\RemoteSsoFacade;
  4. use App\Models\FourActivity;
  5. use Encore\Admin\Controllers\AdminController;
  6. use Encore\Admin\Facades\Admin;
  7. use Encore\Admin\Form;
  8. use Encore\Admin\Grid;
  9. use Encore\Admin\Show;
  10. use Illuminate\Database\Eloquent\Builder;
  11. /**
  12. * 四进活动相关控制器操作
  13. */
  14. class FourActivityController extends AdminController
  15. {
  16. /**
  17. * 访问标题
  18. * @var string
  19. */
  20. protected $title = '四进活动';
  21. /**
  22. * 远程oss首页
  23. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  24. */
  25. public function ssoIndex()
  26. {
  27. $indexUrl = "/admin/activities";
  28. $thirdOpenid = Admin::user()->third_openid;
  29. $menuResult = RemoteSsoFacade::getUserMenuWebsiteData($thirdOpenid);
  30. // if (isset($menuResult["menu"])){
  31. // foreach ($menuResult["menu"] as &$val){
  32. // if($val["id"]==1000000000000016){
  33. // $val["menu_url"]=admin_url("activities");
  34. // }
  35. // }
  36. // }
  37. return view('admin/sso/index', ['menuResult' => $menuResult,"indexUrl"=>$indexUrl]);
  38. }
  39. /**
  40. * Make a grid builder.
  41. *
  42. * @return Grid
  43. */
  44. protected function grid()
  45. {
  46. $user = Admin::user();
  47. $grid = new Grid(new FourActivity());
  48. //权限
  49. $grid->actions(function ($actions) use ($user) {
  50. // 没有`delete-image`权限的角色不显示删除按钮
  51. if (!$user->can('delete-activite')) {
  52. $actions->disableDelete();
  53. }
  54. });
  55. $grid->model()->where(function(Builder $query) use ($user){
  56. if ($user->username != "admin"){
  57. $query->where("creator","=",$user->getAuthIdentifier());
  58. }
  59. }
  60. );
  61. $grid->filter(function($filter){
  62. $filter->disableIdFilter();
  63. // $filter->where(function($query){
  64. // $query->where('activity_range_id=' . $_GET['activity_range_id']);
  65. // },'hidden');
  66. // 在这里添加字段过滤器
  67. $filter->like('title', '主题');
  68. $filter->equal('type', '活动类型')->select(
  69. FourActivity::TYPE_MAP
  70. );
  71. $filter->equal('activities_type', '四进类型')->select(
  72. FourActivity::ACTIVITIES_TYPE_MAP
  73. );
  74. $filter->expand();
  75. });
  76. $grid->column('id', __('ID'));
  77. $grid->column('title', __('主题'));
  78. $grid->column('type', __('活动类型'))->using(
  79. FourActivity::TYPE_MAP
  80. );
  81. $grid->column('activities_type', __('四进类型'))->using(
  82. FourActivity::ACTIVITIES_TYPE_MAP
  83. );
  84. $grid->column('active_time', __('活动时间'));
  85. $grid->column('place', __('活动地点'));
  86. // $grid->column('content', __('活动内容'));
  87. // $grid->column('ext', __('附件资料'));
  88. // $grid->column('creater', __('创建者'));
  89. // $grid->column('updater', __('修改者'));
  90. $grid->column('created_at', __('创建时间'));
  91. $grid->column('updated_at', __('修改时间'));
  92. return $grid;
  93. }
  94. /**
  95. * Make a show builder.
  96. *
  97. * @param mixed $id
  98. * @return Show
  99. */
  100. protected function detail($id)
  101. {
  102. $show = new Show(FourActivity::findOrFail($id));
  103. $show->field('id', __('Id'));
  104. $show->field('title', __('主题'));
  105. $show->field('type', __('活动类型'))->using(FourActivity::TYPE_MAP);
  106. $show->field('activities_type', __('四进类型'))->using(FourActivity::ACTIVITIES_TYPE_MAP);
  107. $show->field('active_time', __('活动时间'));
  108. $show->field('content', __('活动内容'));
  109. $show->field('place', __('活动地点'));
  110. $show->field('audience_crowd', __('受众人群'))->using(FourActivity::AUDIENCE_CROWD_MAP);
  111. $show->field('mode', __('方式'))->using(FourActivity::MODE_MAP);
  112. $show->field('anchor', __('讲者/主持'));
  113. $show->field('educational_materials', __('发放宣教材料(份)'));
  114. $show->field('publicity_board', __('宣传栏(期)'));
  115. $show->field('filling_people', __('填表人'));
  116. $show->field('filling_time', __('填表时间'));
  117. $show->field('member_num', __('受宣人次数'));
  118. $show->field('planned_number', __('计划人数'));
  119. $show->field('actual_number', __('实到人数'));
  120. return $show;
  121. }
  122. /**
  123. * Make a form builder.
  124. *
  125. * @return Form
  126. */
  127. protected function form()
  128. {
  129. $form = new Form(new FourActivity());
  130. $form->radio("type","活动类型")
  131. ->options(FourActivity::TYPE_MAP)
  132. ->when("in",array(FourActivity::TYPE_SCIENCE_POPULARIZATION_BASE,FourActivity::TYPE_PROMOTION_ACTIVITIES),function (Form $form) {
  133. $form->select('activities_type', __('四进类型'))->options(function(){
  134. return FourActivity::ACTIVITIES_TYPE_MAP;
  135. });
  136. $form->datetime('active_time', __('活动时间'));
  137. $form->text('place', __('活动地点'));
  138. $form->select('audience_crowd', __('受众人群'))->options(function(){
  139. return FourActivity::AUDIENCE_CROWD_MAP;
  140. });
  141. $form->text('title', __('主题'));
  142. $form->text('anchor', __('讲者/主持'));
  143. $form->text('educational_materials', __('发放宣教材料(份)'));
  144. $form->text('publicity_board', __('宣传栏(期)'));
  145. $form->text('member_num', __('受宣人次数'));
  146. $form->text('planned_number', __('计划人数'));
  147. $form->text('actual_number', __('实到人数'));
  148. $form->text('filling_people', __('填表人'));
  149. $form->datetime('filling_time', __('填表时间'));
  150. $form->select('mode', __('方式'))->options(function(){
  151. return FourActivity::MODE_MAP;
  152. })->when("in",array(
  153. FourActivity::MODE_HEALTH_EDUCATION_LECTURE,
  154. FourActivity::MODE_TRAIN,
  155. FourActivity::MODE_GROUP_DISCUSSION_AND_DISCUSSION
  156. ),function (Form $form) {
  157. //开展讲座、培训,需同步提交通知、课件、签到表及现场照片
  158. $form->html("<p style='color: red'>备注:需同步提交通知、课件、签到表及现场照片</p>");
  159. })->when("in",array(
  160. FourActivity::MODE_HEALTH_PROMOTION_ACTIVITIES,
  161. ),function (Form $form) {
  162. //开展健康宣传活动,需同步提交活动照片、活动总结
  163. $form->html("<p style='color: red'>备注:需同步提交活动照片、活动总结</p>");
  164. })->when("in",array_values(array_diff(array_keys(FourActivity::MODE_MAP),array(
  165. FourActivity::MODE_HEALTH_EDUCATION_LECTURE,
  166. FourActivity::MODE_TRAIN,
  167. FourActivity::MODE_GROUP_DISCUSSION_AND_DISCUSSION,
  168. FourActivity::MODE_HEALTH_PROMOTION_ACTIVITIES
  169. )
  170. )),function (Form $form) {
  171. //其它形式活动根据实际情况提交影像资料
  172. $form->html("<p style='color: red'>备注:需要根据实际情况提交影像资料</p>");
  173. });
  174. //多文件
  175. $form->multipleFile('ext', __('附件资料'))->removable();
  176. $form->textarea('content', __('活动内容'));
  177. })
  178. ->when("=",FourActivity::TYPE_FEATURED_SERVICES,function (Form $form){
  179. $form->text('title', __('项目名称'));
  180. // $form->text('place', __('活动地点'));
  181. //申报书、任务书、结题报告书和其他
  182. $form->file('declaration_form', __('申报书'))->removable();
  183. $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>");
  184. $form->file('task_book', __('任务书'))->removable();
  185. $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>");
  186. $form->file('final_report', __('结题报告书'))->removable();
  187. $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>");
  188. $form->multipleFile('ext', __('其他'))->removable();
  189. })
  190. ->when("=",FourActivity::TYPE_FEATURED_REPORT_RECEIPT,function (Form $form){
  191. $form->text('title', __('回执名称'));
  192. // $form->text('place', __('活动地点'));
  193. $form->file('return_receipt', __('回执单'))->removable();
  194. $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>");
  195. $form->multipleFile('ext', __('其他'))->removable();
  196. })
  197. ->required();
  198. $form->tools(function (Form\Tools $tools) {
  199. // 去掉`列表`按钮
  200. $tools->disableList();
  201. // // 去掉`删除`按钮
  202. // $tools->disableDelete();
  203. // // 去掉`查看`按钮
  204. // $tools->disableView();
  205. });
  206. return $form;
  207. }
  208. }