新增功能
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
<?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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user