MedicationEntrustmentController.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Models\MedicationEntrustment;
  4. use Dcat\Admin\Form;
  5. use Dcat\Admin\Grid;
  6. use Dcat\Admin\Show;
  7. use Dcat\Admin\Http\Controllers\AdminController;
  8. class MedicationEntrustmentController extends AdminController
  9. {
  10. /**
  11. * Make a grid builder.
  12. *
  13. * @return Grid
  14. */
  15. protected function grid()
  16. {
  17. return Grid::make(new MedicationEntrustment(), function (Grid $grid) {
  18. $grid->column('student_id')->using(config('map.students'));
  19. $grid->column('reason');
  20. $grid->column('use_time');
  21. $grid->column('detail');
  22. $grid->column('desc');
  23. $grid->column('photos')->image('',80);
  24. $grid->column('sign');
  25. $grid->filter(function (Grid\Filter $filter) {
  26. $filter->panel();
  27. $filter->date('created_at')->datetime()->width(4);
  28. $filter->equal('student_id','输入/选择学生')->select(config('map.students'))->width(4);
  29. });
  30. });
  31. }
  32. /**
  33. * Make a show builder.
  34. *
  35. * @param mixed $id
  36. *
  37. * @return Show
  38. */
  39. protected function detail($id)
  40. {
  41. return Show::make($id, new MedicationEntrustment(), function (Show $show) {
  42. $show->row(function (Show\Row $show) {
  43. $show->field('content','用药委托详情')
  44. ->width(8)
  45. ->unescape()
  46. ->as(function () {
  47. $html = '';
  48. $html .= '<div style="text-align:left">';
  49. $html .= '<div style="margin-top:5px">用药对象:' . config('map.students')[$this->student_id] . '</div>';
  50. $html .= '<div style="margin-top:5px">用药时间:' . $this->use_time . '</div>';
  51. $html .= '<div style="margin-top:5px">用药明细:' . $this->detail . '</div>';
  52. $html .= '<div style="margin-top:5px">用药说明:' . $this->desc . '</div>';
  53. $html .= '<div style="margin-top:5px">接回照片:</div>';
  54. $html .= '<img data-action="preview-img" src="' . $this->photos . '" style="height:50px;width:50px;cursor:pointer;margin-right:10px;" class="img img-thumbnail">';
  55. $html .= '<div style="margin-top:5px">签名:' . $this->sign . '</div>';
  56. $html .= '</div>';
  57. return $html;
  58. });
  59. });
  60. });
  61. }
  62. /**
  63. * Make a form builder.
  64. *
  65. * @return Form
  66. */
  67. protected function form()
  68. {
  69. return Form::make(new MedicationEntrustment(), function (Form $form) {
  70. $form->text('student_id');
  71. $form->text('reason');
  72. $form->text('use_time');
  73. $form->text('detail');
  74. $form->text('desc');
  75. $form->text('photos');
  76. $form->text('sign');
  77. });
  78. }
  79. }