ApproveController.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <?php
  2. namespace App\Admin\Controllers\UserManagement\DocterManagement;
  3. use App\Admin\Actions\backstage\Pass;
  4. use App\Admin\Actions\backstage\Refuse;
  5. use App\Admin\Actions\backstage\Revoke;
  6. use App\Models\Docter;
  7. use App\Models\DocterOrganization;
  8. use App\Models\Office;
  9. use Encore\Admin\Controllers\AdminController;
  10. use Encore\Admin\Form;
  11. use Encore\Admin\Grid;
  12. use Encore\Admin\Show;
  13. class ApproveController extends AdminController
  14. {
  15. /**
  16. * Title for current resource.
  17. *
  18. * @var string
  19. */
  20. protected $title = '认证列表';
  21. /**
  22. * Make a grid builder.
  23. *
  24. * @return Grid
  25. */
  26. protected function grid()
  27. {
  28. $grid = new Grid(new DocterOrganization());
  29. $grid->filter(function($filter){
  30. $filter->disableIdFilter();
  31. $filter->like('docter.name','医生姓名');
  32. $filter->like('organization.name','机构名');
  33. $filter->equal('state', '认证状态')->select([1=>'已认证',2=>'审核驳回',3=>'待审核']);
  34. $filter->between('authentication_time', '签约时间')->datetime();
  35. $filter->between('authentication_end_time', '签约到期时间')->datetime();
  36. });
  37. $grid ->model()->where('state','>',0)->orderBy('id','desc');
  38. $grid->column('id', __('Id'));
  39. $grid->column('docter.id', __('医生ID'));
  40. $grid->column('docter.name', __('医生姓名'));
  41. $grid->column('docter.phone', __('医生电话'));
  42. $grid->column('docter.avatar', __('医生头像'))->lightbox(['width' =>'', 'height' => 30]);
  43. $grid->column('docter.sex', __('性别'))->using([0=>'未知',1=>'男',2=>'女']);
  44. $grid->column('organization.name', __('机构'));
  45. $grid->column('office.name', __('科室'));
  46. $grid->column('qualification.name', __('医生资质'));
  47. $grid->column('remarks', __('备注'));
  48. $grid->column('docter.practice','医生照片和执业证书')->display(function ($img) {
  49. $arr = explode(',',$img);
  50. $new_arr = [];
  51. foreach ($arr as $value)
  52. {
  53. $value = str_replace('upload/','',$value);
  54. array_push($new_arr,$value);
  55. }
  56. return $new_arr;
  57. })->lightbox(['width' =>'', 'height' => 30]);
  58. $grid->column('docter.card_photo',' 身份证正反面')->display(function ($img) {
  59. $arr = explode(',',$img);
  60. $new_arr = [];
  61. foreach ($arr as $value)
  62. {
  63. $value = str_replace('upload/','',$value);
  64. array_push($new_arr,$value);
  65. }
  66. return $new_arr;
  67. })->lightbox(['width' =>'', 'height' => 30]);
  68. $grid->column('docter.is_quail','照片和资格证书')->display(function ($img) {
  69. $arr = explode(',',$img);
  70. $new_arr = [];
  71. foreach ($arr as $value)
  72. {
  73. $value = str_replace('upload/','',$value);
  74. array_push($new_arr,$value);
  75. }
  76. return $new_arr;
  77. })->lightbox(['width' =>'', 'height' => 30]);
  78. $grid->column('state', __('认证状态'))->using([1=>'已认证',2=>'审核驳回',3=>'待审核'])->label('info');
  79. $grid->column('authentication_time', __('签约时间'))->display(function ($time){
  80. if ($time == 0){
  81. return '';
  82. }else
  83. {
  84. return $time;
  85. }
  86. });
  87. $grid->column('authentication_end_time', __('签约到期时间'))->display(function ($time){
  88. if ($time == 0){
  89. return '';
  90. }else
  91. {
  92. return $time;
  93. }
  94. });
  95. //禁用创建按钮
  96. $grid->disableCreateButton();
  97. $grid->actions(function ($actions) {
  98. // 去掉删除
  99. $actions->disableDelete();
  100. // 去掉编辑
  101. $actions->disableEdit();
  102. // 去掉查看
  103. $actions->disableView();
  104. //待审核状态下 给通过和驳回
  105. if ($actions->row->state == 3){
  106. //通过申请
  107. $actions->add(new Pass());
  108. //驳回申请
  109. $actions->add(new Refuse());
  110. }
  111. //已认证状态下 给撤销
  112. if ($actions->row->state == 1){
  113. $actions->add(new Revoke());
  114. }
  115. //驳回状态下 不给任何操作
  116. if ($actions->row->state == 2){
  117. }
  118. });
  119. return $grid;
  120. }
  121. /**
  122. * Make a show builder.
  123. *
  124. * @param mixed $id
  125. * @return Show
  126. */
  127. protected function detail($id)
  128. {
  129. $show = new Show(DocterOrganization::findOrFail($id));
  130. $show->field('id', __('Id'));
  131. $show->field('docter.id', __('医生ID'));
  132. $show->field('docter.name', __('名字'));
  133. $show->field('docter.sex', __('性别'))->using([0=>'未知',1=>'男',2=>'女']);
  134. $show->field('docter.card_id', __('身份证'));
  135. $show->field('organization.name', __('机构'));
  136. $show->field('office.name', __('科室'));
  137. $show->field('qualification.name', __('医生资质'));
  138. // $show->field('docter.card_photo', __('身份证正反面'))->as(function ($id){
  139. //// dd($id);
  140. // $imgs = explode(',',$id);
  141. // $html = '';
  142. // foreach ($imgs as $val){
  143. // $html .='img src="'.$val.'"';
  144. // }
  145. // return "<{$html}>";
  146. //// return json_decode($id,true);
  147. // });
  148. $show->field('docter.card_photo', __('身份证正反面'))->image();
  149. return $show;
  150. }
  151. /**
  152. * Make a form builder.
  153. *
  154. * @return Form
  155. */
  156. protected function form()
  157. {
  158. $form = new Form(new DocterOrganization());
  159. $form->number('docter_id', __('Docter id'));
  160. $form->number('organization_id', __('Organization id'));
  161. $form->number('offices_id', __('Offices id'));
  162. $form->number('qualifications_id', __('Qualifications id'));
  163. $form->number('state', __('State'));
  164. return $form;
  165. }
  166. }