1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <?php
- namespace app\admin\controller\hospital;
- use app\common\controller\Backend;
- /**
- * 患者信息
- */
- class Patient extends Backend
- {
- /**
- * Patient模型对象
- * @var object
- * @phpstan-var \app\admin\model\hospital\Patient
- */
- protected object $model;
- protected string|array $defaultSortField = 'create_time,desc';
- protected array|string $preExcludeFields = ['create_time'];
- protected string|array $quickSearchField = ['ID'];
- public function initialize(): void
- {
- parent::initialize();
- $this->model = new \app\zskk\model\HospitalPatient();
- }
- /**
- * 若需重写查看、编辑、删除等方法,请复制 @see \app\admin\library\traits\Backend 中对应的方法至此进行重写
- */
- /**
- * 查看
- * @throws Throwable
- */
- public function index(): void
- {
- if ($this->request->param('select')) {
- $this->select();
- }
- $today = $this->request->get("today", false);
- list($where, $alias, $limit, $order) = $this->queryBuilder();
- if($today) {
- $this->setWhereTodayTimestamp($where, 'create_time');
- }
- $where = $this->model->encryptWhere($where);
-
- // $this->handleWhere($where);
- $res = $this->model
- ->field($this->indexField)
- ->withJoin($this->withJoinTable, $this->withJoinType)
- ->alias($alias)
- ->where($where)
- ->order($order)
- ->paginate($limit);
- $this->success('', [
- 'list' => $res->items(),
- 'total' => $res->total(),
- 'remark' => get_route_remark(),
- ]);
- }
- // private function handleWhere(&$where) {
- // foreach($where as $_where) {
- // if($_where[0] === 'AGE') {
- // $_where[2] = $this->handleAGE()
- // }
- // }
- // }
- private function setWhereTodayTimestamp(&$where, $keyName) {
- // $todayStartTimestamp = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
- // $todayEndTimestamp = mktime(23, 59, 59, date('m'), date('d'), date('Y'));
- // $where[] = [$keyName, '>=', $todayStartTimestamp];
- // $where[] = [$keyName, '<=', $todayEndTimestamp];
- $where[] = [$keyName, '>=', date('Y-m-d 00:00:00')];
- $where[] = [$keyName, '<=', date('Y-m-d 23:59:59')];
- return $where;
- }
- }
|