Files
zyt/server/app/adminapi/lists/doctor/RosterLists.php
T
2026-03-04 15:32:30 +08:00

69 lines
1.9 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', 'status', 'quota', 'max_patients', 'booked_count', 'remark', 'create_time', 'update_time'])
->order(['date' => 'asc', 'period' => 'asc'])
->limit($this->limitOffset, $this->limitLength)
->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();
}
}