71 lines
2.0 KiB
PHP
71 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace app\adminapi\lists\doctor;
|
|
|
|
use app\adminapi\lists\BaseAdminDataLists;
|
|
use app\common\model\doctor\Roster;
|
|
use app\common\lists\ListsSearchInterface;
|
|
|
|
/**
|
|
* 医生排班列表
|
|
* Class RosterLists
|
|
* @package app\adminapi\lists\doctor
|
|
*/
|
|
class RosterLists extends BaseAdminDataLists implements ListsSearchInterface
|
|
{
|
|
/**
|
|
* @notes 设置搜索条件
|
|
* @return array
|
|
*/
|
|
public function setSearch(): array
|
|
{
|
|
return [
|
|
'=' => ['doctor_id', 'period', 'status'],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @notes 获取列表
|
|
* @return array
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
* @throws \think\db\exception\DbException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
*/
|
|
public function lists(): array
|
|
{
|
|
$where = $this->searchWhere;
|
|
|
|
// 处理日期范围搜索
|
|
if (!empty($this->params['start_date']) && !empty($this->params['end_date'])) {
|
|
$where[] = ['date', 'between', [$this->params['start_date'], $this->params['end_date']]];
|
|
}
|
|
|
|
$lists = Roster::where($where)
|
|
->field([
|
|
'id', 'doctor_id', 'date', 'period', 'start_time', 'end_time', 'shift_type', 'slot_minutes',
|
|
'status', 'quota', 'max_patients', 'booked_count', 'remark', 'create_time', 'update_time',
|
|
])
|
|
->order(['date' => 'asc', 'start_time' => 'asc', 'id' => 'asc'])
|
|
->select()
|
|
->toArray();
|
|
|
|
return $lists;
|
|
}
|
|
|
|
/**
|
|
* @notes 获取数量
|
|
* @return int
|
|
*/
|
|
public function count(): int
|
|
{
|
|
$where = $this->searchWhere;
|
|
|
|
// 处理日期范围搜索
|
|
if (!empty($this->params['start_date']) && !empty($this->params['end_date'])) {
|
|
$where[] = ['date', 'between', [$this->params['start_date'], $this->params['end_date']]];
|
|
}
|
|
|
|
return Roster::where($where)->count();
|
|
}
|
|
}
|