修复bug
This commit is contained in:
@@ -536,18 +536,22 @@ class DiagnosisLogic extends BaseLogic
|
||||
*/
|
||||
public static function assignLogList(int $diagnosisId): array
|
||||
{
|
||||
$rows = DiagnosisAssignLog::where('diagnosis_id', $diagnosisId)
|
||||
// Db 直查:避免 AssignLog 模型未维护 schema / fields_strict 时 toArray 丢列,导致前后端「医助」为空
|
||||
$rows = Db::name('tcm_diagnosis_assign_log')
|
||||
->where('diagnosis_id', $diagnosisId)
|
||||
->order('id', 'desc')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
$adminIds = [];
|
||||
foreach ($rows as $r) {
|
||||
if (!empty($r['from_assistant_id'])) {
|
||||
$adminIds[] = (int) $r['from_assistant_id'];
|
||||
$fid = (int) ($r['from_assistant_id'] ?? 0);
|
||||
$tid = (int) ($r['to_assistant_id'] ?? 0);
|
||||
if ($fid > 0) {
|
||||
$adminIds[] = $fid;
|
||||
}
|
||||
if (!empty($r['to_assistant_id'])) {
|
||||
$adminIds[] = (int) $r['to_assistant_id'];
|
||||
if ($tid > 0) {
|
||||
$adminIds[] = $tid;
|
||||
}
|
||||
$rcp = (int) ($r['related_po_creator_id'] ?? 0);
|
||||
if ($rcp > 0) {
|
||||
@@ -557,7 +561,7 @@ class DiagnosisLogic extends BaseLogic
|
||||
$adminIds = array_values(array_unique(array_filter($adminIds)));
|
||||
$nameMap = [];
|
||||
if ($adminIds !== []) {
|
||||
$nameMap = \app\common\model\auth\Admin::whereIn('id', $adminIds)->column('name', 'id');
|
||||
$nameMap = Admin::whereIn('id', $adminIds)->column('name', 'id');
|
||||
}
|
||||
|
||||
foreach ($rows as &$r) {
|
||||
@@ -583,7 +587,7 @@ class DiagnosisLogic extends BaseLogic
|
||||
}
|
||||
unset($r);
|
||||
|
||||
return $rows;
|
||||
return array_values($rows);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,6 +15,7 @@ use app\common\model\tcm\PrescriptionOrderLog;
|
||||
use app\common\model\tcm\PrescriptionOrderPayOrder;
|
||||
use app\common\model\doctor\Appointment;
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\service\DataScope\DataScopeService;
|
||||
use app\common\service\ExpressTrackService;
|
||||
use app\common\service\gancao\GancaoScmRecipelService;
|
||||
use think\facade\Config;
|
||||
@@ -136,6 +137,30 @@ class PrescriptionOrderLogic
|
||||
return $cid === $adminId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 与 PrescriptionOrderLists 数据域一致:创建人或关联诊单医助属于当前账号可见 admin 集合
|
||||
*/
|
||||
private static function orderWithinDataScopeOwners(PrescriptionOrder $row, int $adminId, array $adminInfo): bool
|
||||
{
|
||||
if (!DataScopeService::isEnabled()) {
|
||||
return false;
|
||||
}
|
||||
$ids = DataScopeService::getVisibleAdminIds($adminId, $adminInfo);
|
||||
if ($ids === null || $ids === []) {
|
||||
return false;
|
||||
}
|
||||
if (in_array((int) $row->creator_id, $ids, true)) {
|
||||
return true;
|
||||
}
|
||||
$did = (int) $row->diagnosis_id;
|
||||
if ($did <= 0) {
|
||||
return false;
|
||||
}
|
||||
$da = (int) Diagnosis::where('id', $did)->whereNull('delete_time')->value('assistant_id');
|
||||
|
||||
return $da > 0 && in_array($da, $ids, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PrescriptionOrder $row
|
||||
*/
|
||||
@@ -147,8 +172,20 @@ class PrescriptionOrderLogic
|
||||
if ((int) $row->creator_id === $adminId) {
|
||||
return true;
|
||||
}
|
||||
$did = (int) $row->diagnosis_id;
|
||||
if ($did > 0) {
|
||||
$da = (int) Diagnosis::where('id', $did)->whereNull('delete_time')->value('assistant_id');
|
||||
if ($da === $adminId) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (self::canViewOrdersForOwnPrescription($adminInfo)) {
|
||||
return self::isPrescriptionOrderPrescriber((int) $row->prescription_id, $adminId);
|
||||
if (self::isPrescriptionOrderPrescriber((int) $row->prescription_id, $adminId)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (self::orderWithinDataScopeOwners($row, $adminId, $adminInfo)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user