This commit is contained in:
gr
2026-11-11 14:22:02 +08:00
parent 245618dcdc
commit a62311a8da
64878 changed files with 3747172 additions and 66 deletions
@@ -34,6 +34,7 @@ use app\common\model\dict\DictData;
use app\common\model\tcm\DiagnosisRevisitDue;
use app\common\lists\ListsSearchInterface;
use app\common\lists\Traits\HasDataScopeFilter;
use app\common\service\DataScope\DataScopeService;
use app\common\service\tcm\RevisitDueService;
use think\facade\Db;
@@ -71,8 +72,8 @@ class DiagnosisLists extends BaseAdminDataLists implements ListsSearchInterface
*/
public function lists(): array
{
// 获取当前管理员的角色ID
$roleIds = AdminRole::where('admin_id', $this->adminId)->column('role_id');
// 当前账号生效的“仅本人”一线角色(兼有主管/经理等团队角色时为空,由数据范围按部门过滤)
$selfRoles = DataScopeService::selfOnlyRoleIds($this->adminId, $this->adminInfo);
// 待分配医助筛选:assistant_id 为空或 0(放在最前面判断,便于跳过医助角色的自我过滤)
$pendingAssign = isset($this->params['pending_assign']) && (string) $this->params['pending_assign'] === '1';
@@ -86,8 +87,8 @@ class DiagnosisLists extends BaseAdminDataLists implements ListsSearchInterface
: $this->searchWhere;
$query = Diagnosis::where($baseWhere);
// 医助角色(role_id=2):仅在普通列表(非待分配、非待分配宽搜)下限制为本人诊单;待分配窄列表与宽搜均不设此限
if (in_array(2, $roleIds) && !$pendingAssign && !$pendingWideSearch) {
// 纯医助账号:仅在普通列表(非待分配、非待分配宽搜)下限制为本人诊单;待分配窄列表与宽搜均不设此限
if (in_array(2, $selfRoles, true) && !$pendingAssign && !$pendingWideSearch) {
$query->where('assistant_id', $this->adminId);
}
@@ -566,8 +567,7 @@ class DiagnosisLists extends BaseAdminDataLists implements ListsSearchInterface
*/
public function count(): int
{
// 获取当前管理员的角色ID
$roleIds = AdminRole::where('admin_id', $this->adminId)->column('role_id');
$selfRoles = DataScopeService::selfOnlyRoleIds($this->adminId, $this->adminInfo);
$pendingAssign = isset($this->params['pending_assign']) && (string) $this->params['pending_assign'] === '1';
@@ -579,7 +579,7 @@ class DiagnosisLists extends BaseAdminDataLists implements ListsSearchInterface
: $this->searchWhere;
$query = Diagnosis::where($baseWhere);
if (in_array(2, $roleIds) && !$pendingAssign && !$pendingWideSearch) {
if (in_array(2, $selfRoles, true) && !$pendingAssign && !$pendingWideSearch) {
$query->where('assistant_id', $this->adminId);
}
@@ -14,6 +14,7 @@ use app\common\lists\ListsExcelInterface;
use app\common\lists\ListsExtendInterface;
use app\common\lists\ListsSearchInterface;
use app\common\lists\Traits\HasDataScopeFilter;
use app\common\service\DataScope\DataScopeService;
use app\common\model\Order;
use app\common\model\auth\Admin;
use app\common\model\auth\AdminDept;
@@ -550,9 +551,10 @@ class PrescriptionOrderLists extends BaseAdminDataLists implements ListsSearchIn
} elseif (PrescriptionOrderLogic::canViewOrderListStatsAllScope($this->adminInfo)) {
$this->applyDataScopeForPrescriptionOrder($query);
} else {
// 纯医助只看本人创建的订单;兼有主管等团队角色时(多角色取并集)走下方按数据范围的可见规则
$assistantRid = (int) Config::get('project.prescription_order_stats_assistant_role_id', 2);
$myRoles = array_map('intval', $this->adminInfo['role_id'] ?? []);
if ($assistantRid > 0 && in_array($assistantRid, $myRoles, true)) {
$selfRoles = DataScopeService::selfOnlyRoleIds($this->adminId, $this->adminInfo);
if ($assistantRid > 0 && in_array($assistantRid, $selfRoles, true)) {
$this->applyCreatorOnlyFilter($query);
$this->applyDataScopeForPrescriptionOrder($query);
} else {
@@ -1279,7 +1281,7 @@ class PrescriptionOrderLists extends BaseAdminDataLists implements ListsSearchIn
$scope = 'all';
} else {
$ar = (int) Config::get('project.prescription_order_stats_assistant_role_id', 2);
if ($ar > 0 && in_array($ar, array_map('intval', $this->adminInfo['role_id'] ?? []), true)) {
if ($ar > 0 && in_array($ar, DataScopeService::selfOnlyRoleIds($this->adminId, $this->adminInfo), true)) {
$scope = 'assistant';
} elseif (PrescriptionOrderLogic::canViewOrdersForOwnPrescription($this->adminInfo)) {
$scope = 'own_rx';