feat(admin): 支持通过患者ID批量分配研究员
后端批量分配文件夹研究员接口现在支持两种参数格式:folder_ids(整数数组)和 folder_names(字符串数组)。前端相应地将 patient_ids 参数改为 folder_names 以使用患者ID(即文件夹名称)进行分配。
This commit is contained in:
1 parent
1aabe3dfe3
commit
f4b46e47f3
2 files changed
+32
-13
No files matched your search
@@ -1467,6 +1467,9 @@ def batch_delete_folders():
|
||||
def batch_assign_folder_researcher():
|
||||
"""
|
||||
Batch assign researcher to multiple folders
|
||||
支持两种参数格式:
|
||||
- folder_ids: 整数数组(数据库主键 ID)
|
||||
- folder_names: 字符串数组(文件夹名称)
|
||||
---
|
||||
tags:
|
||||
- integration
|
||||
@@ -1478,14 +1481,17 @@ def batch_assign_folder_researcher():
|
||||
required: true
|
||||
schema:
|
||||
type: object
|
||||
required:
|
||||
- folder_ids
|
||||
properties:
|
||||
folder_ids:
|
||||
type: array
|
||||
items:
|
||||
type: integer
|
||||
description: List of folder IDs to assign
|
||||
folder_names:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
description: List of folder names to assign
|
||||
researcher_id:
|
||||
type: integer
|
||||
description: ID of the researcher to assign (0 or null to unassign)
|
||||
@@ -1507,10 +1513,11 @@ def batch_assign_folder_researcher():
|
||||
"""
|
||||
data = request.get_json() or {}
|
||||
folder_ids = data.get("folder_ids") or []
|
||||
folder_names = data.get("folder_names") or []
|
||||
researcher_id = data.get("researcher_id")
|
||||
|
||||
if not folder_ids:
|
||||
return bad_request("No folder_ids")
|
||||
if not folder_ids and not folder_names:
|
||||
return bad_request("No folder_ids or folder_names provided")
|
||||
|
||||
if researcher_id in (0, "0", None, ""):
|
||||
researcher_id = None
|
||||
@@ -1525,10 +1532,23 @@ def batch_assign_folder_researcher():
|
||||
if not (is_researcher or is_admin):
|
||||
return bad_request("Invalid researcher_id")
|
||||
|
||||
folder_ids = [int(x) for x in folder_ids if str(x).isdigit()]
|
||||
if not folder_ids:
|
||||
return bad_request("No folder_ids")
|
||||
folders = RawDataFolder.query.filter(RawDataFolder.id.in_(folder_ids)).all()
|
||||
# 收集要更新的文件夹
|
||||
folders = []
|
||||
|
||||
# 处理 folder_ids(整数 ID)
|
||||
if folder_ids:
|
||||
int_ids = [int(x) for x in folder_ids if str(x).isdigit()]
|
||||
if int_ids:
|
||||
folders.extend(RawDataFolder.query.filter(RawDataFolder.id.in_(int_ids)).all())
|
||||
|
||||
# 处理 folder_names(字符串名称)
|
||||
if folder_names:
|
||||
name_folders = RawDataFolder.query.filter(RawDataFolder.folder_name.in_(folder_names)).all()
|
||||
folders.extend(name_folders)
|
||||
|
||||
if not folders:
|
||||
return bad_request("No valid folders found")
|
||||
|
||||
updated = len(folders)
|
||||
for folder in folders:
|
||||
folder.researcher_id = researcher_id
|
||||
|
||||
@@ -683,13 +683,12 @@ const batchAssign = async () => {
|
||||
|
||||
assigning.value = true
|
||||
try {
|
||||
// 将患者 ID 转换为文件夹 ID(需要调用后端 API 获取文件夹 ID)
|
||||
// 这里我们使用一个简化的方法:直接传递患者 ID 作为文件夹标识
|
||||
await api.post('/admin/inference-data/batch-assign-researcher', {
|
||||
patient_ids: selectedIds.value,
|
||||
// 使用 folder_names 传递患者 ID(文件夹名称)
|
||||
await api.post('/admin/integration/folders/batch-assign-researcher', {
|
||||
folder_names: selectedIds.value,
|
||||
researcher_id: batchAssignResearcherId.value
|
||||
})
|
||||
|
||||
|
||||
ElMessage.success('分配成功')
|
||||
batchAssignVisible.value = false
|
||||
selectedIds.value = []
|
||||
|
||||
Reference in new issue
Block a user