更新
This commit is contained in:
@@ -135,7 +135,9 @@ class AdminLists extends BaseAdminDataLists implements ListsExtendInterface, Lis
|
||||
{
|
||||
$field = [
|
||||
'id', 'name', 'account', 'create_time', 'disable', 'root',
|
||||
'login_time', 'login_ip', 'multipoint_login', 'avatar'
|
||||
'login_time', 'login_ip', 'multipoint_login', 'avatar',
|
||||
'gender', 'age', 'phone', 'title', 'department',
|
||||
'specialty', 'education', 'experience', 'honors'
|
||||
];
|
||||
|
||||
$adminLists = Admin::field($field)
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace app\adminapi\lists\doctor;
|
||||
|
||||
use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\common\model\doctor\Appointment;
|
||||
use app\common\model\auth\AdminRole;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
|
||||
/**
|
||||
@@ -19,15 +20,18 @@ class AppointmentLists extends BaseAdminDataLists implements ListsSearchInterfac
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
$allowSearch = [
|
||||
'=' => ['a.patient_id', 'a.doctor_id', 'a.status', 'a.appointment_date'],
|
||||
];
|
||||
|
||||
// 处理日期范围搜索
|
||||
if (!empty($this->params['start_date']) && !empty($this->params['end_date'])) {
|
||||
$this->searchWhere[] = ['a.appointment_date', 'between', [$this->params['start_date'], $this->params['end_date']]];
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取列表
|
||||
* @return array
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
// 获取当前管理员的角色ID
|
||||
$roleIds = AdminRole::where('admin_id', $this->adminId)->column('role_id');
|
||||
|
||||
// 处理患者姓名搜索
|
||||
if (!empty($this->params['patient_name'])) {
|
||||
$this->searchWhere[] = ['u.patient_name', 'like', '%' . $this->params['patient_name'] . '%'];
|
||||
@@ -38,22 +42,41 @@ class AppointmentLists extends BaseAdminDataLists implements ListsSearchInterfac
|
||||
$this->searchWhere[] = ['ad.name', 'like', '%' . $this->params['doctor_name'] . '%'];
|
||||
}
|
||||
|
||||
return $allowSearch;
|
||||
}
|
||||
// 处理状态搜索
|
||||
if (isset($this->params['status']) && $this->params['status'] !== '') {
|
||||
$this->searchWhere[] = ['a.status', '=', $this->params['status']];
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取列表
|
||||
* @return array
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
|
||||
$lists = Appointment::alias('a')
|
||||
// 处理日期范围搜索
|
||||
if (!empty($this->params['start_date']) && !empty($this->params['end_date'])) {
|
||||
$this->searchWhere[] = ['a.appointment_date', 'between', [$this->params['start_date'], $this->params['end_date']]];
|
||||
} elseif (!empty($this->params['start_date'])) {
|
||||
$this->searchWhere[] = ['a.appointment_date', '>=', $this->params['start_date']];
|
||||
} elseif (!empty($this->params['end_date'])) {
|
||||
$this->searchWhere[] = ['a.appointment_date', '<=', $this->params['end_date']];
|
||||
}
|
||||
|
||||
// 构建查询
|
||||
$query = Appointment::alias('a')
|
||||
->leftJoin('tcm_diagnosis u', 'a.patient_id = u.id')
|
||||
->leftJoin('admin ad', 'a.doctor_id = ad.id')
|
||||
->field('a.*, u.patient_name as patient_name, u.phone as patient_phone, ad.name as doctor_name')
|
||||
->where($this->searchWhere)
|
||||
->order('a.id', 'desc')
|
||||
->field('a.*, u.patient_name as patient_name, u.phone as patient_phone, ad.name as doctor_name, u.id as diagnosis_id')
|
||||
->where($this->searchWhere);
|
||||
|
||||
// 如果是医生角色(role_id=1),只显示挂自己号的预约
|
||||
if (in_array(1, $roleIds)) {
|
||||
$query->where('a.doctor_id', $this->adminId);
|
||||
}
|
||||
|
||||
// 如果是医助角色(role_id=2),只显示自己添加的患者的预约
|
||||
if (in_array(2, $roleIds)) {
|
||||
$query->where('u.assistant_id', $this->adminId);
|
||||
}
|
||||
|
||||
$lists = $query
|
||||
->order('a.status', 'asc')
|
||||
->order('a.appointment_date', 'asc')
|
||||
->order('a.appointment_time', 'asc')
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->select()
|
||||
->toArray();
|
||||
@@ -64,6 +87,7 @@ class AppointmentLists extends BaseAdminDataLists implements ListsSearchInterfac
|
||||
1 => '已预约',
|
||||
2 => '已取消',
|
||||
3 => '已完成',
|
||||
4 => '已过号',
|
||||
];
|
||||
$item['status_desc'] = $statusMap[$item['status']] ?? '未知';
|
||||
|
||||
@@ -92,10 +116,48 @@ class AppointmentLists extends BaseAdminDataLists implements ListsSearchInterfac
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
// 获取当前管理员的角色ID
|
||||
$roleIds = AdminRole::where('admin_id', $this->adminId)->column('role_id');
|
||||
|
||||
// 处理患者姓名搜索
|
||||
if (!empty($this->params['patient_name'])) {
|
||||
$this->searchWhere[] = ['u.patient_name', 'like', '%' . $this->params['patient_name'] . '%'];
|
||||
}
|
||||
|
||||
// 处理医生姓名搜索
|
||||
if (!empty($this->params['doctor_name'])) {
|
||||
$this->searchWhere[] = ['ad.name', 'like', '%' . $this->params['doctor_name'] . '%'];
|
||||
}
|
||||
|
||||
// 处理状态搜索
|
||||
if (isset($this->params['status']) && $this->params['status'] !== '') {
|
||||
$this->searchWhere[] = ['a.status', '=', $this->params['status']];
|
||||
}
|
||||
|
||||
// 处理日期范围搜索
|
||||
if (!empty($this->params['start_date']) && !empty($this->params['end_date'])) {
|
||||
$this->searchWhere[] = ['a.appointment_date', 'between', [$this->params['start_date'], $this->params['end_date']]];
|
||||
} elseif (!empty($this->params['start_date'])) {
|
||||
$this->searchWhere[] = ['a.appointment_date', '>=', $this->params['start_date']];
|
||||
} elseif (!empty($this->params['end_date'])) {
|
||||
$this->searchWhere[] = ['a.appointment_date', '<=', $this->params['end_date']];
|
||||
}
|
||||
|
||||
// 构建查询
|
||||
$query = Appointment::alias('a')
|
||||
->leftJoin('tcm_diagnosis u', 'a.patient_id = u.id')
|
||||
->leftJoin('admin ad', 'a.doctor_id = ad.id')
|
||||
->where($this->searchWhere);
|
||||
|
||||
// 如果是医生角色(role_id=1),只显示挂自己号的预约
|
||||
if (in_array(1, $roleIds)) {
|
||||
$query->where('a.doctor_id', $this->adminId);
|
||||
}
|
||||
|
||||
// 如果是医助角色(role_id=2),只显示自己添加的患者的预约
|
||||
if (in_array(2, $roleIds)) {
|
||||
$query->where('u.assistant_id', $this->adminId);
|
||||
}
|
||||
|
||||
return $query->count();
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ namespace app\adminapi\lists\tcm;
|
||||
|
||||
use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\common\model\tcm\Diagnosis;
|
||||
use app\common\model\auth\AdminRole;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
|
||||
/**
|
||||
@@ -47,7 +48,18 @@ class DiagnosisLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$lists = Diagnosis::where($this->searchWhere)
|
||||
// 获取当前管理员的角色ID
|
||||
$roleIds = AdminRole::where('admin_id', $this->adminId)->column('role_id');
|
||||
|
||||
// 构建查询
|
||||
$query = Diagnosis::where($this->searchWhere);
|
||||
|
||||
// 如果是医助角色(role_id=2),只显示自己添加的患者
|
||||
if (in_array(2, $roleIds)) {
|
||||
$query->where('assistant_id', $this->adminId);
|
||||
}
|
||||
|
||||
$lists = $query
|
||||
->field(['id', 'patient_id', 'patient_name', 'id_card', 'phone', 'gender', 'age', 'diagnosis_date', 'diagnosis_type', 'syndrome_type', 'assistant_id', 'status', 'create_time', 'update_time'])
|
||||
->append(['gender_desc', 'status_desc', 'diagnosis_date_text'])
|
||||
->order(['id' => 'desc'])
|
||||
@@ -64,6 +76,17 @@ class DiagnosisLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return Diagnosis::where($this->searchWhere)->count();
|
||||
// 获取当前管理员的角色ID
|
||||
$roleIds = AdminRole::where('admin_id', $this->adminId)->column('role_id');
|
||||
|
||||
// 构建查询
|
||||
$query = Diagnosis::where($this->searchWhere);
|
||||
|
||||
// 如果是医助角色(role_id=2),只显示自己添加的患者
|
||||
if (in_array(2, $roleIds)) {
|
||||
$query->where('assistant_id', $this->adminId);
|
||||
}
|
||||
|
||||
return $query->count();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,6 +60,16 @@ class AdminLogic extends BaseLogic
|
||||
'create_time' => time(),
|
||||
'disable' => $params['disable'],
|
||||
'multipoint_login' => $params['multipoint_login'],
|
||||
// 新增字段
|
||||
'gender' => $params['gender'] ?? 1,
|
||||
'age' => $params['age'] ?? null,
|
||||
'phone' => $params['phone'] ?? null,
|
||||
'title' => $params['title'] ?? null,
|
||||
'department' => $params['department'] ?? null,
|
||||
'specialty' => $params['specialty'] ?? null,
|
||||
'education' => $params['education'] ?? null,
|
||||
'experience' => $params['experience'] ?? null,
|
||||
'honors' => $params['honors'] ?? null,
|
||||
]);
|
||||
|
||||
// 角色
|
||||
@@ -99,7 +109,17 @@ class AdminLogic extends BaseLogic
|
||||
'name' => $params['name'],
|
||||
'account' => $params['account'],
|
||||
'disable' => $params['disable'],
|
||||
'multipoint_login' => $params['multipoint_login']
|
||||
'multipoint_login' => $params['multipoint_login'],
|
||||
// 新增字段
|
||||
'gender' => $params['gender'] ?? 1,
|
||||
'age' => $params['age'] ?? null,
|
||||
'phone' => $params['phone'] ?? null,
|
||||
'title' => $params['title'] ?? null,
|
||||
'department' => $params['department'] ?? null,
|
||||
'specialty' => $params['specialty'] ?? null,
|
||||
'education' => $params['education'] ?? null,
|
||||
'experience' => $params['experience'] ?? null,
|
||||
'honors' => $params['honors'] ?? null,
|
||||
];
|
||||
|
||||
// 头像
|
||||
@@ -232,6 +252,8 @@ class AdminLogic extends BaseLogic
|
||||
$admin = Admin::field([
|
||||
'id', 'account', 'name', 'disable', 'root',
|
||||
'multipoint_login', 'avatar',
|
||||
'gender', 'age', 'phone', 'title', 'department',
|
||||
'specialty', 'education', 'experience', 'honors'
|
||||
])->findOrEmpty($params['id'])->toArray();
|
||||
|
||||
if ($action == 'detail') {
|
||||
|
||||
@@ -290,9 +290,9 @@ class AppointmentLogic extends BaseLogic
|
||||
public static function detail(array $params)
|
||||
{
|
||||
$appointment = Appointment::alias('a')
|
||||
->leftJoin('la_user u', 'a.patient_id = u.id')
|
||||
->leftJoin('la_admin ad', 'a.doctor_id = ad.id')
|
||||
->field('a.*, u.nickname as patient_name, u.mobile as patient_phone, ad.name as doctor_name')
|
||||
->leftJoin('zyt_tcm_diagnosis u', 'a.patient_id = u.id')
|
||||
->leftJoin('zyt_admin ad', 'a.doctor_id = ad.id')
|
||||
->field('a.*, u.patient_name as patient_name, u.phone as patient_phone, ad.name as doctor_name')
|
||||
->where('a.id', $params['id'])
|
||||
->findOrEmpty()
|
||||
->toArray();
|
||||
|
||||
Reference in New Issue
Block a user