修复bug
This commit is contained in:
@@ -2,8 +2,16 @@
|
|||||||
<div class="assign-log-panel">
|
<div class="assign-log-panel">
|
||||||
<el-table v-loading="loading" :data="rows" border stripe empty-text="暂无指派记录">
|
<el-table v-loading="loading" :data="rows" border stripe empty-text="暂无指派记录">
|
||||||
<el-table-column label="操作时间" width="175" prop="create_time_text" />
|
<el-table-column label="操作时间" width="175" prop="create_time_text" />
|
||||||
<el-table-column label="原医助" min-width="120" prop="from_assistant_name" />
|
<el-table-column label="原医助" min-width="120">
|
||||||
<el-table-column label="新医助" min-width="120" prop="to_assistant_name" />
|
<template #default="{ row }">
|
||||||
|
{{ assistantLogCellText(row, 'from') }}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="新医助" min-width="120">
|
||||||
|
<template #default="{ row }">
|
||||||
|
{{ assistantLogCellText(row, 'to') }}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
<el-table-column label="操作人" width="110" prop="operator_name" />
|
<el-table-column label="操作人" width="110" prop="operator_name" />
|
||||||
<el-table-column label="操作账号" width="120" prop="operator_account" show-overflow-tooltip />
|
<el-table-column label="操作账号" width="120" prop="operator_account" show-overflow-tooltip />
|
||||||
<el-table-column label="IP" width="130" prop="ip" show-overflow-tooltip />
|
<el-table-column label="IP" width="130" prop="ip" show-overflow-tooltip />
|
||||||
@@ -22,12 +30,27 @@ const props = defineProps<{
|
|||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const rows = ref<any[]>([])
|
const rows = ref<any[]>([])
|
||||||
|
|
||||||
|
function assistantLogCellText(row: Record<string, unknown>, side: 'from' | 'to'): string {
|
||||||
|
const nameKey = side === 'from' ? 'from_assistant_name' : 'to_assistant_name'
|
||||||
|
const idKey = side === 'from' ? 'from_assistant_id' : 'to_assistant_id'
|
||||||
|
const n = row[nameKey]
|
||||||
|
if (n != null && String(n).trim() !== '' && String(n) !== '—') {
|
||||||
|
return String(n)
|
||||||
|
}
|
||||||
|
const id = Number(row[idKey])
|
||||||
|
if (Number.isFinite(id) && id > 0) {
|
||||||
|
return `ID:${id}`
|
||||||
|
}
|
||||||
|
return '—'
|
||||||
|
}
|
||||||
|
|
||||||
const load = async () => {
|
const load = async () => {
|
||||||
if (!props.diagnosisId) return
|
if (!props.diagnosisId) return
|
||||||
loading.value = true
|
loading.value = true
|
||||||
try {
|
try {
|
||||||
const data = await tcmDiagnosisAssignLogList({ id: props.diagnosisId })
|
const data = await tcmDiagnosisAssignLogList({ id: props.diagnosisId })
|
||||||
rows.value = Array.isArray(data) ? data : []
|
const list = Array.isArray(data) ? data : []
|
||||||
|
rows.value = list
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(e)
|
||||||
rows.value = []
|
rows.value = []
|
||||||
|
|||||||
@@ -1446,10 +1446,13 @@ const handleEdit = (id: number) => {
|
|||||||
editRef.value.open('edit', id)
|
editRef.value.open('edit', id)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 与预约列表开方一致:已通过且未作废 → 查看,否则开方 */
|
/** 与预约列表开方一致:已通过且未作废 → 查看,否则开方。(待分配医助 Tab 一律显示「开方」,避免误解为只读) */
|
||||||
function prescriptionActionLabel(row: any) {
|
function prescriptionActionLabel(row: any) {
|
||||||
|
if (formData.pending_assign === '1') {
|
||||||
|
return '开方'
|
||||||
|
}
|
||||||
if (
|
if (
|
||||||
row?.prescription_audit_status === 1 &&
|
Number(row?.prescription_audit_status) === 1 &&
|
||||||
Number(row?.prescription_void_status) !== 1
|
Number(row?.prescription_void_status) !== 1
|
||||||
) {
|
) {
|
||||||
return '查看'
|
return '查看'
|
||||||
|
|||||||
@@ -221,7 +221,9 @@ class PrescriptionOrderLists extends BaseAdminDataLists implements ListsSearchIn
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 非「业务订单全量」角色:默认仅本人创建;若持有 viewOrdersForOwnPrescription 则包含关联处方开方人为本人的订单
|
* 非「业务订单全量」角色:默认仅本人创建;若持有 viewOrdersForOwnPrescription 则包含关联处方开方人为本人的订单;
|
||||||
|
* 另含「关联诊单医助为本人」以便医助跟进出单与履约。
|
||||||
|
* 显式筛选 assistant_id 时:若该医助落在当前账号数据域内,则允许按「诊单医助 / 订单创建人」命中(与 applyDoctorAssistantFilters 一致)。
|
||||||
*/
|
*/
|
||||||
private function applyCreatorOrOwnPrescriptionVisibility($query): void
|
private function applyCreatorOrOwnPrescriptionVisibility($query): void
|
||||||
{
|
{
|
||||||
@@ -229,19 +231,60 @@ class PrescriptionOrderLists extends BaseAdminDataLists implements ListsSearchIn
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$adminId = (int) $this->adminId;
|
$adminId = (int) $this->adminId;
|
||||||
if (PrescriptionOrderLogic::canViewOrdersForOwnPrescription($this->adminInfo)) {
|
$poTbl = (new PrescriptionOrder())->getTable();
|
||||||
$poTbl = (new PrescriptionOrder())->getTable();
|
$rxTbl = (new Prescription())->getTable();
|
||||||
$rxTbl = (new Prescription())->getTable();
|
$diagTbl = (new Diagnosis())->getTable();
|
||||||
$query->where(function ($q) use ($poTbl, $rxTbl, $adminId) {
|
|
||||||
$q->where('creator_id', $adminId);
|
$explicitAssistant = (int) ($this->params['assistant_id'] ?? 0);
|
||||||
$q->whereOrRaw(
|
$allowExplicitAssistantVisibility = false;
|
||||||
"EXISTS (SELECT 1 FROM `{$rxTbl}` rx WHERE rx.`id` = `{$poTbl}`.`prescription_id`"
|
if ($explicitAssistant > 0) {
|
||||||
. " AND rx.`delete_time` IS NULL AND rx.`creator_id` = {$adminId})"
|
if (!$this->dataScopeShouldApply()) {
|
||||||
);
|
$allowExplicitAssistantVisibility = true;
|
||||||
});
|
} else {
|
||||||
} else {
|
$visibleIds = $this->getDataScopeVisibleAdminIds();
|
||||||
$query->where('creator_id', $adminId);
|
if ($visibleIds === null || in_array($explicitAssistant, $visibleIds, true)) {
|
||||||
|
$allowExplicitAssistantVisibility = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$query->where(function ($q) use (
|
||||||
|
$poTbl,
|
||||||
|
$rxTbl,
|
||||||
|
$diagTbl,
|
||||||
|
$adminId,
|
||||||
|
$explicitAssistant,
|
||||||
|
$allowExplicitAssistantVisibility
|
||||||
|
) {
|
||||||
|
if (PrescriptionOrderLogic::canViewOrdersForOwnPrescription($this->adminInfo)) {
|
||||||
|
$q->where(function ($qq) use ($poTbl, $rxTbl, $diagTbl, $adminId) {
|
||||||
|
$qq->where('creator_id', $adminId);
|
||||||
|
$qq->whereOrRaw(
|
||||||
|
"EXISTS (SELECT 1 FROM `{$rxTbl}` rx WHERE rx.`id` = `{$poTbl}`.`prescription_id`"
|
||||||
|
. " AND rx.`delete_time` IS NULL AND rx.`creator_id` = {$adminId})"
|
||||||
|
);
|
||||||
|
$qq->whereOrRaw(
|
||||||
|
"EXISTS (SELECT 1 FROM `{$diagTbl}` dg WHERE dg.`id` = `{$poTbl}`.`diagnosis_id`"
|
||||||
|
. " AND dg.`delete_time` IS NULL AND dg.`assistant_id` = {$adminId})"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$q->where(function ($qq) use ($poTbl, $diagTbl, $adminId) {
|
||||||
|
$qq->where('creator_id', $adminId);
|
||||||
|
$qq->whereOrRaw(
|
||||||
|
"EXISTS (SELECT 1 FROM `{$diagTbl}` dg WHERE dg.`id` = `{$poTbl}`.`diagnosis_id`"
|
||||||
|
. " AND dg.`delete_time` IS NULL AND dg.`assistant_id` = {$adminId})"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if ($allowExplicitAssistantVisibility) {
|
||||||
|
$q->whereOr('creator_id', $explicitAssistant);
|
||||||
|
$q->whereOrRaw(
|
||||||
|
"EXISTS (SELECT 1 FROM `{$diagTbl}` dg WHERE dg.`id` = `{$poTbl}`.`diagnosis_id`"
|
||||||
|
. " AND dg.`delete_time` IS NULL AND dg.`assistant_id` = {$explicitAssistant})"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -813,7 +856,9 @@ class PrescriptionOrderLists extends BaseAdminDataLists implements ListsSearchIn
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 按开方医生(关联处方 creator_id)/ 诊单医助(关联诊单 assistant_id)筛选
|
* 按开方医生(关联处方 creator_id)/ 诊单医助筛选
|
||||||
|
*
|
||||||
|
* 医助:诊单 assistant_id 与业务订单 creator_id 并举——医助常代建单但诊单未写 assistant_id。
|
||||||
*/
|
*/
|
||||||
private function applyDoctorAssistantFilters($query): void
|
private function applyDoctorAssistantFilters($query): void
|
||||||
{
|
{
|
||||||
@@ -828,7 +873,13 @@ class PrescriptionOrderLists extends BaseAdminDataLists implements ListsSearchIn
|
|||||||
if (isset($this->params['assistant_id']) && (int) $this->params['assistant_id'] > 0) {
|
if (isset($this->params['assistant_id']) && (int) $this->params['assistant_id'] > 0) {
|
||||||
$assistantId = (int) $this->params['assistant_id'];
|
$assistantId = (int) $this->params['assistant_id'];
|
||||||
$diagTbl = (new Diagnosis())->getTable();
|
$diagTbl = (new Diagnosis())->getTable();
|
||||||
$query->whereExists("SELECT 1 FROM {$diagTbl} dg WHERE dg.id = {$poTbl}.diagnosis_id AND dg.delete_time IS NULL AND dg.assistant_id = {$assistantId}");
|
$query->where(function ($q) use ($poTbl, $diagTbl, $assistantId) {
|
||||||
|
$q->where('creator_id', $assistantId);
|
||||||
|
$q->whereOrRaw(
|
||||||
|
"EXISTS (SELECT 1 FROM `{$diagTbl}` dg WHERE dg.`id` = `{$poTbl}`.`diagnosis_id`"
|
||||||
|
. " AND dg.`delete_time` IS NULL AND dg.`assistant_id` = {$assistantId})"
|
||||||
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($this->params['assistant_dept_id']) && $this->params['assistant_dept_id'] !== '' && (int) $this->params['assistant_dept_id'] > 0) {
|
if (isset($this->params['assistant_dept_id']) && $this->params['assistant_dept_id'] !== '' && (int) $this->params['assistant_dept_id'] > 0) {
|
||||||
@@ -845,10 +896,16 @@ class PrescriptionOrderLists extends BaseAdminDataLists implements ListsSearchIn
|
|||||||
$inList = implode(',', $deptIds);
|
$inList = implode(',', $deptIds);
|
||||||
$diagTbl = (new Diagnosis())->getTable();
|
$diagTbl = (new Diagnosis())->getTable();
|
||||||
$adTbl = (new AdminDept())->getTable();
|
$adTbl = (new AdminDept())->getTable();
|
||||||
$query->whereExists(
|
$query->where(function ($q) use ($poTbl, $diagTbl, $adTbl, $inList) {
|
||||||
"SELECT 1 FROM `{$adTbl}` ad INNER JOIN `{$diagTbl}` dg ON ad.admin_id = dg.assistant_id AND dg.delete_time IS NULL "
|
$q->whereExists(
|
||||||
. "WHERE dg.id = `{$poTbl}`.`diagnosis_id` AND ad.dept_id IN ({$inList})"
|
"SELECT 1 FROM `{$adTbl}` ad INNER JOIN `{$diagTbl}` dg ON ad.admin_id = dg.assistant_id AND dg.delete_time IS NULL "
|
||||||
);
|
. "WHERE dg.`id` = `{$poTbl}`.`diagnosis_id` AND ad.dept_id IN ({$inList})"
|
||||||
|
);
|
||||||
|
$q->whereExists(
|
||||||
|
"SELECT 1 FROM `{$adTbl}` adc WHERE adc.`admin_id` = `{$poTbl}`.`creator_id` AND adc.`dept_id` IN ({$inList})",
|
||||||
|
'OR'
|
||||||
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -536,18 +536,22 @@ class DiagnosisLogic extends BaseLogic
|
|||||||
*/
|
*/
|
||||||
public static function assignLogList(int $diagnosisId): array
|
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')
|
->order('id', 'desc')
|
||||||
->select()
|
->select()
|
||||||
->toArray();
|
->toArray();
|
||||||
|
|
||||||
$adminIds = [];
|
$adminIds = [];
|
||||||
foreach ($rows as $r) {
|
foreach ($rows as $r) {
|
||||||
if (!empty($r['from_assistant_id'])) {
|
$fid = (int) ($r['from_assistant_id'] ?? 0);
|
||||||
$adminIds[] = (int) $r['from_assistant_id'];
|
$tid = (int) ($r['to_assistant_id'] ?? 0);
|
||||||
|
if ($fid > 0) {
|
||||||
|
$adminIds[] = $fid;
|
||||||
}
|
}
|
||||||
if (!empty($r['to_assistant_id'])) {
|
if ($tid > 0) {
|
||||||
$adminIds[] = (int) $r['to_assistant_id'];
|
$adminIds[] = $tid;
|
||||||
}
|
}
|
||||||
$rcp = (int) ($r['related_po_creator_id'] ?? 0);
|
$rcp = (int) ($r['related_po_creator_id'] ?? 0);
|
||||||
if ($rcp > 0) {
|
if ($rcp > 0) {
|
||||||
@@ -557,7 +561,7 @@ class DiagnosisLogic extends BaseLogic
|
|||||||
$adminIds = array_values(array_unique(array_filter($adminIds)));
|
$adminIds = array_values(array_unique(array_filter($adminIds)));
|
||||||
$nameMap = [];
|
$nameMap = [];
|
||||||
if ($adminIds !== []) {
|
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) {
|
foreach ($rows as &$r) {
|
||||||
@@ -583,7 +587,7 @@ class DiagnosisLogic extends BaseLogic
|
|||||||
}
|
}
|
||||||
unset($r);
|
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\tcm\PrescriptionOrderPayOrder;
|
||||||
use app\common\model\doctor\Appointment;
|
use app\common\model\doctor\Appointment;
|
||||||
use app\common\model\auth\Admin;
|
use app\common\model\auth\Admin;
|
||||||
|
use app\common\service\DataScope\DataScopeService;
|
||||||
use app\common\service\ExpressTrackService;
|
use app\common\service\ExpressTrackService;
|
||||||
use app\common\service\gancao\GancaoScmRecipelService;
|
use app\common\service\gancao\GancaoScmRecipelService;
|
||||||
use think\facade\Config;
|
use think\facade\Config;
|
||||||
@@ -136,6 +137,30 @@ class PrescriptionOrderLogic
|
|||||||
return $cid === $adminId;
|
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
|
* @param PrescriptionOrder $row
|
||||||
*/
|
*/
|
||||||
@@ -147,8 +172,20 @@ class PrescriptionOrderLogic
|
|||||||
if ((int) $row->creator_id === $adminId) {
|
if ((int) $row->creator_id === $adminId) {
|
||||||
return true;
|
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)) {
|
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;
|
return false;
|
||||||
|
|||||||
@@ -47,10 +47,15 @@ trait ListsSearchTrait
|
|||||||
case 'in':
|
case 'in':
|
||||||
foreach ($whereFields as $whereField) {
|
foreach ($whereFields as $whereField) {
|
||||||
$paramsName = substr_symbol_behind($whereField);
|
$paramsName = substr_symbol_behind($whereField);
|
||||||
if (!isset($this->params[$paramsName]) || $this->params[$paramsName] == '') {
|
if (!isset($this->params[$paramsName])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$where[] = [$whereField, $whereType, $this->params[$paramsName]];
|
$paramVal = $this->params[$paramsName];
|
||||||
|
// 勿用 == '':PHP 中 0 == '' 为 true,会误跳过 prescription_audit_status=0 等合法筛选
|
||||||
|
if ($paramVal === '' || $paramVal === null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$where[] = [$whereField, $whereType, $paramVal];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '%like%':
|
case '%like%':
|
||||||
@@ -95,10 +100,14 @@ trait ListsSearchTrait
|
|||||||
case 'find_in_set': // find_in_set查询
|
case 'find_in_set': // find_in_set查询
|
||||||
foreach ($whereFields as $whereField) {
|
foreach ($whereFields as $whereField) {
|
||||||
$paramsName = substr_symbol_behind($whereField);
|
$paramsName = substr_symbol_behind($whereField);
|
||||||
if (!isset($this->params[$paramsName]) || $this->params[$paramsName] == '') {
|
if (!isset($this->params[$paramsName])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$where[] = [$whereField, 'find in set', $this->params[$paramsName]];
|
$paramVal = $this->params[$paramsName];
|
||||||
|
if ($paramVal === '' || $paramVal === null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$where[] = [$whereField, 'find in set', $paramVal];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user