feat(project): show business fields in statistics details

Reuse assignment business columns and keyword searches in the four statistics drill-down lists. Add a statistics-permission read endpoint sharing tenant-scoped detail queries without granting assignment access.

Related to issue #13. Independent static review completed. User self-test arrangement: regression cases authored, no tests or builds executed.
This commit is contained in:
zlwu committed 2026-11-04 14:40:04 +08:00
1 parent f04e24186f
commit fa5efa9629
7 files changed
+106 -8

No files matched your search

+15
View File
@@ -159,6 +159,21 @@ def records(bizType: str, page: int=Query(1, ge=1), pageSize: int=Query(20, ge=1
return success_response(svc.records(db, *ctx, bizType, page, pageSize, teamId=teamId, projectId=projectId, unassigned=unassigned, status=status, keyword=keyword, startDate=startDate, endDate=endDate))
@router.get(PREFIX + '/statistics/records')
def statistics_records(
bizType: Literal['cell_storage', 'research_donation', 'pilot_service', 'basic_experiment'],
page: int = Query(1, ge=1), pageSize: int = Query(20, ge=1, le=200),
teamId: Optional[str] = None, projectId: Optional[str] = None,
unassigned: bool = False, status: Optional[str] = None, keyword: Optional[str] = None,
startDate: Optional[str] = None, endDate: Optional[str] = None,
ctx=Depends(guard('project:statistics:list')), db: Session=Depends(get_db),
):
return success_response(project_assignment_records.statistics_records(
db, *ctx, bizType, page, pageSize, teamId=teamId, projectId=projectId,
unassigned=unassigned, status=status, keyword=keyword, startDate=startDate, endDate=endDate,
))
@router.post(PREFIX + '/assignments/preview')
def preview(body: PreviewBody, ctx=Depends(guard('project:assignment:edit')), db: Session=Depends(get_db)):
return success_response(svc.preview_assignment(db, *ctx, body.bizType, body.id, body.projectId))
@@ -1,4 +1,4 @@
"""历史归属维护专用检索;统计明细不返回业务联系信息。"""
"""项目业务明细检索;统计读取与归属维护分别校验菜单权限。"""
from collections import defaultdict
from fastapi import HTTPException
@@ -162,8 +162,17 @@ def business_details(db, tenant, kind, rows):
def records(db, tenant, user, biz_type, page=1, pageSize=20, **filters):
projects.check_permission(db, tenant, user, 'project:assignment:edit')
return _records(db, tenant, user, biz_type, page, pageSize, **filters)
def statistics_records(db, tenant, user, biz_type, page=1, pageSize=20, **filters):
projects.check_permission(db, tenant, user, 'project:statistics:list')
return _records(db, tenant, user, biz_type, page, pageSize, **filters)
def _records(db, tenant, user, biz_type, page, pageSize, **filters):
if biz_type not in projects.COUNT_TYPES:
raise HTTPException(400, '归属维护仅支持四类正式业务')
raise HTTPException(400, '业务明细仅支持四类正式业务')
model, number, status = projects.BUSINESS[biz_type]
# 继续使用现有租户、主单数据范围、项目/项目组和日期条件。
query = projects.filtered_query(db, tenant, user, biz_type, {**filters, 'keyword': None})