Patient.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. namespace app\admin\controller\hospital;
  3. use app\common\controller\Backend;
  4. /**
  5. * 患者信息
  6. */
  7. class Patient extends Backend
  8. {
  9. /**
  10. * Patient模型对象
  11. * @var object
  12. * @phpstan-var \app\admin\model\hospital\Patient
  13. */
  14. protected object $model;
  15. protected string|array $defaultSortField = 'create_time,desc';
  16. protected array|string $preExcludeFields = ['create_time'];
  17. protected string|array $quickSearchField = ['ID'];
  18. public function initialize(): void
  19. {
  20. parent::initialize();
  21. $this->model = new \app\zskk\model\HospitalPatient();
  22. }
  23. /**
  24. * 若需重写查看、编辑、删除等方法,请复制 @see \app\admin\library\traits\Backend 中对应的方法至此进行重写
  25. */
  26. /**
  27. * 查看
  28. * @throws Throwable
  29. */
  30. public function index(): void
  31. {
  32. if ($this->request->param('select')) {
  33. $this->select();
  34. }
  35. $today = $this->request->get("today", false);
  36. list($where, $alias, $limit, $order) = $this->queryBuilder();
  37. if($today) {
  38. $this->setWhereTodayTimestamp($where, 'create_time');
  39. }
  40. $where = $this->model->encryptWhere($where);
  41. // $this->handleWhere($where);
  42. $res = $this->model
  43. ->field($this->indexField)
  44. ->withJoin($this->withJoinTable, $this->withJoinType)
  45. ->alias($alias)
  46. ->where($where)
  47. ->order($order)
  48. ->paginate($limit);
  49. $this->success('', [
  50. 'list' => $res->items(),
  51. 'total' => $res->total(),
  52. 'remark' => get_route_remark(),
  53. ]);
  54. }
  55. // private function handleWhere(&$where) {
  56. // foreach($where as $_where) {
  57. // if($_where[0] === 'AGE') {
  58. // $_where[2] = $this->handleAGE()
  59. // }
  60. // }
  61. // }
  62. private function setWhereTodayTimestamp(&$where, $keyName) {
  63. // $todayStartTimestamp = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
  64. // $todayEndTimestamp = mktime(23, 59, 59, date('m'), date('d'), date('Y'));
  65. // $where[] = [$keyName, '>=', $todayStartTimestamp];
  66. // $where[] = [$keyName, '<=', $todayEndTimestamp];
  67. $where[] = [$keyName, '>=', date('Y-m-d 00:00:00')];
  68. $where[] = [$keyName, '<=', date('Y-m-d 23:59:59')];
  69. return $where;
  70. }
  71. }