FourActivityController.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Admin\Actions\Activity\Report;
  4. use App\Admin\Actions\ReportAudit;
  5. use App\Facades\RemoteSsoFacade;
  6. use App\Models\FourActivity;
  7. use Encore\Admin\Controllers\AdminController;
  8. use Encore\Admin\Facades\Admin;
  9. use Encore\Admin\Form;
  10. use Encore\Admin\Grid;
  11. use Encore\Admin\Show;
  12. use GuzzleHttp\Psr7\Request as Psr7Request;
  13. use Illuminate\Database\Eloquent\Builder;
  14. use Illuminate\Http\Client\Request;
  15. use Illuminate\Http\Request as HttpRequest;
  16. use Illuminate\Support\Facades\Request as FacadesRequest;
  17. /**
  18. * 四进活动相关控制器操作
  19. */
  20. class FourActivityController extends AdminController
  21. {
  22. /**
  23. * 访问标题
  24. * @var string
  25. */
  26. public $title = '四进活动';
  27. /**
  28. * 远程oss首页
  29. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  30. */
  31. public function ssoIndex(HttpRequest $request)
  32. {
  33. $url = $request->getRequestUri();
  34. $params = explode('?', $url);
  35. $indexUrl = "/admin/activity/create";
  36. $thirdOpenid = Admin::user()->third_openid;
  37. $menuResult = RemoteSsoFacade::getUserMenuWebsiteData($thirdOpenid);
  38. // var_dump($menuResult);exit;
  39. // if (isset($menuResult["menu"])){
  40. // foreach ($menuResult["menu"] as &$val){
  41. // if($val["id"]==1000000000000016){
  42. // $val["menu_url"]=admin_url("activities");
  43. // }
  44. // }
  45. // }
  46. return view('admin/sso/index', ['menuResult' => $menuResult,"indexUrl"=>$indexUrl, "paramUrl" => $params[1]]);
  47. }
  48. /**
  49. * Make a grid builder.
  50. *
  51. * @return Grid
  52. */
  53. protected function grid()
  54. {
  55. $user = Admin::user();
  56. $grid = new Grid(new FourActivity());
  57. //权限
  58. $grid->actions(function ($actions) use ($user) {
  59. // 没有`delete-image`权限的角色不显示删除按钮
  60. if (!$user->can('delete-activite')) {
  61. $actions->disableDelete();
  62. }
  63. });
  64. $grid->model()->where(function(Builder $query) use ($user){
  65. if ($user->username != "admin"){
  66. // $query->where("creator","=",$user->getAuthIdentifier());
  67. $result = RemoteSsoFacade::getChildWorksation($user->workstation_id);
  68. if($result){
  69. $ocIdArr = array_column($result,'open_oc_id');
  70. array_push($ocIdArr, $user->workstation_id);
  71. $query->whereIn('workstation_id',$ocIdArr);
  72. }
  73. }
  74. }
  75. );
  76. $grid->filter(function($filter){
  77. $filter->disableIdFilter();
  78. // $filter->where(function($query){
  79. // $query->where('activity_range_id=' . $_GET['activity_range_id']);
  80. // },'hidden');
  81. // 在这里添加字段过滤器
  82. $filter->like('title', '主题');
  83. $filter->equal('type', '活动类型')->select(
  84. FourActivity::TYPE_MAP
  85. );
  86. $filter->equal('activities_type', '四进类型')->select(
  87. FourActivity::ACTIVITIES_TYPE_MAP
  88. );
  89. $filter->expand();
  90. });
  91. $grid->column('id', __('ID'));
  92. $grid->column('title', __('主题'));
  93. $grid->column('type', __('活动类型'))->using(
  94. FourActivity::TYPE_MAP
  95. );
  96. $grid->column('activities_type', __('四进类型'))->using(
  97. FourActivity::ACTIVITIES_TYPE_MAP
  98. );
  99. $grid->column('active_time', __('活动时间'));
  100. $grid->column('place', __('活动地点'));
  101. $grid->column('audit_status', __('审核状态'))->display(function($vaule){
  102. switch ($vaule) {
  103. case FourActivity::AUDIT_STATUS_PENDING:
  104. $str = "待审核";
  105. break;
  106. case FourActivity::AUDIT_STATUS_PASS:
  107. $str = "<font color='green'>已通过 </font>";
  108. break;
  109. case FourActivity::AUDIT_STATUS_REJECT:
  110. $str = "<font color='red'>已驳回</font>";
  111. break;
  112. default:
  113. $str = "待审核";
  114. break;
  115. }
  116. return $str;
  117. });
  118. // $grid->column('content', __('活动内容'));
  119. // $grid->column('ext', __('附件资料'));
  120. // $grid->column('creater', __('创建者'));
  121. // $grid->column('updater', __('修改者'));
  122. $grid->column('created_at', __('创建时间'));
  123. $grid->column('updated_at', __('修改时间'));
  124. $grid->actions(function ($actions) {
  125. $row = $actions->row;
  126. if($row->audit_status == FourActivity::AUDIT_STATUS_PENDING) {
  127. $actions->add(new ReportAudit);
  128. }
  129. });
  130. $grid->disableCreateButton();
  131. $grid->disableExport();
  132. $grid->disableColumnSelector();
  133. $grid->tools(function (Grid\Tools $tools) {
  134. $tools->append(new Report);
  135. });
  136. return $grid;
  137. }
  138. /**
  139. * Make a show builder.
  140. *
  141. * @param mixed $id
  142. * @return Show
  143. */
  144. protected function detail($id)
  145. {
  146. $show = new Show(FourActivity::findOrFail($id));
  147. $show->field('id', __('Id'));
  148. $show->field('title', __('主题'));
  149. $show->field('type', __('活动类型'))->using(FourActivity::TYPE_MAP);
  150. $show->field('activities_type', __('四进类型'))->using(FourActivity::ACTIVITIES_TYPE_MAP);
  151. $show->field('active_time', __('活动时间'));
  152. $show->field('content', __('活动内容'));
  153. $show->field('place', __('活动地点'));
  154. $show->field('audience_crowd', __('受众人群'))->using(FourActivity::AUDIENCE_CROWD_MAP);
  155. $show->field('mode', __('方式'))->using(FourActivity::MODE_MAP);
  156. $show->field('anchor', __('讲者/主持'));
  157. $show->field('educational_materials', __('发放宣教材料(份)'));
  158. $show->field('publicity_board', __('宣传栏(期)'));
  159. $show->field('filling_people', __('填表人'));
  160. $show->field('filling_time', __('填表时间'));
  161. $show->field('member_num', __('受宣人次数'));
  162. $show->field('planned_number', __('计划人数'));
  163. $show->field('actual_number', __('实到人数'));
  164. $show->field('audit_status', __('审核状态'))->using(FourActivity::AUDIT_STATUS_MAP);
  165. $show->field('audit_not_reason', __('驳回原因'));
  166. return $show;
  167. }
  168. /**
  169. * Make a form builder.
  170. *
  171. * @return Form
  172. */
  173. protected function form(HttpRequest $request)
  174. {
  175. var_dump($request->all());exit;
  176. $form = new Form(new FourActivity());
  177. $form->setTitle('工作上报');
  178. $form->hidden('workstation_id')->value(Admin::user()->workstation_id);
  179. $form->hidden('workstation_name')->value(Admin::user()->workstation_name);
  180. $form->radio("type","活动类型")
  181. ->options(FourActivity::TYPE_MAP)
  182. ->default(FourActivity::TYPE_SCIENCE_POPULARIZATION_BASE)
  183. ->when("=",FourActivity::TYPE_SCIENCE_POPULARIZATION_BASE,function (Form $form) {
  184. $form->select('activities_type', __('四进类型'))->options(function(){
  185. return FourActivity::ACTIVITIES_TYPE_MAP;
  186. });
  187. $form->datetime('active_time', __('活动时间'));
  188. $form->text('place', __('活动地点'));
  189. $form->select('audience_crowd', __('受众人群'))->options(function(){
  190. return FourActivity::AUDIENCE_CROWD_MAP;
  191. });
  192. $form->text('title', __('主题'));
  193. $form->text('anchor', __('讲者/主持'));
  194. $form->text('educational_materials', __('发放宣教材料(份)'));
  195. $form->text('publicity_board', __('宣传栏(期)'));
  196. $form->text('member_num', __('受宣人次数'));
  197. $form->text('planned_number', __('计划人数'));
  198. $form->text('actual_number', __('实到人数'));
  199. $form->text('filling_people', __('填表人'));
  200. $form->datetime('filling_time', __('填表时间'));
  201. $form->select('mode', __('方式'))->options(function(){
  202. return FourActivity::MODE_MAP;
  203. })->when("in",array(
  204. FourActivity::MODE_HEALTH_EDUCATION_LECTURE,
  205. FourActivity::MODE_TRAIN,
  206. FourActivity::MODE_GROUP_DISCUSSION_AND_DISCUSSION
  207. ),function (Form $form) {
  208. //开展讲座、培训,需同步提交通知、课件、签到表及现场照片
  209. $form->html("<p style='color: red'>备注:需同步提交通知、课件、签到表及现场照片</p>");
  210. })->when("in",array(
  211. FourActivity::MODE_HEALTH_PROMOTION_ACTIVITIES,
  212. ),function (Form $form) {
  213. //开展健康宣传活动,需同步提交活动照片、活动总结
  214. $form->html("<p style='color: red'>备注:需同步提交活动照片、活动总结</p>");
  215. })->when("in",array_values(array_diff(array_keys(FourActivity::MODE_MAP),array(
  216. FourActivity::MODE_HEALTH_EDUCATION_LECTURE,
  217. FourActivity::MODE_TRAIN,
  218. FourActivity::MODE_GROUP_DISCUSSION_AND_DISCUSSION,
  219. FourActivity::MODE_HEALTH_PROMOTION_ACTIVITIES
  220. )
  221. )),function (Form $form) {
  222. //其它形式活动根据实际情况提交影像资料
  223. $form->html("<p style='color: red'>备注:需要根据实际情况提交影像资料</p>");
  224. });
  225. //多文件
  226. $form->multipleFile('ext', __('附件资料'))->removable();
  227. $form->textarea('content', __('活动内容'));
  228. $form->html('<div style="color:red"><p>1.开展讲座、培训,需同步提交通知、课件、签到表及现场照片;</p><p>2.开展宣传活动,需同步提交活动照片、活动总结;</p><p>3.其它形式活动根据实际情况提交影像资料。</p></div>','注意事项');
  229. })
  230. ->when("=",FourActivity::TYPE_PROMOTION_ACTIVITIES,function (Form $form) {
  231. $form->select('activities_type', __('四进类型'))->options(function(){
  232. return FourActivity::ACTIVITIES_TYPE_MAP;
  233. });
  234. $form->datetime('active_time', __('活动时间'));
  235. $form->text('place', __('活动地点'));
  236. $form->select('audience_crowd', __('受众人群'))->options(function(){
  237. return FourActivity::AUDIENCE_CROWD_MAP;
  238. });
  239. $form->text('title', __('主题'));
  240. $form->text('anchor', __('讲者/主持'));
  241. $form->text('educational_materials', __('发放宣教材料(份)'));
  242. $form->text('publicity_board', __('宣传栏(期)'));
  243. $form->text('member_num', __('受宣人次数'));
  244. $form->text('planned_number', __('计划人数'));
  245. $form->text('actual_number', __('实到人数'));
  246. $form->text('filling_people', __('填表人'));
  247. $form->datetime('filling_time', __('填表时间'));
  248. $form->select('mode', __('方式'))->options(function(){
  249. return FourActivity::MODE_MAP;
  250. })->when("in",array(
  251. FourActivity::MODE_HEALTH_EDUCATION_LECTURE,
  252. FourActivity::MODE_TRAIN,
  253. FourActivity::MODE_GROUP_DISCUSSION_AND_DISCUSSION
  254. ),function (Form $form) {
  255. //开展讲座、培训,需同步提交通知、课件、签到表及现场照片
  256. $form->html("<p style='color: red'>备注:需同步提交通知、课件、签到表及现场照片</p>");
  257. })->when("in",array(
  258. FourActivity::MODE_HEALTH_PROMOTION_ACTIVITIES,
  259. ),function (Form $form) {
  260. //开展健康宣传活动,需同步提交活动照片、活动总结
  261. $form->html("<p style='color: red'>备注:需同步提交活动照片、活动总结</p>");
  262. })->when("in",array_values(array_diff(array_keys(FourActivity::MODE_MAP),array(
  263. FourActivity::MODE_HEALTH_EDUCATION_LECTURE,
  264. FourActivity::MODE_TRAIN,
  265. FourActivity::MODE_GROUP_DISCUSSION_AND_DISCUSSION,
  266. FourActivity::MODE_HEALTH_PROMOTION_ACTIVITIES
  267. )
  268. )),function (Form $form) {
  269. //其它形式活动根据实际情况提交影像资料
  270. $form->html("<p style='color: red'>备注:需要根据实际情况提交影像资料</p>");
  271. });
  272. //多文件
  273. $form->multipleFile('ext', __('附件资料'))->removable();
  274. $form->textarea('content', __('活动内容'));
  275. $form->html('<div style="color:red"><p>1.开展讲座、培训,需同步提交通知、课件、签到表及现场照片;</p><p>2.开展宣传活动,需同步提交活动照片、活动总结;</p><p>3.其它形式活动根据实际情况提交影像资料。</p></div>','注意事项');
  276. })
  277. ->when("=",FourActivity::TYPE_FEATURED_SERVICES,function (Form $form){
  278. $form->text('title', __('项目名称'));
  279. // $form->text('place', __('活动地点'));
  280. //申报书、任务书、结题报告书和其他
  281. $form->file('declaration_form', __('申报书'))->removable();
  282. $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>");
  283. $form->file('task_book', __('任务书'))->removable();
  284. $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>");
  285. $form->file('final_report', __('结题报告书'))->removable();
  286. $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>");
  287. $form->multipleFile('ext', __('其他'))->removable();
  288. $form->html('<div style="color:red"><p>1.开展讲座、培训,需同步提交通知、课件、签到表及现场照片;</p><p>2.开展宣传活动,需同步提交活动照片、活动总结;</p><p>3.其它形式活动根据实际情况提交影像资料。</p></div>','注意事项');
  289. })
  290. ->when("=",FourActivity::TYPE_FEATURED_REPORT_RECEIPT,function (Form $form){
  291. $form->text('title', __('回执名称'));
  292. // $form->text('place', __('活动地点'));
  293. $form->file('return_receipt', __('回执单'))->removable();
  294. $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>");
  295. $form->multipleFile('ext', __('其他'))->removable();
  296. $form->html('<div style="color:red"><p>1.开展讲座、培训,需同步提交通知、课件、签到表及现场照片;</p><p>2.开展宣传活动,需同步提交活动照片、活动总结;</p><p>3.其它形式活动根据实际情况提交影像资料。</p></div>','注意事项');
  297. })
  298. ->required();
  299. $form->tools(function (Form\Tools $tools) {
  300. // 去掉`列表`按钮
  301. $tools->disableList();
  302. $tools->add('<a class="btn btn-sm" style="background-color:#13d5e8;color:#fff" href="/admin/activities"><i class="fa fa-list"></i>&nbsp;&nbsp;查看上报</a>');
  303. // // 去掉`删除`按钮
  304. // $tools->disableDelete();
  305. // // 去掉`查看`按钮
  306. // $tools->disableView();
  307. });
  308. return $form;
  309. }
  310. }