新增
This commit is contained in:
@@ -73,11 +73,29 @@ class PrescriptionLists extends BaseAdminDataLists implements ListsSearchInterfa
|
||||
private function applyVisibilityScope($query): void
|
||||
{
|
||||
$query->where(function ($query) {
|
||||
// 超级管理员可查看全部
|
||||
if (!empty($this->adminInfo['root']) && (int) $this->adminInfo['root'] === 1) {
|
||||
return;
|
||||
}
|
||||
$adminId = $this->adminId;
|
||||
|
||||
// 检查是否属于可查看全部处方的角色
|
||||
$manageAllRoles = config('project.prescription_library_manage_all_roles', [0, 3]);
|
||||
$roleIds = array_values(array_unique(array_map('intval', $this->adminInfo['role_id'] ?? [])));
|
||||
$canSeeAll = false;
|
||||
foreach ($roleIds as $rid) {
|
||||
if (in_array($rid, $manageAllRoles, true)) {
|
||||
$canSeeAll = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 如果属于可查看全部的角色,不添加任何限制
|
||||
if ($canSeeAll) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 其他用户只能查看:共享的、自己创建的、自己是医助的、或指定给自己角色的
|
||||
$adminId = $this->adminId;
|
||||
$query->where(function ($q) use ($adminId, $roleIds) {
|
||||
$q->whereOr('is_shared', '=', 1);
|
||||
$q->whereOr('creator_id', '=', $adminId);
|
||||
@@ -143,6 +161,14 @@ class PrescriptionLists extends BaseAdminDataLists implements ListsSearchInterfa
|
||||
$hasBizOrderRx = array_fill_keys($orderRxIds, true);
|
||||
}
|
||||
|
||||
// 获取医助姓名
|
||||
$assistantIds = array_unique(array_filter(array_map('intval', array_column($lists, 'assistant_id'))));
|
||||
$assistantNames = [];
|
||||
if (!empty($assistantIds)) {
|
||||
$assistantNames = \app\common\model\auth\Admin::whereIn('id', $assistantIds)
|
||||
->column('name', 'id');
|
||||
}
|
||||
|
||||
// 处理字段格式
|
||||
foreach ($lists as &$item) {
|
||||
// 设置默认值
|
||||
@@ -159,6 +185,10 @@ class PrescriptionLists extends BaseAdminDataLists implements ListsSearchInterfa
|
||||
$item['business_prescription_audit_remark'] = (string) ($bizRejectRemark[$rid] ?? '');
|
||||
$item['has_prescription_order'] = !empty($hasBizOrderRx[$rid]) ? 1 : 0;
|
||||
|
||||
// 添加医助姓名
|
||||
$assistantId = (int) ($item['assistant_id'] ?? 0);
|
||||
$item['assistant_name'] = $assistantId > 0 ? ($assistantNames[$assistantId] ?? '') : '';
|
||||
|
||||
// 将 dietary_taboo 从逗号分隔的字符串转换为数组(前端需要数组格式)
|
||||
if (!empty($item['dietary_taboo']) && is_string($item['dietary_taboo'])) {
|
||||
$item['dietary_taboo'] = array_filter(explode(',', $item['dietary_taboo']));
|
||||
|
||||
Reference in New Issue
Block a user