This commit is contained in:
Your Name
2026-03-27 18:06:12 +08:00
parent 9160c36735
commit 099bc1dd22
645 changed files with 276473 additions and 957 deletions
@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace app\adminapi\lists\tcm;
use app\adminapi\lists\BaseAdminDataLists;
use app\adminapi\logic\tcm\PrescriptionLibraryLogic;
use app\common\model\tcm\PrescriptionLibrary;
use app\common\lists\ListsSearchInterface;
@@ -24,6 +25,21 @@ class PrescriptionLibraryLists extends BaseAdminDataLists implements ListsSearch
];
}
/**
* @notes 列表数据范围:超管/管理员角色看全部;普通账号仅看自己创建 + 公开处方
*/
private function applyDataScope($query)
{
if (PrescriptionLibraryLogic::canManageAllPrescriptions($this->adminId, $this->adminInfo)) {
return $query;
}
return $query->where(function ($q) {
$q->where('creator_id', $this->adminId)
->whereOr('is_public', 1);
});
}
/**
* @notes 获取列表
*/
@@ -34,12 +50,10 @@ class PrescriptionLibraryLists extends BaseAdminDataLists implements ListsSearch
'creator_id', 'creator_name', 'create_time', 'update_time'
];
$lists = PrescriptionLibrary::where($this->searchWhere)
->where(function ($query) {
// 只显示自己创建的或公开的处方
$query->where('creator_id', $this->adminId)
->whereOr('is_public', 1);
})
$query = PrescriptionLibrary::where($this->searchWhere);
$this->applyDataScope($query);
$lists = $query
->field($field)
->limit($this->limitOffset, $this->limitLength)
->order('id', 'desc')
@@ -63,12 +77,9 @@ class PrescriptionLibraryLists extends BaseAdminDataLists implements ListsSearch
*/
public function count(): int
{
return PrescriptionLibrary::where($this->searchWhere)
->where(function ($query) {
// 只统计自己创建的或公开的处方
$query->where('creator_id', $this->adminId)
->whereOr('is_public', 1);
})
->count();
$query = PrescriptionLibrary::where($this->searchWhere);
$this->applyDataScope($query);
return $query->count();
}
}