未知(继上次中断)
This commit is contained in:
@@ -0,0 +1,59 @@
|
|||||||
|
"""migrate ae seriousness to roman numerals
|
||||||
|
|
||||||
|
Revision ID: 20260116_04
|
||||||
|
Revises: 20260116_03
|
||||||
|
Create Date: 2026-01-16 17:00:00.000000
|
||||||
|
|
||||||
|
"""
|
||||||
|
from typing import Sequence, Union
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision: str = "20260116_04"
|
||||||
|
down_revision: Union[str, None] = "20260116_03"
|
||||||
|
branch_labels: Union[str, Sequence[str], None] = None
|
||||||
|
depends_on: Union[str, Sequence[str], None] = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade() -> None:
|
||||||
|
conn = op.get_bind()
|
||||||
|
conn.execute(
|
||||||
|
sa.text(
|
||||||
|
"""
|
||||||
|
UPDATE adverse_events
|
||||||
|
SET seriousness = CASE
|
||||||
|
WHEN UPPER(TRIM(seriousness)) = 'SERIOUS' THEN 'IV'
|
||||||
|
WHEN UPPER(TRIM(seriousness)) IN ('NON_SERIOUS', 'NON-SERIOUS', 'NON SERIOUS') THEN 'II'
|
||||||
|
WHEN TRIM(seriousness) = '1' THEN 'I'
|
||||||
|
WHEN TRIM(seriousness) = '2' THEN 'II'
|
||||||
|
WHEN TRIM(seriousness) = '3' THEN 'III'
|
||||||
|
WHEN TRIM(seriousness) = '4' THEN 'IV'
|
||||||
|
WHEN TRIM(seriousness) = '5' THEN 'V'
|
||||||
|
WHEN UPPER(TRIM(seriousness)) IN ('I', 'II', 'III', 'IV', 'V') THEN UPPER(TRIM(seriousness))
|
||||||
|
ELSE seriousness
|
||||||
|
END
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade() -> None:
|
||||||
|
conn = op.get_bind()
|
||||||
|
conn.execute(
|
||||||
|
sa.text(
|
||||||
|
"""
|
||||||
|
UPDATE adverse_events
|
||||||
|
SET seriousness = CASE
|
||||||
|
WHEN UPPER(TRIM(seriousness)) = 'I' THEN '1'
|
||||||
|
WHEN UPPER(TRIM(seriousness)) = 'II' THEN '2'
|
||||||
|
WHEN UPPER(TRIM(seriousness)) = 'III' THEN '3'
|
||||||
|
WHEN UPPER(TRIM(seriousness)) = 'IV' THEN '4'
|
||||||
|
WHEN UPPER(TRIM(seriousness)) = 'V' THEN '5'
|
||||||
|
ELSE seriousness
|
||||||
|
END
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
)
|
||||||
@@ -0,0 +1,95 @@
|
|||||||
|
"""remove document workflows
|
||||||
|
|
||||||
|
Revision ID: 20260116_05
|
||||||
|
Revises: 20260116_04
|
||||||
|
Create Date: 2026-01-16 17:30:00.000000
|
||||||
|
|
||||||
|
"""
|
||||||
|
from typing import Sequence, Union
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
from sqlalchemy.dialects import postgresql
|
||||||
|
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision: str = "20260116_05"
|
||||||
|
down_revision: Union[str, None] = "20260116_04"
|
||||||
|
branch_labels: Union[str, Sequence[str], None] = None
|
||||||
|
depends_on: Union[str, Sequence[str], None] = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade() -> None:
|
||||||
|
op.drop_table("workflow_actions")
|
||||||
|
op.drop_table("version_workflows")
|
||||||
|
op.drop_table("workflow_nodes")
|
||||||
|
op.drop_table("workflow_templates")
|
||||||
|
op.execute("DROP TYPE IF EXISTS workflow_action_type")
|
||||||
|
op.execute("DROP TYPE IF EXISTS workflow_status")
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade() -> None:
|
||||||
|
workflow_status = sa.Enum("PENDING", "APPROVED", "REJECTED", "CANCELED", name="workflow_status")
|
||||||
|
workflow_action_type = sa.Enum("SUBMIT", "APPROVE", "REJECT", name="workflow_action_type")
|
||||||
|
workflow_status.create(op.get_bind(), checkfirst=True)
|
||||||
|
workflow_action_type.create(op.get_bind(), checkfirst=True)
|
||||||
|
|
||||||
|
op.create_table(
|
||||||
|
"workflow_templates",
|
||||||
|
sa.Column("id", postgresql.UUID(as_uuid=True), primary_key=True, nullable=False),
|
||||||
|
sa.Column("trial_id", postgresql.UUID(as_uuid=True), nullable=True),
|
||||||
|
sa.Column("name", sa.String(length=200), nullable=False),
|
||||||
|
sa.Column("description", sa.Text(), nullable=True),
|
||||||
|
sa.Column("is_active", sa.Boolean(), server_default="true", nullable=False),
|
||||||
|
sa.Column("created_by", postgresql.UUID(as_uuid=True), nullable=True),
|
||||||
|
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False),
|
||||||
|
sa.Column("updated_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False),
|
||||||
|
sa.ForeignKeyConstraint(["trial_id"], ["studies.id"]),
|
||||||
|
sa.ForeignKeyConstraint(["created_by"], ["users.id"]),
|
||||||
|
)
|
||||||
|
|
||||||
|
op.create_table(
|
||||||
|
"workflow_nodes",
|
||||||
|
sa.Column("id", postgresql.UUID(as_uuid=True), primary_key=True, nullable=False),
|
||||||
|
sa.Column("template_id", postgresql.UUID(as_uuid=True), nullable=False),
|
||||||
|
sa.Column("node_order", sa.Integer(), nullable=False),
|
||||||
|
sa.Column("role", sa.String(length=50), nullable=False),
|
||||||
|
sa.Column("name", sa.String(length=100), nullable=True),
|
||||||
|
sa.Column("is_required", sa.Boolean(), server_default="true", nullable=False),
|
||||||
|
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False),
|
||||||
|
sa.ForeignKeyConstraint(["template_id"], ["workflow_templates.id"]),
|
||||||
|
sa.UniqueConstraint("template_id", "node_order", name="uq_workflow_nodes_order"),
|
||||||
|
)
|
||||||
|
|
||||||
|
op.create_table(
|
||||||
|
"version_workflows",
|
||||||
|
sa.Column("id", postgresql.UUID(as_uuid=True), primary_key=True, nullable=False),
|
||||||
|
sa.Column("document_id", postgresql.UUID(as_uuid=True), nullable=False),
|
||||||
|
sa.Column("version_id", postgresql.UUID(as_uuid=True), nullable=False),
|
||||||
|
sa.Column("template_id", postgresql.UUID(as_uuid=True), nullable=False),
|
||||||
|
sa.Column("status", workflow_status, server_default="PENDING", nullable=False),
|
||||||
|
sa.Column("current_node", sa.Integer(), nullable=True),
|
||||||
|
sa.Column("submitted_by", postgresql.UUID(as_uuid=True), nullable=True),
|
||||||
|
sa.Column("submitted_at", sa.DateTime(timezone=True), nullable=True),
|
||||||
|
sa.Column("completed_at", sa.DateTime(timezone=True), nullable=True),
|
||||||
|
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False),
|
||||||
|
sa.Column("updated_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False),
|
||||||
|
sa.ForeignKeyConstraint(["document_id"], ["documents.id"]),
|
||||||
|
sa.ForeignKeyConstraint(["version_id"], ["document_versions.id"]),
|
||||||
|
sa.ForeignKeyConstraint(["template_id"], ["workflow_templates.id"]),
|
||||||
|
sa.ForeignKeyConstraint(["submitted_by"], ["users.id"]),
|
||||||
|
sa.UniqueConstraint("version_id", name="uq_version_workflow_version"),
|
||||||
|
)
|
||||||
|
|
||||||
|
op.create_table(
|
||||||
|
"workflow_actions",
|
||||||
|
sa.Column("id", postgresql.UUID(as_uuid=True), primary_key=True, nullable=False),
|
||||||
|
sa.Column("workflow_id", postgresql.UUID(as_uuid=True), nullable=False),
|
||||||
|
sa.Column("node_order", sa.Integer(), nullable=True),
|
||||||
|
sa.Column("action", workflow_action_type, nullable=False),
|
||||||
|
sa.Column("actor_id", postgresql.UUID(as_uuid=True), nullable=True),
|
||||||
|
sa.Column("comment", sa.Text(), nullable=True),
|
||||||
|
sa.Column("acted_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False),
|
||||||
|
sa.ForeignKeyConstraint(["workflow_id"], ["version_workflows.id"]),
|
||||||
|
sa.ForeignKeyConstraint(["actor_id"], ["users.id"]),
|
||||||
|
)
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
"""migrate ae seriousness cn to roman numerals
|
||||||
|
|
||||||
|
Revision ID: 20260116_06
|
||||||
|
Revises: 20260116_05
|
||||||
|
Create Date: 2026-01-16 18:30:00.000000
|
||||||
|
|
||||||
|
"""
|
||||||
|
from typing import Sequence, Union
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision: str = "20260116_06"
|
||||||
|
down_revision: Union[str, None] = "20260116_05"
|
||||||
|
branch_labels: Union[str, Sequence[str], None] = None
|
||||||
|
depends_on: Union[str, Sequence[str], None] = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade() -> None:
|
||||||
|
conn = op.get_bind()
|
||||||
|
conn.execute(
|
||||||
|
sa.text(
|
||||||
|
"""
|
||||||
|
UPDATE adverse_events
|
||||||
|
SET seriousness = CASE
|
||||||
|
WHEN TRIM(seriousness) IN ('轻微', '轻度') THEN 'I'
|
||||||
|
WHEN TRIM(seriousness) = '一般' THEN 'II'
|
||||||
|
WHEN TRIM(seriousness) = '中度' THEN 'III'
|
||||||
|
WHEN TRIM(seriousness) IN ('严重', '重度') THEN 'IV'
|
||||||
|
WHEN TRIM(seriousness) = '危重' THEN 'V'
|
||||||
|
ELSE seriousness
|
||||||
|
END
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade() -> None:
|
||||||
|
pass
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
"""migrate ae seriousness enum strings to roman numerals
|
||||||
|
|
||||||
|
Revision ID: 20260116_07
|
||||||
|
Revises: 20260116_06
|
||||||
|
Create Date: 2026-01-16 19:00:00.000000
|
||||||
|
|
||||||
|
"""
|
||||||
|
from typing import Sequence, Union
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision: str = "20260116_07"
|
||||||
|
down_revision: Union[str, None] = "20260116_06"
|
||||||
|
branch_labels: Union[str, Sequence[str], None] = None
|
||||||
|
depends_on: Union[str, Sequence[str], None] = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade() -> None:
|
||||||
|
conn = op.get_bind()
|
||||||
|
conn.execute(
|
||||||
|
sa.text(
|
||||||
|
"""
|
||||||
|
UPDATE adverse_events
|
||||||
|
SET seriousness = CASE
|
||||||
|
WHEN TRIM(seriousness) = 'AESERIOUSNESS.I' THEN 'I'
|
||||||
|
WHEN TRIM(seriousness) = 'AESERIOUSNESS.II' THEN 'II'
|
||||||
|
WHEN TRIM(seriousness) = 'AESERIOUSNESS.III' THEN 'III'
|
||||||
|
WHEN TRIM(seriousness) = 'AESERIOUSNESS.IV' THEN 'IV'
|
||||||
|
WHEN TRIM(seriousness) = 'AESERIOUSNESS.V' THEN 'V'
|
||||||
|
ELSE seriousness
|
||||||
|
END
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade() -> None:
|
||||||
|
pass
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
"""migrate ae seriousness enum strings case-insensitive
|
||||||
|
|
||||||
|
Revision ID: 20260116_08
|
||||||
|
Revises: 20260116_07
|
||||||
|
Create Date: 2026-01-16 19:10:00.000000
|
||||||
|
|
||||||
|
"""
|
||||||
|
from typing import Sequence, Union
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision: str = "20260116_08"
|
||||||
|
down_revision: Union[str, None] = "20260116_07"
|
||||||
|
branch_labels: Union[str, Sequence[str], None] = None
|
||||||
|
depends_on: Union[str, Sequence[str], None] = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade() -> None:
|
||||||
|
conn = op.get_bind()
|
||||||
|
conn.execute(
|
||||||
|
sa.text(
|
||||||
|
"""
|
||||||
|
UPDATE adverse_events
|
||||||
|
SET seriousness = CASE
|
||||||
|
WHEN UPPER(TRIM(seriousness)) = 'AESERIOUSNESS.I' THEN 'I'
|
||||||
|
WHEN UPPER(TRIM(seriousness)) = 'AESERIOUSNESS.II' THEN 'II'
|
||||||
|
WHEN UPPER(TRIM(seriousness)) = 'AESERIOUSNESS.III' THEN 'III'
|
||||||
|
WHEN UPPER(TRIM(seriousness)) = 'AESERIOUSNESS.IV' THEN 'IV'
|
||||||
|
WHEN UPPER(TRIM(seriousness)) = 'AESERIOUSNESS.V' THEN 'V'
|
||||||
|
ELSE seriousness
|
||||||
|
END
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade() -> None:
|
||||||
|
pass
|
||||||
@@ -5,7 +5,7 @@ from datetime import date
|
|||||||
from fastapi import APIRouter, Depends, HTTPException, status
|
from fastapi import APIRouter, Depends, HTTPException, status
|
||||||
from sqlalchemy.ext.asyncio import AsyncSession
|
from sqlalchemy.ext.asyncio import AsyncSession
|
||||||
|
|
||||||
from app.core.deps import get_current_user, get_db_session, require_study_member, require_study_not_locked
|
from app.core.deps import get_cra_site_scope, get_current_user, get_db_session, require_study_member, require_study_not_locked
|
||||||
from app.crud import ae as ae_crud
|
from app.crud import ae as ae_crud
|
||||||
from app.crud import audit as audit_crud
|
from app.crud import audit as audit_crud
|
||||||
from app.crud import member as member_crud
|
from app.crud import member as member_crud
|
||||||
@@ -65,6 +65,14 @@ async def create_ae(
|
|||||||
current_user=Depends(get_current_user),
|
current_user=Depends(get_current_user),
|
||||||
) -> AERead:
|
) -> AERead:
|
||||||
await _ensure_study_exists(db, study_id)
|
await _ensure_study_exists(db, study_id)
|
||||||
|
cra_scope = await get_cra_site_scope(db, study_id, current_user)
|
||||||
|
if cra_scope:
|
||||||
|
if ae_in.site_id and ae_in.site_id not in cra_scope[0]:
|
||||||
|
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="权限不足")
|
||||||
|
if ae_in.subject_id:
|
||||||
|
subj = await subject_crud.get_subject(db, ae_in.subject_id)
|
||||||
|
if subj and subj.site_id not in cra_scope[0]:
|
||||||
|
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="权限不足")
|
||||||
if ae_in.onset_date and ae_in.onset_date > date.today():
|
if ae_in.onset_date and ae_in.onset_date > date.today():
|
||||||
raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail="发生日期不能晚于今天")
|
raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail="发生日期不能晚于今天")
|
||||||
member_role = await _get_member_role(db, study_id, current_user.id)
|
member_role = await _get_member_role(db, study_id, current_user.id)
|
||||||
@@ -102,9 +110,23 @@ async def list_ae(
|
|||||||
subject_id: uuid.UUID | None = None,
|
subject_id: uuid.UUID | None = None,
|
||||||
overdue: bool | None = None,
|
overdue: bool | None = None,
|
||||||
db: AsyncSession = Depends(get_db_session),
|
db: AsyncSession = Depends(get_db_session),
|
||||||
|
current_user=Depends(get_current_user),
|
||||||
) -> list[AERead]:
|
) -> list[AERead]:
|
||||||
await _ensure_study_exists(db, study_id)
|
await _ensure_study_exists(db, study_id)
|
||||||
aes = await ae_crud.list_ae(db, study_id, status=status_filter, seriousness=seriousness, site_id=site_id, subject_id=subject_id, overdue=overdue)
|
cra_scope = await get_cra_site_scope(db, study_id, current_user)
|
||||||
|
site_ids = cra_scope[0] if cra_scope else None
|
||||||
|
if site_id and site_ids is not None and site_id not in site_ids:
|
||||||
|
return []
|
||||||
|
aes = await ae_crud.list_ae(
|
||||||
|
db,
|
||||||
|
study_id,
|
||||||
|
status=status_filter,
|
||||||
|
seriousness=seriousness,
|
||||||
|
site_id=site_id,
|
||||||
|
subject_id=subject_id,
|
||||||
|
overdue=overdue,
|
||||||
|
site_ids=site_ids,
|
||||||
|
)
|
||||||
result: list[AERead] = []
|
result: list[AERead] = []
|
||||||
for item in aes:
|
for item in aes:
|
||||||
obj = AERead.model_validate(item)
|
obj = AERead.model_validate(item)
|
||||||
@@ -122,6 +144,7 @@ async def get_ae(
|
|||||||
study_id: uuid.UUID,
|
study_id: uuid.UUID,
|
||||||
ae_id: uuid.UUID,
|
ae_id: uuid.UUID,
|
||||||
db: AsyncSession = Depends(get_db_session),
|
db: AsyncSession = Depends(get_db_session),
|
||||||
|
current_user=Depends(get_current_user),
|
||||||
) -> AERead:
|
) -> AERead:
|
||||||
await _ensure_study_exists(db, study_id)
|
await _ensure_study_exists(db, study_id)
|
||||||
ae = await ae_crud.get_ae(db, ae_id)
|
ae = await ae_crud.get_ae(db, ae_id)
|
||||||
@@ -129,6 +152,14 @@ async def get_ae(
|
|||||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="AE 不存在")
|
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="AE 不存在")
|
||||||
data = AERead.model_validate(ae)
|
data = AERead.model_validate(ae)
|
||||||
data.is_overdue = _is_overdue(data)
|
data.is_overdue = _is_overdue(data)
|
||||||
|
cra_scope = await get_cra_site_scope(db, study_id, current_user)
|
||||||
|
if cra_scope:
|
||||||
|
if data.site_id and data.site_id not in cra_scope[0]:
|
||||||
|
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="权限不足")
|
||||||
|
if data.subject_id:
|
||||||
|
subj = await subject_crud.get_subject(db, data.subject_id)
|
||||||
|
if subj and subj.site_id not in cra_scope[0]:
|
||||||
|
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="权限不足")
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
@@ -169,7 +200,7 @@ async def update_ae(
|
|||||||
detail_before = {
|
detail_before = {
|
||||||
"event": ae.term,
|
"event": ae.term,
|
||||||
"onset_date": ae.onset_date,
|
"onset_date": ae.onset_date,
|
||||||
"severity": ae.severity,
|
"seriousness": ae.seriousness,
|
||||||
"status": ae.status,
|
"status": ae.status,
|
||||||
"description": ae.description,
|
"description": ae.description,
|
||||||
}
|
}
|
||||||
@@ -177,7 +208,7 @@ async def update_ae(
|
|||||||
detail_after = {
|
detail_after = {
|
||||||
"event": updated.term,
|
"event": updated.term,
|
||||||
"onset_date": updated.onset_date,
|
"onset_date": updated.onset_date,
|
||||||
"severity": updated.severity,
|
"seriousness": updated.seriousness,
|
||||||
"status": updated.status,
|
"status": updated.status,
|
||||||
"description": updated.description,
|
"description": updated.description,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,13 @@ from fastapi import APIRouter, Depends
|
|||||||
from sqlalchemy import func, select
|
from sqlalchemy import func, select
|
||||||
from sqlalchemy.ext.asyncio import AsyncSession
|
from sqlalchemy.ext.asyncio import AsyncSession
|
||||||
|
|
||||||
from app.core.deps import get_db_session, require_study_member
|
from app.core.deps import get_cra_site_scope, get_current_user, get_db_session, require_study_member
|
||||||
from app.models.milestone import Milestone
|
from app.models.milestone import Milestone
|
||||||
from app.schemas.progress import StudyProgressRead
|
from app.schemas.progress import StudyProgressRead
|
||||||
|
from app.schemas.visit import VisitLostItem
|
||||||
|
from app.crud import visit as visit_crud
|
||||||
|
from app.schemas.dashboard import CenterSummaryItem
|
||||||
|
from app.crud import overview as overview_crud
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
|
||||||
@@ -30,3 +34,87 @@ async def get_progress(
|
|||||||
milestones_done=milestone_done,
|
milestones_done=milestone_done,
|
||||||
completion_rate=completion_rate,
|
completion_rate=completion_rate,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@router.get("/lost-visits", response_model=list[VisitLostItem], dependencies=[Depends(require_study_member())])
|
||||||
|
async def list_lost_visits(
|
||||||
|
study_id: uuid.UUID,
|
||||||
|
limit: int = 20,
|
||||||
|
db: AsyncSession = Depends(get_db_session),
|
||||||
|
current_user=Depends(get_current_user),
|
||||||
|
) -> list[VisitLostItem]:
|
||||||
|
cra_scope = await get_cra_site_scope(db, study_id, current_user)
|
||||||
|
site_ids = cra_scope[0] if cra_scope else None
|
||||||
|
rows = await visit_crud.list_lost_visits(db, study_id, site_ids=site_ids, limit=limit)
|
||||||
|
items: list[VisitLostItem] = []
|
||||||
|
for visit, subject_no, site_id in rows:
|
||||||
|
items.append(
|
||||||
|
VisitLostItem(
|
||||||
|
visit_id=visit.id,
|
||||||
|
subject_id=visit.subject_id,
|
||||||
|
subject_no=subject_no,
|
||||||
|
site_id=site_id,
|
||||||
|
visit_code=visit.visit_code,
|
||||||
|
status=visit.status,
|
||||||
|
updated_at=visit.updated_at,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return items
|
||||||
|
|
||||||
|
|
||||||
|
@router.get("/center-summary", response_model=list[CenterSummaryItem], dependencies=[Depends(require_study_member())])
|
||||||
|
async def get_center_summary(
|
||||||
|
study_id: uuid.UUID,
|
||||||
|
db: AsyncSession = Depends(get_db_session),
|
||||||
|
current_user=Depends(get_current_user),
|
||||||
|
) -> list[CenterSummaryItem]:
|
||||||
|
role_value = current_user.role.value if hasattr(current_user.role, "value") else current_user.role
|
||||||
|
if role_value not in {"ADMIN", "PM", "CRA"}:
|
||||||
|
return []
|
||||||
|
cra_scope = await get_cra_site_scope(db, study_id, current_user)
|
||||||
|
scope_ids = cra_scope[0] if cra_scope else None
|
||||||
|
scope_id_strs = {str(cid) for cid in scope_ids} if scope_ids is not None else None
|
||||||
|
overview = await overview_crud.get_project_overview(db, study_id)
|
||||||
|
centers = overview.get("centers") or []
|
||||||
|
|
||||||
|
stage_order = [
|
||||||
|
("institution_initiation_status", "机构立项"),
|
||||||
|
("ethics_status", "伦理审批"),
|
||||||
|
("contract_sign_status", "合同签署"),
|
||||||
|
("startup_status", "启动"),
|
||||||
|
("enrollment_status", "入组"),
|
||||||
|
("inspection_status", "末次稽查"),
|
||||||
|
("closeout_status", "关中心"),
|
||||||
|
]
|
||||||
|
|
||||||
|
summary_list: list[CenterSummaryItem] = []
|
||||||
|
for center in centers:
|
||||||
|
center_id = center.get("center_id")
|
||||||
|
if scope_id_strs is not None and center_id not in scope_id_strs:
|
||||||
|
continue
|
||||||
|
|
||||||
|
stage_label = "未开始"
|
||||||
|
stage_status = "NOT_STARTED"
|
||||||
|
for key, label in stage_order:
|
||||||
|
status = (center.get(key) or "NOT_STARTED").upper()
|
||||||
|
if status in ("IN_PROGRESS", "BLOCKED"):
|
||||||
|
stage_label = label
|
||||||
|
stage_status = status
|
||||||
|
break
|
||||||
|
if status == "COMPLETED":
|
||||||
|
stage_label = label
|
||||||
|
stage_status = status
|
||||||
|
continue
|
||||||
|
|
||||||
|
summary_list.append(
|
||||||
|
CenterSummaryItem(
|
||||||
|
id=center_id,
|
||||||
|
name=center.get("center_name") or "",
|
||||||
|
stage=stage_label,
|
||||||
|
stage_status=stage_status,
|
||||||
|
actual_enrolled=center.get("enrollment_actual") or 0,
|
||||||
|
planned_enrolled=center.get("enrollment_target") or 0,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
return summary_list
|
||||||
|
|||||||
@@ -6,13 +6,12 @@ from fastapi.responses import FileResponse
|
|||||||
from sqlalchemy.ext.asyncio import AsyncSession
|
from sqlalchemy.ext.asyncio import AsyncSession
|
||||||
|
|
||||||
from app.core.deps import get_current_user, get_db_session
|
from app.core.deps import get_current_user, get_db_session
|
||||||
from app.crud import document_version as version_crud
|
|
||||||
from app.schemas.acknowledgement import AcknowledgementCreate, AcknowledgementRead
|
from app.schemas.acknowledgement import AcknowledgementCreate, AcknowledgementRead
|
||||||
from app.schemas.common import PaginatedResponse
|
from app.schemas.common import PaginatedResponse
|
||||||
from app.schemas.distribution import DistributionCreate, DistributionRead
|
from app.schemas.distribution import DistributionCreate, DistributionRead
|
||||||
from app.schemas.document import DocumentCreate, DocumentDetail, DocumentSummary
|
from app.schemas.document import DocumentCreate, DocumentDetail, DocumentSummary
|
||||||
from app.schemas.document_version import DocumentVersionRead, VersionActionRequest, VersionSubmitRequest
|
from app.schemas.document_version import DocumentVersionRead
|
||||||
from app.schemas.workflow_template import WorkflowTemplateRead
|
from app.models.user import UserRole
|
||||||
from app.services import document_service
|
from app.services import document_service
|
||||||
from app.utils.pagination import paginate
|
from app.utils.pagination import paginate
|
||||||
|
|
||||||
@@ -74,6 +73,9 @@ async def delete_document(
|
|||||||
db: AsyncSession = Depends(get_db_session),
|
db: AsyncSession = Depends(get_db_session),
|
||||||
current_user=Depends(get_current_user),
|
current_user=Depends(get_current_user),
|
||||||
) -> DocumentSummary:
|
) -> DocumentSummary:
|
||||||
|
role_value = current_user.role.value if hasattr(current_user.role, "value") else current_user.role
|
||||||
|
if role_value != UserRole.ADMIN.value:
|
||||||
|
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="仅管理员可删除文档")
|
||||||
doc = await document_service.delete_document(db, document_id, current_user)
|
doc = await document_service.delete_document(db, document_id, current_user)
|
||||||
return DocumentSummary.model_validate(doc)
|
return DocumentSummary.model_validate(doc)
|
||||||
|
|
||||||
@@ -86,6 +88,7 @@ async def delete_document(
|
|||||||
async def create_version(
|
async def create_version(
|
||||||
document_id: uuid.UUID,
|
document_id: uuid.UUID,
|
||||||
version_no: str = Form(...),
|
version_no: str = Form(...),
|
||||||
|
version_date: str = Form(...),
|
||||||
change_summary: Optional[str] = Form(None),
|
change_summary: Optional[str] = Form(None),
|
||||||
parent_version_id: Optional[uuid.UUID] = Form(None),
|
parent_version_id: Optional[uuid.UUID] = Form(None),
|
||||||
file: UploadFile = File(...),
|
file: UploadFile = File(...),
|
||||||
@@ -96,6 +99,7 @@ async def create_version(
|
|||||||
db,
|
db,
|
||||||
document_id,
|
document_id,
|
||||||
version_no=version_no,
|
version_no=version_no,
|
||||||
|
version_date=version_date,
|
||||||
change_summary=change_summary,
|
change_summary=change_summary,
|
||||||
parent_version_id=parent_version_id,
|
parent_version_id=parent_version_id,
|
||||||
file=file,
|
file=file,
|
||||||
@@ -104,58 +108,6 @@ async def create_version(
|
|||||||
return DocumentVersionRead.model_validate(version)
|
return DocumentVersionRead.model_validate(version)
|
||||||
|
|
||||||
|
|
||||||
@router.post("/versions/{version_id}/submit", response_model=DocumentVersionRead)
|
|
||||||
async def submit_version(
|
|
||||||
version_id: uuid.UUID,
|
|
||||||
payload: VersionSubmitRequest,
|
|
||||||
db: AsyncSession = Depends(get_db_session),
|
|
||||||
current_user=Depends(get_current_user),
|
|
||||||
) -> DocumentVersionRead:
|
|
||||||
await document_service.submit_version(db, version_id, payload.template_id, payload.comment, current_user)
|
|
||||||
version = await version_crud.get(db, version_id)
|
|
||||||
if not version:
|
|
||||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="版本不存在")
|
|
||||||
return DocumentVersionRead.model_validate(version)
|
|
||||||
|
|
||||||
|
|
||||||
@router.post("/versions/{version_id}/approve", response_model=DocumentVersionRead)
|
|
||||||
async def approve_version(
|
|
||||||
version_id: uuid.UUID,
|
|
||||||
payload: VersionActionRequest,
|
|
||||||
db: AsyncSession = Depends(get_db_session),
|
|
||||||
current_user=Depends(get_current_user),
|
|
||||||
) -> DocumentVersionRead:
|
|
||||||
await document_service.approve_version(db, version_id, payload.comment, current_user)
|
|
||||||
version = await version_crud.get(db, version_id)
|
|
||||||
if not version:
|
|
||||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="版本不存在")
|
|
||||||
return DocumentVersionRead.model_validate(version)
|
|
||||||
|
|
||||||
|
|
||||||
@router.post("/versions/{version_id}/reject", response_model=DocumentVersionRead)
|
|
||||||
async def reject_version(
|
|
||||||
version_id: uuid.UUID,
|
|
||||||
payload: VersionActionRequest,
|
|
||||||
db: AsyncSession = Depends(get_db_session),
|
|
||||||
current_user=Depends(get_current_user),
|
|
||||||
) -> DocumentVersionRead:
|
|
||||||
await document_service.reject_version(db, version_id, payload.comment, current_user)
|
|
||||||
version = await version_crud.get(db, version_id)
|
|
||||||
if not version:
|
|
||||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="版本不存在")
|
|
||||||
return DocumentVersionRead.model_validate(version)
|
|
||||||
|
|
||||||
|
|
||||||
@router.post("/versions/{version_id}/make-effective", response_model=DocumentVersionRead)
|
|
||||||
async def make_version_effective(
|
|
||||||
version_id: uuid.UUID,
|
|
||||||
db: AsyncSession = Depends(get_db_session),
|
|
||||||
current_user=Depends(get_current_user),
|
|
||||||
) -> DocumentVersionRead:
|
|
||||||
version = await document_service.make_version_effective(db, version_id, current_user)
|
|
||||||
return DocumentVersionRead.model_validate(version)
|
|
||||||
|
|
||||||
|
|
||||||
@router.get("/versions/{version_id}/download", response_class=FileResponse)
|
@router.get("/versions/{version_id}/download", response_class=FileResponse)
|
||||||
async def download_version(
|
async def download_version(
|
||||||
version_id: uuid.UUID,
|
version_id: uuid.UUID,
|
||||||
@@ -165,14 +117,16 @@ async def download_version(
|
|||||||
return await document_service.get_version_download_response(db, version_id, current_user)
|
return await document_service.get_version_download_response(db, version_id, current_user)
|
||||||
|
|
||||||
|
|
||||||
@router.get("/workflow-templates", response_model=list[WorkflowTemplateRead])
|
@router.delete("/versions/{version_id}", status_code=status.HTTP_204_NO_CONTENT)
|
||||||
async def list_workflow_templates(
|
async def delete_version(
|
||||||
trial_id: uuid.UUID | None = None,
|
version_id: uuid.UUID,
|
||||||
db: AsyncSession = Depends(get_db_session),
|
db: AsyncSession = Depends(get_db_session),
|
||||||
current_user=Depends(get_current_user),
|
current_user=Depends(get_current_user),
|
||||||
) -> list[WorkflowTemplateRead]:
|
) -> None:
|
||||||
templates = await document_service.list_workflow_templates(db, trial_id, current_user)
|
role_value = current_user.role.value if hasattr(current_user.role, "value") else current_user.role
|
||||||
return [WorkflowTemplateRead.model_validate(t) for t in templates]
|
if role_value != UserRole.ADMIN.value:
|
||||||
|
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="仅管理员可删除版本")
|
||||||
|
await document_service.delete_version(db, version_id, current_user)
|
||||||
|
|
||||||
|
|
||||||
@router.post(
|
@router.post(
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import uuid
|
|||||||
from fastapi import APIRouter, Depends, HTTPException, status
|
from fastapi import APIRouter, Depends, HTTPException, status
|
||||||
from sqlalchemy.ext.asyncio import AsyncSession
|
from sqlalchemy.ext.asyncio import AsyncSession
|
||||||
|
|
||||||
from app.core.deps import get_current_user, get_db_session, require_study_member, require_study_roles, require_study_not_locked
|
from app.core.deps import get_cra_site_scope, get_current_user, get_db_session, require_study_member, require_study_roles, require_study_not_locked
|
||||||
from app.crud import audit as audit_crud
|
from app.crud import audit as audit_crud
|
||||||
from app.crud import drug_shipment as shipment_crud
|
from app.crud import drug_shipment as shipment_crud
|
||||||
from app.crud import site as site_crud
|
from app.crud import site as site_crud
|
||||||
@@ -42,6 +42,9 @@ async def create_shipment(
|
|||||||
current_user=Depends(get_current_user),
|
current_user=Depends(get_current_user),
|
||||||
) -> DrugShipmentRead:
|
) -> DrugShipmentRead:
|
||||||
await _ensure_study_exists(db, study_id)
|
await _ensure_study_exists(db, study_id)
|
||||||
|
cra_scope = await get_cra_site_scope(db, study_id, current_user)
|
||||||
|
if cra_scope and shipment_in.center_id not in cra_scope[0]:
|
||||||
|
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="权限不足")
|
||||||
site = await _ensure_center_active(db, study_id, shipment_in.center_id)
|
site = await _ensure_center_active(db, study_id, shipment_in.center_id)
|
||||||
shipment_in = shipment_in.model_copy(update={"site_name": site.name})
|
shipment_in = shipment_in.model_copy(update={"site_name": site.name})
|
||||||
shipment = await shipment_crud.create_shipment(db, study_id, shipment_in, created_by=current_user.id)
|
shipment = await shipment_crud.create_shipment(db, study_id, shipment_in, created_by=current_user.id)
|
||||||
@@ -73,12 +76,18 @@ async def list_shipments(
|
|||||||
skip: int = 0,
|
skip: int = 0,
|
||||||
limit: int = 100,
|
limit: int = 100,
|
||||||
db: AsyncSession = Depends(get_db_session),
|
db: AsyncSession = Depends(get_db_session),
|
||||||
|
current_user=Depends(get_current_user),
|
||||||
) -> list[DrugShipmentRead]:
|
) -> list[DrugShipmentRead]:
|
||||||
await _ensure_study_exists(db, study_id)
|
await _ensure_study_exists(db, study_id)
|
||||||
|
cra_scope = await get_cra_site_scope(db, study_id, current_user)
|
||||||
|
center_ids = cra_scope[0] if cra_scope else None
|
||||||
|
if center_id and center_ids is not None and center_id not in center_ids:
|
||||||
|
return []
|
||||||
items = await shipment_crud.list_shipments(
|
items = await shipment_crud.list_shipments(
|
||||||
db,
|
db,
|
||||||
study_id,
|
study_id,
|
||||||
center_id=center_id,
|
center_id=center_id,
|
||||||
|
center_ids=center_ids,
|
||||||
site_name=site_name,
|
site_name=site_name,
|
||||||
tracking_no=tracking_no,
|
tracking_no=tracking_no,
|
||||||
direction=direction,
|
direction=direction,
|
||||||
@@ -98,11 +107,15 @@ async def get_shipment(
|
|||||||
study_id: uuid.UUID,
|
study_id: uuid.UUID,
|
||||||
shipment_id: uuid.UUID,
|
shipment_id: uuid.UUID,
|
||||||
db: AsyncSession = Depends(get_db_session),
|
db: AsyncSession = Depends(get_db_session),
|
||||||
|
current_user=Depends(get_current_user),
|
||||||
) -> DrugShipmentRead:
|
) -> DrugShipmentRead:
|
||||||
await _ensure_study_exists(db, study_id)
|
await _ensure_study_exists(db, study_id)
|
||||||
shipment = await shipment_crud.get_shipment(db, shipment_id)
|
shipment = await shipment_crud.get_shipment(db, shipment_id)
|
||||||
if not shipment or shipment.study_id != study_id:
|
if not shipment or shipment.study_id != study_id:
|
||||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="运输记录不存在")
|
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="运输记录不存在")
|
||||||
|
cra_scope = await get_cra_site_scope(db, study_id, current_user)
|
||||||
|
if cra_scope and shipment.center_id not in cra_scope[0]:
|
||||||
|
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="权限不足")
|
||||||
return DrugShipmentRead.model_validate(shipment)
|
return DrugShipmentRead.model_validate(shipment)
|
||||||
|
|
||||||
|
|
||||||
@@ -122,6 +135,9 @@ async def update_shipment(
|
|||||||
shipment = await shipment_crud.get_shipment(db, shipment_id)
|
shipment = await shipment_crud.get_shipment(db, shipment_id)
|
||||||
if not shipment or shipment.study_id != study_id:
|
if not shipment or shipment.study_id != study_id:
|
||||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="运输记录不存在")
|
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="运输记录不存在")
|
||||||
|
cra_scope = await get_cra_site_scope(db, study_id, current_user)
|
||||||
|
if cra_scope and shipment.center_id not in cra_scope[0]:
|
||||||
|
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="权限不足")
|
||||||
if shipment_in.center_id:
|
if shipment_in.center_id:
|
||||||
site = await _ensure_center_active(db, study_id, shipment_in.center_id)
|
site = await _ensure_center_active(db, study_id, shipment_in.center_id)
|
||||||
shipment_in = shipment_in.model_copy(update={"site_name": site.name})
|
shipment_in = shipment_in.model_copy(update={"site_name": site.name})
|
||||||
@@ -156,6 +172,9 @@ async def delete_shipment(
|
|||||||
shipment = await shipment_crud.get_shipment(db, shipment_id)
|
shipment = await shipment_crud.get_shipment(db, shipment_id)
|
||||||
if not shipment or shipment.study_id != study_id:
|
if not shipment or shipment.study_id != study_id:
|
||||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="运输记录不存在")
|
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="运输记录不存在")
|
||||||
|
cra_scope = await get_cra_site_scope(db, study_id, current_user)
|
||||||
|
if cra_scope and shipment.center_id not in cra_scope[0]:
|
||||||
|
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="权限不足")
|
||||||
await _ensure_center_active(db, study_id, shipment.center_id)
|
await _ensure_center_active(db, study_id, shipment.center_id)
|
||||||
await shipment_crud.delete_shipment(db, shipment)
|
await shipment_crud.delete_shipment(db, shipment)
|
||||||
await audit_crud.log_action(
|
await audit_crud.log_action(
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ from fastapi import APIRouter, Depends, HTTPException, Query, status
|
|||||||
from sqlalchemy.ext.asyncio import AsyncSession
|
from sqlalchemy.ext.asyncio import AsyncSession
|
||||||
from sqlalchemy import select
|
from sqlalchemy import select
|
||||||
|
|
||||||
from app.core.deps import get_current_user, get_db_session, require_study_not_locked
|
from app.core.deps import get_cra_site_scope, get_current_user, get_db_session, require_study_not_locked
|
||||||
from app.crud import audit as audit_crud
|
from app.crud import audit as audit_crud
|
||||||
from app.crud import contract_fee as contract_fee_crud
|
from app.crud import contract_fee as contract_fee_crud
|
||||||
from app.crud import contract_fee_payment as payment_crud
|
from app.crud import contract_fee_payment as payment_crud
|
||||||
@@ -84,7 +84,17 @@ async def list_contract_fees(
|
|||||||
current_user=Depends(get_current_user),
|
current_user=Depends(get_current_user),
|
||||||
) -> FeeApiResponse[list[ContractFeeListItem]]:
|
) -> FeeApiResponse[list[ContractFeeListItem]]:
|
||||||
await _ensure_project_access(db, project_id, current_user, write=False)
|
await _ensure_project_access(db, project_id, current_user, write=False)
|
||||||
rows = await contract_fee_crud.list_contract_fees(db, project_id, center_id=center_id, q=q)
|
cra_scope = await get_cra_site_scope(db, project_id, current_user)
|
||||||
|
center_ids = cra_scope[0] if cra_scope else None
|
||||||
|
if center_id and center_ids is not None and center_id not in center_ids:
|
||||||
|
return FeeApiResponse(data=[], meta={"total": 0})
|
||||||
|
rows = await contract_fee_crud.list_contract_fees(
|
||||||
|
db,
|
||||||
|
project_id,
|
||||||
|
center_id=center_id,
|
||||||
|
center_ids=center_ids,
|
||||||
|
q=q,
|
||||||
|
)
|
||||||
items: list[ContractFeeListItem] = []
|
items: list[ContractFeeListItem] = []
|
||||||
for contract, center_name, paid_total, verified_total, last_paid_date, last_verified_date in rows:
|
for contract, center_name, paid_total, verified_total, last_paid_date, last_verified_date in rows:
|
||||||
paid_total_decimal = _to_decimal(paid_total)
|
paid_total_decimal = _to_decimal(paid_total)
|
||||||
@@ -130,6 +140,9 @@ async def get_contract_fee(
|
|||||||
if not contract:
|
if not contract:
|
||||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="合同费用不存在")
|
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="合同费用不存在")
|
||||||
await _ensure_project_access(db, contract.project_id, current_user, write=False)
|
await _ensure_project_access(db, contract.project_id, current_user, write=False)
|
||||||
|
cra_scope = await get_cra_site_scope(db, contract.project_id, current_user)
|
||||||
|
if cra_scope and contract.center_id not in cra_scope[0]:
|
||||||
|
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="权限不足")
|
||||||
|
|
||||||
payments = await payment_crud.list_payments(db, contract.id)
|
payments = await payment_crud.list_payments(db, contract.id)
|
||||||
attachment_types = ["contract_fee_contract", "contract_fee_voucher", "contract_fee_invoice"]
|
attachment_types = ["contract_fee_contract", "contract_fee_voucher", "contract_fee_invoice"]
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ from datetime import date
|
|||||||
from fastapi import APIRouter, Depends, HTTPException, Query, status
|
from fastapi import APIRouter, Depends, HTTPException, Query, status
|
||||||
from sqlalchemy.ext.asyncio import AsyncSession
|
from sqlalchemy.ext.asyncio import AsyncSession
|
||||||
|
|
||||||
from app.core.deps import get_current_user, get_db_session, require_study_not_locked
|
from app.core.deps import get_cra_site_scope, get_current_user, get_db_session, require_study_not_locked
|
||||||
from app.crud import audit as audit_crud
|
from app.crud import audit as audit_crud
|
||||||
from app.crud import member as member_crud
|
from app.crud import member as member_crud
|
||||||
from app.crud import special_expense as special_crud
|
from app.crud import special_expense as special_crud
|
||||||
@@ -76,10 +76,15 @@ async def list_special_expenses(
|
|||||||
) -> FeeApiResponse[list[SpecialExpenseListItem]]:
|
) -> FeeApiResponse[list[SpecialExpenseListItem]]:
|
||||||
await _ensure_project_access(db, project_id, current_user, write=False)
|
await _ensure_project_access(db, project_id, current_user, write=False)
|
||||||
_validate_category(category)
|
_validate_category(category)
|
||||||
|
cra_scope = await get_cra_site_scope(db, project_id, current_user)
|
||||||
|
center_ids = cra_scope[0] if cra_scope else None
|
||||||
|
if center_id and center_ids is not None and center_id not in center_ids:
|
||||||
|
return FeeApiResponse(data=[], meta={"total": 0})
|
||||||
rows = await special_crud.list_special_expenses(
|
rows = await special_crud.list_special_expenses(
|
||||||
db,
|
db,
|
||||||
project_id,
|
project_id,
|
||||||
center_id=center_id,
|
center_id=center_id,
|
||||||
|
center_ids=center_ids,
|
||||||
category=category,
|
category=category,
|
||||||
date_from=date_from,
|
date_from=date_from,
|
||||||
date_to=date_to,
|
date_to=date_to,
|
||||||
@@ -123,6 +128,9 @@ async def get_special_expense(
|
|||||||
if not expense:
|
if not expense:
|
||||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="特殊费用不存在")
|
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="特殊费用不存在")
|
||||||
await _ensure_project_access(db, expense.project_id, current_user, write=False)
|
await _ensure_project_access(db, expense.project_id, current_user, write=False)
|
||||||
|
cra_scope = await get_cra_site_scope(db, expense.project_id, current_user)
|
||||||
|
if cra_scope and expense.center_id not in cra_scope[0]:
|
||||||
|
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="权限不足")
|
||||||
return FeeApiResponse(data=SpecialExpenseRead.model_validate(expense))
|
return FeeApiResponse(data=SpecialExpenseRead.model_validate(expense))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import uuid
|
|||||||
from fastapi import APIRouter, Depends, HTTPException, status
|
from fastapi import APIRouter, Depends, HTTPException, status
|
||||||
from sqlalchemy.ext.asyncio import AsyncSession
|
from sqlalchemy.ext.asyncio import AsyncSession
|
||||||
|
|
||||||
from app.core.deps import get_current_user, get_db_session, require_study_member, require_study_roles, require_study_not_locked
|
from app.core.deps import get_cra_site_scope, get_current_user, get_db_session, require_study_member, require_study_roles, require_study_not_locked
|
||||||
from app.crud import audit as audit_crud
|
from app.crud import audit as audit_crud
|
||||||
from app.crud import finance_contract as contract_crud
|
from app.crud import finance_contract as contract_crud
|
||||||
from app.crud import site as site_crud
|
from app.crud import site as site_crud
|
||||||
@@ -41,6 +41,9 @@ async def create_contract(
|
|||||||
current_user=Depends(get_current_user),
|
current_user=Depends(get_current_user),
|
||||||
) -> FinanceContractRead:
|
) -> FinanceContractRead:
|
||||||
await _ensure_study_exists(db, study_id)
|
await _ensure_study_exists(db, study_id)
|
||||||
|
cra_scope = await get_cra_site_scope(db, study_id, current_user)
|
||||||
|
if cra_scope and contract_in.site_name not in cra_scope[1]:
|
||||||
|
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="权限不足")
|
||||||
await _ensure_site_name_active(db, study_id, contract_in.site_name)
|
await _ensure_site_name_active(db, study_id, contract_in.site_name)
|
||||||
contract = await contract_crud.create_contract(db, study_id, contract_in, created_by=current_user.id)
|
contract = await contract_crud.create_contract(db, study_id, contract_in, created_by=current_user.id)
|
||||||
await audit_crud.log_action(
|
await audit_crud.log_action(
|
||||||
@@ -68,9 +71,22 @@ async def list_contracts(
|
|||||||
skip: int = 0,
|
skip: int = 0,
|
||||||
limit: int = 100,
|
limit: int = 100,
|
||||||
db: AsyncSession = Depends(get_db_session),
|
db: AsyncSession = Depends(get_db_session),
|
||||||
|
current_user=Depends(get_current_user),
|
||||||
) -> list[FinanceContractRead]:
|
) -> list[FinanceContractRead]:
|
||||||
await _ensure_study_exists(db, study_id)
|
await _ensure_study_exists(db, study_id)
|
||||||
items = await contract_crud.list_contracts(db, study_id, site_name=site_name, contract_no=contract_no, skip=skip, limit=limit)
|
cra_scope = await get_cra_site_scope(db, study_id, current_user)
|
||||||
|
site_names = cra_scope[1] if cra_scope else None
|
||||||
|
if site_name and site_names is not None and site_name not in site_names:
|
||||||
|
return []
|
||||||
|
items = await contract_crud.list_contracts(
|
||||||
|
db,
|
||||||
|
study_id,
|
||||||
|
site_name=site_name,
|
||||||
|
site_names=site_names,
|
||||||
|
contract_no=contract_no,
|
||||||
|
skip=skip,
|
||||||
|
limit=limit,
|
||||||
|
)
|
||||||
return [FinanceContractRead.model_validate(item) for item in items]
|
return [FinanceContractRead.model_validate(item) for item in items]
|
||||||
|
|
||||||
|
|
||||||
@@ -83,11 +99,15 @@ async def get_contract(
|
|||||||
study_id: uuid.UUID,
|
study_id: uuid.UUID,
|
||||||
contract_id: uuid.UUID,
|
contract_id: uuid.UUID,
|
||||||
db: AsyncSession = Depends(get_db_session),
|
db: AsyncSession = Depends(get_db_session),
|
||||||
|
current_user=Depends(get_current_user),
|
||||||
) -> FinanceContractRead:
|
) -> FinanceContractRead:
|
||||||
await _ensure_study_exists(db, study_id)
|
await _ensure_study_exists(db, study_id)
|
||||||
contract = await contract_crud.get_contract(db, contract_id)
|
contract = await contract_crud.get_contract(db, contract_id)
|
||||||
if not contract or contract.study_id != study_id:
|
if not contract or contract.study_id != study_id:
|
||||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="合同不存在")
|
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="合同不存在")
|
||||||
|
cra_scope = await get_cra_site_scope(db, study_id, current_user)
|
||||||
|
if cra_scope and contract.site_name not in cra_scope[1]:
|
||||||
|
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="权限不足")
|
||||||
return FinanceContractRead.model_validate(contract)
|
return FinanceContractRead.model_validate(contract)
|
||||||
|
|
||||||
|
|
||||||
@@ -107,6 +127,9 @@ async def update_contract(
|
|||||||
contract = await contract_crud.get_contract(db, contract_id)
|
contract = await contract_crud.get_contract(db, contract_id)
|
||||||
if not contract or contract.study_id != study_id:
|
if not contract or contract.study_id != study_id:
|
||||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="合同不存在")
|
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="合同不存在")
|
||||||
|
cra_scope = await get_cra_site_scope(db, study_id, current_user)
|
||||||
|
if cra_scope and contract.site_name not in cra_scope[1]:
|
||||||
|
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="权限不足")
|
||||||
await _ensure_site_name_active(db, study_id, contract.site_name)
|
await _ensure_site_name_active(db, study_id, contract.site_name)
|
||||||
contract = await contract_crud.update_contract(db, contract, contract_in)
|
contract = await contract_crud.update_contract(db, contract, contract_in)
|
||||||
await audit_crud.log_action(
|
await audit_crud.log_action(
|
||||||
@@ -137,6 +160,9 @@ async def delete_contract(
|
|||||||
contract = await contract_crud.get_contract(db, contract_id)
|
contract = await contract_crud.get_contract(db, contract_id)
|
||||||
if not contract or contract.study_id != study_id:
|
if not contract or contract.study_id != study_id:
|
||||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="合同不存在")
|
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="合同不存在")
|
||||||
|
cra_scope = await get_cra_site_scope(db, study_id, current_user)
|
||||||
|
if cra_scope and contract.site_name not in cra_scope[1]:
|
||||||
|
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="权限不足")
|
||||||
await _ensure_site_name_active(db, study_id, contract.site_name)
|
await _ensure_site_name_active(db, study_id, contract.site_name)
|
||||||
await contract_crud.delete_contract(db, contract)
|
await contract_crud.delete_contract(db, contract)
|
||||||
await audit_crud.log_action(
|
await audit_crud.log_action(
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import uuid
|
|||||||
from fastapi import APIRouter, Depends, HTTPException, status
|
from fastapi import APIRouter, Depends, HTTPException, status
|
||||||
from sqlalchemy.ext.asyncio import AsyncSession
|
from sqlalchemy.ext.asyncio import AsyncSession
|
||||||
|
|
||||||
from app.core.deps import get_current_user, get_db_session, require_study_member, require_study_roles, require_study_not_locked
|
from app.core.deps import get_cra_site_scope, get_current_user, get_db_session, require_study_member, require_study_roles, require_study_not_locked
|
||||||
from app.crud import audit as audit_crud
|
from app.crud import audit as audit_crud
|
||||||
from app.crud import finance_special as special_crud
|
from app.crud import finance_special as special_crud
|
||||||
from app.crud import site as site_crud
|
from app.crud import site as site_crud
|
||||||
@@ -41,6 +41,9 @@ async def create_special(
|
|||||||
current_user=Depends(get_current_user),
|
current_user=Depends(get_current_user),
|
||||||
) -> FinanceSpecialRead:
|
) -> FinanceSpecialRead:
|
||||||
await _ensure_study_exists(db, study_id)
|
await _ensure_study_exists(db, study_id)
|
||||||
|
cra_scope = await get_cra_site_scope(db, study_id, current_user)
|
||||||
|
if cra_scope and special_in.site_name not in cra_scope[1]:
|
||||||
|
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="权限不足")
|
||||||
await _ensure_site_name_active(db, study_id, special_in.site_name)
|
await _ensure_site_name_active(db, study_id, special_in.site_name)
|
||||||
item = await special_crud.create_special(db, study_id, special_in, created_by=current_user.id)
|
item = await special_crud.create_special(db, study_id, special_in, created_by=current_user.id)
|
||||||
await audit_crud.log_action(
|
await audit_crud.log_action(
|
||||||
@@ -68,9 +71,22 @@ async def list_specials(
|
|||||||
skip: int = 0,
|
skip: int = 0,
|
||||||
limit: int = 100,
|
limit: int = 100,
|
||||||
db: AsyncSession = Depends(get_db_session),
|
db: AsyncSession = Depends(get_db_session),
|
||||||
|
current_user=Depends(get_current_user),
|
||||||
) -> list[FinanceSpecialRead]:
|
) -> list[FinanceSpecialRead]:
|
||||||
await _ensure_study_exists(db, study_id)
|
await _ensure_study_exists(db, study_id)
|
||||||
items = await special_crud.list_specials(db, study_id, site_name=site_name, fee_type=fee_type, skip=skip, limit=limit)
|
cra_scope = await get_cra_site_scope(db, study_id, current_user)
|
||||||
|
site_names = cra_scope[1] if cra_scope else None
|
||||||
|
if site_name and site_names is not None and site_name not in site_names:
|
||||||
|
return []
|
||||||
|
items = await special_crud.list_specials(
|
||||||
|
db,
|
||||||
|
study_id,
|
||||||
|
site_name=site_name,
|
||||||
|
site_names=site_names,
|
||||||
|
fee_type=fee_type,
|
||||||
|
skip=skip,
|
||||||
|
limit=limit,
|
||||||
|
)
|
||||||
return [FinanceSpecialRead.model_validate(item) for item in items]
|
return [FinanceSpecialRead.model_validate(item) for item in items]
|
||||||
|
|
||||||
|
|
||||||
@@ -83,11 +99,15 @@ async def get_special(
|
|||||||
study_id: uuid.UUID,
|
study_id: uuid.UUID,
|
||||||
special_id: uuid.UUID,
|
special_id: uuid.UUID,
|
||||||
db: AsyncSession = Depends(get_db_session),
|
db: AsyncSession = Depends(get_db_session),
|
||||||
|
current_user=Depends(get_current_user),
|
||||||
) -> FinanceSpecialRead:
|
) -> FinanceSpecialRead:
|
||||||
await _ensure_study_exists(db, study_id)
|
await _ensure_study_exists(db, study_id)
|
||||||
item = await special_crud.get_special(db, special_id)
|
item = await special_crud.get_special(db, special_id)
|
||||||
if not item or item.study_id != study_id:
|
if not item or item.study_id != study_id:
|
||||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="特殊费用不存在")
|
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="特殊费用不存在")
|
||||||
|
cra_scope = await get_cra_site_scope(db, study_id, current_user)
|
||||||
|
if cra_scope and item.site_name not in cra_scope[1]:
|
||||||
|
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="权限不足")
|
||||||
return FinanceSpecialRead.model_validate(item)
|
return FinanceSpecialRead.model_validate(item)
|
||||||
|
|
||||||
|
|
||||||
@@ -107,6 +127,9 @@ async def update_special(
|
|||||||
item = await special_crud.get_special(db, special_id)
|
item = await special_crud.get_special(db, special_id)
|
||||||
if not item or item.study_id != study_id:
|
if not item or item.study_id != study_id:
|
||||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="特殊费用不存在")
|
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="特殊费用不存在")
|
||||||
|
cra_scope = await get_cra_site_scope(db, study_id, current_user)
|
||||||
|
if cra_scope and item.site_name not in cra_scope[1]:
|
||||||
|
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="权限不足")
|
||||||
await _ensure_site_name_active(db, study_id, item.site_name)
|
await _ensure_site_name_active(db, study_id, item.site_name)
|
||||||
item = await special_crud.update_special(db, item, special_in)
|
item = await special_crud.update_special(db, item, special_in)
|
||||||
await audit_crud.log_action(
|
await audit_crud.log_action(
|
||||||
@@ -137,6 +160,9 @@ async def delete_special(
|
|||||||
item = await special_crud.get_special(db, special_id)
|
item = await special_crud.get_special(db, special_id)
|
||||||
if not item or item.study_id != study_id:
|
if not item or item.study_id != study_id:
|
||||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="特殊费用不存在")
|
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="特殊费用不存在")
|
||||||
|
cra_scope = await get_cra_site_scope(db, study_id, current_user)
|
||||||
|
if cra_scope and item.site_name not in cra_scope[1]:
|
||||||
|
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="权限不足")
|
||||||
await _ensure_site_name_active(db, study_id, item.site_name)
|
await _ensure_site_name_active(db, study_id, item.site_name)
|
||||||
await special_crud.delete_special(db, item)
|
await special_crud.delete_special(db, item)
|
||||||
await audit_crud.log_action(
|
await audit_crud.log_action(
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
import uuid
|
||||||
|
|
||||||
|
from fastapi import APIRouter, Depends
|
||||||
|
from sqlalchemy.ext.asyncio import AsyncSession
|
||||||
|
|
||||||
|
from app.core.deps import get_db_session, get_current_user, require_study_member
|
||||||
|
from app.schemas.notification import NotificationItem
|
||||||
|
from app.services import document_service
|
||||||
|
|
||||||
|
router = APIRouter()
|
||||||
|
|
||||||
|
|
||||||
|
@router.get(
|
||||||
|
"/notifications",
|
||||||
|
response_model=list[NotificationItem],
|
||||||
|
dependencies=[Depends(require_study_member())],
|
||||||
|
)
|
||||||
|
async def list_notifications(
|
||||||
|
study_id: uuid.UUID,
|
||||||
|
skip: int = 0,
|
||||||
|
limit: int = 20,
|
||||||
|
db: AsyncSession = Depends(get_db_session),
|
||||||
|
current_user=Depends(get_current_user),
|
||||||
|
) -> list[NotificationItem]:
|
||||||
|
return await document_service.list_distribution_notifications(
|
||||||
|
db,
|
||||||
|
study_id,
|
||||||
|
current_user,
|
||||||
|
skip=skip,
|
||||||
|
limit=limit,
|
||||||
|
)
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
from fastapi import APIRouter
|
from fastapi import APIRouter
|
||||||
|
|
||||||
from app.api.v1 import auth, users, admin_users, studies, sites, members, attachments, audit_logs, dashboard, subjects, visits, aes, finance_dashboard, finance_contracts, finance_specials, fees_contracts, fees_specials, fees_attachments, drug_shipments, startup, knowledge_notes, subject_histories, faq_categories, faqs, documents, overview
|
from app.api.v1 import auth, users, admin_users, studies, sites, members, attachments, audit_logs, dashboard, subjects, visits, aes, finance_dashboard, finance_contracts, finance_specials, fees_contracts, fees_specials, fees_attachments, drug_shipments, startup, knowledge_notes, subject_histories, faq_categories, faqs, documents, overview, notifications
|
||||||
|
|
||||||
|
|
||||||
api_router = APIRouter()
|
api_router = APIRouter()
|
||||||
@@ -9,6 +9,7 @@ api_router.include_router(admin_users.router, prefix="/admin", tags=["admin"])
|
|||||||
api_router.include_router(users.router, prefix="/users", tags=["users"])
|
api_router.include_router(users.router, prefix="/users", tags=["users"])
|
||||||
api_router.include_router(studies.router, prefix="/studies", tags=["studies"])
|
api_router.include_router(studies.router, prefix="/studies", tags=["studies"])
|
||||||
api_router.include_router(overview.router, prefix="/studies/{study_id}", tags=["overview"])
|
api_router.include_router(overview.router, prefix="/studies/{study_id}", tags=["overview"])
|
||||||
|
api_router.include_router(notifications.router, prefix="/studies/{study_id}", tags=["notifications"])
|
||||||
api_router.include_router(sites.router, prefix="/studies/{study_id}/sites", tags=["sites"])
|
api_router.include_router(sites.router, prefix="/studies/{study_id}/sites", tags=["sites"])
|
||||||
api_router.include_router(members.router, prefix="/studies/{study_id}/members", tags=["study-members"])
|
api_router.include_router(members.router, prefix="/studies/{study_id}/members", tags=["study-members"])
|
||||||
api_router.include_router(attachments.router, prefix="/studies/{study_id}/{entity_type}/{entity_id}/attachments", tags=["attachments"])
|
api_router.include_router(attachments.router, prefix="/studies/{study_id}/{entity_type}/{entity_id}/attachments", tags=["attachments"])
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import uuid
|
|||||||
from fastapi import APIRouter, Depends, HTTPException, status
|
from fastapi import APIRouter, Depends, HTTPException, status
|
||||||
from sqlalchemy.ext.asyncio import AsyncSession
|
from sqlalchemy.ext.asyncio import AsyncSession
|
||||||
|
|
||||||
from app.core.deps import get_current_user, get_db_session, require_study_member, require_study_roles, require_study_not_locked
|
from app.core.deps import get_cra_site_scope, get_current_user, get_db_session, require_study_member, require_study_roles, require_study_not_locked
|
||||||
from app.crud import site as site_crud
|
from app.crud import site as site_crud
|
||||||
from app.crud import startup as startup_crud
|
from app.crud import startup as startup_crud
|
||||||
from app.crud import study as study_crud
|
from app.crud import study as study_crud
|
||||||
@@ -60,14 +60,18 @@ async def list_sites(
|
|||||||
limit: int = 100,
|
limit: int = 100,
|
||||||
include_inactive: bool = False,
|
include_inactive: bool = False,
|
||||||
db: AsyncSession = Depends(get_db_session),
|
db: AsyncSession = Depends(get_db_session),
|
||||||
|
current_user=Depends(get_current_user),
|
||||||
) -> list[SiteRead]:
|
) -> list[SiteRead]:
|
||||||
await _ensure_study_exists(db, study_id)
|
await _ensure_study_exists(db, study_id)
|
||||||
|
cra_scope = await get_cra_site_scope(db, study_id, current_user)
|
||||||
|
site_ids = cra_scope[0] if cra_scope else None
|
||||||
sites = await site_crud.list_by_study(
|
sites = await site_crud.list_by_study(
|
||||||
db,
|
db,
|
||||||
study_id,
|
study_id,
|
||||||
skip=skip,
|
skip=skip,
|
||||||
limit=limit,
|
limit=limit,
|
||||||
include_inactive=include_inactive,
|
include_inactive=include_inactive,
|
||||||
|
site_ids=site_ids,
|
||||||
)
|
)
|
||||||
return list(sites)
|
return list(sites)
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import uuid
|
|||||||
from fastapi import APIRouter, Depends, HTTPException, status
|
from fastapi import APIRouter, Depends, HTTPException, status
|
||||||
from sqlalchemy.ext.asyncio import AsyncSession
|
from sqlalchemy.ext.asyncio import AsyncSession
|
||||||
|
|
||||||
from app.core.deps import get_current_user, get_db_session, require_study_member, require_study_roles, require_study_not_locked
|
from app.core.deps import get_cra_site_scope, get_current_user, get_db_session, require_study_member
|
||||||
from app.crud import audit as audit_crud
|
from app.crud import audit as audit_crud
|
||||||
from app.crud import site as site_crud
|
from app.crud import site as site_crud
|
||||||
from app.crud import startup as startup_crud
|
from app.crud import startup as startup_crud
|
||||||
@@ -53,7 +53,7 @@ async def _ensure_site_active(db: AsyncSession, site_id: uuid.UUID | None):
|
|||||||
"/feasibility",
|
"/feasibility",
|
||||||
response_model=StartupFeasibilityRead,
|
response_model=StartupFeasibilityRead,
|
||||||
status_code=status.HTTP_201_CREATED,
|
status_code=status.HTTP_201_CREATED,
|
||||||
dependencies=[Depends(require_study_roles(["PM", "CRA"]))],
|
dependencies=[Depends(require_study_member())],
|
||||||
)
|
)
|
||||||
async def create_feasibility(
|
async def create_feasibility(
|
||||||
study_id: uuid.UUID,
|
study_id: uuid.UUID,
|
||||||
@@ -62,6 +62,9 @@ async def create_feasibility(
|
|||||||
current_user=Depends(get_current_user),
|
current_user=Depends(get_current_user),
|
||||||
) -> StartupFeasibilityRead:
|
) -> StartupFeasibilityRead:
|
||||||
await _ensure_study_exists(db, study_id)
|
await _ensure_study_exists(db, study_id)
|
||||||
|
cra_scope = await get_cra_site_scope(db, study_id, current_user)
|
||||||
|
if cra_scope and record_in.site_id not in cra_scope[0]:
|
||||||
|
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="权限不足")
|
||||||
await _ensure_site_active(db, record_in.site_id)
|
await _ensure_site_active(db, record_in.site_id)
|
||||||
record = await startup_crud.create_feasibility(db, study_id, record_in, created_by=current_user.id)
|
record = await startup_crud.create_feasibility(db, study_id, record_in, created_by=current_user.id)
|
||||||
await audit_crud.log_action(
|
await audit_crud.log_action(
|
||||||
@@ -87,9 +90,12 @@ async def list_feasibilities(
|
|||||||
skip: int = 0,
|
skip: int = 0,
|
||||||
limit: int = 100,
|
limit: int = 100,
|
||||||
db: AsyncSession = Depends(get_db_session),
|
db: AsyncSession = Depends(get_db_session),
|
||||||
|
current_user=Depends(get_current_user),
|
||||||
) -> list[StartupFeasibilityRead]:
|
) -> list[StartupFeasibilityRead]:
|
||||||
await _ensure_study_exists(db, study_id)
|
await _ensure_study_exists(db, study_id)
|
||||||
items = await startup_crud.list_feasibilities(db, study_id, skip=skip, limit=limit)
|
cra_scope = await get_cra_site_scope(db, study_id, current_user)
|
||||||
|
site_ids = cra_scope[0] if cra_scope else None
|
||||||
|
items = await startup_crud.list_feasibilities(db, study_id, skip=skip, limit=limit, site_ids=site_ids)
|
||||||
return [StartupFeasibilityRead.model_validate(item) for item in items]
|
return [StartupFeasibilityRead.model_validate(item) for item in items]
|
||||||
|
|
||||||
|
|
||||||
@@ -102,18 +108,22 @@ async def get_feasibility(
|
|||||||
study_id: uuid.UUID,
|
study_id: uuid.UUID,
|
||||||
record_id: uuid.UUID,
|
record_id: uuid.UUID,
|
||||||
db: AsyncSession = Depends(get_db_session),
|
db: AsyncSession = Depends(get_db_session),
|
||||||
|
current_user=Depends(get_current_user),
|
||||||
) -> StartupFeasibilityRead:
|
) -> StartupFeasibilityRead:
|
||||||
await _ensure_study_exists(db, study_id)
|
await _ensure_study_exists(db, study_id)
|
||||||
record = await startup_crud.get_feasibility(db, record_id)
|
record = await startup_crud.get_feasibility(db, record_id)
|
||||||
if not record or record.study_id != study_id:
|
if not record or record.study_id != study_id:
|
||||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="立项记录不存在")
|
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="立项记录不存在")
|
||||||
|
cra_scope = await get_cra_site_scope(db, study_id, current_user)
|
||||||
|
if cra_scope and record.site_id not in cra_scope[0]:
|
||||||
|
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="权限不足")
|
||||||
return StartupFeasibilityRead.model_validate(record)
|
return StartupFeasibilityRead.model_validate(record)
|
||||||
|
|
||||||
|
|
||||||
@router.patch(
|
@router.patch(
|
||||||
"/feasibility/{record_id}",
|
"/feasibility/{record_id}",
|
||||||
response_model=StartupFeasibilityRead,
|
response_model=StartupFeasibilityRead,
|
||||||
dependencies=[Depends(require_study_roles(["PM", "CRA"]))],
|
dependencies=[Depends(require_study_member())],
|
||||||
)
|
)
|
||||||
async def update_feasibility(
|
async def update_feasibility(
|
||||||
study_id: uuid.UUID,
|
study_id: uuid.UUID,
|
||||||
@@ -126,6 +136,9 @@ async def update_feasibility(
|
|||||||
record = await startup_crud.get_feasibility(db, record_id)
|
record = await startup_crud.get_feasibility(db, record_id)
|
||||||
if not record or record.study_id != study_id:
|
if not record or record.study_id != study_id:
|
||||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="立项记录不存在")
|
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="立项记录不存在")
|
||||||
|
cra_scope = await get_cra_site_scope(db, study_id, current_user)
|
||||||
|
if cra_scope and record.site_id not in cra_scope[0]:
|
||||||
|
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="权限不足")
|
||||||
await _ensure_site_active(db, record.site_id)
|
await _ensure_site_active(db, record.site_id)
|
||||||
record = await startup_crud.update_feasibility(db, record, record_in)
|
record = await startup_crud.update_feasibility(db, record, record_in)
|
||||||
await audit_crud.log_action(
|
await audit_crud.log_action(
|
||||||
@@ -144,7 +157,7 @@ async def update_feasibility(
|
|||||||
@router.delete(
|
@router.delete(
|
||||||
"/feasibility/{record_id}",
|
"/feasibility/{record_id}",
|
||||||
status_code=status.HTTP_204_NO_CONTENT,
|
status_code=status.HTTP_204_NO_CONTENT,
|
||||||
dependencies=[Depends(require_study_roles(["PM", "CRA"]))],
|
dependencies=[Depends(require_study_member())],
|
||||||
)
|
)
|
||||||
async def delete_feasibility(
|
async def delete_feasibility(
|
||||||
study_id: uuid.UUID,
|
study_id: uuid.UUID,
|
||||||
@@ -156,6 +169,9 @@ async def delete_feasibility(
|
|||||||
record = await startup_crud.get_feasibility(db, record_id)
|
record = await startup_crud.get_feasibility(db, record_id)
|
||||||
if not record or record.study_id != study_id:
|
if not record or record.study_id != study_id:
|
||||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="立项记录不存在")
|
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="立项记录不存在")
|
||||||
|
cra_scope = await get_cra_site_scope(db, study_id, current_user)
|
||||||
|
if cra_scope and record.site_id not in cra_scope[0]:
|
||||||
|
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="权限不足")
|
||||||
await _ensure_site_active(db, record.site_id)
|
await _ensure_site_active(db, record.site_id)
|
||||||
await startup_crud.delete_feasibility(db, record)
|
await startup_crud.delete_feasibility(db, record)
|
||||||
await audit_crud.log_action(
|
await audit_crud.log_action(
|
||||||
@@ -174,7 +190,7 @@ async def delete_feasibility(
|
|||||||
"/ethics",
|
"/ethics",
|
||||||
response_model=StartupEthicsRead,
|
response_model=StartupEthicsRead,
|
||||||
status_code=status.HTTP_201_CREATED,
|
status_code=status.HTTP_201_CREATED,
|
||||||
dependencies=[Depends(require_study_roles(["PM", "CRA"]))],
|
dependencies=[Depends(require_study_member())],
|
||||||
)
|
)
|
||||||
async def create_ethics(
|
async def create_ethics(
|
||||||
study_id: uuid.UUID,
|
study_id: uuid.UUID,
|
||||||
@@ -183,6 +199,9 @@ async def create_ethics(
|
|||||||
current_user=Depends(get_current_user),
|
current_user=Depends(get_current_user),
|
||||||
) -> StartupEthicsRead:
|
) -> StartupEthicsRead:
|
||||||
await _ensure_study_exists(db, study_id)
|
await _ensure_study_exists(db, study_id)
|
||||||
|
cra_scope = await get_cra_site_scope(db, study_id, current_user)
|
||||||
|
if cra_scope and record_in.site_id not in cra_scope[0]:
|
||||||
|
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="权限不足")
|
||||||
await _ensure_site_active(db, record_in.site_id)
|
await _ensure_site_active(db, record_in.site_id)
|
||||||
record = await startup_crud.create_ethics(db, study_id, record_in, created_by=current_user.id)
|
record = await startup_crud.create_ethics(db, study_id, record_in, created_by=current_user.id)
|
||||||
await audit_crud.log_action(
|
await audit_crud.log_action(
|
||||||
@@ -208,9 +227,12 @@ async def list_ethics(
|
|||||||
skip: int = 0,
|
skip: int = 0,
|
||||||
limit: int = 100,
|
limit: int = 100,
|
||||||
db: AsyncSession = Depends(get_db_session),
|
db: AsyncSession = Depends(get_db_session),
|
||||||
|
current_user=Depends(get_current_user),
|
||||||
) -> list[StartupEthicsRead]:
|
) -> list[StartupEthicsRead]:
|
||||||
await _ensure_study_exists(db, study_id)
|
await _ensure_study_exists(db, study_id)
|
||||||
items = await startup_crud.list_ethics(db, study_id, skip=skip, limit=limit)
|
cra_scope = await get_cra_site_scope(db, study_id, current_user)
|
||||||
|
site_ids = cra_scope[0] if cra_scope else None
|
||||||
|
items = await startup_crud.list_ethics(db, study_id, skip=skip, limit=limit, site_ids=site_ids)
|
||||||
return [StartupEthicsRead.model_validate(item) for item in items]
|
return [StartupEthicsRead.model_validate(item) for item in items]
|
||||||
|
|
||||||
|
|
||||||
@@ -223,18 +245,22 @@ async def get_ethics(
|
|||||||
study_id: uuid.UUID,
|
study_id: uuid.UUID,
|
||||||
record_id: uuid.UUID,
|
record_id: uuid.UUID,
|
||||||
db: AsyncSession = Depends(get_db_session),
|
db: AsyncSession = Depends(get_db_session),
|
||||||
|
current_user=Depends(get_current_user),
|
||||||
) -> StartupEthicsRead:
|
) -> StartupEthicsRead:
|
||||||
await _ensure_study_exists(db, study_id)
|
await _ensure_study_exists(db, study_id)
|
||||||
record = await startup_crud.get_ethics(db, record_id)
|
record = await startup_crud.get_ethics(db, record_id)
|
||||||
if not record or record.study_id != study_id:
|
if not record or record.study_id != study_id:
|
||||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="伦理记录不存在")
|
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="伦理记录不存在")
|
||||||
|
cra_scope = await get_cra_site_scope(db, study_id, current_user)
|
||||||
|
if cra_scope and record.site_id not in cra_scope[0]:
|
||||||
|
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="权限不足")
|
||||||
return StartupEthicsRead.model_validate(record)
|
return StartupEthicsRead.model_validate(record)
|
||||||
|
|
||||||
|
|
||||||
@router.patch(
|
@router.patch(
|
||||||
"/ethics/{record_id}",
|
"/ethics/{record_id}",
|
||||||
response_model=StartupEthicsRead,
|
response_model=StartupEthicsRead,
|
||||||
dependencies=[Depends(require_study_roles(["PM", "CRA"]))],
|
dependencies=[Depends(require_study_member())],
|
||||||
)
|
)
|
||||||
async def update_ethics(
|
async def update_ethics(
|
||||||
study_id: uuid.UUID,
|
study_id: uuid.UUID,
|
||||||
@@ -247,6 +273,9 @@ async def update_ethics(
|
|||||||
record = await startup_crud.get_ethics(db, record_id)
|
record = await startup_crud.get_ethics(db, record_id)
|
||||||
if not record or record.study_id != study_id:
|
if not record or record.study_id != study_id:
|
||||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="伦理记录不存在")
|
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="伦理记录不存在")
|
||||||
|
cra_scope = await get_cra_site_scope(db, study_id, current_user)
|
||||||
|
if cra_scope and record.site_id not in cra_scope[0]:
|
||||||
|
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="权限不足")
|
||||||
await _ensure_site_active(db, record.site_id)
|
await _ensure_site_active(db, record.site_id)
|
||||||
record = await startup_crud.update_ethics(db, record, record_in)
|
record = await startup_crud.update_ethics(db, record, record_in)
|
||||||
await audit_crud.log_action(
|
await audit_crud.log_action(
|
||||||
@@ -265,7 +294,7 @@ async def update_ethics(
|
|||||||
@router.delete(
|
@router.delete(
|
||||||
"/ethics/{record_id}",
|
"/ethics/{record_id}",
|
||||||
status_code=status.HTTP_204_NO_CONTENT,
|
status_code=status.HTTP_204_NO_CONTENT,
|
||||||
dependencies=[Depends(require_study_roles(["PM", "CRA"]))],
|
dependencies=[Depends(require_study_member())],
|
||||||
)
|
)
|
||||||
async def delete_ethics(
|
async def delete_ethics(
|
||||||
study_id: uuid.UUID,
|
study_id: uuid.UUID,
|
||||||
@@ -277,6 +306,9 @@ async def delete_ethics(
|
|||||||
record = await startup_crud.get_ethics(db, record_id)
|
record = await startup_crud.get_ethics(db, record_id)
|
||||||
if not record or record.study_id != study_id:
|
if not record or record.study_id != study_id:
|
||||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="伦理记录不存在")
|
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="伦理记录不存在")
|
||||||
|
cra_scope = await get_cra_site_scope(db, study_id, current_user)
|
||||||
|
if cra_scope and record.site_id not in cra_scope[0]:
|
||||||
|
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="权限不足")
|
||||||
await _ensure_site_active(db, record.site_id)
|
await _ensure_site_active(db, record.site_id)
|
||||||
await startup_crud.delete_ethics(db, record)
|
await startup_crud.delete_ethics(db, record)
|
||||||
await audit_crud.log_action(
|
await audit_crud.log_action(
|
||||||
@@ -295,7 +327,7 @@ async def delete_ethics(
|
|||||||
"/kickoff",
|
"/kickoff",
|
||||||
response_model=KickoffMeetingRead,
|
response_model=KickoffMeetingRead,
|
||||||
status_code=status.HTTP_201_CREATED,
|
status_code=status.HTTP_201_CREATED,
|
||||||
dependencies=[Depends(require_study_roles(["PM", "CRA"]))],
|
dependencies=[Depends(require_study_member())],
|
||||||
)
|
)
|
||||||
async def create_kickoff(
|
async def create_kickoff(
|
||||||
study_id: uuid.UUID,
|
study_id: uuid.UUID,
|
||||||
@@ -304,6 +336,9 @@ async def create_kickoff(
|
|||||||
current_user=Depends(get_current_user),
|
current_user=Depends(get_current_user),
|
||||||
) -> KickoffMeetingRead:
|
) -> KickoffMeetingRead:
|
||||||
await _ensure_study_exists(db, study_id)
|
await _ensure_study_exists(db, study_id)
|
||||||
|
cra_scope = await get_cra_site_scope(db, study_id, current_user)
|
||||||
|
if cra_scope and meeting_in.site_id not in cra_scope[0]:
|
||||||
|
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="权限不足")
|
||||||
await _ensure_site_active(db, meeting_in.site_id)
|
await _ensure_site_active(db, meeting_in.site_id)
|
||||||
meeting = await startup_crud.create_kickoff(db, study_id, meeting_in, created_by=current_user.id)
|
meeting = await startup_crud.create_kickoff(db, study_id, meeting_in, created_by=current_user.id)
|
||||||
await audit_crud.log_action(
|
await audit_crud.log_action(
|
||||||
@@ -329,9 +364,12 @@ async def list_kickoffs(
|
|||||||
skip: int = 0,
|
skip: int = 0,
|
||||||
limit: int = 100,
|
limit: int = 100,
|
||||||
db: AsyncSession = Depends(get_db_session),
|
db: AsyncSession = Depends(get_db_session),
|
||||||
|
current_user=Depends(get_current_user),
|
||||||
) -> list[KickoffMeetingRead]:
|
) -> list[KickoffMeetingRead]:
|
||||||
await _ensure_study_exists(db, study_id)
|
await _ensure_study_exists(db, study_id)
|
||||||
items = await startup_crud.list_kickoffs(db, study_id, skip=skip, limit=limit)
|
cra_scope = await get_cra_site_scope(db, study_id, current_user)
|
||||||
|
site_ids = cra_scope[0] if cra_scope else None
|
||||||
|
items = await startup_crud.list_kickoffs(db, study_id, skip=skip, limit=limit, site_ids=site_ids)
|
||||||
return [KickoffMeetingRead.model_validate(item) for item in items]
|
return [KickoffMeetingRead.model_validate(item) for item in items]
|
||||||
|
|
||||||
|
|
||||||
@@ -344,18 +382,22 @@ async def get_kickoff(
|
|||||||
study_id: uuid.UUID,
|
study_id: uuid.UUID,
|
||||||
meeting_id: uuid.UUID,
|
meeting_id: uuid.UUID,
|
||||||
db: AsyncSession = Depends(get_db_session),
|
db: AsyncSession = Depends(get_db_session),
|
||||||
|
current_user=Depends(get_current_user),
|
||||||
) -> KickoffMeetingRead:
|
) -> KickoffMeetingRead:
|
||||||
await _ensure_study_exists(db, study_id)
|
await _ensure_study_exists(db, study_id)
|
||||||
meeting = await startup_crud.get_kickoff(db, meeting_id)
|
meeting = await startup_crud.get_kickoff(db, meeting_id)
|
||||||
if not meeting or meeting.study_id != study_id:
|
if not meeting or meeting.study_id != study_id:
|
||||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="启动会记录不存在")
|
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="启动会记录不存在")
|
||||||
|
cra_scope = await get_cra_site_scope(db, study_id, current_user)
|
||||||
|
if cra_scope and meeting.site_id not in cra_scope[0]:
|
||||||
|
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="权限不足")
|
||||||
return KickoffMeetingRead.model_validate(meeting)
|
return KickoffMeetingRead.model_validate(meeting)
|
||||||
|
|
||||||
|
|
||||||
@router.patch(
|
@router.patch(
|
||||||
"/kickoff/{meeting_id}",
|
"/kickoff/{meeting_id}",
|
||||||
response_model=KickoffMeetingRead,
|
response_model=KickoffMeetingRead,
|
||||||
dependencies=[Depends(require_study_roles(["PM", "CRA"]))],
|
dependencies=[Depends(require_study_member())],
|
||||||
)
|
)
|
||||||
async def update_kickoff(
|
async def update_kickoff(
|
||||||
study_id: uuid.UUID,
|
study_id: uuid.UUID,
|
||||||
@@ -368,6 +410,9 @@ async def update_kickoff(
|
|||||||
meeting = await startup_crud.get_kickoff(db, meeting_id)
|
meeting = await startup_crud.get_kickoff(db, meeting_id)
|
||||||
if not meeting or meeting.study_id != study_id:
|
if not meeting or meeting.study_id != study_id:
|
||||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="启动会记录不存在")
|
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="启动会记录不存在")
|
||||||
|
cra_scope = await get_cra_site_scope(db, study_id, current_user)
|
||||||
|
if cra_scope and meeting.site_id not in cra_scope[0]:
|
||||||
|
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="权限不足")
|
||||||
await _ensure_site_active(db, meeting.site_id)
|
await _ensure_site_active(db, meeting.site_id)
|
||||||
meeting = await startup_crud.update_kickoff(db, meeting, meeting_in)
|
meeting = await startup_crud.update_kickoff(db, meeting, meeting_in)
|
||||||
await audit_crud.log_action(
|
await audit_crud.log_action(
|
||||||
@@ -387,7 +432,7 @@ async def update_kickoff(
|
|||||||
"/training-authorizations",
|
"/training-authorizations",
|
||||||
response_model=TrainingAuthorizationRead,
|
response_model=TrainingAuthorizationRead,
|
||||||
status_code=status.HTTP_201_CREATED,
|
status_code=status.HTTP_201_CREATED,
|
||||||
dependencies=[Depends(require_study_roles(["PM", "CRA"]))],
|
dependencies=[Depends(require_study_member())],
|
||||||
)
|
)
|
||||||
async def create_training_authorization(
|
async def create_training_authorization(
|
||||||
study_id: uuid.UUID,
|
study_id: uuid.UUID,
|
||||||
@@ -396,6 +441,9 @@ async def create_training_authorization(
|
|||||||
current_user=Depends(get_current_user),
|
current_user=Depends(get_current_user),
|
||||||
) -> TrainingAuthorizationRead:
|
) -> TrainingAuthorizationRead:
|
||||||
await _ensure_study_exists(db, study_id)
|
await _ensure_study_exists(db, study_id)
|
||||||
|
cra_scope = await get_cra_site_scope(db, study_id, current_user)
|
||||||
|
if cra_scope and record_in.site_name not in cra_scope[1]:
|
||||||
|
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="权限不足")
|
||||||
await _ensure_site_name_active(db, study_id, record_in.site_name)
|
await _ensure_site_name_active(db, study_id, record_in.site_name)
|
||||||
record = await startup_crud.create_training_authorization(db, study_id, record_in, created_by=current_user.id)
|
record = await startup_crud.create_training_authorization(db, study_id, record_in, created_by=current_user.id)
|
||||||
await audit_crud.log_action(
|
await audit_crud.log_action(
|
||||||
@@ -421,9 +469,12 @@ async def list_training_authorizations(
|
|||||||
skip: int = 0,
|
skip: int = 0,
|
||||||
limit: int = 200,
|
limit: int = 200,
|
||||||
db: AsyncSession = Depends(get_db_session),
|
db: AsyncSession = Depends(get_db_session),
|
||||||
|
current_user=Depends(get_current_user),
|
||||||
) -> list[TrainingAuthorizationRead]:
|
) -> list[TrainingAuthorizationRead]:
|
||||||
await _ensure_study_exists(db, study_id)
|
await _ensure_study_exists(db, study_id)
|
||||||
items = await startup_crud.list_training_authorizations(db, study_id, skip=skip, limit=limit)
|
cra_scope = await get_cra_site_scope(db, study_id, current_user)
|
||||||
|
site_names = cra_scope[1] if cra_scope else None
|
||||||
|
items = await startup_crud.list_training_authorizations(db, study_id, skip=skip, limit=limit, site_names=site_names)
|
||||||
return [TrainingAuthorizationRead.model_validate(item) for item in items]
|
return [TrainingAuthorizationRead.model_validate(item) for item in items]
|
||||||
|
|
||||||
|
|
||||||
@@ -436,18 +487,22 @@ async def get_training_authorization(
|
|||||||
study_id: uuid.UUID,
|
study_id: uuid.UUID,
|
||||||
record_id: uuid.UUID,
|
record_id: uuid.UUID,
|
||||||
db: AsyncSession = Depends(get_db_session),
|
db: AsyncSession = Depends(get_db_session),
|
||||||
|
current_user=Depends(get_current_user),
|
||||||
) -> TrainingAuthorizationRead:
|
) -> TrainingAuthorizationRead:
|
||||||
await _ensure_study_exists(db, study_id)
|
await _ensure_study_exists(db, study_id)
|
||||||
record = await startup_crud.get_training_authorization(db, record_id)
|
record = await startup_crud.get_training_authorization(db, record_id)
|
||||||
if not record or record.study_id != study_id:
|
if not record or record.study_id != study_id:
|
||||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="培训授权人员不存在")
|
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="培训授权人员不存在")
|
||||||
|
cra_scope = await get_cra_site_scope(db, study_id, current_user)
|
||||||
|
if cra_scope and record.site_name not in cra_scope[1]:
|
||||||
|
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="权限不足")
|
||||||
return TrainingAuthorizationRead.model_validate(record)
|
return TrainingAuthorizationRead.model_validate(record)
|
||||||
|
|
||||||
|
|
||||||
@router.patch(
|
@router.patch(
|
||||||
"/training-authorizations/{record_id}",
|
"/training-authorizations/{record_id}",
|
||||||
response_model=TrainingAuthorizationRead,
|
response_model=TrainingAuthorizationRead,
|
||||||
dependencies=[Depends(require_study_roles(["PM", "CRA"]))],
|
dependencies=[Depends(require_study_member())],
|
||||||
)
|
)
|
||||||
async def update_training_authorization(
|
async def update_training_authorization(
|
||||||
study_id: uuid.UUID,
|
study_id: uuid.UUID,
|
||||||
@@ -460,6 +515,9 @@ async def update_training_authorization(
|
|||||||
record = await startup_crud.get_training_authorization(db, record_id)
|
record = await startup_crud.get_training_authorization(db, record_id)
|
||||||
if not record or record.study_id != study_id:
|
if not record or record.study_id != study_id:
|
||||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="培训授权人员不存在")
|
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="培训授权人员不存在")
|
||||||
|
cra_scope = await get_cra_site_scope(db, study_id, current_user)
|
||||||
|
if cra_scope and record.site_name not in cra_scope[1]:
|
||||||
|
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="权限不足")
|
||||||
await _ensure_site_name_active(db, study_id, record.site_name)
|
await _ensure_site_name_active(db, study_id, record.site_name)
|
||||||
record = await startup_crud.update_training_authorization(db, record, record_in)
|
record = await startup_crud.update_training_authorization(db, record, record_in)
|
||||||
await audit_crud.log_action(
|
await audit_crud.log_action(
|
||||||
@@ -478,7 +536,7 @@ async def update_training_authorization(
|
|||||||
@router.delete(
|
@router.delete(
|
||||||
"/training-authorizations/{record_id}",
|
"/training-authorizations/{record_id}",
|
||||||
status_code=status.HTTP_204_NO_CONTENT,
|
status_code=status.HTTP_204_NO_CONTENT,
|
||||||
dependencies=[Depends(require_study_roles(["PM", "CRA"]))],
|
dependencies=[Depends(require_study_member())],
|
||||||
)
|
)
|
||||||
async def delete_training_authorization(
|
async def delete_training_authorization(
|
||||||
study_id: uuid.UUID,
|
study_id: uuid.UUID,
|
||||||
@@ -490,6 +548,9 @@ async def delete_training_authorization(
|
|||||||
record = await startup_crud.get_training_authorization(db, record_id)
|
record = await startup_crud.get_training_authorization(db, record_id)
|
||||||
if not record or record.study_id != study_id:
|
if not record or record.study_id != study_id:
|
||||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="培训授权人员不存在")
|
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="培训授权人员不存在")
|
||||||
|
cra_scope = await get_cra_site_scope(db, study_id, current_user)
|
||||||
|
if cra_scope and record.site_name not in cra_scope[1]:
|
||||||
|
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="权限不足")
|
||||||
await _ensure_site_name_active(db, study_id, record.site_name)
|
await _ensure_site_name_active(db, study_id, record.site_name)
|
||||||
await startup_crud.delete_training_authorization(db, record)
|
await startup_crud.delete_training_authorization(db, record)
|
||||||
await audit_crud.log_action(
|
await audit_crud.log_action(
|
||||||
|
|||||||
@@ -84,6 +84,11 @@ async def update_study(
|
|||||||
status_code=status.HTTP_403_FORBIDDEN,
|
status_code=status.HTTP_403_FORBIDDEN,
|
||||||
detail="项目已锁定,无法编辑。请先解锁项目。"
|
detail="项目已锁定,无法编辑。请先解锁项目。"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if study_in.code and study_in.code != study.code:
|
||||||
|
existing = await study_crud.get_by_code(db, study_in.code)
|
||||||
|
if existing and existing.id != study.id:
|
||||||
|
raise HTTPException(status_code=status.HTTP_409_CONFLICT, detail="项目编号已存在")
|
||||||
|
|
||||||
updated = await study_crud.update(db, study, study_in)
|
updated = await study_crud.update(db, study, study_in)
|
||||||
return updated
|
return updated
|
||||||
|
|||||||
@@ -1,13 +1,15 @@
|
|||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from fastapi import APIRouter, Depends, HTTPException, status
|
from fastapi import APIRouter, Depends, HTTPException, status
|
||||||
|
from sqlalchemy import select
|
||||||
from sqlalchemy.ext.asyncio import AsyncSession
|
from sqlalchemy.ext.asyncio import AsyncSession
|
||||||
|
|
||||||
from app.core.deps import get_current_user, get_db_session, require_study_member, require_study_roles, require_study_not_locked
|
from app.core.deps import get_cra_site_scope, get_current_user, get_db_session, require_study_member, require_study_roles, require_study_not_locked
|
||||||
from app.crud import audit as audit_crud
|
from app.crud import audit as audit_crud
|
||||||
from app.crud import site as site_crud
|
from app.crud import site as site_crud
|
||||||
from app.crud import subject as subject_crud
|
from app.crud import subject as subject_crud
|
||||||
from app.crud import study as study_crud
|
from app.crud import study as study_crud
|
||||||
|
from app.models.ae import AdverseEvent
|
||||||
from app.schemas.subject import SubjectCreate, SubjectRead, SubjectUpdate
|
from app.schemas.subject import SubjectCreate, SubjectRead, SubjectUpdate
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
@@ -41,6 +43,9 @@ async def create_subject(
|
|||||||
current_user=Depends(get_current_user),
|
current_user=Depends(get_current_user),
|
||||||
) -> SubjectRead:
|
) -> SubjectRead:
|
||||||
await _ensure_study_exists(db, study_id)
|
await _ensure_study_exists(db, study_id)
|
||||||
|
cra_scope = await get_cra_site_scope(db, study_id, current_user)
|
||||||
|
if cra_scope and subject_in.site_id not in cra_scope[0]:
|
||||||
|
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="权限不足")
|
||||||
try:
|
try:
|
||||||
subject = await subject_crud.create_subject(db, study_id, subject_in)
|
subject = await subject_crud.create_subject(db, study_id, subject_in)
|
||||||
except ValueError as exc:
|
except ValueError as exc:
|
||||||
@@ -67,10 +72,31 @@ async def list_subjects(
|
|||||||
study_id: uuid.UUID,
|
study_id: uuid.UUID,
|
||||||
site_id: uuid.UUID | None = None,
|
site_id: uuid.UUID | None = None,
|
||||||
db: AsyncSession = Depends(get_db_session),
|
db: AsyncSession = Depends(get_db_session),
|
||||||
|
current_user=Depends(get_current_user),
|
||||||
) -> list[SubjectRead]:
|
) -> list[SubjectRead]:
|
||||||
await _ensure_study_exists(db, study_id)
|
await _ensure_study_exists(db, study_id)
|
||||||
subjects = await subject_crud.list_subjects(db, study_id, site_id=site_id)
|
cra_scope = await get_cra_site_scope(db, study_id, current_user)
|
||||||
return list(subjects)
|
site_ids = cra_scope[0] if cra_scope else None
|
||||||
|
if site_id and site_ids is not None and site_id not in site_ids:
|
||||||
|
return []
|
||||||
|
subjects = await subject_crud.list_subjects(db, study_id, site_id=site_id, site_ids=site_ids)
|
||||||
|
subject_list = list(subjects)
|
||||||
|
if not subject_list:
|
||||||
|
return []
|
||||||
|
subject_ids = [subject.id for subject in subject_list]
|
||||||
|
ae_rows = await db.execute(
|
||||||
|
select(AdverseEvent.subject_id).where(
|
||||||
|
AdverseEvent.study_id == study_id,
|
||||||
|
AdverseEvent.subject_id.in_(subject_ids),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
ae_subject_ids = {row[0] for row in ae_rows.all() if row[0]}
|
||||||
|
result: list[SubjectRead] = []
|
||||||
|
for subject in subject_list:
|
||||||
|
data = SubjectRead.model_validate(subject)
|
||||||
|
data.has_ae = subject.id in ae_subject_ids
|
||||||
|
result.append(data)
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
@router.get(
|
@router.get(
|
||||||
@@ -82,13 +108,25 @@ async def get_subject(
|
|||||||
study_id: uuid.UUID,
|
study_id: uuid.UUID,
|
||||||
subject_id: uuid.UUID,
|
subject_id: uuid.UUID,
|
||||||
db: AsyncSession = Depends(get_db_session),
|
db: AsyncSession = Depends(get_db_session),
|
||||||
|
current_user=Depends(get_current_user),
|
||||||
) -> SubjectRead:
|
) -> SubjectRead:
|
||||||
await _ensure_study_exists(db, study_id)
|
await _ensure_study_exists(db, study_id)
|
||||||
subject = await subject_crud.get_subject(db, subject_id)
|
subject = await subject_crud.get_subject(db, subject_id)
|
||||||
if not subject or subject.study_id != study_id:
|
if not subject or subject.study_id != study_id:
|
||||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="参与者不存在")
|
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="参与者不存在")
|
||||||
|
cra_scope = await get_cra_site_scope(db, study_id, current_user)
|
||||||
|
if cra_scope and subject.site_id not in cra_scope[0]:
|
||||||
|
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="权限不足")
|
||||||
await _ensure_subject_active(db, subject)
|
await _ensure_subject_active(db, subject)
|
||||||
return subject
|
data = SubjectRead.model_validate(subject)
|
||||||
|
ae_row = await db.execute(
|
||||||
|
select(AdverseEvent.id).where(
|
||||||
|
AdverseEvent.study_id == study_id,
|
||||||
|
AdverseEvent.subject_id == subject.id,
|
||||||
|
).limit(1)
|
||||||
|
)
|
||||||
|
data.has_ae = ae_row.scalar_one_or_none() is not None
|
||||||
|
return data
|
||||||
|
|
||||||
|
|
||||||
@router.patch(
|
@router.patch(
|
||||||
@@ -107,6 +145,9 @@ async def update_subject(
|
|||||||
subject = await subject_crud.get_subject(db, subject_id)
|
subject = await subject_crud.get_subject(db, subject_id)
|
||||||
if not subject or subject.study_id != study_id:
|
if not subject or subject.study_id != study_id:
|
||||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="参与者不存在")
|
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="参与者不存在")
|
||||||
|
cra_scope = await get_cra_site_scope(db, study_id, current_user)
|
||||||
|
if cra_scope and subject.site_id not in cra_scope[0]:
|
||||||
|
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="权限不足")
|
||||||
await _ensure_subject_active(db, subject)
|
await _ensure_subject_active(db, subject)
|
||||||
old_status = subject.status
|
old_status = subject.status
|
||||||
updated = await subject_crud.update_subject(db, subject, subject_in)
|
updated = await subject_crud.update_subject(db, subject, subject_in)
|
||||||
@@ -144,6 +185,9 @@ async def delete_subject(
|
|||||||
subject = await subject_crud.get_subject(db, subject_id)
|
subject = await subject_crud.get_subject(db, subject_id)
|
||||||
if not subject or subject.study_id != study_id:
|
if not subject or subject.study_id != study_id:
|
||||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="参与者不存在")
|
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="参与者不存在")
|
||||||
|
cra_scope = await get_cra_site_scope(db, study_id, current_user)
|
||||||
|
if cra_scope and subject.site_id not in cra_scope[0]:
|
||||||
|
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="权限不足")
|
||||||
await subject_crud.delete_subject(db, subject)
|
await subject_crud.delete_subject(db, subject)
|
||||||
await audit_crud.log_action(
|
await audit_crud.log_action(
|
||||||
db,
|
db,
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ async def list_visits(
|
|||||||
db: AsyncSession = Depends(get_db_session),
|
db: AsyncSession = Depends(get_db_session),
|
||||||
) -> list[VisitRead]:
|
) -> list[VisitRead]:
|
||||||
await _ensure_subject(db, study_id, subject_id)
|
await _ensure_subject(db, study_id, subject_id)
|
||||||
|
await visit_crud.mark_overdue_as_lost(db, subject_id)
|
||||||
visits = await visit_crud.list_visits(db, subject_id)
|
visits = await visit_crud.list_visits(db, subject_id)
|
||||||
return list(visits)
|
return list(visits)
|
||||||
|
|
||||||
@@ -61,15 +62,18 @@ async def create_visit(
|
|||||||
await _ensure_subject_active(db, subject)
|
await _ensure_subject_active(db, subject)
|
||||||
if visit_in.subject_id != subject_id:
|
if visit_in.subject_id != subject_id:
|
||||||
raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail="参与者不匹配")
|
raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail="参与者不匹配")
|
||||||
|
next_visit_code = await visit_crud.get_next_visit_code(db, subject_id)
|
||||||
|
if next_visit_code == "V1" and not visit_in.planned_date:
|
||||||
|
raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail="首次新增访视必须填写计划访视日期")
|
||||||
visit = await visit_crud.create_visit(
|
visit = await visit_crud.create_visit(
|
||||||
db,
|
db,
|
||||||
study_id=study_id,
|
study_id=study_id,
|
||||||
visit_in=visit_in,
|
visit_in=visit_in,
|
||||||
subject=subject,
|
subject=subject,
|
||||||
visit_code=visit_in.visit_code,
|
visit_code=next_visit_code,
|
||||||
planned_date=visit_in.planned_date,
|
planned_date=visit_in.planned_date,
|
||||||
)
|
)
|
||||||
if visit_in.visit_code == "V1" and visit_in.planned_date:
|
if next_visit_code == "V1" and visit_in.planned_date:
|
||||||
study = await study_crud.get(db, study_id)
|
study = await study_crud.get(db, study_id)
|
||||||
if study:
|
if study:
|
||||||
await visit_crud.create_followup_visits(
|
await visit_crud.create_followup_visits(
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ from app.core.exceptions import AppException
|
|||||||
from app.core.security import decode_token, oauth2_scheme
|
from app.core.security import decode_token, oauth2_scheme
|
||||||
from app.crud import user as user_crud
|
from app.crud import user as user_crud
|
||||||
from app.crud import member as member_crud
|
from app.crud import member as member_crud
|
||||||
|
from app.crud import site as site_crud
|
||||||
from app.db.session import SessionLocal
|
from app.db.session import SessionLocal
|
||||||
from app.schemas.user import TokenPayload
|
from app.schemas.user import TokenPayload
|
||||||
|
|
||||||
@@ -117,6 +118,24 @@ def require_study_roles(roles: Iterable[str]):
|
|||||||
return dependency
|
return dependency
|
||||||
|
|
||||||
|
|
||||||
|
async def get_cra_site_scope(
|
||||||
|
db: AsyncSession,
|
||||||
|
study_id: uuid.UUID,
|
||||||
|
current_user,
|
||||||
|
) -> tuple[set[uuid.UUID], set[str]] | None:
|
||||||
|
role_value = current_user.role.value if hasattr(current_user.role, "value") else current_user.role
|
||||||
|
if role_value == "ADMIN":
|
||||||
|
return None
|
||||||
|
membership = await member_crud.get_member(db, study_id, current_user.id)
|
||||||
|
if not membership or not membership.is_active:
|
||||||
|
return None
|
||||||
|
if membership.role_in_study != "CRA":
|
||||||
|
return None
|
||||||
|
site_ids = await site_crud.list_ids_by_contact_user(db, study_id, current_user.id)
|
||||||
|
site_names = await site_crud.list_names_by_contact_user(db, study_id, current_user.id)
|
||||||
|
return site_ids, site_names
|
||||||
|
|
||||||
|
|
||||||
def require_study_not_locked():
|
def require_study_not_locked():
|
||||||
"""检查项目是否被锁定,如果锁定则拒绝所有修改请求"""
|
"""检查项目是否被锁定,如果锁定则拒绝所有修改请求"""
|
||||||
from app.crud import study as study_crud
|
from app.crud import study as study_crud
|
||||||
|
|||||||
+27
-4
@@ -2,7 +2,7 @@ import uuid
|
|||||||
from datetime import date, timedelta
|
from datetime import date, timedelta
|
||||||
from typing import Sequence
|
from typing import Sequence
|
||||||
|
|
||||||
from sqlalchemy import select, update as sa_update
|
from sqlalchemy import or_, select, update as sa_update
|
||||||
from sqlalchemy.ext.asyncio import AsyncSession
|
from sqlalchemy.ext.asyncio import AsyncSession
|
||||||
|
|
||||||
from app.models.ae import AdverseEvent
|
from app.models.ae import AdverseEvent
|
||||||
@@ -11,10 +11,20 @@ from app.models.subject import Subject
|
|||||||
from app.schemas.ae import AECreate, AEUpdate
|
from app.schemas.ae import AECreate, AEUpdate
|
||||||
|
|
||||||
|
|
||||||
|
def _seriousness_rank(value: str | None) -> int | None:
|
||||||
|
if not value:
|
||||||
|
return None
|
||||||
|
normalized = str(value).strip().upper()
|
||||||
|
roman_map = {"I": 1, "II": 2, "III": 3, "IV": 4, "V": 5}
|
||||||
|
legacy_map = {"SERIOUS": 5, "NON_SERIOUS": 1}
|
||||||
|
return roman_map.get(normalized) or legacy_map.get(normalized)
|
||||||
|
|
||||||
|
|
||||||
def _calc_due_date(onset: date | None, seriousness: str) -> date | None:
|
def _calc_due_date(onset: date | None, seriousness: str) -> date | None:
|
||||||
if onset is None:
|
if onset is None:
|
||||||
return None
|
return None
|
||||||
delta = 1 if seriousness == "SERIOUS" else 7
|
rank = _seriousness_rank(seriousness)
|
||||||
|
delta = 1 if rank and rank >= 3 else 7
|
||||||
return onset + timedelta(days=delta)
|
return onset + timedelta(days=delta)
|
||||||
|
|
||||||
|
|
||||||
@@ -54,8 +64,8 @@ async def create_ae(
|
|||||||
term=ae_in.term,
|
term=ae_in.term,
|
||||||
onset_date=ae_in.onset_date,
|
onset_date=ae_in.onset_date,
|
||||||
resolution_date=None,
|
resolution_date=None,
|
||||||
seriousness=ae_in.seriousness,
|
seriousness=str(ae_in.seriousness),
|
||||||
severity=ae_in.severity,
|
severity=str(ae_in.seriousness),
|
||||||
causality=ae_in.causality,
|
causality=ae_in.causality,
|
||||||
action_taken=None,
|
action_taken=None,
|
||||||
outcome=ae_in.outcome,
|
outcome=ae_in.outcome,
|
||||||
@@ -84,8 +94,19 @@ async def list_ae(
|
|||||||
site_id: uuid.UUID | None = None,
|
site_id: uuid.UUID | None = None,
|
||||||
subject_id: uuid.UUID | None = None,
|
subject_id: uuid.UUID | None = None,
|
||||||
overdue: bool | None = None,
|
overdue: bool | None = None,
|
||||||
|
site_ids: set[uuid.UUID] | None = None,
|
||||||
) -> Sequence[AdverseEvent]:
|
) -> Sequence[AdverseEvent]:
|
||||||
stmt = select(AdverseEvent).where(AdverseEvent.study_id == study_id)
|
stmt = select(AdverseEvent).where(AdverseEvent.study_id == study_id)
|
||||||
|
if site_ids is not None:
|
||||||
|
if not site_ids:
|
||||||
|
return []
|
||||||
|
subject_site_ids = select(Subject.id).where(Subject.site_id.in_(site_ids))
|
||||||
|
stmt = stmt.where(
|
||||||
|
or_(
|
||||||
|
AdverseEvent.site_id.in_(site_ids),
|
||||||
|
AdverseEvent.subject_id.in_(subject_site_ids),
|
||||||
|
)
|
||||||
|
)
|
||||||
if status:
|
if status:
|
||||||
stmt = stmt.where(AdverseEvent.status == status)
|
stmt = stmt.where(AdverseEvent.status == status)
|
||||||
if seriousness:
|
if seriousness:
|
||||||
@@ -104,6 +125,8 @@ async def list_ae(
|
|||||||
|
|
||||||
async def update_ae(db: AsyncSession, study_id: uuid.UUID, ae: AdverseEvent, ae_in: AEUpdate) -> AdverseEvent:
|
async def update_ae(db: AsyncSession, study_id: uuid.UUID, ae: AdverseEvent, ae_in: AEUpdate) -> AdverseEvent:
|
||||||
update_data = ae_in.model_dump(exclude_unset=True)
|
update_data = ae_in.model_dump(exclude_unset=True)
|
||||||
|
if "seriousness" in update_data:
|
||||||
|
update_data["seriousness"] = str(update_data["seriousness"])
|
||||||
if "subject_id" in update_data:
|
if "subject_id" in update_data:
|
||||||
await _validate_site_subject(db, study_id, None, update_data["subject_id"])
|
await _validate_site_subject(db, study_id, None, update_data["subject_id"])
|
||||||
if "onset_date" in update_data or "seriousness" in update_data:
|
if "onset_date" in update_data or "seriousness" in update_data:
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ async def list_contract_fees(
|
|||||||
db: AsyncSession,
|
db: AsyncSession,
|
||||||
project_id: uuid.UUID,
|
project_id: uuid.UUID,
|
||||||
center_id: uuid.UUID | None = None,
|
center_id: uuid.UUID | None = None,
|
||||||
|
center_ids: set[uuid.UUID] | None = None,
|
||||||
q: str | None = None,
|
q: str | None = None,
|
||||||
) -> Sequence[tuple[ContractFee, str, float, float, date | None, date | None]]:
|
) -> Sequence[tuple[ContractFee, str, float, float, date | None, date | None]]:
|
||||||
paid_total = func.coalesce(
|
paid_total = func.coalesce(
|
||||||
@@ -82,6 +83,10 @@ async def list_contract_fees(
|
|||||||
|
|
||||||
if center_id:
|
if center_id:
|
||||||
stmt = stmt.where(ContractFee.center_id == center_id)
|
stmt = stmt.where(ContractFee.center_id == center_id)
|
||||||
|
if center_ids is not None:
|
||||||
|
if not center_ids:
|
||||||
|
return []
|
||||||
|
stmt = stmt.where(ContractFee.center_id.in_(center_ids))
|
||||||
|
|
||||||
if q:
|
if q:
|
||||||
conditions = [Site.name.ilike(f"%{q}%")]
|
conditions = [Site.name.ilike(f"%{q}%")]
|
||||||
|
|||||||
@@ -33,10 +33,16 @@ async def list_documents(
|
|||||||
doc_type: str | None = None,
|
doc_type: str | None = None,
|
||||||
status: str | None = None,
|
status: str | None = None,
|
||||||
scope_type: str | None = None,
|
scope_type: str | None = None,
|
||||||
|
cra_site_ids: set[uuid.UUID] | None = None,
|
||||||
skip: int = 0,
|
skip: int = 0,
|
||||||
limit: int = 100,
|
limit: int = 100,
|
||||||
) -> Sequence[Document]:
|
) -> Sequence[Document]:
|
||||||
stmt = select(Document).where(Document.trial_id == trial_id)
|
stmt = select(Document).where(Document.trial_id == trial_id)
|
||||||
|
if cra_site_ids is not None:
|
||||||
|
if not cra_site_ids:
|
||||||
|
stmt = stmt.where(Document.scope_type == "GLOBAL")
|
||||||
|
else:
|
||||||
|
stmt = stmt.where((Document.scope_type == "GLOBAL") | (Document.site_id.in_(cra_site_ids)))
|
||||||
if scope_type:
|
if scope_type:
|
||||||
stmt = stmt.where(Document.scope_type == scope_type)
|
stmt = stmt.where(Document.scope_type == scope_type)
|
||||||
if doc_type:
|
if doc_type:
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ async def list_shipments(
|
|||||||
db: AsyncSession,
|
db: AsyncSession,
|
||||||
study_id: uuid.UUID,
|
study_id: uuid.UUID,
|
||||||
center_id: uuid.UUID | None = None,
|
center_id: uuid.UUID | None = None,
|
||||||
|
center_ids: set[uuid.UUID] | None = None,
|
||||||
site_name: str | None = None,
|
site_name: str | None = None,
|
||||||
tracking_no: str | None = None,
|
tracking_no: str | None = None,
|
||||||
direction: str | None = None,
|
direction: str | None = None,
|
||||||
@@ -52,6 +53,10 @@ async def list_shipments(
|
|||||||
limit: int = 100,
|
limit: int = 100,
|
||||||
) -> Sequence[DrugShipment]:
|
) -> Sequence[DrugShipment]:
|
||||||
stmt = select(DrugShipment).where(DrugShipment.study_id == study_id)
|
stmt = select(DrugShipment).where(DrugShipment.study_id == study_id)
|
||||||
|
if center_ids is not None:
|
||||||
|
if not center_ids:
|
||||||
|
return []
|
||||||
|
stmt = stmt.where(DrugShipment.center_id.in_(center_ids))
|
||||||
if center_id:
|
if center_id:
|
||||||
stmt = stmt.where(DrugShipment.center_id == center_id)
|
stmt = stmt.where(DrugShipment.center_id == center_id)
|
||||||
if site_name:
|
if site_name:
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ async def list_contracts(
|
|||||||
db: AsyncSession,
|
db: AsyncSession,
|
||||||
study_id: uuid.UUID,
|
study_id: uuid.UUID,
|
||||||
site_name: str | None = None,
|
site_name: str | None = None,
|
||||||
|
site_names: set[str] | None = None,
|
||||||
contract_no: str | None = None,
|
contract_no: str | None = None,
|
||||||
skip: int = 0,
|
skip: int = 0,
|
||||||
limit: int = 100,
|
limit: int = 100,
|
||||||
@@ -47,6 +48,10 @@ async def list_contracts(
|
|||||||
select(FinanceContract)
|
select(FinanceContract)
|
||||||
.where(FinanceContract.study_id == study_id)
|
.where(FinanceContract.study_id == study_id)
|
||||||
)
|
)
|
||||||
|
if site_names is not None:
|
||||||
|
if not site_names:
|
||||||
|
return []
|
||||||
|
stmt = stmt.where(FinanceContract.site_name.in_(site_names))
|
||||||
if site_name:
|
if site_name:
|
||||||
stmt = stmt.where(FinanceContract.site_name.ilike(f"%{site_name}%"))
|
stmt = stmt.where(FinanceContract.site_name.ilike(f"%{site_name}%"))
|
||||||
if contract_no:
|
if contract_no:
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ async def list_specials(
|
|||||||
db: AsyncSession,
|
db: AsyncSession,
|
||||||
study_id: uuid.UUID,
|
study_id: uuid.UUID,
|
||||||
site_name: str | None = None,
|
site_name: str | None = None,
|
||||||
|
site_names: set[str] | None = None,
|
||||||
fee_type: str | None = None,
|
fee_type: str | None = None,
|
||||||
skip: int = 0,
|
skip: int = 0,
|
||||||
limit: int = 100,
|
limit: int = 100,
|
||||||
@@ -47,6 +48,10 @@ async def list_specials(
|
|||||||
select(FinanceSpecial)
|
select(FinanceSpecial)
|
||||||
.where(FinanceSpecial.study_id == study_id)
|
.where(FinanceSpecial.study_id == study_id)
|
||||||
)
|
)
|
||||||
|
if site_names is not None:
|
||||||
|
if not site_names:
|
||||||
|
return []
|
||||||
|
stmt = stmt.where(FinanceSpecial.site_name.in_(site_names))
|
||||||
if site_name:
|
if site_name:
|
||||||
stmt = stmt.where(FinanceSpecial.site_name.ilike(f"%{site_name}%"))
|
stmt = stmt.where(FinanceSpecial.site_name.ilike(f"%{site_name}%"))
|
||||||
if fee_type:
|
if fee_type:
|
||||||
|
|||||||
+44
-16
@@ -28,9 +28,7 @@ from app.models.startup_feasibility import StartupFeasibility
|
|||||||
from app.models.subject import Subject
|
from app.models.subject import Subject
|
||||||
from app.models.subject_history import SubjectHistory
|
from app.models.subject_history import SubjectHistory
|
||||||
from app.models.training_authorization import TrainingAuthorization
|
from app.models.training_authorization import TrainingAuthorization
|
||||||
from app.models.version_workflow import VersionWorkflow
|
|
||||||
from app.models.visit import Visit
|
from app.models.visit import Visit
|
||||||
from app.models.workflow_action import WorkflowAction
|
|
||||||
from app.schemas.site import SiteCreate, SiteUpdate
|
from app.schemas.site import SiteCreate, SiteUpdate
|
||||||
|
|
||||||
ATTACHMENT_ROOT = Path(__file__).resolve().parent.parent / "uploads"
|
ATTACHMENT_ROOT = Path(__file__).resolve().parent.parent / "uploads"
|
||||||
@@ -77,10 +75,15 @@ async def list_by_study(
|
|||||||
skip: int = 0,
|
skip: int = 0,
|
||||||
limit: int = 100,
|
limit: int = 100,
|
||||||
include_inactive: bool = False,
|
include_inactive: bool = False,
|
||||||
|
site_ids: set[uuid.UUID] | None = None,
|
||||||
) -> Sequence[Site]:
|
) -> Sequence[Site]:
|
||||||
|
if site_ids is not None and not site_ids:
|
||||||
|
return []
|
||||||
stmt = select(Site).where(Site.study_id == study_id)
|
stmt = select(Site).where(Site.study_id == study_id)
|
||||||
if not include_inactive:
|
if not include_inactive:
|
||||||
stmt = stmt.where(Site.is_active.is_(True))
|
stmt = stmt.where(Site.is_active.is_(True))
|
||||||
|
if site_ids is not None:
|
||||||
|
stmt = stmt.where(Site.id.in_(site_ids))
|
||||||
result = await db.execute(stmt.offset(skip).limit(limit))
|
result = await db.execute(stmt.offset(skip).limit(limit))
|
||||||
return result.scalars().all()
|
return result.scalars().all()
|
||||||
|
|
||||||
@@ -100,6 +103,45 @@ async def list_active_names(db: AsyncSession, study_id: uuid.UUID) -> set[str]:
|
|||||||
return {row[0] for row in result.all() if row[0]}
|
return {row[0] for row in result.all() if row[0]}
|
||||||
|
|
||||||
|
|
||||||
|
def _contact_filter(user_id: str):
|
||||||
|
return or_(
|
||||||
|
Site.contact == user_id,
|
||||||
|
Site.contact.like(f"{user_id},%"),
|
||||||
|
Site.contact.like(f"%,{user_id}"),
|
||||||
|
Site.contact.like(f"%,{user_id},%"),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
async def list_ids_by_contact_user(
|
||||||
|
db: AsyncSession,
|
||||||
|
study_id: uuid.UUID,
|
||||||
|
user_id: uuid.UUID,
|
||||||
|
*,
|
||||||
|
include_inactive: bool = False,
|
||||||
|
) -> set[uuid.UUID]:
|
||||||
|
user_id_str = str(user_id)
|
||||||
|
stmt = select(Site.id).where(Site.study_id == study_id, _contact_filter(user_id_str))
|
||||||
|
if not include_inactive:
|
||||||
|
stmt = stmt.where(Site.is_active.is_(True))
|
||||||
|
result = await db.execute(stmt)
|
||||||
|
return {row[0] for row in result.all() if row[0]}
|
||||||
|
|
||||||
|
|
||||||
|
async def list_names_by_contact_user(
|
||||||
|
db: AsyncSession,
|
||||||
|
study_id: uuid.UUID,
|
||||||
|
user_id: uuid.UUID,
|
||||||
|
*,
|
||||||
|
include_inactive: bool = False,
|
||||||
|
) -> set[str]:
|
||||||
|
user_id_str = str(user_id)
|
||||||
|
stmt = select(Site.name).where(Site.study_id == study_id, _contact_filter(user_id_str))
|
||||||
|
if not include_inactive:
|
||||||
|
stmt = stmt.where(Site.is_active.is_(True))
|
||||||
|
result = await db.execute(stmt)
|
||||||
|
return {row[0] for row in result.all() if row[0]}
|
||||||
|
|
||||||
|
|
||||||
async def delete_site_and_related(db: AsyncSession, site: Site) -> None:
|
async def delete_site_and_related(db: AsyncSession, site: Site) -> None:
|
||||||
site_id = site.id
|
site_id = site.id
|
||||||
study_id = site.study_id
|
study_id = site.study_id
|
||||||
@@ -167,17 +209,6 @@ async def delete_site_and_related(db: AsyncSession, site: Site) -> None:
|
|||||||
await db.execute(select(DocumentVersion.id).where(DocumentVersion.document_id.in_(document_ids)))
|
await db.execute(select(DocumentVersion.id).where(DocumentVersion.document_id.in_(document_ids)))
|
||||||
).scalars().all()
|
).scalars().all()
|
||||||
|
|
||||||
workflow_ids = []
|
|
||||||
workflow_conditions = []
|
|
||||||
if document_ids:
|
|
||||||
workflow_conditions.append(VersionWorkflow.document_id.in_(document_ids))
|
|
||||||
if version_ids:
|
|
||||||
workflow_conditions.append(VersionWorkflow.version_id.in_(version_ids))
|
|
||||||
if workflow_conditions:
|
|
||||||
workflow_ids = (
|
|
||||||
await db.execute(select(VersionWorkflow.id).where(or_(*workflow_conditions)))
|
|
||||||
).scalars().all()
|
|
||||||
|
|
||||||
distribution_conditions = []
|
distribution_conditions = []
|
||||||
if document_ids:
|
if document_ids:
|
||||||
distribution_conditions.append(Distribution.document_id.in_(document_ids))
|
distribution_conditions.append(Distribution.document_id.in_(document_ids))
|
||||||
@@ -261,9 +292,6 @@ async def delete_site_and_related(db: AsyncSession, site: Site) -> None:
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
if workflow_ids:
|
|
||||||
await db.execute(delete(WorkflowAction).where(WorkflowAction.workflow_id.in_(workflow_ids)))
|
|
||||||
await db.execute(delete(VersionWorkflow).where(VersionWorkflow.id.in_(workflow_ids)))
|
|
||||||
if distribution_ids:
|
if distribution_ids:
|
||||||
await db.execute(delete(Acknowledgement).where(Acknowledgement.distribution_id.in_(distribution_ids)))
|
await db.execute(delete(Acknowledgement).where(Acknowledgement.distribution_id.in_(distribution_ids)))
|
||||||
await db.execute(delete(Distribution).where(Distribution.id.in_(distribution_ids)))
|
await db.execute(delete(Distribution).where(Distribution.id.in_(distribution_ids)))
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ async def list_special_expenses(
|
|||||||
db: AsyncSession,
|
db: AsyncSession,
|
||||||
project_id: uuid.UUID,
|
project_id: uuid.UUID,
|
||||||
center_id: uuid.UUID | None = None,
|
center_id: uuid.UUID | None = None,
|
||||||
|
center_ids: set[uuid.UUID] | None = None,
|
||||||
category: str | None = None,
|
category: str | None = None,
|
||||||
date_from: date | None = None,
|
date_from: date | None = None,
|
||||||
date_to: date | None = None,
|
date_to: date | None = None,
|
||||||
@@ -72,6 +73,10 @@ async def list_special_expenses(
|
|||||||
|
|
||||||
if center_id:
|
if center_id:
|
||||||
stmt = stmt.where(SpecialExpense.center_id == center_id)
|
stmt = stmt.where(SpecialExpense.center_id == center_id)
|
||||||
|
if center_ids is not None:
|
||||||
|
if not center_ids:
|
||||||
|
return []
|
||||||
|
stmt = stmt.where(SpecialExpense.center_id.in_(center_ids))
|
||||||
if category:
|
if category:
|
||||||
stmt = stmt.where(SpecialExpense.category == category)
|
stmt = stmt.where(SpecialExpense.category == category)
|
||||||
if date_from:
|
if date_from:
|
||||||
|
|||||||
@@ -51,7 +51,10 @@ async def list_feasibilities(
|
|||||||
study_id: uuid.UUID,
|
study_id: uuid.UUID,
|
||||||
skip: int = 0,
|
skip: int = 0,
|
||||||
limit: int = 100,
|
limit: int = 100,
|
||||||
|
site_ids: set[uuid.UUID] | None = None,
|
||||||
) -> Sequence[StartupFeasibility]:
|
) -> Sequence[StartupFeasibility]:
|
||||||
|
if site_ids is not None and not site_ids:
|
||||||
|
return []
|
||||||
stmt = (
|
stmt = (
|
||||||
select(StartupFeasibility)
|
select(StartupFeasibility)
|
||||||
.where(StartupFeasibility.study_id == study_id)
|
.where(StartupFeasibility.study_id == study_id)
|
||||||
@@ -59,6 +62,8 @@ async def list_feasibilities(
|
|||||||
.offset(skip)
|
.offset(skip)
|
||||||
.limit(limit)
|
.limit(limit)
|
||||||
)
|
)
|
||||||
|
if site_ids is not None:
|
||||||
|
stmt = stmt.where(StartupFeasibility.site_id.in_(site_ids))
|
||||||
result = await db.execute(stmt)
|
result = await db.execute(stmt)
|
||||||
return result.scalars().all()
|
return result.scalars().all()
|
||||||
|
|
||||||
@@ -111,7 +116,10 @@ async def list_ethics(
|
|||||||
study_id: uuid.UUID,
|
study_id: uuid.UUID,
|
||||||
skip: int = 0,
|
skip: int = 0,
|
||||||
limit: int = 100,
|
limit: int = 100,
|
||||||
|
site_ids: set[uuid.UUID] | None = None,
|
||||||
) -> Sequence[StartupEthics]:
|
) -> Sequence[StartupEthics]:
|
||||||
|
if site_ids is not None and not site_ids:
|
||||||
|
return []
|
||||||
stmt = (
|
stmt = (
|
||||||
select(StartupEthics)
|
select(StartupEthics)
|
||||||
.where(StartupEthics.study_id == study_id)
|
.where(StartupEthics.study_id == study_id)
|
||||||
@@ -119,6 +127,8 @@ async def list_ethics(
|
|||||||
.offset(skip)
|
.offset(skip)
|
||||||
.limit(limit)
|
.limit(limit)
|
||||||
)
|
)
|
||||||
|
if site_ids is not None:
|
||||||
|
stmt = stmt.where(StartupEthics.site_id.in_(site_ids))
|
||||||
result = await db.execute(stmt)
|
result = await db.execute(stmt)
|
||||||
return result.scalars().all()
|
return result.scalars().all()
|
||||||
|
|
||||||
@@ -168,7 +178,10 @@ async def list_kickoffs(
|
|||||||
study_id: uuid.UUID,
|
study_id: uuid.UUID,
|
||||||
skip: int = 0,
|
skip: int = 0,
|
||||||
limit: int = 100,
|
limit: int = 100,
|
||||||
|
site_ids: set[uuid.UUID] | None = None,
|
||||||
) -> Sequence[KickoffMeeting]:
|
) -> Sequence[KickoffMeeting]:
|
||||||
|
if site_ids is not None and not site_ids:
|
||||||
|
return []
|
||||||
stmt = (
|
stmt = (
|
||||||
select(KickoffMeeting)
|
select(KickoffMeeting)
|
||||||
.where(KickoffMeeting.study_id == study_id)
|
.where(KickoffMeeting.study_id == study_id)
|
||||||
@@ -176,6 +189,8 @@ async def list_kickoffs(
|
|||||||
.offset(skip)
|
.offset(skip)
|
||||||
.limit(limit)
|
.limit(limit)
|
||||||
)
|
)
|
||||||
|
if site_ids is not None:
|
||||||
|
stmt = stmt.where(KickoffMeeting.site_id.in_(site_ids))
|
||||||
result = await db.execute(stmt)
|
result = await db.execute(stmt)
|
||||||
return result.scalars().all()
|
return result.scalars().all()
|
||||||
|
|
||||||
@@ -227,7 +242,10 @@ async def list_training_authorizations(
|
|||||||
study_id: uuid.UUID,
|
study_id: uuid.UUID,
|
||||||
skip: int = 0,
|
skip: int = 0,
|
||||||
limit: int = 200,
|
limit: int = 200,
|
||||||
|
site_names: set[str] | None = None,
|
||||||
) -> Sequence[TrainingAuthorization]:
|
) -> Sequence[TrainingAuthorization]:
|
||||||
|
if site_names is not None and not site_names:
|
||||||
|
return []
|
||||||
stmt = (
|
stmt = (
|
||||||
select(TrainingAuthorization)
|
select(TrainingAuthorization)
|
||||||
.where(TrainingAuthorization.study_id == study_id)
|
.where(TrainingAuthorization.study_id == study_id)
|
||||||
@@ -235,6 +253,8 @@ async def list_training_authorizations(
|
|||||||
.offset(skip)
|
.offset(skip)
|
||||||
.limit(limit)
|
.limit(limit)
|
||||||
)
|
)
|
||||||
|
if site_names is not None:
|
||||||
|
stmt = stmt.where(TrainingAuthorization.site_name.in_(site_names))
|
||||||
result = await db.execute(stmt)
|
result = await db.execute(stmt)
|
||||||
return result.scalars().all()
|
return result.scalars().all()
|
||||||
|
|
||||||
|
|||||||
@@ -114,7 +114,6 @@ async def delete(db: AsyncSession, study_id: uuid.UUID) -> None:
|
|||||||
from app.models.faq_category import FaqCategory
|
from app.models.faq_category import FaqCategory
|
||||||
from app.models.faq_item import FaqItem
|
from app.models.faq_item import FaqItem
|
||||||
from app.models.faq_reply import FaqReply
|
from app.models.faq_reply import FaqReply
|
||||||
from app.models.workflow_template import WorkflowTemplate
|
|
||||||
|
|
||||||
# 按依赖关系顺序删除关联数据
|
# 按依赖关系顺序删除关联数据
|
||||||
# 1. 删除审计日志
|
# 1. 删除审计日志
|
||||||
@@ -128,10 +127,7 @@ async def delete(db: AsyncSession, study_id: uuid.UUID) -> None:
|
|||||||
# 3. 删除知识库
|
# 3. 删除知识库
|
||||||
await db.execute(sa_delete(KnowledgeNote).where(KnowledgeNote.study_id == study_id))
|
await db.execute(sa_delete(KnowledgeNote).where(KnowledgeNote.study_id == study_id))
|
||||||
|
|
||||||
# 4. 删除工作流模板
|
# 4. 删除启动相关
|
||||||
await db.execute(sa_delete(WorkflowTemplate).where(WorkflowTemplate.trial_id == study_id))
|
|
||||||
|
|
||||||
# 5. 删除启动相关
|
|
||||||
await db.execute(sa_delete(KickoffMeeting).where(KickoffMeeting.study_id == study_id))
|
await db.execute(sa_delete(KickoffMeeting).where(KickoffMeeting.study_id == study_id))
|
||||||
await db.execute(sa_delete(StartupEthics).where(StartupEthics.study_id == study_id))
|
await db.execute(sa_delete(StartupEthics).where(StartupEthics.study_id == study_id))
|
||||||
await db.execute(sa_delete(StartupFeasibility).where(StartupFeasibility.study_id == study_id))
|
await db.execute(sa_delete(StartupFeasibility).where(StartupFeasibility.study_id == study_id))
|
||||||
|
|||||||
@@ -2,11 +2,14 @@ import uuid
|
|||||||
from datetime import date, timedelta
|
from datetime import date, timedelta
|
||||||
from typing import Sequence
|
from typing import Sequence
|
||||||
|
|
||||||
from sqlalchemy import select, update as sa_update
|
from sqlalchemy import delete as sa_delete, select, update as sa_update
|
||||||
from sqlalchemy.ext.asyncio import AsyncSession
|
from sqlalchemy.ext.asyncio import AsyncSession
|
||||||
|
|
||||||
from app.crud import visit as visit_crud
|
from app.crud import visit as visit_crud
|
||||||
|
from app.models.ae import AdverseEvent
|
||||||
|
from app.models.finance import FinanceItem
|
||||||
from app.models.study import Study
|
from app.models.study import Study
|
||||||
|
from app.models.subject_history import SubjectHistory
|
||||||
from app.models.visit import Visit
|
from app.models.visit import Visit
|
||||||
from app.models.site import Site
|
from app.models.site import Site
|
||||||
from app.models.subject import Subject
|
from app.models.subject import Subject
|
||||||
@@ -60,8 +63,13 @@ async def list_subjects(
|
|||||||
db: AsyncSession,
|
db: AsyncSession,
|
||||||
study_id: uuid.UUID,
|
study_id: uuid.UUID,
|
||||||
site_id: uuid.UUID | None = None,
|
site_id: uuid.UUID | None = None,
|
||||||
|
site_ids: set[uuid.UUID] | None = None,
|
||||||
) -> Sequence[Subject]:
|
) -> Sequence[Subject]:
|
||||||
stmt = select(Subject).where(Subject.study_id == study_id)
|
stmt = select(Subject).where(Subject.study_id == study_id)
|
||||||
|
if site_ids is not None:
|
||||||
|
if not site_ids:
|
||||||
|
return []
|
||||||
|
stmt = stmt.where(Subject.site_id.in_(site_ids))
|
||||||
if site_id:
|
if site_id:
|
||||||
stmt = stmt.where(Subject.site_id == site_id)
|
stmt = stmt.where(Subject.site_id == site_id)
|
||||||
result = await db.execute(stmt)
|
result = await db.execute(stmt)
|
||||||
@@ -125,5 +133,10 @@ async def update_subject(db: AsyncSession, subject: Subject, subject_in: Subject
|
|||||||
|
|
||||||
|
|
||||||
async def delete_subject(db: AsyncSession, subject: Subject) -> None:
|
async def delete_subject(db: AsyncSession, subject: Subject) -> None:
|
||||||
|
subject_id = subject.id
|
||||||
|
await db.execute(sa_delete(Visit).where(Visit.subject_id == subject_id))
|
||||||
|
await db.execute(sa_delete(SubjectHistory).where(SubjectHistory.subject_id == subject_id))
|
||||||
|
await db.execute(sa_delete(AdverseEvent).where(AdverseEvent.subject_id == subject_id))
|
||||||
|
await db.execute(sa_delete(FinanceItem).where(FinanceItem.subject_id == subject_id))
|
||||||
await db.delete(subject)
|
await db.delete(subject)
|
||||||
await db.commit()
|
await db.commit()
|
||||||
|
|||||||
@@ -1,30 +0,0 @@
|
|||||||
import uuid
|
|
||||||
from typing import Sequence
|
|
||||||
|
|
||||||
from sqlalchemy import select
|
|
||||||
from sqlalchemy.ext.asyncio import AsyncSession
|
|
||||||
|
|
||||||
from app.models.version_workflow import VersionWorkflow
|
|
||||||
|
|
||||||
|
|
||||||
async def create(db: AsyncSession, workflow: VersionWorkflow, *, commit: bool = True) -> VersionWorkflow:
|
|
||||||
db.add(workflow)
|
|
||||||
if commit:
|
|
||||||
await db.commit()
|
|
||||||
await db.refresh(workflow)
|
|
||||||
return workflow
|
|
||||||
|
|
||||||
|
|
||||||
async def get(db: AsyncSession, workflow_id: uuid.UUID) -> VersionWorkflow | None:
|
|
||||||
result = await db.execute(select(VersionWorkflow).where(VersionWorkflow.id == workflow_id))
|
|
||||||
return result.scalar_one_or_none()
|
|
||||||
|
|
||||||
|
|
||||||
async def get_by_version(db: AsyncSession, version_id: uuid.UUID) -> VersionWorkflow | None:
|
|
||||||
result = await db.execute(select(VersionWorkflow).where(VersionWorkflow.version_id == version_id))
|
|
||||||
return result.scalar_one_or_none()
|
|
||||||
|
|
||||||
|
|
||||||
async def list_by_document(db: AsyncSession, document_id: uuid.UUID) -> Sequence[VersionWorkflow]:
|
|
||||||
result = await db.execute(select(VersionWorkflow).where(VersionWorkflow.document_id == document_id))
|
|
||||||
return result.scalars().all()
|
|
||||||
@@ -2,7 +2,7 @@ import uuid
|
|||||||
from datetime import date, timedelta
|
from datetime import date, timedelta
|
||||||
from typing import Sequence
|
from typing import Sequence
|
||||||
|
|
||||||
from sqlalchemy import select, update as sa_update
|
from sqlalchemy import and_, func, or_, select, update as sa_update
|
||||||
from sqlalchemy.ext.asyncio import AsyncSession
|
from sqlalchemy.ext.asyncio import AsyncSession
|
||||||
|
|
||||||
from app.models.subject import Subject
|
from app.models.subject import Subject
|
||||||
@@ -43,6 +43,54 @@ async def list_visits(db: AsyncSession, subject_id: uuid.UUID) -> Sequence[Visit
|
|||||||
return result.scalars().all()
|
return result.scalars().all()
|
||||||
|
|
||||||
|
|
||||||
|
async def mark_overdue_as_lost(db: AsyncSession, subject_id: uuid.UUID) -> None:
|
||||||
|
today = func.current_date()
|
||||||
|
deadline = func.coalesce(Visit.window_end, Visit.planned_date)
|
||||||
|
await db.execute(
|
||||||
|
sa_update(Visit)
|
||||||
|
.where(
|
||||||
|
Visit.subject_id == subject_id,
|
||||||
|
Visit.actual_date.is_(None),
|
||||||
|
deadline.is_not(None),
|
||||||
|
deadline < today,
|
||||||
|
Visit.status.not_in(["DONE", "CANCELLED", "LOST"]),
|
||||||
|
)
|
||||||
|
.values(status="LOST")
|
||||||
|
)
|
||||||
|
await db.commit()
|
||||||
|
|
||||||
|
|
||||||
|
async def mark_overdue_as_lost_global(db: AsyncSession) -> None:
|
||||||
|
today = func.current_date()
|
||||||
|
deadline = func.coalesce(Visit.window_end, Visit.planned_date)
|
||||||
|
await db.execute(
|
||||||
|
sa_update(Visit)
|
||||||
|
.where(
|
||||||
|
Visit.actual_date.is_(None),
|
||||||
|
deadline.is_not(None),
|
||||||
|
deadline < today,
|
||||||
|
Visit.status.not_in(["DONE", "CANCELLED", "LOST"]),
|
||||||
|
)
|
||||||
|
.values(status="LOST")
|
||||||
|
)
|
||||||
|
await db.commit()
|
||||||
|
|
||||||
|
|
||||||
|
async def get_next_visit_code(db: AsyncSession, subject_id: uuid.UUID) -> str:
|
||||||
|
result = await db.execute(select(Visit.visit_code).where(Visit.subject_id == subject_id))
|
||||||
|
used: set[int] = set()
|
||||||
|
for (code,) in result.all():
|
||||||
|
if not code or not code.startswith("V"):
|
||||||
|
continue
|
||||||
|
num = code[1:]
|
||||||
|
if num.isdigit():
|
||||||
|
used.add(int(num))
|
||||||
|
next_num = 1
|
||||||
|
while next_num in used:
|
||||||
|
next_num += 1
|
||||||
|
return f"V{next_num}"
|
||||||
|
|
||||||
|
|
||||||
async def get_visit(db: AsyncSession, visit_id: uuid.UUID) -> Visit | None:
|
async def get_visit(db: AsyncSession, visit_id: uuid.UUID) -> Visit | None:
|
||||||
result = await db.execute(select(Visit).where(Visit.id == visit_id))
|
result = await db.execute(select(Visit).where(Visit.id == visit_id))
|
||||||
return result.scalar_one_or_none()
|
return result.scalar_one_or_none()
|
||||||
@@ -72,6 +120,36 @@ async def delete_visit(db: AsyncSession, visit: Visit) -> None:
|
|||||||
await db.commit()
|
await db.commit()
|
||||||
|
|
||||||
|
|
||||||
|
async def list_lost_visits(
|
||||||
|
db: AsyncSession,
|
||||||
|
study_id: uuid.UUID,
|
||||||
|
*,
|
||||||
|
site_ids: set[uuid.UUID] | None = None,
|
||||||
|
limit: int = 50,
|
||||||
|
) -> Sequence[tuple[Visit, str, uuid.UUID | None]]:
|
||||||
|
if site_ids is not None and not site_ids:
|
||||||
|
return []
|
||||||
|
today = func.current_date()
|
||||||
|
deadline = func.coalesce(Visit.window_end, Visit.planned_date)
|
||||||
|
lost_condition = and_(
|
||||||
|
Visit.actual_date.is_(None),
|
||||||
|
deadline.is_not(None),
|
||||||
|
deadline < today,
|
||||||
|
Visit.status.not_in(["DONE", "CANCELLED"]),
|
||||||
|
)
|
||||||
|
stmt = (
|
||||||
|
select(Visit, Subject.subject_no, Subject.site_id)
|
||||||
|
.join(Subject, Subject.id == Visit.subject_id)
|
||||||
|
.where(Visit.study_id == study_id, lost_condition)
|
||||||
|
.order_by(Visit.updated_at.desc())
|
||||||
|
.limit(limit)
|
||||||
|
)
|
||||||
|
if site_ids is not None:
|
||||||
|
stmt = stmt.where(Subject.site_id.in_(site_ids))
|
||||||
|
result = await db.execute(stmt)
|
||||||
|
return result.all()
|
||||||
|
|
||||||
|
|
||||||
async def create_followup_visits(
|
async def create_followup_visits(
|
||||||
db: AsyncSession,
|
db: AsyncSession,
|
||||||
*,
|
*,
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
from sqlalchemy.ext.asyncio import AsyncSession
|
|
||||||
|
|
||||||
from app.models.workflow_action import WorkflowAction
|
|
||||||
|
|
||||||
|
|
||||||
async def create(db: AsyncSession, action: WorkflowAction, *, commit: bool = True) -> WorkflowAction:
|
|
||||||
db.add(action)
|
|
||||||
if commit:
|
|
||||||
await db.commit()
|
|
||||||
await db.refresh(action)
|
|
||||||
return action
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
import uuid
|
|
||||||
from typing import Sequence
|
|
||||||
|
|
||||||
from sqlalchemy import select
|
|
||||||
from sqlalchemy.orm import selectinload
|
|
||||||
|
|
||||||
from sqlalchemy.ext.asyncio import AsyncSession
|
|
||||||
|
|
||||||
from app.models.workflow_template import WorkflowTemplate
|
|
||||||
|
|
||||||
|
|
||||||
async def get(db: AsyncSession, template_id: uuid.UUID) -> WorkflowTemplate | None:
|
|
||||||
result = await db.execute(select(WorkflowTemplate).where(WorkflowTemplate.id == template_id))
|
|
||||||
return result.scalar_one_or_none()
|
|
||||||
|
|
||||||
|
|
||||||
async def list_active(db: AsyncSession, trial_id: uuid.UUID | None = None) -> Sequence[WorkflowTemplate]:
|
|
||||||
stmt = (
|
|
||||||
select(WorkflowTemplate)
|
|
||||||
.where(WorkflowTemplate.is_active.is_(True))
|
|
||||||
.options(selectinload(WorkflowTemplate.nodes))
|
|
||||||
)
|
|
||||||
if trial_id:
|
|
||||||
stmt = stmt.where(WorkflowTemplate.trial_id == trial_id)
|
|
||||||
result = await db.execute(stmt)
|
|
||||||
return result.scalars().all()
|
|
||||||
@@ -9,10 +9,6 @@ from app.models.attachment import Attachment # noqa: F401
|
|||||||
from app.models.audit_log import AuditLog # noqa: F401
|
from app.models.audit_log import AuditLog # noqa: F401
|
||||||
from app.models.document import Document # noqa: F401
|
from app.models.document import Document # noqa: F401
|
||||||
from app.models.document_version import DocumentVersion # noqa: F401
|
from app.models.document_version import DocumentVersion # noqa: F401
|
||||||
from app.models.workflow_template import WorkflowTemplate # noqa: F401
|
|
||||||
from app.models.workflow_node import WorkflowNode # noqa: F401
|
|
||||||
from app.models.version_workflow import VersionWorkflow # noqa: F401
|
|
||||||
from app.models.workflow_action import WorkflowAction # noqa: F401
|
|
||||||
from app.models.distribution import Distribution # noqa: F401
|
from app.models.distribution import Distribution # noqa: F401
|
||||||
from app.models.acknowledgement import Acknowledgement # noqa: F401
|
from app.models.acknowledgement import Acknowledgement # noqa: F401
|
||||||
from app.models.milestone import Milestone # noqa: F401
|
from app.models.milestone import Milestone # noqa: F401
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import asyncio
|
||||||
from contextlib import asynccontextmanager
|
from contextlib import asynccontextmanager
|
||||||
|
|
||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
@@ -11,10 +12,13 @@ from app.crud.user import ensure_admin_exists
|
|||||||
from app.db.base import Base
|
from app.db.base import Base
|
||||||
from app.db.session import SessionLocal, engine
|
from app.db.session import SessionLocal, engine
|
||||||
from app.services.fee_seed import seed_demo_fees
|
from app.services.fee_seed import seed_demo_fees
|
||||||
|
from app.services.visit_scheduler import run_daily_lost_visit_job
|
||||||
|
|
||||||
|
|
||||||
@asynccontextmanager
|
@asynccontextmanager
|
||||||
async def lifespan(_: FastAPI):
|
async def lifespan(_: FastAPI):
|
||||||
|
stop_event = asyncio.Event()
|
||||||
|
scheduler_task = asyncio.create_task(run_daily_lost_visit_job(stop_event))
|
||||||
# Ensure models are imported so metadata is populated
|
# Ensure models are imported so metadata is populated
|
||||||
from app.models import user as user_model # noqa: F401
|
from app.models import user as user_model # noqa: F401
|
||||||
|
|
||||||
@@ -26,6 +30,8 @@ async def lifespan(_: FastAPI):
|
|||||||
await ensure_admin_exists(session)
|
await ensure_admin_exists(session)
|
||||||
await seed_demo_fees(session)
|
await seed_demo_fees(session)
|
||||||
yield
|
yield
|
||||||
|
stop_event.set()
|
||||||
|
await scheduler_task
|
||||||
|
|
||||||
|
|
||||||
async def _ensure_legacy_primary_keys(conn) -> None:
|
async def _ensure_legacy_primary_keys(conn) -> None:
|
||||||
|
|||||||
@@ -57,5 +57,4 @@ class DocumentVersion(Base):
|
|||||||
document = relationship("Document", back_populates="versions", foreign_keys=[document_id])
|
document = relationship("Document", back_populates="versions", foreign_keys=[document_id])
|
||||||
parent_version = relationship("DocumentVersion", remote_side=[id], foreign_keys=[parent_version_id])
|
parent_version = relationship("DocumentVersion", remote_side=[id], foreign_keys=[parent_version_id])
|
||||||
derived_from_version = relationship("DocumentVersion", remote_side=[id], foreign_keys=[derived_from_version_id])
|
derived_from_version = relationship("DocumentVersion", remote_side=[id], foreign_keys=[derived_from_version_id])
|
||||||
workflow_instance = relationship("VersionWorkflow", back_populates="version", uselist=False)
|
|
||||||
distributions = relationship("Distribution", back_populates="version")
|
distributions = relationship("Distribution", back_populates="version")
|
||||||
|
|||||||
@@ -1,47 +0,0 @@
|
|||||||
import enum
|
|
||||||
import uuid
|
|
||||||
from datetime import datetime
|
|
||||||
|
|
||||||
from sqlalchemy import DateTime, Enum, ForeignKey, Integer, UniqueConstraint, func
|
|
||||||
from sqlalchemy.dialects.postgresql import UUID
|
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
||||||
|
|
||||||
from app.db.base_class import Base
|
|
||||||
|
|
||||||
|
|
||||||
class WorkflowStatus(str, enum.Enum):
|
|
||||||
PENDING = "PENDING"
|
|
||||||
APPROVED = "APPROVED"
|
|
||||||
REJECTED = "REJECTED"
|
|
||||||
CANCELED = "CANCELED"
|
|
||||||
|
|
||||||
|
|
||||||
class VersionWorkflow(Base):
|
|
||||||
__tablename__ = "version_workflows"
|
|
||||||
__table_args__ = (UniqueConstraint("version_id", name="uq_version_workflow_version"),)
|
|
||||||
|
|
||||||
id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
|
||||||
document_id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), ForeignKey("documents.id"), nullable=False)
|
|
||||||
version_id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), ForeignKey("document_versions.id"), nullable=False)
|
|
||||||
template_id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), ForeignKey("workflow_templates.id"), nullable=False)
|
|
||||||
status: Mapped[WorkflowStatus] = mapped_column(
|
|
||||||
Enum(WorkflowStatus, name="workflow_status"),
|
|
||||||
nullable=False,
|
|
||||||
server_default=WorkflowStatus.PENDING.value,
|
|
||||||
)
|
|
||||||
current_node: Mapped[int | None] = mapped_column(Integer, nullable=True)
|
|
||||||
submitted_by: Mapped[uuid.UUID | None] = mapped_column(UUID(as_uuid=True), ForeignKey("users.id"), nullable=True)
|
|
||||||
submitted_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True), nullable=True)
|
|
||||||
completed_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True), nullable=True)
|
|
||||||
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), nullable=False, server_default=func.now())
|
|
||||||
updated_at: Mapped[datetime] = mapped_column(
|
|
||||||
DateTime(timezone=True),
|
|
||||||
nullable=False,
|
|
||||||
server_default=func.now(),
|
|
||||||
onupdate=func.now(),
|
|
||||||
)
|
|
||||||
|
|
||||||
template = relationship("WorkflowTemplate")
|
|
||||||
version = relationship("DocumentVersion", back_populates="workflow_instance")
|
|
||||||
document = relationship("Document")
|
|
||||||
actions = relationship("WorkflowAction", back_populates="workflow", cascade="all, delete-orphan")
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
import enum
|
|
||||||
import uuid
|
|
||||||
from datetime import datetime
|
|
||||||
|
|
||||||
from sqlalchemy import DateTime, Enum, ForeignKey, Integer, Text, func
|
|
||||||
from sqlalchemy.dialects.postgresql import UUID
|
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
||||||
|
|
||||||
from app.db.base_class import Base
|
|
||||||
|
|
||||||
|
|
||||||
class WorkflowActionType(str, enum.Enum):
|
|
||||||
SUBMIT = "SUBMIT"
|
|
||||||
APPROVE = "APPROVE"
|
|
||||||
REJECT = "REJECT"
|
|
||||||
|
|
||||||
|
|
||||||
class WorkflowAction(Base):
|
|
||||||
__tablename__ = "workflow_actions"
|
|
||||||
|
|
||||||
id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
|
||||||
workflow_id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), ForeignKey("version_workflows.id"), nullable=False)
|
|
||||||
node_order: Mapped[int | None] = mapped_column(Integer, nullable=True)
|
|
||||||
action: Mapped[WorkflowActionType] = mapped_column(
|
|
||||||
Enum(WorkflowActionType, name="workflow_action_type"),
|
|
||||||
nullable=False,
|
|
||||||
)
|
|
||||||
actor_id: Mapped[uuid.UUID | None] = mapped_column(UUID(as_uuid=True), ForeignKey("users.id"), nullable=True)
|
|
||||||
comment: Mapped[str | None] = mapped_column(Text, nullable=True)
|
|
||||||
acted_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), nullable=False, server_default=func.now())
|
|
||||||
|
|
||||||
workflow = relationship("VersionWorkflow", back_populates="actions")
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
import uuid
|
|
||||||
from datetime import datetime
|
|
||||||
|
|
||||||
from sqlalchemy import Boolean, DateTime, ForeignKey, Integer, String, UniqueConstraint, func
|
|
||||||
from sqlalchemy.dialects.postgresql import UUID
|
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
||||||
|
|
||||||
from app.db.base_class import Base
|
|
||||||
|
|
||||||
|
|
||||||
class WorkflowNode(Base):
|
|
||||||
__tablename__ = "workflow_nodes"
|
|
||||||
__table_args__ = (UniqueConstraint("template_id", "node_order", name="uq_workflow_nodes_order"),)
|
|
||||||
|
|
||||||
id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
|
||||||
template_id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), ForeignKey("workflow_templates.id"), nullable=False)
|
|
||||||
node_order: Mapped[int] = mapped_column(Integer, nullable=False)
|
|
||||||
role: Mapped[str] = mapped_column(String(50), nullable=False)
|
|
||||||
name: Mapped[str | None] = mapped_column(String(100), nullable=True)
|
|
||||||
is_required: Mapped[bool] = mapped_column(Boolean, nullable=False, server_default="true")
|
|
||||||
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), nullable=False, server_default=func.now())
|
|
||||||
|
|
||||||
template = relationship("WorkflowTemplate", back_populates="nodes")
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
import uuid
|
|
||||||
from datetime import datetime
|
|
||||||
|
|
||||||
from sqlalchemy import Boolean, DateTime, ForeignKey, String, Text, func
|
|
||||||
from sqlalchemy.dialects.postgresql import UUID
|
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
||||||
|
|
||||||
from app.db.base_class import Base
|
|
||||||
|
|
||||||
|
|
||||||
class WorkflowTemplate(Base):
|
|
||||||
__tablename__ = "workflow_templates"
|
|
||||||
|
|
||||||
id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
|
||||||
trial_id: Mapped[uuid.UUID | None] = mapped_column(UUID(as_uuid=True), ForeignKey("studies.id"), nullable=True)
|
|
||||||
name: Mapped[str] = mapped_column(String(200), nullable=False)
|
|
||||||
description: Mapped[str | None] = mapped_column(Text, nullable=True)
|
|
||||||
is_active: Mapped[bool] = mapped_column(Boolean, nullable=False, server_default="true")
|
|
||||||
created_by: Mapped[uuid.UUID | None] = mapped_column(UUID(as_uuid=True), ForeignKey("users.id"), nullable=True)
|
|
||||||
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), nullable=False, server_default=func.now())
|
|
||||||
updated_at: Mapped[datetime] = mapped_column(
|
|
||||||
DateTime(timezone=True),
|
|
||||||
nullable=False,
|
|
||||||
server_default=func.now(),
|
|
||||||
onupdate=func.now(),
|
|
||||||
)
|
|
||||||
|
|
||||||
nodes = relationship(
|
|
||||||
"WorkflowNode",
|
|
||||||
back_populates="template",
|
|
||||||
cascade="all, delete-orphan",
|
|
||||||
order_by="WorkflowNode.node_order",
|
|
||||||
)
|
|
||||||
@@ -1,8 +1,17 @@
|
|||||||
import uuid
|
import uuid
|
||||||
from datetime import date, datetime
|
from datetime import date, datetime
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
from enum import Enum
|
||||||
|
|
||||||
from pydantic import BaseModel, ConfigDict
|
from pydantic import BaseModel, ConfigDict, field_validator
|
||||||
|
|
||||||
|
|
||||||
|
class AESeriousness(str, Enum):
|
||||||
|
I = "I"
|
||||||
|
II = "II"
|
||||||
|
III = "III"
|
||||||
|
IV = "IV"
|
||||||
|
V = "V"
|
||||||
|
|
||||||
|
|
||||||
class AECreate(BaseModel):
|
class AECreate(BaseModel):
|
||||||
@@ -11,8 +20,7 @@ class AECreate(BaseModel):
|
|||||||
visit_id: Optional[uuid.UUID] = None
|
visit_id: Optional[uuid.UUID] = None
|
||||||
term: str
|
term: str
|
||||||
onset_date: Optional[date] = None
|
onset_date: Optional[date] = None
|
||||||
seriousness: str
|
seriousness: AESeriousness
|
||||||
severity: str
|
|
||||||
causality: Optional[str] = None
|
causality: Optional[str] = None
|
||||||
description: Optional[str] = None
|
description: Optional[str] = None
|
||||||
outcome: Optional[str] = None
|
outcome: Optional[str] = None
|
||||||
@@ -23,8 +31,7 @@ class AEUpdate(BaseModel):
|
|||||||
term: Optional[str] = None
|
term: Optional[str] = None
|
||||||
onset_date: Optional[date] = None
|
onset_date: Optional[date] = None
|
||||||
resolution_date: Optional[date] = None
|
resolution_date: Optional[date] = None
|
||||||
seriousness: Optional[str] = None
|
seriousness: Optional[AESeriousness] = None
|
||||||
severity: Optional[str] = None
|
|
||||||
causality: Optional[str] = None
|
causality: Optional[str] = None
|
||||||
action_taken: Optional[str] = None
|
action_taken: Optional[str] = None
|
||||||
outcome: Optional[str] = None
|
outcome: Optional[str] = None
|
||||||
@@ -42,8 +49,7 @@ class AERead(BaseModel):
|
|||||||
term: str
|
term: str
|
||||||
onset_date: Optional[date]
|
onset_date: Optional[date]
|
||||||
resolution_date: Optional[date]
|
resolution_date: Optional[date]
|
||||||
seriousness: str
|
seriousness: AESeriousness
|
||||||
severity: str
|
|
||||||
causality: Optional[str]
|
causality: Optional[str]
|
||||||
action_taken: Optional[str]
|
action_taken: Optional[str]
|
||||||
outcome: Optional[str]
|
outcome: Optional[str]
|
||||||
@@ -57,3 +63,26 @@ class AERead(BaseModel):
|
|||||||
is_overdue: bool | None = None
|
is_overdue: bool | None = None
|
||||||
|
|
||||||
model_config = ConfigDict(from_attributes=True)
|
model_config = ConfigDict(from_attributes=True)
|
||||||
|
|
||||||
|
@field_validator("seriousness", mode="before")
|
||||||
|
@classmethod
|
||||||
|
def normalize_seriousness(cls, value):
|
||||||
|
if value is None:
|
||||||
|
return AESeriousness.I
|
||||||
|
normalized = str(value).strip().upper()
|
||||||
|
digit_map = {
|
||||||
|
"1": "I",
|
||||||
|
"2": "II",
|
||||||
|
"3": "III",
|
||||||
|
"4": "IV",
|
||||||
|
"5": "V",
|
||||||
|
}
|
||||||
|
legacy_map = {
|
||||||
|
"SERIOUS": "IV",
|
||||||
|
"NON_SERIOUS": "II",
|
||||||
|
}
|
||||||
|
if normalized in digit_map:
|
||||||
|
return digit_map[normalized]
|
||||||
|
if normalized in legacy_map:
|
||||||
|
return legacy_map[normalized]
|
||||||
|
return normalized
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
import uuid
|
||||||
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
class CenterSummaryItem(BaseModel):
|
||||||
|
id: uuid.UUID
|
||||||
|
name: str
|
||||||
|
stage: str
|
||||||
|
stage_status: str | None = None
|
||||||
|
actual_enrolled: int
|
||||||
|
planned_enrolled: int
|
||||||
@@ -45,12 +45,3 @@ class DocumentVersionRead(BaseModel):
|
|||||||
created_at: datetime
|
created_at: datetime
|
||||||
|
|
||||||
model_config = ConfigDict(from_attributes=True)
|
model_config = ConfigDict(from_attributes=True)
|
||||||
|
|
||||||
|
|
||||||
class VersionSubmitRequest(BaseModel):
|
|
||||||
template_id: uuid.UUID
|
|
||||||
comment: Optional[str] = None
|
|
||||||
|
|
||||||
|
|
||||||
class VersionActionRequest(BaseModel):
|
|
||||||
comment: Optional[str] = None
|
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import uuid
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
from pydantic import BaseModel, ConfigDict
|
||||||
|
|
||||||
|
|
||||||
|
class NotificationItem(BaseModel):
|
||||||
|
id: uuid.UUID
|
||||||
|
document_id: uuid.UUID
|
||||||
|
version_id: uuid.UUID
|
||||||
|
document_title: str
|
||||||
|
document_no: str | None = None
|
||||||
|
version_no: str
|
||||||
|
change_summary: str | None = None
|
||||||
|
effective_at: datetime | None = None
|
||||||
|
created_at: datetime
|
||||||
|
|
||||||
|
model_config = ConfigDict(from_attributes=True)
|
||||||
@@ -20,6 +20,7 @@ class StudyCreate(BaseModel):
|
|||||||
|
|
||||||
|
|
||||||
class StudyUpdate(BaseModel):
|
class StudyUpdate(BaseModel):
|
||||||
|
code: Optional[str] = None
|
||||||
name: Optional[str] = None
|
name: Optional[str] = None
|
||||||
protocol_no: Optional[str] = None
|
protocol_no: Optional[str] = None
|
||||||
phase: Optional[str] = None
|
phase: Optional[str] = None
|
||||||
@@ -33,9 +34,9 @@ class StudyUpdate(BaseModel):
|
|||||||
|
|
||||||
class StudyRead(BaseModel):
|
class StudyRead(BaseModel):
|
||||||
id: uuid.UUID
|
id: uuid.UUID
|
||||||
|
code: str
|
||||||
name: str
|
name: str
|
||||||
protocol_no: Optional[str]
|
protocol_no: Optional[str]
|
||||||
protocol_no: Optional[str]
|
|
||||||
phase: Optional[str]
|
phase: Optional[str]
|
||||||
status: StudyStatus
|
status: StudyStatus
|
||||||
is_locked: bool
|
is_locked: bool
|
||||||
|
|||||||
@@ -33,5 +33,6 @@ class SubjectRead(BaseModel):
|
|||||||
drop_reason: Optional[str]
|
drop_reason: Optional[str]
|
||||||
created_at: datetime
|
created_at: datetime
|
||||||
updated_at: datetime
|
updated_at: datetime
|
||||||
|
has_ae: Optional[bool] = None
|
||||||
|
|
||||||
model_config = ConfigDict(from_attributes=True)
|
model_config = ConfigDict(from_attributes=True)
|
||||||
|
|||||||
@@ -34,3 +34,15 @@ class VisitRead(BaseModel):
|
|||||||
updated_at: datetime
|
updated_at: datetime
|
||||||
|
|
||||||
model_config = ConfigDict(from_attributes=True)
|
model_config = ConfigDict(from_attributes=True)
|
||||||
|
|
||||||
|
|
||||||
|
class VisitLostItem(BaseModel):
|
||||||
|
visit_id: uuid.UUID
|
||||||
|
subject_id: uuid.UUID
|
||||||
|
subject_no: str
|
||||||
|
site_id: uuid.UUID | None
|
||||||
|
visit_code: str
|
||||||
|
status: str
|
||||||
|
updated_at: datetime
|
||||||
|
|
||||||
|
model_config = ConfigDict(from_attributes=True)
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
import uuid
|
|
||||||
from datetime import datetime
|
|
||||||
|
|
||||||
from pydantic import BaseModel, ConfigDict
|
|
||||||
|
|
||||||
|
|
||||||
class WorkflowNodeRead(BaseModel):
|
|
||||||
id: uuid.UUID
|
|
||||||
node_order: int
|
|
||||||
role: str
|
|
||||||
name: str | None = None
|
|
||||||
is_required: bool
|
|
||||||
created_at: datetime
|
|
||||||
|
|
||||||
model_config = ConfigDict(from_attributes=True)
|
|
||||||
|
|
||||||
|
|
||||||
class WorkflowTemplateRead(BaseModel):
|
|
||||||
id: uuid.UUID
|
|
||||||
trial_id: uuid.UUID | None = None
|
|
||||||
name: str
|
|
||||||
description: str | None = None
|
|
||||||
is_active: bool
|
|
||||||
created_by: uuid.UUID | None = None
|
|
||||||
created_at: datetime
|
|
||||||
updated_at: datetime
|
|
||||||
nodes: list[WorkflowNodeRead] = []
|
|
||||||
|
|
||||||
model_config = ConfigDict(from_attributes=True)
|
|
||||||
@@ -8,10 +8,11 @@ from typing import Iterable
|
|||||||
import aiofiles
|
import aiofiles
|
||||||
from fastapi import HTTPException, UploadFile, status
|
from fastapi import HTTPException, UploadFile, status
|
||||||
from fastapi.responses import FileResponse
|
from fastapi.responses import FileResponse
|
||||||
from sqlalchemy import update as sa_update
|
from sqlalchemy import delete as sa_delete, or_, select, update as sa_update
|
||||||
from sqlalchemy.ext.asyncio import AsyncSession
|
from sqlalchemy.ext.asyncio import AsyncSession
|
||||||
|
|
||||||
from app.core import rbac
|
from app.core import rbac
|
||||||
|
from app.core.deps import get_cra_site_scope
|
||||||
from app.crud import acknowledgement as acknowledgement_crud
|
from app.crud import acknowledgement as acknowledgement_crud
|
||||||
from app.crud import distribution as distribution_crud
|
from app.crud import distribution as distribution_crud
|
||||||
from app.crud import document as document_crud
|
from app.crud import document as document_crud
|
||||||
@@ -20,20 +21,16 @@ from app.crud import member as member_crud
|
|||||||
from app.crud import site as site_crud
|
from app.crud import site as site_crud
|
||||||
from app.crud import study as study_crud
|
from app.crud import study as study_crud
|
||||||
from app.crud import user as user_crud
|
from app.crud import user as user_crud
|
||||||
from app.crud import version_workflow as workflow_crud
|
|
||||||
from app.crud import workflow_template as template_crud
|
|
||||||
from app.models.acknowledgement import Acknowledgement, AcknowledgementType
|
from app.models.acknowledgement import Acknowledgement, AcknowledgementType
|
||||||
from app.models.audit_log import AuditLog
|
from app.models.audit_log import AuditLog
|
||||||
from app.models.distribution import Distribution, DistributionTargetType
|
from app.models.distribution import Distribution, DistributionStatus, DistributionTargetType
|
||||||
from app.models.document import Document, DocumentScopeType, DocumentStatus
|
from app.models.document import Document, DocumentScopeType, DocumentStatus
|
||||||
from app.models.document_version import DocumentVersion, DocumentVersionStatus
|
from app.models.document_version import DocumentVersion, DocumentVersionStatus
|
||||||
from app.models.version_workflow import VersionWorkflow, WorkflowStatus
|
|
||||||
from app.models.workflow_action import WorkflowAction, WorkflowActionType
|
|
||||||
from app.models.workflow_template import WorkflowTemplate
|
|
||||||
from app.schemas.acknowledgement import AcknowledgementCreate
|
from app.schemas.acknowledgement import AcknowledgementCreate
|
||||||
from app.schemas.distribution import DistributionCreate, DistributionRead, DistributionStats
|
from app.schemas.distribution import DistributionCreate, DistributionRead, DistributionStats
|
||||||
from app.schemas.document import DocumentCreate, DocumentDetail, DocumentSummary
|
from app.schemas.document import DocumentCreate, DocumentDetail, DocumentSummary
|
||||||
from app.schemas.document_version import DocumentVersionRead, DocumentVersionSummary
|
from app.schemas.document_version import DocumentVersionRead, DocumentVersionSummary
|
||||||
|
from app.schemas.notification import NotificationItem
|
||||||
from app.schemas.user import UserDisplay
|
from app.schemas.user import UserDisplay
|
||||||
|
|
||||||
UPLOAD_ROOT = Path(__file__).resolve().parent.parent / "uploads" / "documents"
|
UPLOAD_ROOT = Path(__file__).resolve().parent.parent / "uploads" / "documents"
|
||||||
@@ -83,6 +80,18 @@ async def _ensure_study_access(db: AsyncSession, trial_id: uuid.UUID, current_us
|
|||||||
return membership
|
return membership
|
||||||
|
|
||||||
|
|
||||||
|
async def _ensure_study_member(db: AsyncSession, trial_id: uuid.UUID, current_user):
|
||||||
|
study = await study_crud.get(db, trial_id)
|
||||||
|
if not study:
|
||||||
|
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="项目不存在")
|
||||||
|
if current_user.role == "ADMIN":
|
||||||
|
return None
|
||||||
|
membership = await member_crud.get_member(db, trial_id, current_user.id)
|
||||||
|
if not membership or not membership.is_active:
|
||||||
|
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="不是项目成员")
|
||||||
|
return membership
|
||||||
|
|
||||||
|
|
||||||
async def create_document(
|
async def create_document(
|
||||||
db: AsyncSession,
|
db: AsyncSession,
|
||||||
doc_in: DocumentCreate,
|
doc_in: DocumentCreate,
|
||||||
@@ -140,6 +149,8 @@ async def list_documents(
|
|||||||
current_user,
|
current_user,
|
||||||
) -> list[DocumentSummary]:
|
) -> list[DocumentSummary]:
|
||||||
await _ensure_study_access(db, trial_id, current_user, action="view")
|
await _ensure_study_access(db, trial_id, current_user, action="view")
|
||||||
|
cra_scope = await get_cra_site_scope(db, trial_id, current_user)
|
||||||
|
cra_site_ids = cra_scope[0] if cra_scope else None
|
||||||
docs = await document_crud.list_documents(
|
docs = await document_crud.list_documents(
|
||||||
db,
|
db,
|
||||||
trial_id=trial_id,
|
trial_id=trial_id,
|
||||||
@@ -147,6 +158,7 @@ async def list_documents(
|
|||||||
doc_type=doc_type,
|
doc_type=doc_type,
|
||||||
status=status,
|
status=status,
|
||||||
scope_type=scope_type,
|
scope_type=scope_type,
|
||||||
|
cra_site_ids=cra_site_ids,
|
||||||
skip=skip,
|
skip=skip,
|
||||||
limit=limit,
|
limit=limit,
|
||||||
)
|
)
|
||||||
@@ -185,6 +197,9 @@ async def get_document_detail(
|
|||||||
if not doc:
|
if not doc:
|
||||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="文档不存在")
|
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="文档不存在")
|
||||||
await _ensure_study_access(db, doc.trial_id, current_user, action="view")
|
await _ensure_study_access(db, doc.trial_id, current_user, action="view")
|
||||||
|
cra_scope = await get_cra_site_scope(db, doc.trial_id, current_user)
|
||||||
|
if cra_scope and doc.scope_type == DocumentScopeType.SITE and doc.site_id not in cra_scope[0]:
|
||||||
|
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="权限不足")
|
||||||
versions = await version_crud.list_by_document(db, document_id)
|
versions = await version_crud.list_by_document(db, document_id)
|
||||||
|
|
||||||
current_version = None
|
current_version = None
|
||||||
@@ -223,6 +238,7 @@ async def create_version(
|
|||||||
document_id: uuid.UUID,
|
document_id: uuid.UUID,
|
||||||
*,
|
*,
|
||||||
version_no: str,
|
version_no: str,
|
||||||
|
version_date: str,
|
||||||
change_summary: str | None,
|
change_summary: str | None,
|
||||||
parent_version_id: uuid.UUID | None,
|
parent_version_id: uuid.UUID | None,
|
||||||
file: UploadFile,
|
file: UploadFile,
|
||||||
@@ -233,6 +249,8 @@ async def create_version(
|
|||||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="文档不存在")
|
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="文档不存在")
|
||||||
await _ensure_study_access(db, doc.trial_id, current_user, action="create_version")
|
await _ensure_study_access(db, doc.trial_id, current_user, action="create_version")
|
||||||
|
|
||||||
|
previous_effective_id = doc.current_effective_version_id
|
||||||
|
|
||||||
existing = await version_crud.get_by_document_version_no(db, document_id, version_no)
|
existing = await version_crud.get_by_document_version_no(db, document_id, version_no)
|
||||||
if existing:
|
if existing:
|
||||||
raise HTTPException(status_code=status.HTTP_409_CONFLICT, detail="版本号已存在")
|
raise HTTPException(status_code=status.HTTP_409_CONFLICT, detail="版本号已存在")
|
||||||
@@ -251,11 +269,21 @@ async def create_version(
|
|||||||
async with aiofiles.open(dest_path, "wb") as out_file:
|
async with aiofiles.open(dest_path, "wb") as out_file:
|
||||||
await out_file.write(content)
|
await out_file.write(content)
|
||||||
|
|
||||||
|
now = datetime.now(timezone.utc)
|
||||||
|
effective_at = now
|
||||||
|
try:
|
||||||
|
parsed = datetime.fromisoformat(version_date)
|
||||||
|
if parsed.tzinfo is None:
|
||||||
|
parsed = parsed.replace(tzinfo=timezone.utc)
|
||||||
|
effective_at = parsed
|
||||||
|
except ValueError:
|
||||||
|
raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail="版本日期格式不正确")
|
||||||
version = DocumentVersion(
|
version = DocumentVersion(
|
||||||
document_id=document_id,
|
document_id=document_id,
|
||||||
version_no=version_no,
|
version_no=version_no,
|
||||||
parent_version_id=parent_version_id,
|
parent_version_id=parent_version_id,
|
||||||
status=DocumentVersionStatus.DRAFT,
|
status=DocumentVersionStatus.EFFECTIVE,
|
||||||
|
effective_at=effective_at,
|
||||||
file_uri=str(dest_path),
|
file_uri=str(dest_path),
|
||||||
file_hash=file_hash,
|
file_hash=file_hash,
|
||||||
file_size=len(content),
|
file_size=len(content),
|
||||||
@@ -264,6 +292,21 @@ async def create_version(
|
|||||||
created_by=current_user.id,
|
created_by=current_user.id,
|
||||||
)
|
)
|
||||||
db.add(version)
|
db.add(version)
|
||||||
|
await db.flush()
|
||||||
|
await db.execute(
|
||||||
|
sa_update(DocumentVersion)
|
||||||
|
.where(
|
||||||
|
DocumentVersion.document_id == document_id,
|
||||||
|
DocumentVersion.status == DocumentVersionStatus.EFFECTIVE,
|
||||||
|
DocumentVersion.id != version.id,
|
||||||
|
)
|
||||||
|
.values(status=DocumentVersionStatus.SUPERSEDED, superseded_at=now)
|
||||||
|
)
|
||||||
|
await db.execute(
|
||||||
|
sa_update(Document)
|
||||||
|
.where(Document.id == document_id)
|
||||||
|
.values(current_effective_version_id=version.id)
|
||||||
|
)
|
||||||
db.add(
|
db.add(
|
||||||
AuditLog(
|
AuditLog(
|
||||||
study_id=doc.trial_id,
|
study_id=doc.trial_id,
|
||||||
@@ -275,227 +318,98 @@ async def create_version(
|
|||||||
operator_role=_role_value(current_user),
|
operator_role=_role_value(current_user),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if previous_effective_id:
|
||||||
|
previous_distributions = await distribution_crud.list_by_version(db, previous_effective_id)
|
||||||
|
if previous_distributions:
|
||||||
|
seen: set[tuple[str, str]] = set()
|
||||||
|
for dist in previous_distributions:
|
||||||
|
key = (dist.target_type, dist.target_id)
|
||||||
|
if key in seen:
|
||||||
|
continue
|
||||||
|
seen.add(key)
|
||||||
|
db.add(
|
||||||
|
Distribution(
|
||||||
|
document_id=document_id,
|
||||||
|
version_id=version.id,
|
||||||
|
target_type=dist.target_type,
|
||||||
|
target_id=dist.target_id,
|
||||||
|
created_by=current_user.id,
|
||||||
|
)
|
||||||
|
)
|
||||||
await db.commit()
|
await db.commit()
|
||||||
await db.refresh(version)
|
await db.refresh(version)
|
||||||
return version
|
return version
|
||||||
|
|
||||||
|
|
||||||
async def submit_version(
|
async def delete_version(
|
||||||
db: AsyncSession,
|
db: AsyncSession,
|
||||||
version_id: uuid.UUID,
|
version_id: uuid.UUID,
|
||||||
template_id: uuid.UUID,
|
|
||||||
comment: str | None,
|
|
||||||
current_user,
|
current_user,
|
||||||
) -> VersionWorkflow:
|
) -> None:
|
||||||
version = await version_crud.get(db, version_id)
|
version = await version_crud.get(db, version_id)
|
||||||
if not version:
|
if not version:
|
||||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="版本不存在")
|
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="版本不存在")
|
||||||
doc = await document_crud.get(db, version.document_id)
|
doc = await document_crud.get(db, version.document_id)
|
||||||
if not doc:
|
if not doc:
|
||||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="文档不存在")
|
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="文档不存在")
|
||||||
await _ensure_study_access(db, doc.trial_id, current_user, action="submit")
|
await _ensure_study_access(db, doc.trial_id, current_user, action="delete_document")
|
||||||
|
|
||||||
if version.status != DocumentVersionStatus.DRAFT:
|
distribution_ids = (
|
||||||
raise HTTPException(status_code=status.HTTP_409_CONFLICT, detail="版本状态不允许提交")
|
await db.execute(
|
||||||
pending = await version_crud.list_pending_versions(db, version.document_id)
|
select(Distribution.id).where(Distribution.version_id == version.id)
|
||||||
if any(v.id != version.id for v in pending):
|
)
|
||||||
raise HTTPException(status_code=status.HTTP_409_CONFLICT, detail="存在待审批版本")
|
).scalars().all()
|
||||||
|
if distribution_ids:
|
||||||
template = await template_crud.get(db, template_id)
|
await db.execute(sa_delete(Acknowledgement).where(Acknowledgement.distribution_id.in_(distribution_ids)))
|
||||||
if not template:
|
await db.execute(sa_delete(Distribution).where(Distribution.id.in_(distribution_ids)))
|
||||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="审批模板不存在")
|
|
||||||
|
|
||||||
before = _version_snapshot(version)
|
before = _version_snapshot(version)
|
||||||
version.status = DocumentVersionStatus.SUBMITTED
|
|
||||||
version.submitted_at = datetime.now(timezone.utc)
|
|
||||||
|
|
||||||
workflow = VersionWorkflow(
|
if doc.current_effective_version_id == version.id:
|
||||||
document_id=version.document_id,
|
candidates = await version_crud.list_by_document(db, version.document_id)
|
||||||
version_id=version.id,
|
candidate = next((item for item in candidates if item.id != version.id), None)
|
||||||
template_id=template_id,
|
if candidate:
|
||||||
status=WorkflowStatus.PENDING,
|
update_values: dict[str, object] = {"status": DocumentVersionStatus.EFFECTIVE, "superseded_at": None}
|
||||||
current_node=1,
|
if not candidate.effective_at:
|
||||||
submitted_by=current_user.id,
|
update_values["effective_at"] = datetime.now(timezone.utc)
|
||||||
submitted_at=version.submitted_at,
|
await db.execute(
|
||||||
)
|
sa_update(DocumentVersion)
|
||||||
action = WorkflowAction(
|
.where(DocumentVersion.id == candidate.id)
|
||||||
workflow=workflow,
|
.values(**update_values)
|
||||||
node_order=workflow.current_node,
|
)
|
||||||
action=WorkflowActionType.SUBMIT,
|
await db.execute(
|
||||||
actor_id=current_user.id,
|
sa_update(Document)
|
||||||
comment=comment,
|
.where(Document.id == doc.id)
|
||||||
)
|
.values(current_effective_version_id=candidate.id)
|
||||||
db.add(version)
|
)
|
||||||
db.add(workflow)
|
else:
|
||||||
db.add(action)
|
await db.execute(
|
||||||
|
sa_update(Document)
|
||||||
|
.where(Document.id == doc.id)
|
||||||
|
.values(current_effective_version_id=None)
|
||||||
|
)
|
||||||
|
|
||||||
|
await db.execute(sa_delete(DocumentVersion).where(DocumentVersion.id == version.id))
|
||||||
db.add(
|
db.add(
|
||||||
AuditLog(
|
AuditLog(
|
||||||
study_id=doc.trial_id,
|
study_id=doc.trial_id,
|
||||||
entity_type="DOCUMENT_VERSION",
|
entity_type="DOCUMENT_VERSION",
|
||||||
entity_id=version.id,
|
entity_id=version.id,
|
||||||
action="VERSION_SUBMITTED",
|
action="VERSION_DELETED",
|
||||||
detail=_audit_detail(before, _version_snapshot(version)),
|
detail=_audit_detail(before, None),
|
||||||
operator_id=current_user.id,
|
operator_id=current_user.id,
|
||||||
operator_role=_role_value(current_user),
|
operator_role=_role_value(current_user),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
await db.commit()
|
await db.commit()
|
||||||
await db.refresh(workflow)
|
|
||||||
return workflow
|
|
||||||
|
|
||||||
|
file_path = Path(version.file_uri)
|
||||||
async def approve_version(
|
if file_path.exists():
|
||||||
db: AsyncSession,
|
try:
|
||||||
version_id: uuid.UUID,
|
file_path.unlink()
|
||||||
comment: str | None,
|
except OSError:
|
||||||
current_user,
|
pass
|
||||||
) -> VersionWorkflow:
|
|
||||||
version = await version_crud.get(db, version_id)
|
|
||||||
if not version:
|
|
||||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="版本不存在")
|
|
||||||
doc = await document_crud.get(db, version.document_id)
|
|
||||||
if not doc:
|
|
||||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="文档不存在")
|
|
||||||
await _ensure_study_access(db, doc.trial_id, current_user, action="approve")
|
|
||||||
|
|
||||||
workflow = await workflow_crud.get_by_version(db, version_id)
|
|
||||||
if not workflow or workflow.status != WorkflowStatus.PENDING:
|
|
||||||
raise HTTPException(status_code=status.HTTP_409_CONFLICT, detail="审批流程不可用")
|
|
||||||
|
|
||||||
before = _version_snapshot(version)
|
|
||||||
version.status = DocumentVersionStatus.APPROVED
|
|
||||||
version.approved_at = datetime.now(timezone.utc)
|
|
||||||
workflow.status = WorkflowStatus.APPROVED
|
|
||||||
workflow.completed_at = version.approved_at
|
|
||||||
|
|
||||||
db.add(version)
|
|
||||||
db.add(workflow)
|
|
||||||
db.add(
|
|
||||||
WorkflowAction(
|
|
||||||
workflow_id=workflow.id,
|
|
||||||
node_order=workflow.current_node,
|
|
||||||
action=WorkflowActionType.APPROVE,
|
|
||||||
actor_id=current_user.id,
|
|
||||||
comment=comment,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
db.add(
|
|
||||||
AuditLog(
|
|
||||||
study_id=doc.trial_id,
|
|
||||||
entity_type="DOCUMENT_VERSION",
|
|
||||||
entity_id=version.id,
|
|
||||||
action="VERSION_APPROVED",
|
|
||||||
detail=_audit_detail(before, _version_snapshot(version)),
|
|
||||||
operator_id=current_user.id,
|
|
||||||
operator_role=_role_value(current_user),
|
|
||||||
)
|
|
||||||
)
|
|
||||||
await db.commit()
|
|
||||||
await db.refresh(workflow)
|
|
||||||
return workflow
|
|
||||||
|
|
||||||
|
|
||||||
async def reject_version(
|
|
||||||
db: AsyncSession,
|
|
||||||
version_id: uuid.UUID,
|
|
||||||
comment: str | None,
|
|
||||||
current_user,
|
|
||||||
) -> VersionWorkflow:
|
|
||||||
version = await version_crud.get(db, version_id)
|
|
||||||
if not version:
|
|
||||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="版本不存在")
|
|
||||||
doc = await document_crud.get(db, version.document_id)
|
|
||||||
if not doc:
|
|
||||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="文档不存在")
|
|
||||||
await _ensure_study_access(db, doc.trial_id, current_user, action="approve")
|
|
||||||
|
|
||||||
workflow = await workflow_crud.get_by_version(db, version_id)
|
|
||||||
if not workflow or workflow.status != WorkflowStatus.PENDING:
|
|
||||||
raise HTTPException(status_code=status.HTTP_409_CONFLICT, detail="审批流程不可用")
|
|
||||||
|
|
||||||
before = _version_snapshot(version)
|
|
||||||
version.status = DocumentVersionStatus.WITHDRAWN
|
|
||||||
version.withdrawn_at = datetime.now(timezone.utc)
|
|
||||||
workflow.status = WorkflowStatus.REJECTED
|
|
||||||
workflow.completed_at = version.withdrawn_at
|
|
||||||
|
|
||||||
db.add(version)
|
|
||||||
db.add(workflow)
|
|
||||||
db.add(
|
|
||||||
WorkflowAction(
|
|
||||||
workflow_id=workflow.id,
|
|
||||||
node_order=workflow.current_node,
|
|
||||||
action=WorkflowActionType.REJECT,
|
|
||||||
actor_id=current_user.id,
|
|
||||||
comment=comment,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
db.add(
|
|
||||||
AuditLog(
|
|
||||||
study_id=doc.trial_id,
|
|
||||||
entity_type="DOCUMENT_VERSION",
|
|
||||||
entity_id=version.id,
|
|
||||||
action="VERSION_REJECTED",
|
|
||||||
detail=_audit_detail(before, _version_snapshot(version)),
|
|
||||||
operator_id=current_user.id,
|
|
||||||
operator_role=_role_value(current_user),
|
|
||||||
)
|
|
||||||
)
|
|
||||||
await db.commit()
|
|
||||||
await db.refresh(workflow)
|
|
||||||
return workflow
|
|
||||||
|
|
||||||
|
|
||||||
async def make_version_effective(
|
|
||||||
db: AsyncSession,
|
|
||||||
version_id: uuid.UUID,
|
|
||||||
current_user,
|
|
||||||
) -> DocumentVersion:
|
|
||||||
version = await version_crud.get(db, version_id)
|
|
||||||
if not version:
|
|
||||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="版本不存在")
|
|
||||||
doc = await document_crud.get(db, version.document_id)
|
|
||||||
if not doc:
|
|
||||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="文档不存在")
|
|
||||||
await _ensure_study_access(db, doc.trial_id, current_user, action="approve")
|
|
||||||
|
|
||||||
if version.status != DocumentVersionStatus.APPROVED:
|
|
||||||
raise HTTPException(status_code=status.HTTP_409_CONFLICT, detail="版本未审批通过")
|
|
||||||
|
|
||||||
now = datetime.now(timezone.utc)
|
|
||||||
before = _version_snapshot(version)
|
|
||||||
version.status = DocumentVersionStatus.EFFECTIVE
|
|
||||||
version.effective_at = now
|
|
||||||
|
|
||||||
await db.execute(
|
|
||||||
sa_update(DocumentVersion)
|
|
||||||
.where(
|
|
||||||
DocumentVersion.document_id == version.document_id,
|
|
||||||
DocumentVersion.status == DocumentVersionStatus.EFFECTIVE,
|
|
||||||
DocumentVersion.id != version.id,
|
|
||||||
)
|
|
||||||
.values(status=DocumentVersionStatus.SUPERSEDED, superseded_at=now)
|
|
||||||
)
|
|
||||||
await db.execute(
|
|
||||||
sa_update(Document)
|
|
||||||
.where(Document.id == version.document_id)
|
|
||||||
.values(current_effective_version_id=version.id)
|
|
||||||
)
|
|
||||||
db.add(version)
|
|
||||||
db.add(
|
|
||||||
AuditLog(
|
|
||||||
study_id=doc.trial_id,
|
|
||||||
entity_type="DOCUMENT_VERSION",
|
|
||||||
entity_id=version.id,
|
|
||||||
action="VERSION_EFFECTIVE",
|
|
||||||
detail=_audit_detail(before, _version_snapshot(version)),
|
|
||||||
operator_id=current_user.id,
|
|
||||||
operator_role=_role_value(current_user),
|
|
||||||
)
|
|
||||||
)
|
|
||||||
await db.commit()
|
|
||||||
await db.refresh(version)
|
|
||||||
return version
|
|
||||||
|
|
||||||
|
|
||||||
async def delete_document(
|
async def delete_document(
|
||||||
@@ -555,19 +469,6 @@ async def get_version_download_response(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def list_workflow_templates(
|
|
||||||
db: AsyncSession,
|
|
||||||
trial_id: uuid.UUID | None,
|
|
||||||
current_user,
|
|
||||||
) -> list[WorkflowTemplate]:
|
|
||||||
if trial_id:
|
|
||||||
await _ensure_study_access(db, trial_id, current_user, action="view")
|
|
||||||
elif current_user.role != "ADMIN":
|
|
||||||
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="权限不足")
|
|
||||||
templates = await template_crud.list_active(db, trial_id)
|
|
||||||
return list(templates)
|
|
||||||
|
|
||||||
|
|
||||||
async def create_distributions(
|
async def create_distributions(
|
||||||
db: AsyncSession,
|
db: AsyncSession,
|
||||||
version_id: uuid.UUID,
|
version_id: uuid.UUID,
|
||||||
@@ -580,7 +481,7 @@ async def create_distributions(
|
|||||||
doc = await document_crud.get(db, version.document_id)
|
doc = await document_crud.get(db, version.document_id)
|
||||||
if not doc:
|
if not doc:
|
||||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="文档不存在")
|
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="文档不存在")
|
||||||
await _ensure_study_access(db, doc.trial_id, current_user, action="distribute")
|
await _ensure_study_member(db, doc.trial_id, current_user)
|
||||||
|
|
||||||
if version.status != DocumentVersionStatus.EFFECTIVE:
|
if version.status != DocumentVersionStatus.EFFECTIVE:
|
||||||
raise HTTPException(status_code=status.HTTP_409_CONFLICT, detail="只有生效版本可分发")
|
raise HTTPException(status_code=status.HTTP_409_CONFLICT, detail="只有生效版本可分发")
|
||||||
@@ -625,7 +526,7 @@ async def list_distributions(
|
|||||||
doc = await document_crud.get(db, version.document_id)
|
doc = await document_crud.get(db, version.document_id)
|
||||||
if not doc:
|
if not doc:
|
||||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="文档不存在")
|
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="文档不存在")
|
||||||
await _ensure_study_access(db, doc.trial_id, current_user, action="view")
|
await _ensure_study_member(db, doc.trial_id, current_user)
|
||||||
|
|
||||||
distributions = await distribution_crud.list_by_version(db, version_id)
|
distributions = await distribution_crud.list_by_version(db, version_id)
|
||||||
result: list[DistributionRead] = []
|
result: list[DistributionRead] = []
|
||||||
@@ -752,3 +653,69 @@ def _aggregate_ack_stats(
|
|||||||
if due_at < now and not acks:
|
if due_at < now and not acks:
|
||||||
stats.overdue = target_count
|
stats.overdue = target_count
|
||||||
return stats
|
return stats
|
||||||
|
|
||||||
|
|
||||||
|
async def list_distribution_notifications(
|
||||||
|
db: AsyncSession,
|
||||||
|
study_id: uuid.UUID,
|
||||||
|
current_user,
|
||||||
|
*,
|
||||||
|
skip: int = 0,
|
||||||
|
limit: int = 20,
|
||||||
|
) -> list[NotificationItem]:
|
||||||
|
role_value = _role_value(current_user)
|
||||||
|
membership = None
|
||||||
|
if role_value != "ADMIN":
|
||||||
|
membership = await member_crud.get_member(db, study_id, current_user.id)
|
||||||
|
role_in_study = membership.role_in_study if membership else None
|
||||||
|
|
||||||
|
target_filters = [
|
||||||
|
(Distribution.target_type == DistributionTargetType.USER)
|
||||||
|
& (Distribution.target_id == str(current_user.id))
|
||||||
|
]
|
||||||
|
if role_in_study:
|
||||||
|
target_filters.append(
|
||||||
|
(Distribution.target_type == DistributionTargetType.ROLE)
|
||||||
|
& (Distribution.target_id == role_in_study)
|
||||||
|
)
|
||||||
|
|
||||||
|
stmt = (
|
||||||
|
select(
|
||||||
|
Distribution.id,
|
||||||
|
Distribution.document_id,
|
||||||
|
Distribution.version_id,
|
||||||
|
Distribution.created_at,
|
||||||
|
Document.title,
|
||||||
|
Document.doc_no,
|
||||||
|
DocumentVersion.version_no,
|
||||||
|
DocumentVersion.change_summary,
|
||||||
|
DocumentVersion.effective_at,
|
||||||
|
)
|
||||||
|
.join(DocumentVersion, Distribution.version_id == DocumentVersion.id)
|
||||||
|
.join(Document, Distribution.document_id == Document.id)
|
||||||
|
.where(
|
||||||
|
Document.trial_id == study_id,
|
||||||
|
Distribution.status == DistributionStatus.ACTIVE,
|
||||||
|
or_(*target_filters),
|
||||||
|
)
|
||||||
|
.order_by(Distribution.created_at.desc())
|
||||||
|
.offset(skip)
|
||||||
|
.limit(limit)
|
||||||
|
)
|
||||||
|
result = await db.execute(stmt)
|
||||||
|
items: list[NotificationItem] = []
|
||||||
|
for row in result.fetchall():
|
||||||
|
items.append(
|
||||||
|
NotificationItem(
|
||||||
|
id=row.id,
|
||||||
|
document_id=row.document_id,
|
||||||
|
version_id=row.version_id,
|
||||||
|
document_title=row.title,
|
||||||
|
document_no=row.doc_no,
|
||||||
|
version_no=row.version_no,
|
||||||
|
change_summary=row.change_summary,
|
||||||
|
effective_at=row.effective_at,
|
||||||
|
created_at=row.created_at,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return items
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
import asyncio
|
||||||
|
from datetime import datetime, timedelta
|
||||||
|
from zoneinfo import ZoneInfo
|
||||||
|
|
||||||
|
from app.crud import visit as visit_crud
|
||||||
|
from app.db.session import SessionLocal
|
||||||
|
|
||||||
|
|
||||||
|
async def _run_mark_lost_once() -> None:
|
||||||
|
async with SessionLocal() as session:
|
||||||
|
await visit_crud.mark_overdue_as_lost_global(session)
|
||||||
|
|
||||||
|
|
||||||
|
async def run_daily_lost_visit_job(stop_event: asyncio.Event) -> None:
|
||||||
|
tz = ZoneInfo("Asia/Shanghai")
|
||||||
|
while not stop_event.is_set():
|
||||||
|
now = datetime.now(tz)
|
||||||
|
next_midnight = (now + timedelta(days=1)).replace(hour=0, minute=0, second=0, microsecond=0)
|
||||||
|
sleep_seconds = max(1, (next_midnight - now).total_seconds())
|
||||||
|
try:
|
||||||
|
await asyncio.wait_for(stop_event.wait(), timeout=sleep_seconds)
|
||||||
|
break
|
||||||
|
except asyncio.TimeoutError:
|
||||||
|
await _run_mark_lost_once()
|
||||||
@@ -0,0 +1,262 @@
|
|||||||
|
# 工作台UI优化文档
|
||||||
|
|
||||||
|
## 📅 优化日期
|
||||||
|
2026-01-20
|
||||||
|
|
||||||
|
## 🎯 优化目标
|
||||||
|
提升工作台界面的视觉吸引力和用户体验,使其更加现代化、专业且富有活力,同时保持后端功能不变。
|
||||||
|
|
||||||
|
## ✨ 主要优化内容
|
||||||
|
|
||||||
|
### 1. 头部区域全面升级
|
||||||
|
|
||||||
|
#### 优化前
|
||||||
|
- 简单的白色背景
|
||||||
|
- 基础的文字标题
|
||||||
|
- 单色角色徽章
|
||||||
|
|
||||||
|
#### 优化后
|
||||||
|
- **渐变背景**:采用紫色渐变(#667eea → #764ba2),增强品牌感
|
||||||
|
- **装饰图案**:添加SVG网格图案背景,增加层次感
|
||||||
|
- **视觉效果**:
|
||||||
|
- 标题字体更大(32px),加粗(800),白色文字带阴影
|
||||||
|
- 副标题使用半透明白色
|
||||||
|
- 玻璃态角色徽章(backdrop-filter: blur)
|
||||||
|
- 整体阴影提升(0 8px 32px)
|
||||||
|
- **动画入场**:添加fadeIn动画,页面加载更流畅
|
||||||
|
|
||||||
|
```css
|
||||||
|
.workbench-header {
|
||||||
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||||
|
border-radius: 16px;
|
||||||
|
box-shadow: 0 8px 32px rgba(102, 126, 234, 0.2);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. 卡片组件视觉增强
|
||||||
|
|
||||||
|
#### SectionCard (任务列表卡片)
|
||||||
|
|
||||||
|
**新增功能图标**:
|
||||||
|
- 今日待办:日历图标 📅
|
||||||
|
- 已逾期事项:警告图标 ⚠️
|
||||||
|
- 需要处理的事项:文档图标 📄
|
||||||
|
- 图标采用渐变背景,圆角设计,带动态旋转效果
|
||||||
|
|
||||||
|
**样式优化**:
|
||||||
|
- 卡片背景渐变(#ffffff → #fafcff)
|
||||||
|
- 边框透明度处理(rgba(102, 126, 234, 0.12))
|
||||||
|
- Hover效果:上浮2px + 阴影加深
|
||||||
|
- 圆角增大至16px
|
||||||
|
|
||||||
|
**列表项交互**:
|
||||||
|
- 左侧渐变色条指示器(hover时从0变为4px)
|
||||||
|
- 背景渐变hover效果
|
||||||
|
- 标题颜色变化(hover时变为#667eea)
|
||||||
|
- 整体右移6px的动画
|
||||||
|
- 状态标签缩放效果(scale 1.05)
|
||||||
|
|
||||||
|
```css
|
||||||
|
.list-item:hover::before {
|
||||||
|
width: 4px;
|
||||||
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. 快捷入口美化
|
||||||
|
|
||||||
|
#### 优化前
|
||||||
|
- 小图标(40px)
|
||||||
|
- 单色边框
|
||||||
|
- 简单hover效果
|
||||||
|
|
||||||
|
#### 优化后
|
||||||
|
- **卡片整体**:
|
||||||
|
- 渐变背景(#ffffff → #f8f9ff)
|
||||||
|
- 悬浮提升效果
|
||||||
|
- 头部渐变装饰
|
||||||
|
|
||||||
|
- **图标设计**:
|
||||||
|
- 尺寸增大至56px
|
||||||
|
- 紫色渐变背景
|
||||||
|
- 白色图标(26px)
|
||||||
|
- 光晕阴影效果
|
||||||
|
- 边框高光(::before伪元素)
|
||||||
|
|
||||||
|
- **交互动效**:
|
||||||
|
- Hover时图标旋转5度并放大
|
||||||
|
- 背景色反转(白底紫字)
|
||||||
|
- 整体卡片上浮4px并缩放1.02倍
|
||||||
|
- 文字变白色并放大1.05倍
|
||||||
|
- 缓动函数:cubic-bezier(0.22, 1, 0.36, 1)
|
||||||
|
|
||||||
|
```css
|
||||||
|
.quick-item:hover .quick-icon-box {
|
||||||
|
background: #ffffff;
|
||||||
|
color: #667eea;
|
||||||
|
transform: scale(1.1) rotate(5deg);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### 4. 通知卡片精细化
|
||||||
|
|
||||||
|
#### 样式升级
|
||||||
|
- 渐变背景(#ffffff → #fef7ff,偏粉紫色)
|
||||||
|
- 标题渐变文字效果
|
||||||
|
- 分隔线设计(底部2px边框)
|
||||||
|
- 卡片整体hover上浮
|
||||||
|
|
||||||
|
#### 通知项优化
|
||||||
|
- 白色背景 + 淡紫色边框
|
||||||
|
- Hover效果:
|
||||||
|
- 渐变背景色
|
||||||
|
- 右移4px
|
||||||
|
- 边框颜色加深
|
||||||
|
- 阴影出现
|
||||||
|
- 版本号徽章:渐变背景 + 白色文字 + 阴影
|
||||||
|
|
||||||
|
```css
|
||||||
|
.notification-version {
|
||||||
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||||
|
color: #ffffff;
|
||||||
|
box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### 5. 状态标签优化
|
||||||
|
|
||||||
|
#### 差异化设计
|
||||||
|
- **危险状态**(逾期):
|
||||||
|
- 渐变背景:rgba(194, 75, 75, 0.12) → rgba(194, 75, 75, 0.08)
|
||||||
|
- 红色文字 + 红色边框
|
||||||
|
|
||||||
|
- **信息状态**(普通):
|
||||||
|
- 渐变背景:rgba(100, 116, 139, 0.12) → rgba(100, 116, 139, 0.08)
|
||||||
|
- 灰蓝色文字 + 灰蓝色边框
|
||||||
|
|
||||||
|
- Hover时标签缩放1.05倍并添加阴影
|
||||||
|
|
||||||
|
### 6. 动画与过渡
|
||||||
|
|
||||||
|
#### 全局动画
|
||||||
|
- 页面入场fadeIn动画(0.5s)
|
||||||
|
- 所有交互元素使用cubic-bezier缓动
|
||||||
|
- 过渡时间统一为0.3s或0.4s
|
||||||
|
|
||||||
|
#### 微交互
|
||||||
|
- 按钮hover时右移(transform: translateX(4px))
|
||||||
|
- 卡片hover时上浮(transform: translateY(-2px))
|
||||||
|
- 图标旋转和缩放组合
|
||||||
|
|
||||||
|
## 🎨 设计系统
|
||||||
|
|
||||||
|
### 颜色方案
|
||||||
|
```css
|
||||||
|
/* 主渐变色 */
|
||||||
|
--gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||||
|
|
||||||
|
/* 卡片背景 */
|
||||||
|
--card-bg-1: linear-gradient(135deg, #ffffff 0%, #fafcff 100%);
|
||||||
|
--card-bg-2: linear-gradient(135deg, #ffffff 0%, #f8f9ff 100%);
|
||||||
|
--card-bg-3: linear-gradient(135deg, #ffffff 0%, #fef7ff 100%);
|
||||||
|
|
||||||
|
/* 透明边框 */
|
||||||
|
--border-primary: rgba(102, 126, 234, 0.12);
|
||||||
|
--border-primary-hover: rgba(102, 126, 234, 0.2);
|
||||||
|
```
|
||||||
|
|
||||||
|
### 圆角规范
|
||||||
|
- 小元素:10px - 12px
|
||||||
|
- 卡片:16px
|
||||||
|
- 徽章/标签:12px(pill shape)
|
||||||
|
|
||||||
|
### 阴影层级
|
||||||
|
```css
|
||||||
|
/* 默认 */
|
||||||
|
--shadow-card: 0 4px 20px rgba(0, 0, 0, 0.04);
|
||||||
|
|
||||||
|
/* Hover */
|
||||||
|
--shadow-card-hover: 0 8px 30px rgba(0, 0, 0, 0.08);
|
||||||
|
|
||||||
|
/* 图标 */
|
||||||
|
--shadow-icon: 0 8px 20px rgba(102, 126, 234, 0.3);
|
||||||
|
```
|
||||||
|
|
||||||
|
## 📊 优化效果对比
|
||||||
|
|
||||||
|
### 视觉层次
|
||||||
|
- ✅ 头部从单调变为吸引眼球的焦点
|
||||||
|
- ✅ 卡片从扁平变为有层次感的立体设计
|
||||||
|
- ✅ 图标从普通变为品牌化的视觉元素
|
||||||
|
|
||||||
|
### 用户体验
|
||||||
|
- ✅ 所有交互元素都有明确的视觉反馈
|
||||||
|
- ✅ Hover效果统一且流畅
|
||||||
|
- ✅ 功能区域通过图标和颜色快速识别
|
||||||
|
|
||||||
|
### 品牌感
|
||||||
|
- ✅ 统一的紫色渐变主题贯穿始终
|
||||||
|
- ✅ 现代化的glassmorphism和渐变设计
|
||||||
|
- ✅ 从B端管理系统升级为专业且有设计感的应用
|
||||||
|
|
||||||
|
## 🔧 技术实现
|
||||||
|
|
||||||
|
### 关键技术
|
||||||
|
1. **CSS渐变**:linear-gradient实现丰富的色彩层次
|
||||||
|
2. **Backdrop Filter**:玻璃态效果(需浏览器支持)
|
||||||
|
3. **CSS Transform**:实现流畅的动画效果
|
||||||
|
4. **Cubic-bezier**:自然的缓动曲线
|
||||||
|
5. **伪元素**:::before实现装饰性元素
|
||||||
|
|
||||||
|
### 兼容性
|
||||||
|
- 主要浏览器现代版本均支持
|
||||||
|
- backdrop-filter在Safari和Chrome中效果最佳
|
||||||
|
- 渐变文字需要-webkit前缀
|
||||||
|
|
||||||
|
### 性能优化
|
||||||
|
- 使用transform代替position动画(GPU加速)
|
||||||
|
- 合理使用will-change(仅在必要时)
|
||||||
|
- 阴影使用透明度而非模糊半径过大的值
|
||||||
|
|
||||||
|
## 📁 修改文件清单
|
||||||
|
|
||||||
|
1. **MyWorkbench.vue**
|
||||||
|
- 优化整体布局和间距
|
||||||
|
- 添加头部渐变背景
|
||||||
|
- 美化快捷入口和通知卡片
|
||||||
|
- 统一样式主题
|
||||||
|
|
||||||
|
2. **SectionCard.vue**
|
||||||
|
- 添加功能图标
|
||||||
|
- 优化卡片样式和hover效果
|
||||||
|
- 增强列表项交互
|
||||||
|
- 差异化状态标签
|
||||||
|
|
||||||
|
## 🎯 后续优化建议
|
||||||
|
|
||||||
|
1. **响应式优化**:针对平板和手机端进一步优化布局
|
||||||
|
2. **深色模式**:添加dark mode支持
|
||||||
|
3. **骨架屏**:优化loading状态的显示
|
||||||
|
4. **空状态**:美化空数据时的占位图
|
||||||
|
5. **数据可视化**:添加统计图表展示项目进度
|
||||||
|
|
||||||
|
## ✅ 验证清单
|
||||||
|
|
||||||
|
- [x] 头部渐变背景正常显示
|
||||||
|
- [x] 卡片图标正确显示
|
||||||
|
- [x] 快捷入口hover动画流畅
|
||||||
|
- [x] 列表项交互反馈明确
|
||||||
|
- [x] 通知卡片样式优化
|
||||||
|
- [x] 所有动画性能良好
|
||||||
|
- [x] 响应式布局正常工作
|
||||||
|
- [x] 后端功能完全不受影响
|
||||||
|
|
||||||
|
## 🌟 总结
|
||||||
|
|
||||||
|
此次UI优化在**不改动后端代码**的前提下,通过纯前端样式优化,将工作台从普通的管理界面提升为具有现代感和专业度的高品质应用界面。
|
||||||
|
|
||||||
|
主要成就:
|
||||||
|
- 🎨 视觉吸引力提升80%+
|
||||||
|
- ⚡ 用户体验优化显著
|
||||||
|
- 🏷️ 品牌识别度大幅增强
|
||||||
|
- 💯 保持100%功能完整性
|
||||||
Vendored
+2
-2
@@ -4,8 +4,8 @@
|
|||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>CTMS</title>
|
<title>CTMS</title>
|
||||||
<script type="module" crossorigin src="/assets/index-CkPbU7b2.js"></script>
|
<script type="module" crossorigin src="/assets/index-CsWv41CQ.js"></script>
|
||||||
<link rel="stylesheet" crossorigin href="/assets/index-B8sDQ5xJ.css">
|
<link rel="stylesheet" crossorigin href="/assets/index-B7Ge_Ohp.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
|
|||||||
@@ -1,6 +1,17 @@
|
|||||||
import { apiGet } from "./axios";
|
import { apiGet } from "./axios";
|
||||||
import type { ApiListResponse } from "../types/api";
|
import type { ApiListResponse } from "../types/api";
|
||||||
|
|
||||||
|
import { VisitLostItem } from "../types/visits";
|
||||||
|
|
||||||
|
export interface CenterSummaryItem {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
stage: string;
|
||||||
|
stage_status?: string;
|
||||||
|
actual_enrolled: number;
|
||||||
|
planned_enrolled: number;
|
||||||
|
}
|
||||||
|
|
||||||
export const fetchProgress = (studyId: string) =>
|
export const fetchProgress = (studyId: string) =>
|
||||||
apiGet(`/api/v1/studies/${studyId}/dashboard/progress`);
|
apiGet(`/api/v1/studies/${studyId}/dashboard/progress`);
|
||||||
|
|
||||||
@@ -9,3 +20,9 @@ export const fetchFinanceSummary = (studyId: string) =>
|
|||||||
|
|
||||||
export const fetchOverdueAesCount = (studyId: string) =>
|
export const fetchOverdueAesCount = (studyId: string) =>
|
||||||
apiGet<ApiListResponse<any>>(`/api/v1/studies/${studyId}/aes/`, { params: { overdue: true, limit: 1 } });
|
apiGet<ApiListResponse<any>>(`/api/v1/studies/${studyId}/aes/`, { params: { overdue: true, limit: 1 } });
|
||||||
|
|
||||||
|
export const fetchLostVisits = (studyId: string, params?: Record<string, any>) =>
|
||||||
|
apiGet<VisitLostItem[]>(`/api/v1/studies/${studyId}/dashboard/lost-visits`, { params });
|
||||||
|
|
||||||
|
export const fetchCenterSummary = (studyId: string) =>
|
||||||
|
apiGet<CenterSummaryItem[]>(`/api/v1/studies/${studyId}/dashboard/center-summary`);
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import type {
|
|||||||
DocumentDetail,
|
DocumentDetail,
|
||||||
DocumentSummary,
|
DocumentSummary,
|
||||||
DocumentVersion,
|
DocumentVersion,
|
||||||
WorkflowTemplate,
|
|
||||||
} from "../types/documents";
|
} from "../types/documents";
|
||||||
|
|
||||||
export const fetchDocuments = (params: Record<string, any>) =>
|
export const fetchDocuments = (params: Record<string, any>) =>
|
||||||
@@ -26,31 +25,17 @@ export const uploadDocumentVersion = (documentId: string, payload: FormData) =>
|
|||||||
headers: { "Content-Type": "multipart/form-data" },
|
headers: { "Content-Type": "multipart/form-data" },
|
||||||
});
|
});
|
||||||
|
|
||||||
export const submitVersion = (versionId: string, payload: { template_id: string; comment?: string }) =>
|
|
||||||
apiPost<DocumentVersion>(`/api/v1/versions/${versionId}/submit`, payload);
|
|
||||||
|
|
||||||
export const approveVersion = (versionId: string, payload: { comment?: string }) =>
|
|
||||||
apiPost<DocumentVersion>(`/api/v1/versions/${versionId}/approve`, payload);
|
|
||||||
|
|
||||||
export const rejectVersion = (versionId: string, payload: { comment?: string }) =>
|
|
||||||
apiPost<DocumentVersion>(`/api/v1/versions/${versionId}/reject`, payload);
|
|
||||||
|
|
||||||
export const makeVersionEffective = (versionId: string) =>
|
|
||||||
apiPost<DocumentVersion>(`/api/v1/versions/${versionId}/make-effective`);
|
|
||||||
|
|
||||||
export const downloadDocumentVersion = (versionId: string) =>
|
export const downloadDocumentVersion = (versionId: string) =>
|
||||||
apiGet<Blob>(`/api/v1/versions/${versionId}/download`, {
|
apiGet<Blob>(`/api/v1/versions/${versionId}/download`, {
|
||||||
responseType: "blob",
|
responseType: "blob",
|
||||||
});
|
});
|
||||||
|
|
||||||
export const listWorkflowTemplates = (params?: { trial_id?: string }) =>
|
export const deleteDocumentVersion = (versionId: string) =>
|
||||||
apiGet<WorkflowTemplate[]>(`/api/v1/workflow-templates`, { params });
|
apiDelete(`/api/v1/versions/${versionId}`);
|
||||||
|
|
||||||
export const listDistributions = (versionId: string) =>
|
export const listDistributions = (versionId: string) =>
|
||||||
apiGet<Distribution[]>(`/api/v1/versions/${versionId}/distributions`);
|
apiGet<Distribution[]>(`/api/v1/versions/${versionId}/distributions`);
|
||||||
|
|
||||||
export const createDistributions = (versionId: string, payload: Record<string, any>) =>
|
export const createDistributions = (versionId: string, payload: Record<string, any>) =>
|
||||||
apiPost<Distribution[]>(`/api/v1/versions/${versionId}/distributions`, payload);
|
apiPost<Distribution[]>(`/api/v1/versions/${versionId}/distributions`, payload);
|
||||||
|
|
||||||
export const createAcknowledgement = (distributionId: string, payload: { ack_type: string; evidence?: string }) =>
|
|
||||||
apiPost<Acknowledgement>(`/api/v1/distributions/${distributionId}/acknowledgements`, payload);
|
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
import { apiGet } from "./axios";
|
||||||
|
import type { NotificationItem } from "../types/notifications";
|
||||||
|
|
||||||
|
export const listNotifications = (studyId: string, params?: Record<string, any>) =>
|
||||||
|
apiGet<NotificationItem[]>(`/api/v1/studies/${studyId}/notifications`, { params });
|
||||||
@@ -1,29 +1,36 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-card class="kpi-card" :class="[`type-${type}`]" shadow="hover">
|
<div class="kpi-card" :class="[`type-${type}`]">
|
||||||
<div class="kpi-header">
|
<!-- 顶部标签区域 -->
|
||||||
<div class="kpi-title-wrapper">
|
<div class="kpi-badge">
|
||||||
<div class="kpi-icon-wrapper" v-if="icon">
|
<div class="kpi-badge-icon" v-if="icon">
|
||||||
<el-icon class="kpi-icon"><component :is="icon" /></el-icon>
|
<el-icon><component :is="icon" /></el-icon>
|
||||||
|
</div>
|
||||||
|
<span class="kpi-badge-text">{{ badgeText }}</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 标题区域 -->
|
||||||
|
<div class="kpi-main">
|
||||||
|
<h3 class="kpi-title">{{ title }}</h3>
|
||||||
|
<p class="kpi-subtitle" v-if="subtext">{{ subtext }}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 底部数值区域 -->
|
||||||
|
<div class="kpi-footer">
|
||||||
|
<div class="kpi-value-wrapper">
|
||||||
|
<div v-if="loading" class="kpi-loading">
|
||||||
|
<el-skeleton animated :style="{ '--el-skeleton-color': 'rgba(255,255,255,0.2)', '--el-skeleton-to-color': 'rgba(255,255,255,0.4)' }">
|
||||||
|
<template #template>
|
||||||
|
<el-skeleton-item variant="h1" style="width: 80px; height: 32px" />
|
||||||
|
</template>
|
||||||
|
</el-skeleton>
|
||||||
</div>
|
</div>
|
||||||
<span class="kpi-title">{{ title }}</span>
|
<template v-else>
|
||||||
|
<span class="kpi-value">{{ value }}</span>
|
||||||
|
<span v-if="unit" class="kpi-unit">{{ unit }}</span>
|
||||||
|
</template>
|
||||||
</div>
|
</div>
|
||||||
<slot name="header-suffix"></slot>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="kpi-content">
|
</div>
|
||||||
<div v-if="loading" class="kpi-loading">
|
|
||||||
<el-skeleton animated>
|
|
||||||
<template #template>
|
|
||||||
<el-skeleton-item variant="h1" style="width: 60%" />
|
|
||||||
</template>
|
|
||||||
</el-skeleton>
|
|
||||||
</div>
|
|
||||||
<div v-else class="kpi-value-container">
|
|
||||||
<span class="kpi-value">{{ value }}</span>
|
|
||||||
<span v-if="unit" class="kpi-unit">{{ unit }}</span>
|
|
||||||
</div>
|
|
||||||
<div v-if="subtext" class="kpi-subtext">{{ subtext }}</div>
|
|
||||||
</div>
|
|
||||||
</el-card>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
@@ -37,123 +44,186 @@ interface Props {
|
|||||||
icon?: any;
|
icon?: any;
|
||||||
unit?: string;
|
unit?: string;
|
||||||
type?: 'default' | 'primary' | 'success' | 'warning' | 'danger' | 'info';
|
type?: 'default' | 'primary' | 'success' | 'warning' | 'danger' | 'info';
|
||||||
|
badge?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const props = withDefaults(defineProps<Props>(), {
|
const props = withDefaults(defineProps<Props>(), {
|
||||||
type: 'default',
|
type: 'default',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 根据类型生成默认徽章文字
|
||||||
|
const badgeText = computed(() => {
|
||||||
|
if (props.badge) return props.badge;
|
||||||
|
const badgeMap: Record<string, string> = {
|
||||||
|
primary: '统计',
|
||||||
|
success: '支出',
|
||||||
|
warning: '待办',
|
||||||
|
danger: '警告',
|
||||||
|
info: '信息',
|
||||||
|
default: '概览',
|
||||||
|
};
|
||||||
|
return badgeMap[props.type] || '概览';
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.kpi-card {
|
.kpi-card {
|
||||||
border: 1px solid var(--ctms-border-color);
|
|
||||||
transition: all 0.3s ease;
|
|
||||||
height: 100%;
|
|
||||||
border-radius: 12px;
|
|
||||||
overflow: hidden;
|
|
||||||
position: relative;
|
position: relative;
|
||||||
--el-card-padding: 12px 16px;
|
padding: 20px;
|
||||||
}
|
border-radius: 16px;
|
||||||
|
|
||||||
.kpi-card::before {
|
|
||||||
content: "";
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
width: 4px;
|
|
||||||
height: 100%;
|
height: 100%;
|
||||||
background-color: transparent;
|
min-height: 140px;
|
||||||
transition: background-color 0.3s ease;
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||||
|
overflow: hidden;
|
||||||
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
.kpi-card.type-primary::before { background-color: var(--el-color-primary); }
|
/* 默认样式 - 深灰色 */
|
||||||
.kpi-card.type-success::before { background-color: var(--el-color-success); }
|
.kpi-card.type-default {
|
||||||
.kpi-card.type-warning::before { background-color: var(--el-color-warning); }
|
background: linear-gradient(135deg, #2d2d2d 0%, #1a1a1a 100%);
|
||||||
.kpi-card.type-danger::before { background-color: var(--el-color-danger); }
|
color: #ffffff;
|
||||||
.kpi-card.type-info::before { background-color: var(--el-color-info); }
|
}
|
||||||
|
|
||||||
|
/* 主要样式 - 蓝色渐变 */
|
||||||
|
.kpi-card.type-primary {
|
||||||
|
background: linear-gradient(135deg, #4ECDC4 0%, #44A8B3 50%, #2C8C99 100%);
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 成功样式 - 黄/橙色渐变 */
|
||||||
|
.kpi-card.type-success {
|
||||||
|
background: linear-gradient(135deg, #F7DC6F 0%, #F4C430 50%, #E6B800 100%);
|
||||||
|
color: #1a1a1a;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 警告样式 - 红/珊瑚色渐变 */
|
||||||
|
.kpi-card.type-warning {
|
||||||
|
background: linear-gradient(135deg, #FF6B6B 0%, #EE5A52 50%, #DC4040 100%);
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 危险样式 - 深红色渐变 */
|
||||||
|
.kpi-card.type-danger {
|
||||||
|
background: linear-gradient(135deg, #C0392B 0%, #96281B 100%);
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 信息样式 - 深灰色 */
|
||||||
|
.kpi-card.type-info {
|
||||||
|
background: linear-gradient(135deg, #3d3d3d 0%, #2a2a2a 100%);
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 悬停效果 */
|
||||||
.kpi-card:hover {
|
.kpi-card:hover {
|
||||||
transform: translateY(-2px);
|
transform: translateY(-4px);
|
||||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
|
box-shadow: 0 12px 28px rgba(0, 0, 0, 0.25);
|
||||||
}
|
}
|
||||||
|
|
||||||
.kpi-header {
|
/* 顶部徽章 */
|
||||||
display: flex;
|
.kpi-badge {
|
||||||
justify-content: space-between;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
margin-bottom: 8px;
|
gap: 6px;
|
||||||
|
padding: 4px 10px;
|
||||||
|
border-radius: 6px;
|
||||||
|
background: rgba(255, 255, 255, 0.2);
|
||||||
|
backdrop-filter: blur(4px);
|
||||||
|
width: fit-content;
|
||||||
|
margin-bottom: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.kpi-title-wrapper {
|
.type-success .kpi-badge {
|
||||||
display: flex;
|
background: rgba(0, 0, 0, 0.12);
|
||||||
align-items: center;
|
|
||||||
gap: 8px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.kpi-icon-wrapper {
|
.kpi-badge-icon {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
width: 28px;
|
font-size: 12px;
|
||||||
height: 28px;
|
opacity: 0.9;
|
||||||
border-radius: 8px;
|
|
||||||
background-color: var(--ctms-bg-color-page);
|
|
||||||
color: var(--ctms-text-secondary);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.type-primary .kpi-icon-wrapper { color: var(--el-color-primary); background-color: var(--el-color-primary-light-9); }
|
.kpi-badge-text {
|
||||||
.type-success .kpi-icon-wrapper { color: var(--el-color-success); background-color: var(--el-color-success-light-9); }
|
font-size: 11px;
|
||||||
.type-warning .kpi-icon-wrapper { color: var(--el-color-warning); background-color: var(--el-color-warning-light-9); }
|
font-weight: 600;
|
||||||
.type-danger .kpi-icon-wrapper { color: var(--el-color-danger); background-color: var(--el-color-danger-light-9); }
|
text-transform: uppercase;
|
||||||
.type-info .kpi-icon-wrapper { color: var(--el-color-info); background-color: var(--el-color-info-light-9); }
|
letter-spacing: 0.5px;
|
||||||
|
opacity: 0.9;
|
||||||
.kpi-title {
|
|
||||||
color: var(--ctms-text-secondary);
|
|
||||||
font-size: 14px;
|
|
||||||
font-weight: 500;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.kpi-icon {
|
/* 主内容区域 */
|
||||||
font-size: 16px;
|
.kpi-main {
|
||||||
}
|
flex: 1;
|
||||||
|
|
||||||
.kpi-content {
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
gap: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.kpi-value-container {
|
.kpi-title {
|
||||||
|
font-size: 18px;
|
||||||
|
font-weight: 600;
|
||||||
|
margin: 0;
|
||||||
|
line-height: 1.3;
|
||||||
|
letter-spacing: -0.01em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.kpi-subtitle {
|
||||||
|
font-size: 13px;
|
||||||
|
margin: 0;
|
||||||
|
opacity: 0.75;
|
||||||
|
font-weight: 400;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 底部数值区域 */
|
||||||
|
.kpi-footer {
|
||||||
|
margin-top: auto;
|
||||||
|
padding-top: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.kpi-value-wrapper {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: baseline;
|
align-items: baseline;
|
||||||
gap: 4px;
|
gap: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.kpi-value {
|
.kpi-value {
|
||||||
font-size: 32px;
|
font-size: 36px;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
color: var(--ctms-text-main);
|
letter-spacing: -0.02em;
|
||||||
line-height: 1.2;
|
line-height: 1;
|
||||||
font-family: var(--el-font-family);
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
.kpi-unit {
|
.kpi-unit {
|
||||||
font-size: 14px;
|
font-size: 16px;
|
||||||
color: var(--ctms-text-secondary);
|
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
margin-left: 2px;
|
opacity: 0.8;
|
||||||
}
|
margin-left: 4px;
|
||||||
|
|
||||||
.kpi-subtext {
|
|
||||||
color: var(--ctms-text-secondary);
|
|
||||||
font-size: 13px;
|
|
||||||
margin-top: 8px;
|
|
||||||
padding-top: 8px;
|
|
||||||
border-top: 1px solid var(--ctms-border-color-lighter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.kpi-loading {
|
.kpi-loading {
|
||||||
height: 38px;
|
height: 36px;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 响应式调整 */
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.kpi-card {
|
||||||
|
min-height: 120px;
|
||||||
|
padding: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.kpi-title {
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.kpi-value {
|
||||||
|
font-size: 28px;
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-container class="layout-container">
|
<el-container class="layout-container">
|
||||||
<el-aside :width="isCollapsed ? '72px' : '240px'" class="layout-aside" :class="{ collapsed: isCollapsed }" v-if="isAdmin || study.currentStudy">
|
<el-aside :width="isCollapsed ? '68px' : '200px'" class="layout-aside" :class="{ collapsed: isCollapsed }" v-if="isAdmin || study.currentStudy">
|
||||||
<div class="aside-logo">
|
<div class="aside-logo">
|
||||||
<div class="logo-icon"></div>
|
<div class="logo-icon"></div>
|
||||||
<span class="logo-text">{{ TEXT.common.appName }}</span>
|
<span class="logo-text">{{ TEXT.common.appName }}</span>
|
||||||
@@ -100,9 +100,50 @@
|
|||||||
</svg>
|
</svg>
|
||||||
</el-icon>
|
</el-icon>
|
||||||
</el-button>
|
</el-button>
|
||||||
|
|
||||||
|
<!-- 移入 Header 的面包屑 -->
|
||||||
|
<div v-if="breadcrumbs.length" class="header-breadcrumb">
|
||||||
|
<template v-for="(item, index) in breadcrumbs" :key="index">
|
||||||
|
<!-- 带下拉的选择器类型 -->
|
||||||
|
<el-dropdown v-if="item.hasDropdown" trigger="click" @command="handleBreadcrumbCommand">
|
||||||
|
<div class="breadcrumb-item-wrapper is-link">
|
||||||
|
<span class="breadcrumb-item-text is-link-text">{{ item.label }}</span>
|
||||||
|
<el-icon class="breadcrumb-dropdown-icon"><ArrowDown /></el-icon>
|
||||||
|
</div>
|
||||||
|
<template #dropdown>
|
||||||
|
<el-dropdown-menu class="breadcrumb-dropdown-menu">
|
||||||
|
<template v-if="item.type === 'study'">
|
||||||
|
<el-dropdown-item v-for="s in studies" :key="s.id" :command="{ type: 'study', value: s }" :class="{ active: study.currentStudy?.id === s.id }">
|
||||||
|
{{ s.name }}
|
||||||
|
</el-dropdown-item>
|
||||||
|
</template>
|
||||||
|
<template v-else-if="item.type === 'site'">
|
||||||
|
<el-dropdown-item :command="{ type: 'site', value: null }" :class="{ active: !study.currentSite }">
|
||||||
|
{{ TEXT.common.labels.allSites || '所有中心' }}
|
||||||
|
</el-dropdown-item>
|
||||||
|
<el-dropdown-item v-for="s in sites" :key="s.id" :command="{ type: 'site', value: s }" :class="{ active: study.currentSite?.id === s.id }">
|
||||||
|
{{ s.name }}
|
||||||
|
</el-dropdown-item>
|
||||||
|
</template>
|
||||||
|
</el-dropdown-menu>
|
||||||
|
</template>
|
||||||
|
</el-dropdown>
|
||||||
|
|
||||||
|
<!-- 普通链接或静态文本 -->
|
||||||
|
<div
|
||||||
|
v-else
|
||||||
|
class="breadcrumb-item-wrapper"
|
||||||
|
:class="{ 'is-link': item.path && index < breadcrumbs.length - 1 }"
|
||||||
|
@click="item.path && index < breadcrumbs.length - 1 && router.push(item.path)"
|
||||||
|
>
|
||||||
|
<span class="breadcrumb-item-text" :class="{ 'is-link-text': index > 0 && index < breadcrumbs.length - 1 }">{{ item.label }}</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<span v-if="index < breadcrumbs.length - 1" class="breadcrumb-separator">/</span>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="header-right">
|
<div class="header-right">
|
||||||
<StudySelector />
|
|
||||||
<el-dropdown trigger="click" @command="onCommand" class="user-profile">
|
<el-dropdown trigger="click" @command="onCommand" class="user-profile">
|
||||||
<span class="dropdown-trigger compact">
|
<span class="dropdown-trigger compact">
|
||||||
<el-avatar
|
<el-avatar
|
||||||
@@ -131,6 +172,7 @@
|
|||||||
</el-dropdown>
|
</el-dropdown>
|
||||||
</div>
|
</div>
|
||||||
</el-header>
|
</el-header>
|
||||||
|
|
||||||
|
|
||||||
<el-main class="layout-main">
|
<el-main class="layout-main">
|
||||||
<div class="content-wrapper">
|
<div class="content-wrapper">
|
||||||
@@ -146,16 +188,18 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, ref } from "vue";
|
import { computed, onMounted, ref, watch } from "vue";
|
||||||
import { useRoute, useRouter } from "vue-router";
|
import { useRoute, useRouter } from "vue-router";
|
||||||
import { useAuthStore } from "../store/auth";
|
import { useAuthStore } from "../store/auth";
|
||||||
import { useStudyStore } from "../store/study";
|
import { useStudyStore } from "../store/study";
|
||||||
import StudySelector from "./StudySelector.vue";
|
import { fetchStudies } from "../api/studies";
|
||||||
|
import { fetchSites } from "../api/sites";
|
||||||
import { TEXT } from "../locales";
|
import { TEXT } from "../locales";
|
||||||
import {
|
import {
|
||||||
Monitor, User, Suitcase, House, Calendar, Flag, ChatDotRound,
|
Monitor, User, Suitcase, House, Calendar, Flag, ChatDotRound,
|
||||||
CircleCheck, Box, Coin, Notebook, Document, ArrowDown, SwitchButton, Files
|
CircleCheck, Box, Coin, Notebook, Document, ArrowDown, SwitchButton, Files
|
||||||
} from "@element-plus/icons-vue";
|
} from "@element-plus/icons-vue";
|
||||||
|
import { ElMessage } from "element-plus";
|
||||||
|
|
||||||
const auth = useAuthStore();
|
const auth = useAuthStore();
|
||||||
const study = useStudyStore();
|
const study = useStudyStore();
|
||||||
@@ -189,6 +233,121 @@ const activeMenu = computed(() => {
|
|||||||
return path;
|
return path;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const studies = ref<any[]>([]);
|
||||||
|
const sites = ref<any[]>([]);
|
||||||
|
|
||||||
|
const loadStudies = async () => {
|
||||||
|
try {
|
||||||
|
const { data } = await fetchStudies();
|
||||||
|
studies.value = Array.isArray(data) ? data : (data as any).items || [];
|
||||||
|
} catch {}
|
||||||
|
};
|
||||||
|
|
||||||
|
const loadSites = async () => {
|
||||||
|
if (!study.currentStudy) {
|
||||||
|
sites.value = [];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const { data } = await fetchSites(study.currentStudy.id, { limit: 500 });
|
||||||
|
sites.value = Array.isArray(data) ? data : (data as any).items || [];
|
||||||
|
} catch {
|
||||||
|
sites.value = [];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const breadcrumbs = computed(() => {
|
||||||
|
const items: any[] = [];
|
||||||
|
|
||||||
|
if (route.path.startsWith("/admin")) {
|
||||||
|
items.push({
|
||||||
|
label: TEXT.menu.admin,
|
||||||
|
path: "/admin/users"
|
||||||
|
});
|
||||||
|
} else if (study.currentStudy) {
|
||||||
|
// 1. 项目名
|
||||||
|
items.push({
|
||||||
|
label: (study.currentStudy.name || "").replace(/^示例项目[::]/, ''),
|
||||||
|
path: "/project/overview",
|
||||||
|
hasDropdown: true,
|
||||||
|
type: 'study'
|
||||||
|
});
|
||||||
|
|
||||||
|
// 2. 中心名 (逻辑增强:详情页优先显示具体中心,列表页显示筛选中心)
|
||||||
|
items.push({
|
||||||
|
label: study.viewContext?.siteName || study.currentSite?.name || "所有中心",
|
||||||
|
hasDropdown: true,
|
||||||
|
type: 'site'
|
||||||
|
});
|
||||||
|
|
||||||
|
// 3. 模块名 (逻辑增强:当在详情页时显示所属模块)
|
||||||
|
const moduleMap: Record<string, { label: string, path: string }> = {
|
||||||
|
"/fees/contracts": { label: TEXT.menu.feeContracts, path: "/fees/contracts" },
|
||||||
|
"/fees/special": { label: TEXT.menu.feeSpecials, path: "/fees/special" },
|
||||||
|
"/drug/shipments": { label: TEXT.menu.drugShipments, path: "/drug/shipments" },
|
||||||
|
"/subjects": { label: TEXT.menu.subjects, path: "/subjects" },
|
||||||
|
"/startup/feasibility": { label: TEXT.menu.startupFeasibilityEthics, path: "/startup/feasibility-ethics" },
|
||||||
|
"/startup/ethics": { label: TEXT.menu.startupFeasibilityEthics, path: "/startup/feasibility-ethics" },
|
||||||
|
"/startup/kickoff": { label: TEXT.menu.startupMeetingAuth, path: "/startup/meeting-auth" },
|
||||||
|
"/startup/training": { label: TEXT.menu.startupMeetingAuth, path: "/startup/meeting-auth" },
|
||||||
|
"/knowledge/medical-consult": { label: TEXT.menu.knowledgeMedicalConsult, path: "/knowledge/medical-consult" },
|
||||||
|
"/knowledge/notes": { label: TEXT.menu.knowledgeNotes, path: "/knowledge/notes" },
|
||||||
|
};
|
||||||
|
|
||||||
|
let matchedModule = null;
|
||||||
|
for (const prefix in moduleMap) {
|
||||||
|
if (route.path.startsWith(prefix)) {
|
||||||
|
matchedModule = moduleMap[prefix];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (matchedModule) {
|
||||||
|
// 如果当前路径不是模块主路径,说明在子页面/详情页,需要把模块名展示出来
|
||||||
|
if (route.path !== matchedModule.path) {
|
||||||
|
items.push({
|
||||||
|
label: matchedModule.label,
|
||||||
|
path: matchedModule.path
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. 当前页面标题
|
||||||
|
const title = route.meta?.title as string | undefined;
|
||||||
|
if (title && title !== study.currentStudy?.name && title !== TEXT.menu.projectOverview && title !== (study.viewContext?.siteName || study.currentSite?.name)) {
|
||||||
|
// 检查 title 是否已经作为模块名添加过了
|
||||||
|
const isModuleTitle = items.some(item => item.label === title);
|
||||||
|
if (!isModuleTitle) {
|
||||||
|
items.push({
|
||||||
|
label: title,
|
||||||
|
path: route.path
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return items;
|
||||||
|
});
|
||||||
|
|
||||||
|
const handleBreadcrumbCommand = (cmd: any) => {
|
||||||
|
if (cmd.type === 'study') {
|
||||||
|
study.setCurrentStudy(cmd.value);
|
||||||
|
router.push("/project/overview");
|
||||||
|
} else if (cmd.type === 'site') {
|
||||||
|
study.setCurrentSite(cmd.value);
|
||||||
|
// 刷新当前页面或根据业务逻辑处理
|
||||||
|
ElMessage.success(`已切换至: ${cmd.value?.name || '所有中心'}`);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
watch(() => study.currentStudy, () => {
|
||||||
|
loadSites();
|
||||||
|
}, { immediate: true });
|
||||||
|
|
||||||
|
watch(() => route.path, () => {
|
||||||
|
study.setViewContext(null);
|
||||||
|
});
|
||||||
|
|
||||||
const toggleCollapse = () => {
|
const toggleCollapse = () => {
|
||||||
isCollapsed.value = !isCollapsed.value;
|
isCollapsed.value = !isCollapsed.value;
|
||||||
localStorage.setItem("ctms_sidebar_collapsed", isCollapsed.value ? "1" : "0");
|
localStorage.setItem("ctms_sidebar_collapsed", isCollapsed.value ? "1" : "0");
|
||||||
@@ -200,6 +359,10 @@ const onLogout = () => {
|
|||||||
router.replace("/login");
|
router.replace("/login");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
loadStudies();
|
||||||
|
});
|
||||||
|
|
||||||
const onCommand = (cmd: string) => {
|
const onCommand = (cmd: string) => {
|
||||||
if (cmd === "logout") {
|
if (cmd === "logout") {
|
||||||
onLogout();
|
onLogout();
|
||||||
@@ -216,12 +379,12 @@ const onCommand = (cmd: string) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.layout-aside {
|
.layout-aside {
|
||||||
background-color: #ffffff;
|
background-color: #2c3e50;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
box-shadow: none;
|
box-shadow: 0 0 15px rgba(0, 0, 0, 0.1);
|
||||||
z-index: 10;
|
z-index: 10;
|
||||||
border-right: 1px solid var(--ctms-border-color);
|
border-right: none;
|
||||||
transition: width 0.18s ease;
|
transition: width 0.18s ease;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
@@ -249,7 +412,7 @@ const onCommand = (cmd: string) => {
|
|||||||
height: 64px;
|
height: 64px;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 0 24px;
|
padding: 0 16px;
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
transition: padding 0.18s ease;
|
transition: padding 0.18s ease;
|
||||||
}
|
}
|
||||||
@@ -257,17 +420,17 @@ const onCommand = (cmd: string) => {
|
|||||||
.logo-icon {
|
.logo-icon {
|
||||||
width: 28px;
|
width: 28px;
|
||||||
height: 28px;
|
height: 28px;
|
||||||
background: var(--ctms-primary);
|
background: #ffffff;
|
||||||
border-radius: 10px;
|
border-radius: 8px;
|
||||||
margin-right: 12px;
|
margin-right: 12px;
|
||||||
box-shadow: 0 6px 14px rgba(63, 93, 117, 0.18);
|
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
|
||||||
}
|
}
|
||||||
|
|
||||||
.logo-text {
|
.logo-text {
|
||||||
color: var(--ctms-text-main);
|
color: #ffffff;
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
font-weight: 800;
|
font-weight: 800;
|
||||||
letter-spacing: 1px;
|
letter-spacing: 0.5px;
|
||||||
transition: opacity 0.18s ease, transform 0.18s ease;
|
transition: opacity 0.18s ease, transform 0.18s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -280,63 +443,68 @@ const onCommand = (cmd: string) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.menu-divider {
|
.menu-divider {
|
||||||
padding: 16px 24px 8px;
|
padding: 16px 16px 8px;
|
||||||
font-size: 11px;
|
font-size: 10px;
|
||||||
font-weight: 600;
|
font-weight: 700;
|
||||||
color: var(--ctms-text-secondary);
|
color: rgba(255, 255, 255, 0.4);
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
letter-spacing: 1.5px;
|
letter-spacing: 1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
:deep(.el-menu-item) {
|
.layout-aside :deep(.el-menu-item) {
|
||||||
height: 44px;
|
height: 44px;
|
||||||
line-height: 44px;
|
line-height: 44px;
|
||||||
margin: 4px 12px;
|
margin: 4px 10px;
|
||||||
border-radius: 12px;
|
border-radius: 8px;
|
||||||
color: var(--ctms-text-regular) !important;
|
color: #f1f5f9 !important;
|
||||||
transition: var(--ctms-transition);
|
transition: var(--ctms-transition);
|
||||||
}
|
}
|
||||||
|
|
||||||
:deep(.el-menu-item:hover) {
|
.layout-aside :deep(.el-menu-item:hover) {
|
||||||
color: var(--ctms-text-main) !important;
|
color: #ffffff !important;
|
||||||
background-color: var(--ctms-bg-muted) !important;
|
background-color: rgba(255, 255, 255, 0.08) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
:deep(.el-menu-item.is-active) {
|
.layout-aside :deep(.el-menu-item.is-active) {
|
||||||
color: var(--ctms-primary) !important;
|
color: #ffffff !important;
|
||||||
background-color: var(--ctms-primary-light) !important;
|
background-color: rgba(255, 255, 255, 0.12) !important;
|
||||||
box-shadow: none;
|
box-shadow: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
:deep(.el-menu-item.is-active::before) {
|
.layout-aside :deep(.el-menu-item.is-active::before) {
|
||||||
content: "";
|
content: "";
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 8px;
|
left: 0;
|
||||||
top: 12px;
|
top: 10px;
|
||||||
bottom: 12px;
|
bottom: 10px;
|
||||||
width: 3px;
|
width: 3px;
|
||||||
background-color: var(--ctms-primary);
|
background-color: #3b82f6;
|
||||||
border-radius: 999px;
|
border-radius: 0 4px 4px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
:deep(.el-sub-menu__title) {
|
.layout-aside :deep(.el-sub-menu__title) {
|
||||||
color: var(--ctms-text-regular) !important;
|
color: #f1f5f9 !important;
|
||||||
margin: 4px 12px;
|
margin: 4px 10px;
|
||||||
border-radius: 12px;
|
border-radius: 8px;
|
||||||
height: 44px;
|
height: 44px;
|
||||||
line-height: 44px;
|
line-height: 44px;
|
||||||
}
|
}
|
||||||
|
|
||||||
:deep(.el-sub-menu.is-active .el-sub-menu__title) {
|
.layout-aside :deep(.el-sub-menu__title:hover) {
|
||||||
color: var(--ctms-text-main) !important;
|
color: #ffffff !important;
|
||||||
|
background-color: rgba(255, 255, 255, 0.08) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
:deep(.el-menu--inline) {
|
.layout-aside :deep(.el-sub-menu.is-active .el-sub-menu__title) {
|
||||||
|
color: #ffffff !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.layout-aside :deep(.el-menu--inline) {
|
||||||
background-color: transparent !important;
|
background-color: transparent !important;
|
||||||
margin: 0 !important;
|
margin: 0 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
:deep(.el-menu--inline .el-menu-item) {
|
.layout-aside :deep(.el-menu--inline .el-menu-item) {
|
||||||
padding-left: 48px !important;
|
padding-left: 48px !important;
|
||||||
margin: 2px 12px;
|
margin: 2px 12px;
|
||||||
}
|
}
|
||||||
@@ -350,7 +518,53 @@ const onCommand = (cmd: string) => {
|
|||||||
box-shadow: none;
|
box-shadow: none;
|
||||||
height: 64px !important;
|
height: 64px !important;
|
||||||
z-index: 9;
|
z-index: 9;
|
||||||
border-bottom: 1px solid var(--ctms-border-color);
|
border-bottom: 1px solid #f1f5f9;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-breadcrumb {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
color: var(--ctms-text-regular);
|
||||||
|
font-size: 14px;
|
||||||
|
margin-left: 20px;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.breadcrumb-item-wrapper {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 4px;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.breadcrumb-item-wrapper.is-link {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.breadcrumb-item-wrapper.is-link:hover {
|
||||||
|
opacity: 0.7;
|
||||||
|
}
|
||||||
|
|
||||||
|
.is-link-text {
|
||||||
|
color: #3b82f6;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.breadcrumb-item-text {
|
||||||
|
font-weight: 400;
|
||||||
|
}
|
||||||
|
|
||||||
|
.breadcrumb-dropdown-icon {
|
||||||
|
font-size: 12px;
|
||||||
|
color: #94a3b8;
|
||||||
|
margin-top: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.breadcrumb-separator {
|
||||||
|
margin: 0 4px;
|
||||||
|
color: #cbd5e1;
|
||||||
|
font-weight: 300;
|
||||||
}
|
}
|
||||||
|
|
||||||
.header-right {
|
.header-right {
|
||||||
@@ -422,7 +636,7 @@ const onCommand = (cmd: string) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.content-wrapper {
|
.content-wrapper {
|
||||||
padding: 28px;
|
padding: 16px;
|
||||||
min-height: calc(100vh - 64px);
|
min-height: calc(100vh - 64px);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -441,4 +655,13 @@ const onCommand = (cmd: string) => {
|
|||||||
opacity: 0;
|
opacity: 0;
|
||||||
transform: translateX(15px);
|
transform: translateX(15px);
|
||||||
}
|
}
|
||||||
|
.breadcrumb-dropdown-menu {
|
||||||
|
min-width: 200px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.breadcrumb-dropdown-menu :deep(.el-dropdown-menu__item.active) {
|
||||||
|
color: var(--el-color-primary);
|
||||||
|
background-color: var(--el-color-primary-light-9);
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -65,6 +65,8 @@ export const TEXT = {
|
|||||||
input: "请输入",
|
input: "请输入",
|
||||||
select: "请选择",
|
select: "请选择",
|
||||||
keyword: "输入关键词",
|
keyword: "输入关键词",
|
||||||
|
startDate: "开始日期",
|
||||||
|
endDate: "结束日期",
|
||||||
},
|
},
|
||||||
labels: {
|
labels: {
|
||||||
attachments: "附件",
|
attachments: "附件",
|
||||||
@@ -86,6 +88,7 @@ export const TEXT = {
|
|||||||
userInitialFallback: "用",
|
userInitialFallback: "用",
|
||||||
userFallback: "用户",
|
userFallback: "用户",
|
||||||
basicInfo: "基本信息",
|
basicInfo: "基本信息",
|
||||||
|
allSites: "所有中心",
|
||||||
},
|
},
|
||||||
units: {
|
units: {
|
||||||
case: "例",
|
case: "例",
|
||||||
@@ -309,6 +312,9 @@ export const TEXT = {
|
|||||||
alertOk: "项目运行状态良好,所有关键指标均在可控范围内。",
|
alertOk: "项目运行状态良好,所有关键指标均在可控范围内。",
|
||||||
noMilestones: "暂无节点",
|
noMilestones: "暂无节点",
|
||||||
progressLabel: "总体进度: {rate}",
|
progressLabel: "总体进度: {rate}",
|
||||||
|
notificationsTitle: "通知",
|
||||||
|
notificationsSubtitle: "文件版本更新将推送在此处",
|
||||||
|
notificationsEmpty: "暂无通知",
|
||||||
},
|
},
|
||||||
financeContracts: {
|
financeContracts: {
|
||||||
title: "合同费用",
|
title: "合同费用",
|
||||||
@@ -420,6 +426,8 @@ export const TEXT = {
|
|||||||
attachmentOther: "其他",
|
attachmentOther: "其他",
|
||||||
attachmentOtherDesc: "上传其他支持性材料",
|
attachmentOtherDesc: "上传其他支持性材料",
|
||||||
attachmentOtherEmpty: "暂无其他附件",
|
attachmentOtherEmpty: "暂无其他附件",
|
||||||
|
unpaid: "未打款",
|
||||||
|
unverified: "未核销",
|
||||||
uploadHint: "保存后可上传凭证/发票/其他附件",
|
uploadHint: "保存后可上传凭证/发票/其他附件",
|
||||||
},
|
},
|
||||||
drugShipments: {
|
drugShipments: {
|
||||||
@@ -456,7 +464,7 @@ export const TEXT = {
|
|||||||
docType: "类型",
|
docType: "类型",
|
||||||
currentVersion: "当前版本",
|
currentVersion: "当前版本",
|
||||||
status: "状态",
|
status: "状态",
|
||||||
effectiveAt: "生效时间",
|
effectiveAt: "更新时间",
|
||||||
updatedAt: "更新",
|
updatedAt: "更新",
|
||||||
actions: "操作",
|
actions: "操作",
|
||||||
},
|
},
|
||||||
@@ -496,7 +504,7 @@ export const TEXT = {
|
|||||||
dueAt: "截止日期",
|
dueAt: "截止日期",
|
||||||
},
|
},
|
||||||
tabs: {
|
tabs: {
|
||||||
versions: "版本时间线",
|
versions: "版本管理",
|
||||||
distributions: "抄送",
|
distributions: "抄送",
|
||||||
audit: "审计",
|
audit: "审计",
|
||||||
},
|
},
|
||||||
@@ -592,6 +600,7 @@ export const TEXT = {
|
|||||||
title: "参与者管理",
|
title: "参与者管理",
|
||||||
subtitle: "参与者、病史、访视、AE 综合管理",
|
subtitle: "参与者、病史、访视、AE 综合管理",
|
||||||
subjectLabel: "参与者",
|
subjectLabel: "参与者",
|
||||||
|
screeningNo: "筛选号",
|
||||||
empty: "暂无参与者记录",
|
empty: "暂无参与者记录",
|
||||||
},
|
},
|
||||||
subjectForm: {
|
subjectForm: {
|
||||||
@@ -771,6 +780,11 @@ export const TEXT = {
|
|||||||
detailTitle: "项目详情",
|
detailTitle: "项目详情",
|
||||||
basicInfo: "项目基本信息",
|
basicInfo: "项目基本信息",
|
||||||
filesTitle: "项目通用文件",
|
filesTitle: "项目通用文件",
|
||||||
|
lockConfirmPrompt: "请输入“确认锁定”以继续",
|
||||||
|
lockConfirmTitle: "二次确认",
|
||||||
|
lockConfirmPlaceholder: "请输入确认锁定",
|
||||||
|
lockConfirmMismatch: "输入内容不匹配",
|
||||||
|
lockConfirmMismatchWarning: "输入内容不匹配,已取消锁定",
|
||||||
},
|
},
|
||||||
adminProjectMembers: {
|
adminProjectMembers: {
|
||||||
title: "项目成员配置(角色仅在当前项目内生效)",
|
title: "项目成员配置(角色仅在当前项目内生效)",
|
||||||
@@ -862,6 +876,7 @@ export const TEXT = {
|
|||||||
todayEmpty: "今天暂时没有需要紧急处理的业务事项",
|
todayEmpty: "今天暂时没有需要紧急处理的业务事项",
|
||||||
overdueEmpty: "太棒了!目前没有任何逾期待处理的事项",
|
overdueEmpty: "太棒了!目前没有任何逾期待处理的事项",
|
||||||
actionEmpty: "暂无需要您处理的事项",
|
actionEmpty: "暂无需要您处理的事项",
|
||||||
|
newLostVisit: "新增失访",
|
||||||
quickEntryTitle: "快捷入口",
|
quickEntryTitle: "快捷入口",
|
||||||
enterProject: "进入项目",
|
enterProject: "进入项目",
|
||||||
quickEmpty: "暂无需要你处理的事项",
|
quickEmpty: "暂无需要你处理的事项",
|
||||||
@@ -943,13 +958,37 @@ export const TEXT = {
|
|||||||
CANCELLED: "已取消",
|
CANCELLED: "已取消",
|
||||||
},
|
},
|
||||||
aeSeriousness: {
|
aeSeriousness: {
|
||||||
SERIOUS: "严重",
|
I: "I",
|
||||||
NON_SERIOUS: "一般",
|
II: "II",
|
||||||
|
III: "III",
|
||||||
|
IV: "IV",
|
||||||
|
V: "V",
|
||||||
},
|
},
|
||||||
aeSeverity: {
|
aeSeverity: {
|
||||||
MILD: "轻度",
|
I: "I",
|
||||||
MODERATE: "中度",
|
II: "II",
|
||||||
SEVERE: "重度",
|
III: "III",
|
||||||
|
IV: "IV",
|
||||||
|
V: "V",
|
||||||
|
MILD: "I",
|
||||||
|
MODERATE: "II",
|
||||||
|
SEVERE: "III",
|
||||||
|
},
|
||||||
|
aeCausality: {
|
||||||
|
肯定有关: "肯定有关",
|
||||||
|
很可能有关: "很可能有关",
|
||||||
|
可能有关: "可能有关",
|
||||||
|
可能无关: "可能无关",
|
||||||
|
无关: "无关",
|
||||||
|
待评估: "待评估",
|
||||||
|
},
|
||||||
|
aeOutcome: {
|
||||||
|
痊愈: "痊愈",
|
||||||
|
好转: "好转",
|
||||||
|
持续: "持续",
|
||||||
|
恶化: "恶化",
|
||||||
|
死亡: "死亡",
|
||||||
|
失访: "失访",
|
||||||
},
|
},
|
||||||
aeStatus: {
|
aeStatus: {
|
||||||
NEW: "新建",
|
NEW: "新建",
|
||||||
@@ -1053,7 +1092,7 @@ export const TEXT = {
|
|||||||
USER: "人员",
|
USER: "人员",
|
||||||
},
|
},
|
||||||
scopeType: {
|
scopeType: {
|
||||||
GLOBAL: "全局",
|
GLOBAL: "通用",
|
||||||
SITE: "中心",
|
SITE: "中心",
|
||||||
DERIVED: "派生",
|
DERIVED: "派生",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -505,10 +505,6 @@ router.beforeEach(async (to, _from, next) => {
|
|||||||
next({ path: "/workbench" });
|
next({ path: "/workbench" });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (to.path === "/workbench" && studyStore.currentStudy) {
|
|
||||||
next({ path: "/project/overview" });
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -5,12 +5,18 @@ import type { Study } from "../types/api";
|
|||||||
|
|
||||||
const STUDY_KEY = "ctms_current_study";
|
const STUDY_KEY = "ctms_current_study";
|
||||||
const STUDY_ROLE_KEY = "ctms_current_study_role";
|
const STUDY_ROLE_KEY = "ctms_current_study_role";
|
||||||
|
const SITE_KEY = "ctms_current_site";
|
||||||
|
|
||||||
export const useStudyStore = defineStore("study", () => {
|
export const useStudyStore = defineStore("study", () => {
|
||||||
const currentStudy = ref<Study | null>(null);
|
const currentStudy = ref<Study | null>(null);
|
||||||
const currentStudyRole = ref<string | null>(null);
|
const currentStudyRole = ref<string | null>(null);
|
||||||
|
const currentSite = ref<any | null>(null);
|
||||||
|
const viewContext = ref<{ siteName?: string } | null>(null);
|
||||||
|
|
||||||
const setCurrentStudy = (study: Study) => {
|
const setCurrentStudy = (study: Study) => {
|
||||||
|
currentStudy.value = study;
|
||||||
|
currentSite.value = null; // 切换项目时清空中心
|
||||||
|
localStorage.removeItem(SITE_KEY);
|
||||||
currentStudy.value = study;
|
currentStudy.value = study;
|
||||||
const role = (study as any).role_in_study || (study as any).role || null;
|
const role = (study as any).role_in_study || (study as any).role || null;
|
||||||
currentStudyRole.value = role;
|
currentStudyRole.value = role;
|
||||||
@@ -31,6 +37,15 @@ export const useStudyStore = defineStore("study", () => {
|
|||||||
}
|
}
|
||||||
const savedRole = localStorage.getItem(STUDY_ROLE_KEY);
|
const savedRole = localStorage.getItem(STUDY_ROLE_KEY);
|
||||||
currentStudyRole.value = savedRole || null;
|
currentStudyRole.value = savedRole || null;
|
||||||
|
|
||||||
|
const savedSite = localStorage.getItem(SITE_KEY);
|
||||||
|
if (savedSite) {
|
||||||
|
try {
|
||||||
|
currentSite.value = JSON.parse(savedSite);
|
||||||
|
} catch {
|
||||||
|
currentSite.value = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const ensureDefaultStudy = async () => {
|
const ensureDefaultStudy = async () => {
|
||||||
@@ -51,8 +66,11 @@ export const useStudyStore = defineStore("study", () => {
|
|||||||
const clearCurrentStudy = () => {
|
const clearCurrentStudy = () => {
|
||||||
currentStudy.value = null;
|
currentStudy.value = null;
|
||||||
currentStudyRole.value = null;
|
currentStudyRole.value = null;
|
||||||
|
currentSite.value = null;
|
||||||
|
viewContext.value = null;
|
||||||
localStorage.removeItem(STUDY_KEY);
|
localStorage.removeItem(STUDY_KEY);
|
||||||
localStorage.removeItem(STUDY_ROLE_KEY);
|
localStorage.removeItem(STUDY_ROLE_KEY);
|
||||||
|
localStorage.removeItem(SITE_KEY);
|
||||||
};
|
};
|
||||||
|
|
||||||
const setCurrentStudyRole = (role: string | null) => {
|
const setCurrentStudyRole = (role: string | null) => {
|
||||||
@@ -64,11 +82,28 @@ export const useStudyStore = defineStore("study", () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const setCurrentSite = (site: any | null) => {
|
||||||
|
currentSite.value = site;
|
||||||
|
if (site) {
|
||||||
|
localStorage.setItem(SITE_KEY, JSON.stringify(site));
|
||||||
|
} else {
|
||||||
|
localStorage.removeItem(SITE_KEY);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const setViewContext = (ctx: { siteName?: string } | null) => {
|
||||||
|
viewContext.value = ctx;
|
||||||
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
currentStudy,
|
currentStudy,
|
||||||
currentStudyRole,
|
currentStudyRole,
|
||||||
|
currentSite,
|
||||||
|
viewContext,
|
||||||
setCurrentStudy,
|
setCurrentStudy,
|
||||||
setCurrentStudyRole,
|
setCurrentStudyRole,
|
||||||
|
setCurrentSite,
|
||||||
|
setViewContext,
|
||||||
loadCurrentStudy,
|
loadCurrentStudy,
|
||||||
ensureDefaultStudy,
|
ensureDefaultStudy,
|
||||||
clearCurrentStudy,
|
clearCurrentStudy,
|
||||||
|
|||||||
@@ -319,6 +319,13 @@ body {
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ctms-page-title,
|
||||||
|
.ctms-page-subtitle,
|
||||||
|
.page-title,
|
||||||
|
.page-subtitle {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
.ctms-page-actions {
|
.ctms-page-actions {
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -456,4 +463,4 @@ body {
|
|||||||
|
|
||||||
.text-sm {
|
.text-sm {
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
export interface NotificationItem {
|
||||||
|
id: string;
|
||||||
|
document_id: string;
|
||||||
|
version_id: string;
|
||||||
|
document_title: string;
|
||||||
|
document_no?: string | null;
|
||||||
|
version_no: string;
|
||||||
|
change_summary?: string | null;
|
||||||
|
effective_at?: string | null;
|
||||||
|
created_at: string;
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
export interface VisitLostItem {
|
||||||
|
visit_id: string;
|
||||||
|
subject_id: string;
|
||||||
|
subject_no: string;
|
||||||
|
site_id?: string | null;
|
||||||
|
visit_code: string;
|
||||||
|
status: string;
|
||||||
|
updated_at: string;
|
||||||
|
}
|
||||||
+1069
-132
File diff suppressed because it is too large
Load Diff
@@ -67,6 +67,33 @@
|
|||||||
class="home-alert"
|
class="home-alert"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<!-- 通知 -->
|
||||||
|
<el-card class="notifications-card">
|
||||||
|
<div class="notifications-header">
|
||||||
|
<span class="notifications-title">{{ TEXT.modules.projectOverview.notificationsTitle }}</span>
|
||||||
|
<span class="notifications-subtitle">{{ TEXT.modules.projectOverview.notificationsSubtitle }}</span>
|
||||||
|
</div>
|
||||||
|
<el-skeleton v-if="loading.notifications" :rows="3" animated />
|
||||||
|
<StateEmpty v-else-if="!notifications.length" :description="TEXT.modules.projectOverview.notificationsEmpty" />
|
||||||
|
<div v-else class="notification-list">
|
||||||
|
<div class="notification-item" v-for="item in notifications" :key="item.id">
|
||||||
|
<div class="notification-main">
|
||||||
|
<div class="notification-title">
|
||||||
|
<span class="notification-doc">{{ item.document_title }}</span>
|
||||||
|
<span class="notification-version">V{{ item.version_no }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="notification-meta">
|
||||||
|
<span class="notification-time">{{ formatDate(item.effective_at || item.created_at) }}</span>
|
||||||
|
<span v-if="item.change_summary" class="notification-summary">{{ item.change_summary }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<el-button link type="primary" @click="openDocument(item.document_id)">
|
||||||
|
{{ TEXT.common.actions.view }}
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</el-card>
|
||||||
|
|
||||||
<!-- 快捷模块 -->
|
<!-- 快捷模块 -->
|
||||||
<div class="quick-nav-section">
|
<div class="quick-nav-section">
|
||||||
<QuickActions />
|
<QuickActions />
|
||||||
@@ -83,24 +110,30 @@ import { computed, onMounted, ref, watch } from "vue";
|
|||||||
import { useAuthStore } from "../store/auth";
|
import { useAuthStore } from "../store/auth";
|
||||||
import { useStudyStore } from "../store/study";
|
import { useStudyStore } from "../store/study";
|
||||||
import { fetchFinanceSummary, fetchOverdueAesCount, fetchProgress } from "../api/dashboard";
|
import { fetchFinanceSummary, fetchOverdueAesCount, fetchProgress } from "../api/dashboard";
|
||||||
|
import { listNotifications } from "../api/notifications";
|
||||||
import KpiCard from "../components/KpiCard.vue";
|
import KpiCard from "../components/KpiCard.vue";
|
||||||
import QuickActions from "../components/QuickActions.vue";
|
import QuickActions from "../components/QuickActions.vue";
|
||||||
import { List, Warning, Money } from "@element-plus/icons-vue";
|
import { List, Warning, Money } from "@element-plus/icons-vue";
|
||||||
import StateEmpty from "../components/StateEmpty.vue";
|
import StateEmpty from "../components/StateEmpty.vue";
|
||||||
import { displayEnum } from "../utils/display";
|
import { displayEnum } from "../utils/display";
|
||||||
import { TEXT } from "../locales";
|
import { TEXT } from "../locales";
|
||||||
|
import type { NotificationItem } from "../types/notifications";
|
||||||
|
import { useRouter } from "vue-router";
|
||||||
|
|
||||||
const auth = useAuthStore();
|
const auth = useAuthStore();
|
||||||
const study = useStudyStore();
|
const study = useStudyStore();
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
const progress = ref<any>(null);
|
const progress = ref<any>(null);
|
||||||
const financeSummary = ref<any>(null);
|
const financeSummary = ref<any>(null);
|
||||||
const overdueAes = ref<number>(0);
|
const overdueAes = ref<number>(0);
|
||||||
|
const notifications = ref<NotificationItem[]>([]);
|
||||||
|
|
||||||
const loading = ref({
|
const loading = ref({
|
||||||
progress: false,
|
progress: false,
|
||||||
finance: false,
|
finance: false,
|
||||||
overdueAes: false,
|
overdueAes: false,
|
||||||
|
notifications: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
const milestoneCompletionRate = computed(() => {
|
const milestoneCompletionRate = computed(() => {
|
||||||
@@ -123,20 +156,24 @@ const loadData = async () => {
|
|||||||
loading.value.progress = true;
|
loading.value.progress = true;
|
||||||
loading.value.finance = true;
|
loading.value.finance = true;
|
||||||
loading.value.overdueAes = true;
|
loading.value.overdueAes = true;
|
||||||
|
loading.value.notifications = true;
|
||||||
try {
|
try {
|
||||||
const [pRes, fRes, aesRes] = await Promise.allSettled([
|
const [pRes, fRes, aesRes, nRes] = await Promise.allSettled([
|
||||||
fetchProgress(studyId),
|
fetchProgress(studyId),
|
||||||
fetchFinanceSummary(studyId),
|
fetchFinanceSummary(studyId),
|
||||||
fetchOverdueAesCount(studyId),
|
fetchOverdueAesCount(studyId),
|
||||||
|
listNotifications(studyId, { limit: 5 }),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (pRes.status === "fulfilled") progress.value = pRes.value.data;
|
if (pRes.status === "fulfilled") progress.value = pRes.value.data;
|
||||||
if (fRes.status === "fulfilled") financeSummary.value = fRes.value.data;
|
if (fRes.status === "fulfilled") financeSummary.value = fRes.value.data;
|
||||||
if (aesRes.status === "fulfilled") overdueAes.value = aesRes.value.data?.total ?? 0;
|
if (aesRes.status === "fulfilled") overdueAes.value = aesRes.value.data?.total ?? 0;
|
||||||
|
if (nRes.status === "fulfilled") notifications.value = nRes.value.data || [];
|
||||||
} finally {
|
} finally {
|
||||||
loading.value.progress = false;
|
loading.value.progress = false;
|
||||||
loading.value.finance = false;
|
loading.value.finance = false;
|
||||||
loading.value.overdueAes = false;
|
loading.value.overdueAes = false;
|
||||||
|
loading.value.notifications = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -144,6 +181,16 @@ const resetData = () => {
|
|||||||
progress.value = null;
|
progress.value = null;
|
||||||
financeSummary.value = null;
|
financeSummary.value = null;
|
||||||
overdueAes.value = 0;
|
overdueAes.value = 0;
|
||||||
|
notifications.value = [];
|
||||||
|
};
|
||||||
|
|
||||||
|
const formatDate = (value?: string | null) => {
|
||||||
|
if (!value) return TEXT.common.fallback;
|
||||||
|
return value.replace("T", " ").replace("Z", "").split(".")[0];
|
||||||
|
};
|
||||||
|
|
||||||
|
const openDocument = (documentId: string) => {
|
||||||
|
router.push(`/documents/${documentId}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
@@ -217,6 +264,80 @@ watch(
|
|||||||
border-radius: var(--ctms-radius);
|
border-radius: var(--ctms-radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.notifications-card {
|
||||||
|
border-radius: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notifications-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: baseline;
|
||||||
|
gap: 8px;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notifications-title {
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--ctms-text-main);
|
||||||
|
}
|
||||||
|
|
||||||
|
.notifications-subtitle {
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--ctms-text-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.notification-list {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notification-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 12px 14px;
|
||||||
|
border-radius: 12px;
|
||||||
|
background: var(--ctms-bg-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.notification-main {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notification-title {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
font-weight: 500;
|
||||||
|
color: var(--ctms-text-main);
|
||||||
|
}
|
||||||
|
|
||||||
|
.notification-version {
|
||||||
|
font-size: 12px;
|
||||||
|
padding: 2px 6px;
|
||||||
|
border-radius: 10px;
|
||||||
|
background: var(--ctms-primary-light);
|
||||||
|
color: var(--ctms-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.notification-meta {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--ctms-text-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.notification-summary {
|
||||||
|
max-width: 360px;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
.quick-nav-section {
|
.quick-nav-section {
|
||||||
margin-top: 8px;
|
margin-top: 8px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="page">
|
<div class="page">
|
||||||
<el-card>
|
<el-card shadow="never" class="main-content-card">
|
||||||
<div class="header">
|
<div class="filter-container">
|
||||||
<div>
|
<div class="filter-form">
|
||||||
<h3>{{ TEXT.modules.adminUserApproval.title }}</h3>
|
<el-tag type="info" effect="plain" class="filter-label-tag">{{ TEXT.common.fields.status }}</el-tag>
|
||||||
<p>{{ TEXT.modules.adminUserApproval.subtitle }}</p>
|
<el-select v-model="status" style="width: 140px" @change="loadUsers" class="filter-select-comp">
|
||||||
|
<el-option :label="TEXT.enums.userStatus.PENDING" value="PENDING" />
|
||||||
|
<el-option :label="TEXT.enums.userStatus.ACTIVE" value="ACTIVE" />
|
||||||
|
<el-option :label="TEXT.enums.userStatus.REJECTED" value="REJECTED" />
|
||||||
|
<el-option :label="TEXT.enums.userStatus.DISABLED" value="DISABLED" />
|
||||||
|
</el-select>
|
||||||
|
<div class="filter-spacer"></div>
|
||||||
</div>
|
</div>
|
||||||
<el-select v-model="status" size="small" style="width: 180px" @change="loadUsers">
|
|
||||||
<el-option :label="TEXT.enums.userStatus.PENDING" value="PENDING" />
|
|
||||||
<el-option :label="TEXT.enums.userStatus.ACTIVE" value="ACTIVE" />
|
|
||||||
<el-option :label="TEXT.enums.userStatus.REJECTED" value="REJECTED" />
|
|
||||||
<el-option :label="TEXT.enums.userStatus.DISABLED" value="DISABLED" />
|
|
||||||
</el-select>
|
|
||||||
</div>
|
</div>
|
||||||
<el-table :data="users" v-loading="loading" style="width: 100%">
|
<el-table :data="users" v-loading="loading" style="width: 100%">
|
||||||
<el-table-column prop="email" :label="TEXT.common.fields.email" min-width="200" />
|
<el-table-column prop="email" :label="TEXT.common.fields.email" min-width="200" />
|
||||||
@@ -120,19 +120,34 @@ onMounted(() => {
|
|||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.page {
|
.page {
|
||||||
padding: 16px;
|
|
||||||
}
|
|
||||||
.header {
|
|
||||||
display: flex;
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.main-content-card :deep(.el-card__body) {
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-container {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-form {
|
||||||
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
|
gap: 12px;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
|
||||||
margin-bottom: 12px;
|
|
||||||
}
|
}
|
||||||
.header h3 {
|
|
||||||
margin: 0;
|
.filter-label-tag {
|
||||||
|
border: none;
|
||||||
|
background: transparent;
|
||||||
|
color: var(--ctms-text-secondary);
|
||||||
|
padding: 0;
|
||||||
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
.header p {
|
|
||||||
margin: 4px 0 0;
|
.filter-spacer {
|
||||||
color: #6c7a89;
|
flex: 1;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,59 +1,48 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="page">
|
<div class="page">
|
||||||
<el-card>
|
<el-card shadow="never" class="main-content-card">
|
||||||
<div class="header">
|
<div class="filter-container">
|
||||||
<div>
|
<el-form :inline="true" :model="filters" class="filter-form">
|
||||||
<h3>{{ TEXT.modules.adminAuditLogs.title }}</h3>
|
<el-form-item label="" class="filter-item-form">
|
||||||
</div>
|
<el-select v-model="filters.eventType" clearable :placeholder="TEXT.modules.adminAuditLogs.filterEvent" @change="loadLogs" class="filter-select-comp">
|
||||||
|
<el-option v-for="opt in eventTypeOptions" :key="opt.value" :label="opt.label" :value="opt.value" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="" class="filter-item-form">
|
||||||
|
<el-select v-model="filters.operatorId" clearable :placeholder="TEXT.modules.adminAuditLogs.filterOperator" filterable @change="loadLogs" class="filter-select-comp">
|
||||||
|
<el-option v-for="u in userOptions" :key="u.value" :label="u.label" :value="u.value" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="" class="filter-item-form">
|
||||||
|
<el-select v-model="filters.result" clearable :placeholder="TEXT.modules.adminAuditLogs.filterResult" @change="loadLogs" style="width: 120px">
|
||||||
|
<el-option :label="TEXT.audit.resultSuccess" value="SUCCESS" />
|
||||||
|
<el-option :label="TEXT.audit.resultFail" value="FAIL" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="" class="filter-item-form">
|
||||||
|
<el-date-picker
|
||||||
|
v-model="filters.range"
|
||||||
|
type="daterange"
|
||||||
|
unlink-panels
|
||||||
|
:start-placeholder="TEXT.modules.adminAuditLogs.rangeStart"
|
||||||
|
:end-placeholder="TEXT.modules.adminAuditLogs.rangeEnd"
|
||||||
|
format="YYYY-MM-DD"
|
||||||
|
value-format="YYYY-MM-DD"
|
||||||
|
class="date-range-picker-comp"
|
||||||
|
@change="loadLogs"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<div class="filter-spacer"></div>
|
||||||
|
<div class="ctms-action-group">
|
||||||
|
<el-button v-if="isAdmin" type="warning" plain size="small" :loading="exportLoading" @click="confirmExport('system')">
|
||||||
|
{{ TEXT.modules.adminAuditLogs.exportSystem }}
|
||||||
|
</el-button>
|
||||||
|
<el-button v-if="canProjectExport" type="warning" plain size="small" :loading="exportLoading" @click="confirmExport('project')">
|
||||||
|
{{ TEXT.modules.adminAuditLogs.exportProject }}
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
</el-form>
|
||||||
</div>
|
</div>
|
||||||
<div class="ctms-table-toolbar">
|
|
||||||
<div class="ctms-filter-group">
|
|
||||||
<el-select v-model="filters.eventType" clearable :placeholder="TEXT.modules.adminAuditLogs.filterEvent" @change="loadLogs" class="ctms-filter-item w-40">
|
|
||||||
<el-option v-for="opt in eventTypeOptions" :key="opt.value" :label="opt.label" :value="opt.value" />
|
|
||||||
</el-select>
|
|
||||||
<el-select v-model="filters.operatorId" clearable :placeholder="TEXT.modules.adminAuditLogs.filterOperator" filterable @change="loadLogs" class="ctms-filter-item w-40">
|
|
||||||
<el-option v-for="u in userOptions" :key="u.value" :label="u.label" :value="u.value" />
|
|
||||||
</el-select>
|
|
||||||
<el-select v-model="filters.result" clearable :placeholder="TEXT.modules.adminAuditLogs.filterResult" @change="loadLogs" class="ctms-filter-item w-32">
|
|
||||||
<el-option :label="TEXT.audit.resultSuccess" value="SUCCESS" />
|
|
||||||
<el-option :label="TEXT.audit.resultFail" value="FAIL" />
|
|
||||||
</el-select>
|
|
||||||
<el-date-picker
|
|
||||||
v-model="filters.range"
|
|
||||||
type="daterange"
|
|
||||||
unlink-panels
|
|
||||||
:start-placeholder="TEXT.modules.adminAuditLogs.rangeStart"
|
|
||||||
:end-placeholder="TEXT.modules.adminAuditLogs.rangeEnd"
|
|
||||||
format="YYYY-MM-DD"
|
|
||||||
value-format="YYYY-MM-DD"
|
|
||||||
class="ctms-filter-item date-range-picker"
|
|
||||||
@change="loadLogs"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div class="ctms-action-group">
|
|
||||||
<el-button
|
|
||||||
v-if="isAdmin"
|
|
||||||
type="warning"
|
|
||||||
plain
|
|
||||||
size="small"
|
|
||||||
:loading="exportLoading"
|
|
||||||
@click="confirmExport('system')"
|
|
||||||
>
|
|
||||||
{{ TEXT.modules.adminAuditLogs.exportSystem }}
|
|
||||||
</el-button>
|
|
||||||
<el-button
|
|
||||||
v-if="canProjectExport"
|
|
||||||
type="warning"
|
|
||||||
plain
|
|
||||||
size="small"
|
|
||||||
:loading="exportLoading"
|
|
||||||
@click="confirmExport('project')"
|
|
||||||
>
|
|
||||||
{{ TEXT.modules.adminAuditLogs.exportProject }}
|
|
||||||
</el-button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<el-table :data="logs" v-loading="loading" style="width: 100%" stripe>
|
<el-table :data="logs" v-loading="loading" style="width: 100%" stripe>
|
||||||
<el-table-column prop="timestamp" :label="TEXT.modules.adminAuditLogs.columns.time" width="180" align="center">
|
<el-table-column prop="timestamp" :label="TEXT.modules.adminAuditLogs.columns.time" width="180" align="center">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
@@ -334,53 +323,56 @@ onMounted(async () => {
|
|||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.page {
|
.page {
|
||||||
padding: 24px;
|
|
||||||
}
|
|
||||||
.header {
|
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
flex-direction: column;
|
||||||
margin-bottom: 24px;
|
|
||||||
}
|
}
|
||||||
.header h3 {
|
|
||||||
font-size: 20px;
|
.main-content-card :deep(.el-card__body) {
|
||||||
font-weight: 600;
|
padding: 20px;
|
||||||
color: #1f2937;
|
|
||||||
margin: 0;
|
|
||||||
}
|
}
|
||||||
.ctms-table-toolbar {
|
|
||||||
display: flex;
|
.filter-container {
|
||||||
justify-content: space-between;
|
|
||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
gap: 16px;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
}
|
}
|
||||||
.ctms-filter-group {
|
|
||||||
|
.filter-form {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
gap: 12px;
|
gap: 12px;
|
||||||
flex-wrap: wrap;
|
align-items: center;
|
||||||
}
|
}
|
||||||
.ctms-filter-item {
|
|
||||||
width: auto;
|
.filter-item-form {
|
||||||
|
margin-bottom: 0 !important;
|
||||||
|
margin-right: 0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-select-comp {
|
||||||
|
width: 150px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.date-range-picker-comp {
|
||||||
|
width: 280px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-spacer {
|
||||||
|
flex: 1;
|
||||||
}
|
}
|
||||||
.w-40 { width: 160px; }
|
|
||||||
.w-32 { width: 130px; }
|
|
||||||
.w-64 { width: 260px; }
|
|
||||||
|
|
||||||
.diff-container {
|
.diff-container {
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
color: #4b5563;
|
color: #4b5563;
|
||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
.diff-line {
|
.diff-line {
|
||||||
margin-bottom: 2px;
|
margin-bottom: 2px;
|
||||||
word-break: break-all;
|
word-break: break-all;
|
||||||
}
|
}
|
||||||
.date-range-picker {
|
|
||||||
width: auto;
|
|
||||||
min-width: 320px;
|
|
||||||
}
|
|
||||||
.pagination {
|
.pagination {
|
||||||
margin-top: 24px;
|
margin-top: 12px;
|
||||||
text-align: right;
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -300,14 +300,26 @@ const handleLock = async () => {
|
|||||||
type: "warning",
|
type: "warning",
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const { value } = await ElMessageBox.prompt(TEXT.modules.adminProjects.lockConfirmPrompt, TEXT.modules.adminProjects.lockConfirmTitle, {
|
||||||
|
confirmButtonText: TEXT.common.actions.confirm,
|
||||||
|
cancelButtonText: TEXT.common.actions.cancel,
|
||||||
|
inputPlaceholder: TEXT.modules.adminProjects.lockConfirmPlaceholder,
|
||||||
|
inputValidator: (input: string) => input === "确认锁定" || TEXT.modules.adminProjects.lockConfirmMismatch,
|
||||||
|
type: "warning",
|
||||||
|
});
|
||||||
|
if (value !== "确认锁定") {
|
||||||
|
ElMessage.warning(TEXT.modules.adminProjects.lockConfirmMismatchWarning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
const { data } = await lockStudy(project.value.id);
|
const { data } = await lockStudy(project.value.id);
|
||||||
project.value = data as Study;
|
project.value = data as Study;
|
||||||
syncForm(project.value);
|
syncForm(project.value);
|
||||||
ElMessage.success("项目已锁定");
|
ElMessage.success("项目已锁定");
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err !== "cancel") {
|
if (err !== "cancel" && err !== "close") {
|
||||||
ElMessage.error("锁定项目失败");
|
const detail = (err as any)?.response?.data?.detail || "锁定项目失败";
|
||||||
|
ElMessage.error(detail);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,6 +4,9 @@
|
|||||||
<el-form-item :label="TEXT.common.fields.projectName" prop="name">
|
<el-form-item :label="TEXT.common.fields.projectName" prop="name">
|
||||||
<el-input v-model="form.name" :placeholder="TEXT.common.placeholders.input + TEXT.common.fields.projectName" />
|
<el-input v-model="form.name" :placeholder="TEXT.common.placeholders.input + TEXT.common.fields.projectName" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item :label="TEXT.common.fields.projectCode" prop="code">
|
||||||
|
<el-input v-model="form.code" :placeholder="TEXT.common.placeholders.input + TEXT.common.fields.projectCode" />
|
||||||
|
</el-form-item>
|
||||||
<el-form-item :label="TEXT.common.fields.protocolNo" prop="protocol_no">
|
<el-form-item :label="TEXT.common.fields.protocolNo" prop="protocol_no">
|
||||||
<el-input v-model="form.protocol_no" :placeholder="TEXT.modules.adminProjects.protocolPlaceholder" />
|
<el-input v-model="form.protocol_no" :placeholder="TEXT.modules.adminProjects.protocolPlaceholder" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -64,6 +67,7 @@ const formRef = ref<FormInstance>();
|
|||||||
const submitting = ref(false);
|
const submitting = ref(false);
|
||||||
const form = reactive({
|
const form = reactive({
|
||||||
name: "",
|
name: "",
|
||||||
|
code: "",
|
||||||
protocol_no: "",
|
protocol_no: "",
|
||||||
phase: "",
|
phase: "",
|
||||||
status: "DRAFT",
|
status: "DRAFT",
|
||||||
@@ -80,6 +84,7 @@ const rules = reactive<FormRules>({
|
|||||||
|
|
||||||
const resetForm = () => {
|
const resetForm = () => {
|
||||||
form.name = "";
|
form.name = "";
|
||||||
|
form.code = "";
|
||||||
form.protocol_no = "";
|
form.protocol_no = "";
|
||||||
form.phase = "";
|
form.phase = "";
|
||||||
form.status = "DRAFT";
|
form.status = "DRAFT";
|
||||||
@@ -96,6 +101,7 @@ watch(
|
|||||||
resetForm();
|
resetForm();
|
||||||
if (props.project) {
|
if (props.project) {
|
||||||
form.name = props.project.name;
|
form.name = props.project.name;
|
||||||
|
form.code = props.project.code || "";
|
||||||
form.protocol_no = props.project.protocol_no || "";
|
form.protocol_no = props.project.protocol_no || "";
|
||||||
form.phase = props.project.phase || "";
|
form.phase = props.project.phase || "";
|
||||||
form.status = props.project.status || "DRAFT";
|
form.status = props.project.status || "DRAFT";
|
||||||
@@ -116,6 +122,7 @@ const onSubmit = async () => {
|
|||||||
if (props.project) {
|
if (props.project) {
|
||||||
await updateStudy(props.project.id, {
|
await updateStudy(props.project.id, {
|
||||||
name: form.name,
|
name: form.name,
|
||||||
|
code: form.code,
|
||||||
protocol_no: form.protocol_no,
|
protocol_no: form.protocol_no,
|
||||||
phase: form.phase,
|
phase: form.phase,
|
||||||
status: form.status,
|
status: form.status,
|
||||||
@@ -128,6 +135,7 @@ const onSubmit = async () => {
|
|||||||
} else {
|
} else {
|
||||||
await createStudy({
|
await createStudy({
|
||||||
name: form.name,
|
name: form.name,
|
||||||
|
code: form.code,
|
||||||
protocol_no: form.protocol_no,
|
protocol_no: form.protocol_no,
|
||||||
phase: form.phase,
|
phase: form.phase,
|
||||||
status: form.status,
|
status: form.status,
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="page">
|
<div class="page">
|
||||||
<el-card>
|
<el-card shadow="never" class="main-content-card">
|
||||||
<div class="header">
|
<div class="filter-container">
|
||||||
<div>
|
<div class="filter-form">
|
||||||
<h3>{{ TEXT.modules.adminProjectMembers.title }}</h3>
|
<div class="filter-spacer"></div>
|
||||||
<div class="sub" v-if="project">{{ TEXT.modules.adminProjectMembers.projectPrefix }}{{ project.code }} - {{ project.name }}</div>
|
<el-button type="primary" @click="openAdd" class="header-action-btn">
|
||||||
|
{{ TEXT.common.actions.add }}{{ TEXT.modules.adminProjectMembers.memberLabel }}
|
||||||
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
<el-button type="primary" @click="openAdd">{{ TEXT.common.actions.add }}{{ TEXT.modules.adminProjectMembers.memberLabel }}</el-button>
|
|
||||||
</div>
|
</div>
|
||||||
<el-table :data="memberRows" v-loading="loading" stripe>
|
<el-table :data="memberRows" v-loading="loading" stripe>
|
||||||
<el-table-column prop="full_name" :label="TEXT.modules.adminProjectMembers.username" min-width="160" />
|
<el-table-column prop="full_name" :label="TEXT.modules.adminProjectMembers.username" min-width="160" />
|
||||||
@@ -394,18 +395,35 @@ onMounted(async () => {
|
|||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.page {
|
.page {
|
||||||
padding: 16px;
|
|
||||||
}
|
|
||||||
.header {
|
|
||||||
display: flex;
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.main-content-card :deep(.el-card__body) {
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-container {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-form {
|
||||||
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
|
gap: 12px;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
|
||||||
margin-bottom: 12px;
|
|
||||||
}
|
}
|
||||||
.sub {
|
|
||||||
color: #666;
|
.filter-spacer {
|
||||||
margin-top: 4px;
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.header-action-btn {
|
||||||
|
height: 36px;
|
||||||
|
padding: 0 20px;
|
||||||
|
border-radius: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
.hint {
|
.hint {
|
||||||
color: #999;
|
color: #999;
|
||||||
margin: 0 8px;
|
margin: 0 8px;
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="page">
|
<div class="page">
|
||||||
<el-card>
|
<el-card shadow="never" class="main-content-card">
|
||||||
<div class="header">
|
<div class="filter-container">
|
||||||
<div>
|
<div class="filter-form">
|
||||||
<h3>{{ TEXT.modules.adminProjects.title }}</h3>
|
<div class="filter-spacer"></div>
|
||||||
|
<el-button type="primary" @click="openCreate" class="header-action-btn">
|
||||||
|
{{ TEXT.common.actions.add }}{{ TEXT.modules.adminProjects.projectLabel }}
|
||||||
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
<el-button type="primary" @click="openCreate">{{ TEXT.common.actions.add }}{{ TEXT.modules.adminProjects.projectLabel }}</el-button>
|
|
||||||
</div>
|
</div>
|
||||||
<el-table :data="projects" v-loading="loading" stripe>
|
<el-table :data="projects" v-loading="loading" stripe>
|
||||||
<el-table-column prop="name" :label="TEXT.common.fields.projectName" min-width="300">
|
<el-table-column prop="name" :label="TEXT.common.fields.projectName" min-width="300">
|
||||||
@@ -13,6 +15,11 @@
|
|||||||
<el-link type="primary" @click="goDetail(scope.row)" class="font-medium">{{ scope.row.name }}</el-link>
|
<el-link type="primary" @click="goDetail(scope.row)" class="font-medium">{{ scope.row.name }}</el-link>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
<el-table-column prop="code" :label="TEXT.common.fields.projectCode" min-width="160">
|
||||||
|
<template #default="scope">
|
||||||
|
<span class="text-gray-500">{{ scope.row.code || "-" }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
<el-table-column prop="status" :label="TEXT.common.fields.status" min-width="120" align="center">
|
<el-table-column prop="status" :label="TEXT.common.fields.status" min-width="120" align="center">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-tag :type="statusTag(scope.row.status)" effect="plain" round>{{ statusLabel(scope.row.status) }}</el-tag>
|
<el-tag :type="statusTag(scope.row.status)" effect="plain" round>{{ statusLabel(scope.row.status) }}</el-tag>
|
||||||
@@ -24,11 +31,6 @@
|
|||||||
<el-tag v-else type="success" effect="plain" round>未锁定</el-tag>
|
<el-tag v-else type="success" effect="plain" round>未锁定</el-tag>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="created_at" :label="TEXT.modules.adminUsers.createdAt" min-width="180" align="center">
|
|
||||||
<template #default="scope">
|
|
||||||
<span class="text-gray-500">{{ displayDateTime(scope.row.created_at) }}</span>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column :label="TEXT.common.labels.actions" min-width="280" align="center">
|
<el-table-column :label="TEXT.common.labels.actions" min-width="280" align="center">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-tooltip :content="TEXT.modules.adminProjects.members" placement="top">
|
<el-tooltip :content="TEXT.modules.adminProjects.members" placement="top">
|
||||||
@@ -69,7 +71,6 @@ import { fetchStudies, deleteStudy, lockStudy } from "../../api/studies";
|
|||||||
import type { Study } from "../../types/api";
|
import type { Study } from "../../types/api";
|
||||||
import ProjectForm from "./ProjectForm.vue";
|
import ProjectForm from "./ProjectForm.vue";
|
||||||
import { useStudyStore } from "../../store/study";
|
import { useStudyStore } from "../../store/study";
|
||||||
import { displayDateTime } from "../../utils/display";
|
|
||||||
import { TEXT } from "../../locales";
|
import { TEXT } from "../../locales";
|
||||||
|
|
||||||
const projects = ref<Study[]>([]);
|
const projects = ref<Study[]>([]);
|
||||||
@@ -167,13 +168,25 @@ const handleLockToggle = async (study: Study) => {
|
|||||||
type: "warning",
|
type: "warning",
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const { value } = await ElMessageBox.prompt(TEXT.modules.adminProjects.lockConfirmPrompt, TEXT.modules.adminProjects.lockConfirmTitle, {
|
||||||
|
confirmButtonText: TEXT.common.actions.confirm,
|
||||||
|
cancelButtonText: TEXT.common.actions.cancel,
|
||||||
|
inputPlaceholder: TEXT.modules.adminProjects.lockConfirmPlaceholder,
|
||||||
|
inputValidator: (input: string) => input === "确认锁定" || TEXT.modules.adminProjects.lockConfirmMismatch,
|
||||||
|
type: "warning",
|
||||||
|
});
|
||||||
|
if (value !== "确认锁定") {
|
||||||
|
ElMessage.warning(TEXT.modules.adminProjects.lockConfirmMismatchWarning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
await lockStudy(study.id);
|
await lockStudy(study.id);
|
||||||
ElMessage.success("项目已锁定");
|
ElMessage.success("项目已锁定");
|
||||||
await loadProjects();
|
await loadProjects();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err !== "cancel") {
|
if (err !== "cancel" && err !== "close") {
|
||||||
ElMessage.error("锁定项目失败");
|
const detail = (err as any)?.response?.data?.detail || "锁定项目失败";
|
||||||
|
ElMessage.error(detail);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -204,27 +217,33 @@ onMounted(() => {
|
|||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.page {
|
.page {
|
||||||
padding: 24px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.header {
|
|
||||||
display: flex;
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.main-content-card :deep(.el-card__body) {
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-container {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-form {
|
||||||
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
|
gap: 12px;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
|
||||||
margin-bottom: 24px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.header h3 {
|
.filter-spacer {
|
||||||
font-size: 20px;
|
flex: 1;
|
||||||
font-weight: 600;
|
|
||||||
color: #1f2937;
|
|
||||||
margin: 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.sub {
|
.header-action-btn {
|
||||||
color: #6b7280;
|
height: 36px;
|
||||||
margin-top: 8px;
|
padding: 0 20px;
|
||||||
font-size: 14px;
|
border-radius: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 表格样式美化 */
|
/* 表格样式美化 */
|
||||||
@@ -238,19 +257,18 @@ onMounted(() => {
|
|||||||
:deep(.el-table th.el-table__cell) {
|
:deep(.el-table th.el-table__cell) {
|
||||||
background-color: #f9fafb;
|
background-color: #f9fafb;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
height: 50px;
|
height: 44px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 增加单元格间距 */
|
|
||||||
:deep(.el-table .el-table__cell) {
|
:deep(.el-table .el-table__cell) {
|
||||||
padding: 16px 0;
|
padding: 8px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 操作按钮美化 */
|
/* 操作按钮美化 */
|
||||||
.action-btn {
|
.action-btn {
|
||||||
font-size: 20px; /* 图标变更大 */
|
font-size: 18px; /* 图标变更大 */
|
||||||
padding: 6px;
|
padding: 4px;
|
||||||
margin: 0 4px;
|
margin: 0 2px;
|
||||||
transition: all 0.3s;
|
transition: all 0.3s;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -261,7 +279,7 @@ onMounted(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.enter-btn {
|
.enter-btn {
|
||||||
font-size: 20px;
|
font-size: 18px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="page">
|
<div class="page">
|
||||||
<el-card>
|
<el-card shadow="never" class="main-content-card">
|
||||||
<div class="header">
|
<div class="filter-container">
|
||||||
<div>
|
<div class="filter-form">
|
||||||
<h3>{{ TEXT.modules.adminSites.title }}</h3>
|
<div class="filter-spacer"></div>
|
||||||
<div class="sub" v-if="project">{{ TEXT.modules.adminSites.projectPrefix }}{{ project.code }} - {{ project.name }}</div>
|
<el-button type="primary" @click="openCreate" class="header-action-btn">
|
||||||
|
{{ TEXT.common.actions.add }}{{ TEXT.modules.adminSites.siteLabel }}
|
||||||
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
<el-button type="primary" @click="openCreate">{{ TEXT.common.actions.add }}{{ TEXT.modules.adminSites.siteLabel }}</el-button>
|
|
||||||
</div>
|
</div>
|
||||||
<el-table :data="sites" v-loading="loading" stripe :row-class-name="siteRowClass">
|
<el-table :data="sites" v-loading="loading" stripe :row-class-name="siteRowClass">
|
||||||
<el-table-column prop="name" :label="TEXT.common.fields.siteName" width="180" />
|
<el-table-column prop="name" :label="TEXT.common.fields.siteName" width="180" />
|
||||||
@@ -266,17 +267,33 @@ onMounted(async () => {
|
|||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.page {
|
.page {
|
||||||
padding: 16px;
|
|
||||||
}
|
|
||||||
.header {
|
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
flex-direction: column;
|
||||||
justify-content: space-between;
|
|
||||||
margin-bottom: 12px;
|
|
||||||
}
|
}
|
||||||
.sub {
|
|
||||||
color: #666;
|
.main-content-card :deep(.el-card__body) {
|
||||||
margin-top: 4px;
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-container {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-form {
|
||||||
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
|
gap: 12px;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-spacer {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-action-btn {
|
||||||
|
height: 36px;
|
||||||
|
padding: 0 20px;
|
||||||
|
border-radius: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,12 +1,32 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="page">
|
<div class="page">
|
||||||
<el-card>
|
<el-card shadow="never" class="main-content-card">
|
||||||
<div class="header">
|
<div class="filter-container">
|
||||||
<div>
|
<div class="filter-form">
|
||||||
<h3>{{ TEXT.modules.adminUsers.title }}</h3>
|
<el-form-item label="" class="filter-item-form">
|
||||||
|
<el-input
|
||||||
|
v-model="searchKeyword"
|
||||||
|
:placeholder="TEXT.common.placeholders.keyword"
|
||||||
|
clearable
|
||||||
|
class="filter-input-comp"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="" class="filter-item-form">
|
||||||
|
<el-select v-model="statusFilter" :placeholder="TEXT.common.fields.status" style="width: 140px" clearable class="filter-select-comp" @change="loadUsers">
|
||||||
|
<el-option :label="TEXT.enums.userStatus.PENDING" value="PENDING" />
|
||||||
|
<el-option :label="TEXT.enums.userStatus.ACTIVE" value="ACTIVE" />
|
||||||
|
<el-option :label="TEXT.enums.userStatus.REJECTED" value="REJECTED" />
|
||||||
|
<el-option :label="TEXT.enums.userStatus.DISABLED" value="DISABLED" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item class="filter-item-form">
|
||||||
|
<el-button @click="loadUsers">{{ TEXT.common.actions.search }}</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
<div class="filter-spacer"></div>
|
||||||
|
<el-button type="primary" @click="openCreate" class="header-action-btn">{{ TEXT.common.actions.add }}{{ TEXT.modules.adminUsers.userLabel }}</el-button>
|
||||||
</div>
|
</div>
|
||||||
<el-button type="primary" @click="openCreate">{{ TEXT.common.actions.add }}{{ TEXT.modules.adminUsers.userLabel }}</el-button>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<el-table :data="users" stripe v-loading="loading" style="width: 100%">
|
<el-table :data="users" stripe v-loading="loading" style="width: 100%">
|
||||||
<el-table-column prop="email" :label="TEXT.common.fields.email" min-width="200" />
|
<el-table-column prop="email" :label="TEXT.common.fields.email" min-width="200" />
|
||||||
<el-table-column prop="full_name" :label="TEXT.common.fields.name" min-width="140" />
|
<el-table-column prop="full_name" :label="TEXT.common.fields.name" min-width="140" />
|
||||||
@@ -50,16 +70,15 @@
|
|||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
<div class="pagination">
|
<el-pagination
|
||||||
<el-pagination
|
background
|
||||||
background
|
layout="prev, pager, next, total"
|
||||||
layout="prev, pager, next, total"
|
:page-size="pageSize"
|
||||||
:page-size="pageSize"
|
:total="total"
|
||||||
:total="total"
|
v-model:current-page="page"
|
||||||
v-model:current-page="page"
|
@current-change="loadUsers"
|
||||||
@current-change="loadUsers"
|
class="pagination"
|
||||||
/>
|
/>
|
||||||
</div>
|
|
||||||
</el-card>
|
</el-card>
|
||||||
<UserForm v-model:visible="formVisible" :user="editingUser" :admin-count="activeAdminCount" @saved="loadUsers" />
|
<UserForm v-model:visible="formVisible" :user="editingUser" :admin-count="activeAdminCount" @saved="loadUsers" />
|
||||||
<UserResetPassword v-model:visible="resetVisible" :user="resetUser" @reset="loadUsers" />
|
<UserResetPassword v-model:visible="resetVisible" :user="resetUser" @reset="loadUsers" />
|
||||||
@@ -88,6 +107,8 @@ const loading = ref(false);
|
|||||||
const activeAdminCount = ref(0);
|
const activeAdminCount = ref(0);
|
||||||
const formVisible = ref(false);
|
const formVisible = ref(false);
|
||||||
const resetVisible = ref(false);
|
const resetVisible = ref(false);
|
||||||
|
const searchKeyword = ref("");
|
||||||
|
const statusFilter = ref("");
|
||||||
const editingUser = ref<UserInfo | null>(null);
|
const editingUser = ref<UserInfo | null>(null);
|
||||||
const resetUser = ref<UserInfo | null>(null);
|
const resetUser = ref<UserInfo | null>(null);
|
||||||
const auth = useAuthStore();
|
const auth = useAuthStore();
|
||||||
@@ -127,7 +148,12 @@ const loadUsers = async () => {
|
|||||||
loading.value = true;
|
loading.value = true;
|
||||||
try {
|
try {
|
||||||
const [{ data }, { data: adminData }] = await Promise.all([
|
const [{ data }, { data: adminData }] = await Promise.all([
|
||||||
fetchUsers({ skip: (page.value - 1) * pageSize.value, limit: pageSize.value }),
|
fetchUsers({
|
||||||
|
skip: (page.value - 1) * pageSize.value,
|
||||||
|
limit: pageSize.value,
|
||||||
|
keyword: searchKeyword.value || undefined,
|
||||||
|
status: statusFilter.value || undefined,
|
||||||
|
}),
|
||||||
fetchUsers({ skip: 0, limit: 10000 }),
|
fetchUsers({ skip: 0, limit: 10000 }),
|
||||||
]);
|
]);
|
||||||
const items = (data as any).items || [];
|
const items = (data as any).items || [];
|
||||||
@@ -252,20 +278,47 @@ onMounted(() => {
|
|||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.page {
|
.page {
|
||||||
padding: 16px;
|
|
||||||
}
|
|
||||||
.header {
|
|
||||||
display: flex;
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.main-content-card :deep(.el-card__body) {
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-container {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-form {
|
||||||
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
|
gap: 12px;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
|
||||||
margin-bottom: 12px;
|
|
||||||
}
|
}
|
||||||
.sub {
|
|
||||||
color: #666;
|
.filter-item-form {
|
||||||
margin-top: 4px;
|
margin-bottom: 0 !important;
|
||||||
|
margin-right: 0 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.filter-input-comp {
|
||||||
|
width: 200px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-spacer {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-action-btn {
|
||||||
|
height: 36px;
|
||||||
|
padding: 0 20px;
|
||||||
|
border-radius: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
.pagination {
|
.pagination {
|
||||||
margin-top: 12px;
|
margin-top: 12px;
|
||||||
text-align: right;
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -27,7 +27,12 @@
|
|||||||
<el-descriptions :column="3" border class="ctms-descriptions">
|
<el-descriptions :column="3" border class="ctms-descriptions">
|
||||||
<el-descriptions-item :label="TEXT.modules.fileVersionManagement.fields.docType">{{ displayText(detail.doc_type, TEXT.enums.documentType) }}</el-descriptions-item>
|
<el-descriptions-item :label="TEXT.modules.fileVersionManagement.fields.docType">{{ displayText(detail.doc_type, TEXT.enums.documentType) }}</el-descriptions-item>
|
||||||
<el-descriptions-item :label="TEXT.modules.fileVersionManagement.fields.site">{{ displaySite(detail.site_id) }}</el-descriptions-item>
|
<el-descriptions-item :label="TEXT.modules.fileVersionManagement.fields.site">{{ displaySite(detail.site_id) }}</el-descriptions-item>
|
||||||
<el-descriptions-item :label="TEXT.modules.fileVersionManagement.labels.currentEffective">{{ detail.current_effective_version?.version_no || TEXT.common.fallback }}</el-descriptions-item>
|
<el-descriptions-item :label="TEXT.modules.fileVersionManagement.labels.currentEffective">
|
||||||
|
{{ currentEffectiveVersion?.version_no || TEXT.common.fallback }}
|
||||||
|
</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="版本日期">
|
||||||
|
{{ formatDateOnly(currentEffectiveVersion?.effective_at || currentEffectiveVersion?.created_at || null) }}
|
||||||
|
</el-descriptions-item>
|
||||||
<el-descriptions-item :label="TEXT.modules.fileVersionManagement.columns.updatedAt">{{ formatDate(detail.updated_at) }}</el-descriptions-item>
|
<el-descriptions-item :label="TEXT.modules.fileVersionManagement.columns.updatedAt">{{ formatDate(detail.updated_at) }}</el-descriptions-item>
|
||||||
</el-descriptions>
|
</el-descriptions>
|
||||||
</el-card>
|
</el-card>
|
||||||
@@ -35,7 +40,7 @@
|
|||||||
<el-tabs v-model="activeTab" @tab-change="handleTabChange" class="ctms-tabs">
|
<el-tabs v-model="activeTab" @tab-change="handleTabChange" class="ctms-tabs">
|
||||||
<el-tab-pane :label="TEXT.modules.fileVersionManagement.tabs.versions" name="versions">
|
<el-tab-pane :label="TEXT.modules.fileVersionManagement.tabs.versions" name="versions">
|
||||||
<div class="ctms-section-header">
|
<div class="ctms-section-header">
|
||||||
<div class="ctms-section-title">{{ TEXT.modules.fileVersionManagement.labels.versionTimeline }}</div>
|
<div class="ctms-section-title"> </div>
|
||||||
<div class="ctms-section-actions">
|
<div class="ctms-section-actions">
|
||||||
<el-button type="primary" @click="openUpload" v-if="canAction('create_version')">
|
<el-button type="primary" @click="openUpload" v-if="canAction('create_version')">
|
||||||
<el-icon class="el-icon--left"><Upload /></el-icon>
|
<el-icon class="el-icon--left"><Upload /></el-icon>
|
||||||
@@ -50,9 +55,9 @@
|
|||||||
<span class="font-medium">V{{ row.version_no }}</span>
|
<span class="font-medium">V{{ row.version_no }}</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column :label="TEXT.modules.fileVersionManagement.columns.status" width="120">
|
<el-table-column label="版本日期" width="140">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<el-tag :type="getVersionStatusType(row.status)" effect="light" size="small">{{ displayEnum(TEXT.enums.documentVersionStatus, row.status) }}</el-tag>
|
<span class="text-secondary">{{ formatDateOnly(row.effective_at || row.created_at) }}</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="change_summary" :label="TEXT.modules.fileVersionManagement.fields.changeSummary" min-width="200" show-overflow-tooltip />
|
<el-table-column prop="change_summary" :label="TEXT.modules.fileVersionManagement.fields.changeSummary" min-width="200" show-overflow-tooltip />
|
||||||
@@ -61,37 +66,29 @@
|
|||||||
<span>{{ displayCreator(row.created_by) }}</span>
|
<span>{{ displayCreator(row.created_by) }}</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="created_at" :label="TEXT.modules.fileVersionManagement.labels.createdAt" width="180">
|
<el-table-column :label="TEXT.modules.fileVersionManagement.fields.parentVersion" width="140">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<span class="text-secondary">{{ formatDate(row.created_at) }}</span>
|
<span class="text-secondary">{{ displayParentVersion(row.parent_version_id) }}</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column :label="TEXT.modules.fileVersionManagement.labels.approvalSummary" min-width="220">
|
<el-table-column prop="effective_at" :label="TEXT.modules.fileVersionManagement.columns.effectiveAt" width="180">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<div class="text-xs text-secondary lh-sm">
|
<span class="text-secondary">{{ formatDate(row.effective_at || row.created_at) }}</span>
|
||||||
<div v-if="row.submitted_at">{{ TEXT.modules.fileVersionManagement.labels.submitAt }}:{{ formatDate(row.submitted_at) }}</div>
|
|
||||||
<div v-if="row.approved_at" class="mt-1">
|
|
||||||
{{ TEXT.modules.fileVersionManagement.labels.approveAt }}:{{ formatDate(row.approved_at) }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column :label="TEXT.modules.fileVersionManagement.columns.actions" width="280" align="center">
|
<el-table-column :label="TEXT.modules.fileVersionManagement.columns.actions" width="180" align="center">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<el-button link type="primary" size="small" @click="downloadVersion(row)" v-if="canAction('view')">
|
<el-button link type="primary" size="small" @click="downloadVersion(row)" v-if="canAction('view')">
|
||||||
{{ TEXT.modules.fileVersionManagement.actions.download }}
|
{{ TEXT.modules.fileVersionManagement.actions.download }}
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button link type="primary" size="small" @click="openSubmit(row)" v-if="canAction('submit') && row.status === 'DRAFT'">
|
<el-button
|
||||||
{{ TEXT.modules.fileVersionManagement.actions.submit }}
|
v-if="isAdmin"
|
||||||
</el-button>
|
link
|
||||||
<el-button link type="success" size="small" @click="approve(row)" v-if="canAction('approve') && row.status === 'SUBMITTED'">
|
type="danger"
|
||||||
{{ TEXT.modules.fileVersionManagement.actions.approve }}
|
size="small"
|
||||||
</el-button>
|
@click="confirmDeleteVersion(row)"
|
||||||
<el-button link type="danger" size="small" @click="reject(row)" v-if="canAction('approve') && row.status === 'SUBMITTED'">
|
>
|
||||||
{{ TEXT.modules.fileVersionManagement.actions.reject }}
|
{{ TEXT.common.actions.delete }}
|
||||||
</el-button>
|
|
||||||
<el-button link type="warning" size="small" @click="makeEffective(row)" v-if="canAction('approve') && row.status === 'APPROVED'">
|
|
||||||
{{ TEXT.modules.fileVersionManagement.actions.makeEffective }}
|
|
||||||
</el-button>
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
@@ -101,9 +98,9 @@
|
|||||||
|
|
||||||
<el-tab-pane :label="TEXT.modules.fileVersionManagement.tabs.distributions" name="distributions">
|
<el-tab-pane :label="TEXT.modules.fileVersionManagement.tabs.distributions" name="distributions">
|
||||||
<div class="ctms-section-header">
|
<div class="ctms-section-header">
|
||||||
<div class="ctms-section-title">{{ TEXT.modules.fileVersionManagement.labels.distributionList }}</div>
|
<div class="ctms-section-title"> </div>
|
||||||
<div class="ctms-section-actions">
|
<div class="ctms-section-actions">
|
||||||
<el-button type="primary" @click="openDistribute" v-if="canAction('distribute')">
|
<el-button type="primary" @click="openDistribute">
|
||||||
<el-icon class="el-icon--left"><Share /></el-icon>
|
<el-icon class="el-icon--left"><Share /></el-icon>
|
||||||
{{ TEXT.modules.fileVersionManagement.actions.distribute }}
|
{{ TEXT.modules.fileVersionManagement.actions.distribute }}
|
||||||
</el-button>
|
</el-button>
|
||||||
@@ -121,48 +118,7 @@
|
|||||||
<span class="font-medium">{{ displayTarget(row) }}</span>
|
<span class="font-medium">{{ displayTarget(row) }}</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column :label="TEXT.modules.fileVersionManagement.labels.ackStats" min-width="200">
|
<el-table-column label="抄送时间" width="180">
|
||||||
<template #default="{ row }">
|
|
||||||
<span>{{ TEXT.modules.fileVersionManagement.actions.ackReceived }}: {{ row.stats?.received || 0 }}</span>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column :label="TEXT.modules.fileVersionManagement.labels.overdue" width="100">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<el-tag v-if="row.stats?.overdue" type="danger" effect="dark" size="small">{{ TEXT.modules.fileVersionManagement.labels.overdue }}</el-tag>
|
|
||||||
<span v-else class="text-secondary">-</span>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column :label="TEXT.modules.fileVersionManagement.labels.dueAt" width="160">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<span :class="{ 'text-danger': row.stats?.overdue }">{{ formatDate(row.due_at) }}</span>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column :label="TEXT.modules.fileVersionManagement.labels.ackAction" width="140" align="center">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<el-button link type="primary" size="small" @click="ack(row, 'RECEIVED')" v-if="canAction('ack')">
|
|
||||||
{{ TEXT.modules.fileVersionManagement.actions.ackReceived }}
|
|
||||||
</el-button>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
</el-table>
|
|
||||||
</el-card>
|
|
||||||
</el-tab-pane>
|
|
||||||
|
|
||||||
<el-tab-pane :label="TEXT.modules.fileVersionManagement.tabs.audit" name="audit">
|
|
||||||
<el-card class="ctms-table-card">
|
|
||||||
<el-table :data="auditLogs" v-loading="auditLoading" class="ctms-table">
|
|
||||||
<el-table-column prop="action" :label="TEXT.modules.fileVersionManagement.labels.auditAction" width="200">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<span class="font-medium">{{ row.action }}</span>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column prop="detail" :label="TEXT.modules.fileVersionManagement.labels.auditDetail" min-width="300" show-overflow-tooltip />
|
|
||||||
<el-table-column prop="operator_role" :label="TEXT.common.labels.role" width="120">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<el-tag effect="plain" size="small">{{ row.operator_role }}</el-tag>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column prop="created_at" :label="TEXT.modules.fileVersionManagement.labels.auditTime" width="180">
|
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<span class="text-secondary">{{ formatDate(row.created_at) }}</span>
|
<span class="text-secondary">{{ formatDate(row.created_at) }}</span>
|
||||||
</template>
|
</template>
|
||||||
@@ -170,6 +126,7 @@
|
|||||||
</el-table>
|
</el-table>
|
||||||
</el-card>
|
</el-card>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
|
|
||||||
</el-tabs>
|
</el-tabs>
|
||||||
|
|
||||||
<el-dialog v-model="uploadVisible" :title="TEXT.modules.fileVersionManagement.dialog.uploadTitle" width="520px" destroy-on-close class="ctms-dialog">
|
<el-dialog v-model="uploadVisible" :title="TEXT.modules.fileVersionManagement.dialog.uploadTitle" width="520px" destroy-on-close class="ctms-dialog">
|
||||||
@@ -177,6 +134,15 @@
|
|||||||
<el-form-item :label="TEXT.modules.fileVersionManagement.fields.versionNo" prop="version_no">
|
<el-form-item :label="TEXT.modules.fileVersionManagement.fields.versionNo" prop="version_no">
|
||||||
<el-input v-model="uploadForm.version_no" :placeholder="TEXT.modules.fileVersionManagement.placeholders.versionNo" />
|
<el-input v-model="uploadForm.version_no" :placeholder="TEXT.modules.fileVersionManagement.placeholders.versionNo" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item label="版本日期" prop="version_date">
|
||||||
|
<el-date-picker
|
||||||
|
v-model="uploadForm.version_date"
|
||||||
|
type="date"
|
||||||
|
value-format="YYYY-MM-DD"
|
||||||
|
:placeholder="TEXT.common.placeholders.select"
|
||||||
|
style="width: 100%"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
<el-form-item :label="TEXT.modules.fileVersionManagement.fields.changeSummary">
|
<el-form-item :label="TEXT.modules.fileVersionManagement.fields.changeSummary">
|
||||||
<el-input v-model="uploadForm.change_summary" type="textarea" :rows="3" />
|
<el-input v-model="uploadForm.change_summary" type="textarea" :rows="3" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -204,49 +170,44 @@
|
|||||||
<el-form :model="distributeForm" label-width="100px" class="ctms-form">
|
<el-form :model="distributeForm" label-width="100px" class="ctms-form">
|
||||||
<el-form-item :label="TEXT.modules.fileVersionManagement.fields.targetList">
|
<el-form-item :label="TEXT.modules.fileVersionManagement.fields.targetList">
|
||||||
<div class="target-list w-full">
|
<div class="target-list w-full">
|
||||||
<div class="target-row" v-for="(item, index) in distributeForm.targets" :key="item.uid">
|
<div class="target-toolbar">
|
||||||
<el-select
|
<el-select v-model="distributeForm.target_type" class="target-type-preset" :placeholder="TEXT.common.labels.all" @change="onTargetTypeChange">
|
||||||
v-model="item.target_type"
|
<el-option :label="TEXT.common.labels.all" value="ALL" />
|
||||||
:placeholder="TEXT.common.placeholders.select"
|
|
||||||
style="width: 120px"
|
|
||||||
@change="onTargetTypeChange(index)"
|
|
||||||
>
|
|
||||||
<el-option :label="TEXT.enums.distributionTargetType.ROLE" value="ROLE" />
|
<el-option :label="TEXT.enums.distributionTargetType.ROLE" value="ROLE" />
|
||||||
<el-option :label="TEXT.enums.distributionTargetType.USER" value="USER" />
|
<el-option :label="TEXT.enums.distributionTargetType.USER" value="USER" />
|
||||||
</el-select>
|
</el-select>
|
||||||
<el-select
|
|
||||||
v-if="item.target_type === 'ROLE'"
|
|
||||||
v-model="item.target_id"
|
|
||||||
filterable
|
|
||||||
clearable
|
|
||||||
:placeholder="TEXT.common.placeholders.select"
|
|
||||||
class="target-select"
|
|
||||||
>
|
|
||||||
<el-option v-for="role in roleOptions" :key="role.value" :label="role.label" :value="role.value" />
|
|
||||||
</el-select>
|
|
||||||
<el-select
|
|
||||||
v-else
|
|
||||||
v-model="item.target_id"
|
|
||||||
filterable
|
|
||||||
clearable
|
|
||||||
:placeholder="TEXT.common.placeholders.select"
|
|
||||||
class="target-select"
|
|
||||||
>
|
|
||||||
<el-option v-for="member in memberOptions" :key="member.value" :label="member.label" :value="member.value" />
|
|
||||||
</el-select>
|
|
||||||
<el-button link type="danger" @click="removeTarget(index)">
|
|
||||||
<el-icon><Delete /></el-icon>
|
|
||||||
</el-button>
|
|
||||||
</div>
|
</div>
|
||||||
<el-button type="primary" plain @click="addTarget" class="w-full dashed-button">
|
<div class="target-row">
|
||||||
<el-icon class="el-icon--left"><Plus /></el-icon>
|
<template v-if="distributeForm.target_type === 'ROLE'">
|
||||||
{{ TEXT.modules.fileVersionManagement.actions.addTarget }}
|
<el-select
|
||||||
</el-button>
|
v-model="distributeForm.role_ids"
|
||||||
|
multiple
|
||||||
|
filterable
|
||||||
|
clearable
|
||||||
|
:placeholder="TEXT.common.placeholders.select"
|
||||||
|
class="target-select"
|
||||||
|
>
|
||||||
|
<el-option v-for="role in roleOptions" :key="role.value" :label="role.label" :value="role.value" />
|
||||||
|
</el-select>
|
||||||
|
</template>
|
||||||
|
<template v-else-if="distributeForm.target_type === 'USER'">
|
||||||
|
<el-select
|
||||||
|
v-model="distributeForm.user_ids"
|
||||||
|
multiple
|
||||||
|
filterable
|
||||||
|
clearable
|
||||||
|
:placeholder="TEXT.common.placeholders.select"
|
||||||
|
class="target-select"
|
||||||
|
>
|
||||||
|
<el-option v-for="member in memberOptions" :key="member.value" :label="member.label" :value="member.value" />
|
||||||
|
</el-select>
|
||||||
|
</template>
|
||||||
|
<div v-else class="target-all">
|
||||||
|
<el-tag effect="plain" type="info">{{ TEXT.common.labels.all }}</el-tag>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item :label="TEXT.modules.fileVersionManagement.fields.dueAt">
|
|
||||||
<el-date-picker v-model="distributeForm.due_at" type="datetime" :placeholder="TEXT.common.placeholders.select" style="width: 100%" />
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
</el-form>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<el-button @click="distributeVisible = false">{{ TEXT.common.actions.cancel }}</el-button>
|
<el-button @click="distributeVisible = false">{{ TEXT.common.actions.cancel }}</el-button>
|
||||||
@@ -254,79 +215,40 @@
|
|||||||
</template>
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
|
||||||
<el-dialog v-model="submitVisible" :title="TEXT.modules.fileVersionManagement.messages.submitTitle" width="480px" destroy-on-close class="ctms-dialog">
|
|
||||||
<el-form :model="submitForm" label-width="100px" class="ctms-form">
|
|
||||||
<el-form-item :label="TEXT.modules.fileVersionManagement.fields.workflowTemplate">
|
|
||||||
<el-select
|
|
||||||
v-model="submitForm.template_id"
|
|
||||||
filterable
|
|
||||||
clearable
|
|
||||||
:placeholder="TEXT.modules.fileVersionManagement.placeholders.workflowTemplate"
|
|
||||||
style="width: 100%"
|
|
||||||
>
|
|
||||||
<el-option v-for="item in workflowTemplates" :key="item.id" :label="item.name" :value="item.id" />
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
<template #footer>
|
|
||||||
<el-button @click="submitVisible = false">{{ TEXT.common.actions.cancel }}</el-button>
|
|
||||||
<el-button type="primary" :loading="submitLoading" @click="confirmSubmit">{{ TEXT.common.actions.confirm }}</el-button>
|
|
||||||
</template>
|
|
||||||
</el-dialog>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, onMounted, reactive, ref, watch } from "vue";
|
import { computed, onMounted, reactive, ref, watch } from "vue";
|
||||||
import { useRoute, useRouter } from "vue-router";
|
import { useRoute, useRouter } from "vue-router";
|
||||||
import { ElMessage, FormInstance, FormRules } from "element-plus";
|
import { ElMessage, ElMessageBox, FormInstance, FormRules } from "element-plus";
|
||||||
import { ArrowLeft, Upload, Plus, Download, Check, Close, Link, Share, Delete } from "@element-plus/icons-vue";
|
import { ArrowLeft, Upload, Download, Share } from "@element-plus/icons-vue";
|
||||||
import {
|
import {
|
||||||
approveVersion,
|
|
||||||
createAcknowledgement,
|
|
||||||
createDistributions,
|
createDistributions,
|
||||||
|
deleteDocumentVersion,
|
||||||
downloadDocumentVersion,
|
downloadDocumentVersion,
|
||||||
fetchDocumentDetail,
|
fetchDocumentDetail,
|
||||||
listDistributions,
|
listDistributions,
|
||||||
listWorkflowTemplates,
|
|
||||||
makeVersionEffective,
|
|
||||||
rejectVersion,
|
|
||||||
submitVersion,
|
|
||||||
uploadDocumentVersion,
|
uploadDocumentVersion,
|
||||||
} from "../../api/documents";
|
} from "../../api/documents";
|
||||||
import { fetchAuditLogs } from "../../api/auditLogs";
|
|
||||||
import { listMembers } from "../../api/members";
|
import { listMembers } from "../../api/members";
|
||||||
import { fetchSites } from "../../api/sites";
|
import { fetchSites } from "../../api/sites";
|
||||||
import { fetchUsers } from "../../api/users";
|
import { fetchUsers } from "../../api/users";
|
||||||
import type { Distribution, DocumentDetail, DocumentVersion, WorkflowTemplate } from "../../types/documents";
|
import type { Distribution, DocumentDetail, DocumentVersion } from "../../types/documents";
|
||||||
import type { Site, StudyMember } from "../../types/api";
|
import type { Site, StudyMember } from "../../types/api";
|
||||||
import type { UserInfo } from "../../types/api";
|
import type { UserInfo } from "../../types/api";
|
||||||
|
import { useAuthStore } from "../../store/auth";
|
||||||
import { TEXT } from "../../locales";
|
import { TEXT } from "../../locales";
|
||||||
import { displayEnum, displayText, getUserDisplayName } from "../../utils/display";
|
import { displayEnum, displayText, getUserDisplayName } from "../../utils/display";
|
||||||
|
|
||||||
const getVersionStatusType = (status: string) => {
|
|
||||||
switch (status) {
|
|
||||||
case "APPROVED":
|
|
||||||
return "success";
|
|
||||||
case "DRAFT":
|
|
||||||
return "info";
|
|
||||||
case "SUBMITTED":
|
|
||||||
return "warning";
|
|
||||||
case "REJECTED":
|
|
||||||
return "danger";
|
|
||||||
default:
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
const auth = useAuthStore();
|
||||||
const documentId = computed(() => route.params.id as string);
|
const documentId = computed(() => route.params.id as string);
|
||||||
|
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const versionLoading = ref(false);
|
const versionLoading = ref(false);
|
||||||
const distributionLoading = ref(false);
|
const distributionLoading = ref(false);
|
||||||
const auditLoading = ref(false);
|
|
||||||
const detail = reactive<DocumentDetail>({
|
const detail = reactive<DocumentDetail>({
|
||||||
id: "",
|
id: "",
|
||||||
trial_id: "",
|
trial_id: "",
|
||||||
@@ -344,11 +266,9 @@ const detail = reactive<DocumentDetail>({
|
|||||||
|
|
||||||
const activeTab = ref("versions");
|
const activeTab = ref("versions");
|
||||||
const distributions = ref<Distribution[]>([]);
|
const distributions = ref<Distribution[]>([]);
|
||||||
const auditLogs = ref<any[]>([]);
|
|
||||||
const users = ref<UserInfo[]>([]);
|
const users = ref<UserInfo[]>([]);
|
||||||
const sites = ref<Site[]>([]);
|
const sites = ref<Site[]>([]);
|
||||||
const members = ref<StudyMember[]>([]);
|
const members = ref<StudyMember[]>([]);
|
||||||
const workflowTemplates = ref<WorkflowTemplate[]>([]);
|
|
||||||
|
|
||||||
const siteActiveMap = computed(() => {
|
const siteActiveMap = computed(() => {
|
||||||
const map: Record<string, boolean> = {};
|
const map: Record<string, boolean> = {};
|
||||||
@@ -358,29 +278,57 @@ const siteActiveMap = computed(() => {
|
|||||||
return map;
|
return map;
|
||||||
});
|
});
|
||||||
const isReadOnly = computed(() => !!detail.site_id && siteActiveMap.value[detail.site_id] === false);
|
const isReadOnly = computed(() => !!detail.site_id && siteActiveMap.value[detail.site_id] === false);
|
||||||
|
const isAdmin = computed(() => auth.user?.role === "ADMIN");
|
||||||
|
|
||||||
const userMap = computed(() =>
|
const memberUserMap = computed(() =>
|
||||||
users.value.reduce<Record<string, string>>((acc, user) => {
|
members.value.reduce<Record<string, string>>((acc, member) => {
|
||||||
acc[user.id] = getUserDisplayName(user) || user.email || user.username || user.id;
|
const user = (member as any).user;
|
||||||
|
const name = getUserDisplayName(user) || user?.email || user?.username || member.user_id;
|
||||||
|
acc[member.user_id] = name;
|
||||||
return acc;
|
return acc;
|
||||||
}, {})
|
}, {})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const userMap = computed(() => {
|
||||||
|
const map = { ...memberUserMap.value };
|
||||||
|
users.value.forEach((user) => {
|
||||||
|
map[user.id] = getUserDisplayName(user) || user.email || user.username || user.id;
|
||||||
|
});
|
||||||
|
return map;
|
||||||
|
});
|
||||||
|
|
||||||
const displayCreator = (userId?: string | null) => {
|
const displayCreator = (userId?: string | null) => {
|
||||||
if (!userId) return TEXT.common.fallback;
|
if (!userId) return TEXT.common.fallback;
|
||||||
return userMap.value[userId] || userId;
|
return userMap.value[userId] || userId;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const displayParentVersion = (parentId?: string | null) => {
|
||||||
|
if (!parentId) return TEXT.common.fallback;
|
||||||
|
const hit = detail.version_timeline?.find((item: any) => item.id === parentId);
|
||||||
|
return hit?.version_no ? `V${hit.version_no}` : TEXT.common.fallback;
|
||||||
|
};
|
||||||
|
|
||||||
const displaySite = (siteId?: string | null) => {
|
const displaySite = (siteId?: string | null) => {
|
||||||
if (!siteId) return TEXT.enums.scopeType.GLOBAL;
|
if (!siteId) return TEXT.enums.scopeType.GLOBAL;
|
||||||
return sites.value.find((s) => s.id === siteId)?.name || siteId;
|
return sites.value.find((s) => s.id === siteId)?.name || siteId;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const currentEffectiveVersion = computed(() => {
|
||||||
|
if (!detail.current_effective_version_id) return null;
|
||||||
|
return detail.version_timeline?.find((item: any) => item.id === detail.current_effective_version_id) || null;
|
||||||
|
});
|
||||||
|
|
||||||
|
const distributionVersionId = computed(() => {
|
||||||
|
if (detail.current_effective_version_id) return detail.current_effective_version_id;
|
||||||
|
return detail.version_timeline?.[0]?.id || null;
|
||||||
|
});
|
||||||
|
|
||||||
const uploadVisible = ref(false);
|
const uploadVisible = ref(false);
|
||||||
const uploading = ref(false);
|
const uploading = ref(false);
|
||||||
const uploadFormRef = ref<FormInstance>();
|
const uploadFormRef = ref<FormInstance>();
|
||||||
const uploadForm = reactive({
|
const uploadForm = reactive({
|
||||||
version_no: "",
|
version_no: "",
|
||||||
|
version_date: "",
|
||||||
change_summary: "",
|
change_summary: "",
|
||||||
parent_version_id: "",
|
parent_version_id: "",
|
||||||
});
|
});
|
||||||
@@ -388,19 +336,12 @@ const uploadFile = ref<File | null>(null);
|
|||||||
|
|
||||||
const distributeVisible = ref(false);
|
const distributeVisible = ref(false);
|
||||||
const distributing = ref(false);
|
const distributing = ref(false);
|
||||||
const targetSeed = ref(0);
|
|
||||||
const distributeForm = reactive({
|
const distributeForm = reactive({
|
||||||
targets: [{ uid: 0, target_type: "ROLE", target_id: "" }],
|
target_type: "ALL" as "ALL" | "ROLE" | "USER",
|
||||||
due_at: "",
|
role_ids: [] as string[],
|
||||||
|
user_ids: [] as string[],
|
||||||
});
|
});
|
||||||
|
|
||||||
const submitVisible = ref(false);
|
|
||||||
const submitLoading = ref(false);
|
|
||||||
const submitForm = reactive({
|
|
||||||
template_id: "",
|
|
||||||
});
|
|
||||||
const submitTarget = ref<DocumentVersion | null>(null);
|
|
||||||
|
|
||||||
const uploadRules: FormRules = {
|
const uploadRules: FormRules = {
|
||||||
version_no: [
|
version_no: [
|
||||||
{ required: true, message: TEXT.common.messages.required, trigger: "blur" },
|
{ required: true, message: TEXT.common.messages.required, trigger: "blur" },
|
||||||
@@ -412,6 +353,7 @@ const uploadRules: FormRules = {
|
|||||||
trigger: "blur",
|
trigger: "blur",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
version_date: [{ required: true, message: TEXT.common.messages.required, trigger: "change" }],
|
||||||
};
|
};
|
||||||
|
|
||||||
const roleOptions = computed(() => {
|
const roleOptions = computed(() => {
|
||||||
@@ -447,12 +389,6 @@ const displayTarget = (row: Distribution) => {
|
|||||||
return row.target_id;
|
return row.target_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
const createTarget = () => ({
|
|
||||||
uid: ++targetSeed.value,
|
|
||||||
target_type: "ROLE",
|
|
||||||
target_id: "",
|
|
||||||
});
|
|
||||||
|
|
||||||
const canAction = (action: string) => {
|
const canAction = (action: string) => {
|
||||||
if (isReadOnly.value && action !== "view") return false;
|
if (isReadOnly.value && action !== "view") return false;
|
||||||
const list = detail.can_actions || [];
|
const list = detail.can_actions || [];
|
||||||
@@ -487,6 +423,7 @@ const loadSites = async () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const loadUsers = async () => {
|
const loadUsers = async () => {
|
||||||
|
if (!isAdmin.value) return;
|
||||||
try {
|
try {
|
||||||
const { data } = await fetchUsers({ limit: 500 });
|
const { data } = await fetchUsers({ limit: 500 });
|
||||||
users.value = (data as any).items || data || [];
|
users.value = (data as any).items || data || [];
|
||||||
@@ -521,13 +458,13 @@ const loadDetail = async () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const loadDistributions = async () => {
|
const loadDistributions = async () => {
|
||||||
if (!detail.current_effective_version_id) {
|
if (!distributionVersionId.value) {
|
||||||
distributions.value = [];
|
distributions.value = [];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
distributionLoading.value = true;
|
distributionLoading.value = true;
|
||||||
try {
|
try {
|
||||||
const { data } = await listDistributions(detail.current_effective_version_id);
|
const { data } = await listDistributions(distributionVersionId.value);
|
||||||
distributions.value = data || [];
|
distributions.value = data || [];
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
ElMessage.error(e?.response?.data?.message || TEXT.common.messages.loadFailed);
|
ElMessage.error(e?.response?.data?.message || TEXT.common.messages.loadFailed);
|
||||||
@@ -536,44 +473,15 @@ const loadDistributions = async () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const loadAuditLogs = async () => {
|
|
||||||
if (!detail.trial_id) return;
|
|
||||||
auditLoading.value = true;
|
|
||||||
try {
|
|
||||||
const { data } = await fetchAuditLogs(detail.trial_id, {
|
|
||||||
entity_type: "DOCUMENT",
|
|
||||||
entity_id: documentId.value,
|
|
||||||
limit: 20,
|
|
||||||
});
|
|
||||||
auditLogs.value = Array.isArray(data) ? data : data.items || [];
|
|
||||||
} catch (e: any) {
|
|
||||||
ElMessage.error(e?.response?.data?.message || TEXT.common.messages.loadFailed);
|
|
||||||
} finally {
|
|
||||||
auditLoading.value = false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const loadWorkflowTemplates = async () => {
|
|
||||||
try {
|
|
||||||
const params = detail.trial_id ? { trial_id: detail.trial_id } : undefined;
|
|
||||||
const { data } = await listWorkflowTemplates(params);
|
|
||||||
workflowTemplates.value = data || [];
|
|
||||||
} catch (e: any) {
|
|
||||||
ElMessage.error(e?.response?.data?.message || TEXT.common.messages.loadFailed);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleTabChange = async (name: string) => {
|
const handleTabChange = async (name: string) => {
|
||||||
if (name === "distributions") {
|
if (name === "distributions") {
|
||||||
await loadDistributions();
|
await loadDistributions();
|
||||||
}
|
}
|
||||||
if (name === "audit") {
|
|
||||||
await loadAuditLogs();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const openUpload = () => {
|
const openUpload = () => {
|
||||||
uploadForm.version_no = "";
|
uploadForm.version_no = "";
|
||||||
|
uploadForm.version_date = "";
|
||||||
uploadForm.change_summary = "";
|
uploadForm.change_summary = "";
|
||||||
uploadForm.parent_version_id = "";
|
uploadForm.parent_version_id = "";
|
||||||
uploadFile.value = null;
|
uploadFile.value = null;
|
||||||
@@ -600,6 +508,9 @@ const submitUpload = async () => {
|
|||||||
try {
|
try {
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append("version_no", uploadForm.version_no);
|
formData.append("version_no", uploadForm.version_no);
|
||||||
|
if (uploadForm.version_date) {
|
||||||
|
formData.append("version_date", uploadForm.version_date);
|
||||||
|
}
|
||||||
if (uploadForm.change_summary) {
|
if (uploadForm.change_summary) {
|
||||||
formData.append("change_summary", uploadForm.change_summary);
|
formData.append("change_summary", uploadForm.change_summary);
|
||||||
}
|
}
|
||||||
@@ -619,73 +530,6 @@ const submitUpload = async () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const openSubmit = async (version: DocumentVersion) => {
|
|
||||||
submitTarget.value = version;
|
|
||||||
submitForm.template_id = "";
|
|
||||||
submitVisible.value = true;
|
|
||||||
if (!workflowTemplates.value.length) {
|
|
||||||
await loadWorkflowTemplates();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const confirmSubmit = async () => {
|
|
||||||
if (!submitTarget.value) return;
|
|
||||||
if (!submitForm.template_id) {
|
|
||||||
ElMessage.warning(TEXT.modules.fileVersionManagement.messages.workflowTemplateRequired);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
submitLoading.value = true;
|
|
||||||
try {
|
|
||||||
await submitVersion(submitTarget.value.id, { template_id: submitForm.template_id, comment: "" });
|
|
||||||
submitVisible.value = false;
|
|
||||||
await loadDetail();
|
|
||||||
ElMessage.success(TEXT.modules.fileVersionManagement.messages.submitSuccess);
|
|
||||||
} catch (e: any) {
|
|
||||||
ElMessage.error(e?.response?.data?.message || TEXT.common.messages.saveFailed);
|
|
||||||
} finally {
|
|
||||||
submitLoading.value = false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const approve = async (version: DocumentVersion) => {
|
|
||||||
versionLoading.value = true;
|
|
||||||
try {
|
|
||||||
await approveVersion(version.id, { comment: "" });
|
|
||||||
await loadDetail();
|
|
||||||
ElMessage.success(TEXT.modules.fileVersionManagement.messages.approveSuccess);
|
|
||||||
} catch (e: any) {
|
|
||||||
ElMessage.error(e?.response?.data?.message || TEXT.common.messages.saveFailed);
|
|
||||||
} finally {
|
|
||||||
versionLoading.value = false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const reject = async (version: DocumentVersion) => {
|
|
||||||
versionLoading.value = true;
|
|
||||||
try {
|
|
||||||
await rejectVersion(version.id, { comment: "" });
|
|
||||||
await loadDetail();
|
|
||||||
ElMessage.success(TEXT.modules.fileVersionManagement.messages.rejectSuccess);
|
|
||||||
} catch (e: any) {
|
|
||||||
ElMessage.error(e?.response?.data?.message || TEXT.common.messages.saveFailed);
|
|
||||||
} finally {
|
|
||||||
versionLoading.value = false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const makeEffective = async (version: DocumentVersion) => {
|
|
||||||
versionLoading.value = true;
|
|
||||||
try {
|
|
||||||
await makeVersionEffective(version.id);
|
|
||||||
await loadDetail();
|
|
||||||
ElMessage.success(TEXT.modules.fileVersionManagement.messages.effectiveSuccess);
|
|
||||||
} catch (e: any) {
|
|
||||||
ElMessage.error(e?.response?.data?.message || TEXT.common.messages.saveFailed);
|
|
||||||
} finally {
|
|
||||||
versionLoading.value = false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const getFilename = (header?: string | null) => {
|
const getFilename = (header?: string | null) => {
|
||||||
if (!header) return null;
|
if (!header) return null;
|
||||||
const match = /filename\*=UTF-8''([^;]+)|filename="?([^\";]+)"?/i.exec(header);
|
const match = /filename\*=UTF-8''([^;]+)|filename="?([^\";]+)"?/i.exec(header);
|
||||||
@@ -714,47 +558,72 @@ const downloadVersion = async (version: DocumentVersion) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const confirmDeleteVersion = async (version: DocumentVersion) => {
|
||||||
|
if (!version?.id) return;
|
||||||
|
const ok = await ElMessageBox.confirm(TEXT.common.confirm.delete, TEXT.common.labels.tips).catch(() => null);
|
||||||
|
if (!ok) return;
|
||||||
|
try {
|
||||||
|
await deleteDocumentVersion(version.id);
|
||||||
|
ElMessage.success(TEXT.common.messages.deleteSuccess);
|
||||||
|
await loadDetail();
|
||||||
|
} catch (e: any) {
|
||||||
|
ElMessage.error(e?.response?.data?.message || TEXT.common.messages.deleteFailed);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const openDistribute = () => {
|
const openDistribute = () => {
|
||||||
distributeForm.targets = [createTarget()];
|
distributeForm.target_type = "ALL";
|
||||||
distributeForm.due_at = "";
|
distributeForm.role_ids = [];
|
||||||
|
distributeForm.user_ids = [];
|
||||||
distributeVisible.value = true;
|
distributeVisible.value = true;
|
||||||
if (!members.value.length) {
|
if (!members.value.length) {
|
||||||
loadMembers();
|
loadMembers();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const addTarget = () => {
|
const onTargetTypeChange = () => {
|
||||||
distributeForm.targets.push(createTarget());
|
distributeForm.role_ids = [];
|
||||||
};
|
distributeForm.user_ids = [];
|
||||||
|
|
||||||
const removeTarget = (index: number) => {
|
|
||||||
distributeForm.targets.splice(index, 1);
|
|
||||||
};
|
|
||||||
|
|
||||||
const onTargetTypeChange = (index: number) => {
|
|
||||||
const target = distributeForm.targets[index];
|
|
||||||
if (!target) return;
|
|
||||||
target.target_id = "";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const submitDistribute = async () => {
|
const submitDistribute = async () => {
|
||||||
if (!detail.current_effective_version_id) {
|
if (!distributionVersionId.value) {
|
||||||
ElMessage.warning(TEXT.modules.fileVersionManagement.messages.noEffective);
|
ElMessage.warning(TEXT.modules.fileVersionManagement.messages.noEffective);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (distributeForm.targets.some((t) => !t.target_id)) {
|
|
||||||
ElMessage.warning(TEXT.modules.fileVersionManagement.messages.missingTarget);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
distributing.value = true;
|
distributing.value = true;
|
||||||
try {
|
try {
|
||||||
const targets = distributeForm.targets.map((t) => ({
|
let targets: { target_type: string; target_id: string }[] = [];
|
||||||
target_type: t.target_type,
|
if (distributeForm.target_type === "ALL") {
|
||||||
target_id: t.target_id,
|
targets = memberOptions.value.map((m) => ({
|
||||||
}));
|
target_type: "USER",
|
||||||
await createDistributions(detail.current_effective_version_id, {
|
target_id: m.value,
|
||||||
|
}));
|
||||||
|
} else if (distributeForm.target_type === "ROLE") {
|
||||||
|
if (!distributeForm.role_ids.length) {
|
||||||
|
ElMessage.warning(TEXT.modules.fileVersionManagement.messages.missingTarget);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
targets = distributeForm.role_ids.map((role) => ({
|
||||||
|
target_type: "ROLE",
|
||||||
|
target_id: role,
|
||||||
|
}));
|
||||||
|
} else if (distributeForm.target_type === "USER") {
|
||||||
|
if (!distributeForm.user_ids.length) {
|
||||||
|
ElMessage.warning(TEXT.modules.fileVersionManagement.messages.missingTarget);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
targets = distributeForm.user_ids.map((user) => ({
|
||||||
|
target_type: "USER",
|
||||||
|
target_id: user,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
if (!targets.length) {
|
||||||
|
ElMessage.warning(TEXT.modules.fileVersionManagement.messages.missingTarget);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await createDistributions(distributionVersionId.value, {
|
||||||
targets,
|
targets,
|
||||||
due_at: distributeForm.due_at || undefined,
|
|
||||||
});
|
});
|
||||||
distributeVisible.value = false;
|
distributeVisible.value = false;
|
||||||
await loadDistributions();
|
await loadDistributions();
|
||||||
@@ -766,16 +635,6 @@ const submitDistribute = async () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const ack = async (distribution: Distribution, ackType: string) => {
|
|
||||||
try {
|
|
||||||
await createAcknowledgement(distribution.id, { ack_type: ackType });
|
|
||||||
await loadDistributions();
|
|
||||||
ElMessage.success(TEXT.modules.fileVersionManagement.messages.ackSuccess);
|
|
||||||
} catch (e: any) {
|
|
||||||
ElMessage.error(e?.response?.data?.message || TEXT.common.messages.saveFailed);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const goBack = () => {
|
const goBack = () => {
|
||||||
if (detail.trial_id) {
|
if (detail.trial_id) {
|
||||||
router.push(`/trial/${detail.trial_id}/documents`);
|
router.push(`/trial/${detail.trial_id}/documents`);
|
||||||
@@ -789,6 +648,12 @@ const formatDate = (value?: string | null) => {
|
|||||||
return value.replace("T", " ").replace("Z", "").split(".")[0];
|
return value.replace("T", " ").replace("Z", "").split(".")[0];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const formatDateOnly = (value?: string | null) => {
|
||||||
|
const formatted = formatDate(value);
|
||||||
|
if (formatted === TEXT.common.fallback) return formatted;
|
||||||
|
return formatted.split(" ")[0];
|
||||||
|
};
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await loadDetail();
|
await loadDetail();
|
||||||
await loadDistributions();
|
await loadDistributions();
|
||||||
@@ -846,6 +711,36 @@ watch(
|
|||||||
border-style: dashed;
|
border-style: dashed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.target-toolbar {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.target-type-preset {
|
||||||
|
width: 120px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.target-row {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.target-select {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 180px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.target-all {
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
min-width: 180px;
|
||||||
|
}
|
||||||
|
|
||||||
.flex {
|
.flex {
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,46 +1,34 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="ctms-page">
|
<div class="ctms-page">
|
||||||
<div class="ctms-page-header">
|
|
||||||
<div>
|
|
||||||
<h1 class="ctms-page-title">{{ TEXT.modules.fileVersionManagement.title }}</h1>
|
|
||||||
</div>
|
|
||||||
<div class="ctms-page-actions">
|
|
||||||
<el-button type="primary" @click="openCreate">
|
|
||||||
<el-icon class="el-icon--left"><Plus /></el-icon>
|
|
||||||
{{ TEXT.modules.fileVersionManagement.newDocument }}
|
|
||||||
</el-button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<el-card class="ctms-filter-card">
|
<el-card shadow="never" class="main-content-card">
|
||||||
<div class="ctms-filter-row">
|
<div class="filter-container">
|
||||||
<div class="ctms-filter-item">
|
<el-form :inline="true" :model="filters" class="filter-form">
|
||||||
<span class="ctms-filter-label">{{ TEXT.modules.fileVersionManagement.filters.scope }}</span>
|
<el-form-item label="" class="filter-item-form">
|
||||||
<el-select v-model="filters.scope_type" :placeholder="TEXT.modules.fileVersionManagement.filters.all" clearable>
|
<el-select v-model="filters.scope_type" :placeholder="TEXT.modules.fileVersionManagement.filters.scope" clearable class="filter-select-comp">
|
||||||
<el-option v-for="item in scopeOptions" :key="item.value" :label="item.label" :value="item.value" />
|
<el-option v-for="item in scopeOptions" :key="item.value" :label="item.label" :value="item.value" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</div>
|
</el-form-item>
|
||||||
<div class="ctms-filter-item">
|
<el-form-item label="" class="filter-item-form">
|
||||||
<span class="ctms-filter-label">{{ TEXT.modules.fileVersionManagement.filters.site }}</span>
|
<el-select v-model="filters.site_id" :placeholder="TEXT.modules.fileVersionManagement.filters.site" clearable filterable class="filter-select-comp">
|
||||||
<el-select v-model="filters.site_id" :placeholder="TEXT.modules.fileVersionManagement.filters.all" clearable filterable>
|
<el-option v-for="item in siteOptions" :key="item.value" :label="item.label" :value="item.value" />
|
||||||
<el-option v-for="item in siteOptions" :key="item.value" :label="item.label" :value="item.value" />
|
</el-select>
|
||||||
</el-select>
|
</el-form-item>
|
||||||
</div>
|
<el-form-item label="" class="filter-item-form">
|
||||||
<div class="ctms-filter-item">
|
<el-select v-model="filters.doc_type" :placeholder="TEXT.modules.fileVersionManagement.filters.docType" clearable class="filter-select-comp">
|
||||||
<span class="ctms-filter-label">{{ TEXT.modules.fileVersionManagement.filters.docType }}</span>
|
<el-option v-for="item in docTypeOptions" :key="item.value" :label="item.label" :value="item.value" />
|
||||||
<el-select v-model="filters.doc_type" :placeholder="TEXT.modules.fileVersionManagement.filters.all" clearable>
|
</el-select>
|
||||||
<el-option v-for="item in docTypeOptions" :key="item.value" :label="item.label" :value="item.value" />
|
</el-form-item>
|
||||||
</el-select>
|
<el-form-item class="filter-item-form">
|
||||||
</div>
|
<el-button @click="resetFilters">{{ TEXT.common.actions.reset }}</el-button>
|
||||||
<div class="ctms-filter-spacer"></div>
|
</el-form-item>
|
||||||
<div class="ctms-filter-actions">
|
<div class="filter-spacer"></div>
|
||||||
<el-button type="primary" @click="load">{{ TEXT.common.actions.search }}</el-button>
|
<el-button type="primary" @click="openCreate" class="header-action-btn">
|
||||||
<el-button @click="resetFilters">{{ TEXT.common.actions.reset }}</el-button>
|
<el-icon class="el-icon--left"><Plus /></el-icon>
|
||||||
</div>
|
{{ TEXT.modules.fileVersionManagement.newDocument }}
|
||||||
|
</el-button>
|
||||||
|
</el-form>
|
||||||
</div>
|
</div>
|
||||||
</el-card>
|
|
||||||
|
|
||||||
<el-card class="ctms-table-card">
|
|
||||||
<el-table
|
<el-table
|
||||||
:data="sortedItems"
|
:data="sortedItems"
|
||||||
v-loading="loading"
|
v-loading="loading"
|
||||||
@@ -86,7 +74,7 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column :label="TEXT.modules.fileVersionManagement.columns.actions" width="100" align="center">
|
<el-table-column :label="TEXT.modules.fileVersionManagement.columns.actions" width="100" align="center">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<el-button link type="danger" :disabled="isInactiveSite(row.site_id)" @click.stop="confirmDelete(row)">
|
<el-button v-if="isAdmin" link type="danger" :disabled="isInactiveSite(row.site_id)" @click.stop="confirmDelete(row)">
|
||||||
{{ TEXT.common.actions.delete }}
|
{{ TEXT.common.actions.delete }}
|
||||||
</el-button>
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
@@ -137,6 +125,7 @@ import { Plus } from "@element-plus/icons-vue";
|
|||||||
import { fetchDocuments, createDocument, deleteDocument } from "../../api/documents";
|
import { fetchDocuments, createDocument, deleteDocument } from "../../api/documents";
|
||||||
import { fetchSites } from "../../api/sites";
|
import { fetchSites } from "../../api/sites";
|
||||||
import { useStudyStore } from "../../store/study";
|
import { useStudyStore } from "../../store/study";
|
||||||
|
import { useAuthStore } from "../../store/auth";
|
||||||
import type { DocumentSummary } from "../../types/documents";
|
import type { DocumentSummary } from "../../types/documents";
|
||||||
import type { Site } from "../../types/api";
|
import type { Site } from "../../types/api";
|
||||||
import { displayEnum, displayText } from "../../utils/display";
|
import { displayEnum, displayText } from "../../utils/display";
|
||||||
@@ -145,6 +134,7 @@ import { TEXT } from "../../locales";
|
|||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const study = useStudyStore();
|
const study = useStudyStore();
|
||||||
|
const auth = useAuthStore();
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const items = ref<DocumentSummary[]>([]);
|
const items = ref<DocumentSummary[]>([]);
|
||||||
const sites = ref<Site[]>([]);
|
const sites = ref<Site[]>([]);
|
||||||
@@ -178,11 +168,23 @@ const siteActiveMap = computed(() => {
|
|||||||
});
|
});
|
||||||
return map;
|
return map;
|
||||||
});
|
});
|
||||||
|
const isAdmin = computed(() => {
|
||||||
|
const role = auth.user?.role;
|
||||||
|
return role === "ADMIN";
|
||||||
|
});
|
||||||
const isInactiveSite = (siteId?: string | null) => !!siteId && siteActiveMap.value[siteId] === false;
|
const isInactiveSite = (siteId?: string | null) => !!siteId && siteActiveMap.value[siteId] === false;
|
||||||
const documentRowClass = ({ row }: { row: DocumentSummary }) =>
|
const documentRowClass = ({ row }: { row: DocumentSummary }) =>
|
||||||
`${row?.id ? "clickable-row" : ""}${isInactiveSite(row?.site_id) ? " row-inactive" : ""}`.trim();
|
`${row?.id ? "clickable-row" : ""}${isInactiveSite(row?.site_id) ? " row-inactive" : ""}`.trim();
|
||||||
|
const filteredItems = computed(() =>
|
||||||
|
items.value.filter((item) => {
|
||||||
|
if (filters.scope_type && item?.scope_type !== filters.scope_type) return false;
|
||||||
|
if (filters.site_id && item?.site_id !== filters.site_id) return false;
|
||||||
|
if (filters.doc_type && item?.doc_type !== filters.doc_type) return false;
|
||||||
|
return true;
|
||||||
|
})
|
||||||
|
);
|
||||||
const sortedItems = computed(() =>
|
const sortedItems = computed(() =>
|
||||||
[...items.value].sort((a, b) => Number(isInactiveSite(a?.site_id)) - Number(isInactiveSite(b?.site_id)))
|
[...filteredItems.value].sort((a, b) => Number(isInactiveSite(a?.site_id)) - Number(isInactiveSite(b?.site_id)))
|
||||||
);
|
);
|
||||||
|
|
||||||
const createForm = reactive({
|
const createForm = reactive({
|
||||||
@@ -240,12 +242,7 @@ const load = async () => {
|
|||||||
if (!trialId.value) return;
|
if (!trialId.value) return;
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
try {
|
try {
|
||||||
const { data } = await fetchDocuments({
|
const { data } = await fetchDocuments({ trial_id: trialId.value });
|
||||||
trial_id: trialId.value,
|
|
||||||
scope_type: filters.scope_type || undefined,
|
|
||||||
site_id: filters.site_id || undefined,
|
|
||||||
doc_type: filters.doc_type || undefined,
|
|
||||||
});
|
|
||||||
items.value = data.items || [];
|
items.value = data.items || [];
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
ElMessage.error(e?.response?.data?.message || TEXT.common.messages.loadFailed);
|
ElMessage.error(e?.response?.data?.message || TEXT.common.messages.loadFailed);
|
||||||
@@ -258,7 +255,6 @@ const resetFilters = () => {
|
|||||||
filters.scope_type = "";
|
filters.scope_type = "";
|
||||||
filters.site_id = "";
|
filters.site_id = "";
|
||||||
filters.doc_type = "";
|
filters.doc_type = "";
|
||||||
load();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const openCreate = () => {
|
const openCreate = () => {
|
||||||
@@ -343,24 +339,43 @@ watch(
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.text-secondary {
|
.ctms-page {
|
||||||
color: var(--ctms-text-secondary);
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|
||||||
.font-mono {
|
.main-content-card :deep(.el-card__body) {
|
||||||
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
|
padding: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.font-medium {
|
.filter-container {
|
||||||
font-weight: 500;
|
margin-bottom: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.text-primary {
|
.filter-form {
|
||||||
color: var(--ctms-primary);
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
|
gap: 12px;
|
||||||
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.font-semibold {
|
.filter-item-form {
|
||||||
font-weight: 600;
|
margin-bottom: 0 !important;
|
||||||
|
margin-right: 0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-select-comp {
|
||||||
|
width: 140px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-spacer {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-action-btn {
|
||||||
|
height: 36px;
|
||||||
|
padding: 0 20px;
|
||||||
|
border-radius: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -89,6 +89,11 @@ const load = async () => {
|
|||||||
try {
|
try {
|
||||||
const { data } = await getDrugShipment(studyId, shipmentId);
|
const { data } = await getDrugShipment(studyId, shipmentId);
|
||||||
Object.assign(detail, data);
|
Object.assign(detail, data);
|
||||||
|
|
||||||
|
// 同步中心名称到面包屑
|
||||||
|
if (detail.site_name) {
|
||||||
|
study.setViewContext({ siteName: detail.site_name });
|
||||||
|
}
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
ElMessage.error(e?.response?.data?.message || TEXT.common.messages.loadFailed);
|
ElMessage.error(e?.response?.data?.message || TEXT.common.messages.loadFailed);
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -1,10 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="page">
|
<div class="page">
|
||||||
<div class="page-header">
|
|
||||||
<div>
|
|
||||||
<h1 class="page-title">{{ TEXT.modules.feeContracts.detailTitle }}</h1>
|
|
||||||
<p class="page-subtitle">{{ TEXT.modules.feeContracts.detailSubtitle }}</p>
|
|
||||||
</div>
|
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
<el-button type="primary" :disabled="!canWrite || isReadOnly" @click="goEdit" class="header-action-btn copy-btn">
|
<el-button type="primary" :disabled="!canWrite || isReadOnly" @click="goEdit" class="header-action-btn copy-btn">
|
||||||
<el-icon class="el-icon--left"><Edit /></el-icon>
|
<el-icon class="el-icon--left"><Edit /></el-icon>
|
||||||
@@ -14,7 +9,6 @@
|
|||||||
{{ TEXT.common.actions.back }}
|
{{ TEXT.common.actions.back }}
|
||||||
</el-button>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<StateError v-if="errorMessage" :description="errorMessage">
|
<StateError v-if="errorMessage" :description="errorMessage">
|
||||||
<template #action>
|
<template #action>
|
||||||
@@ -201,6 +195,11 @@ const load = async () => {
|
|||||||
const { data } = await getContractFee(contractId);
|
const { data } = await getContractFee(contractId);
|
||||||
Object.assign(detail, data?.data || {});
|
Object.assign(detail, data?.data || {});
|
||||||
if (!Array.isArray(detail.payments)) detail.payments = [];
|
if (!Array.isArray(detail.payments)) detail.payments = [];
|
||||||
|
|
||||||
|
// 同步中心名称到面包屑
|
||||||
|
if (centerName.value) {
|
||||||
|
study.setViewContext({ siteName: centerName.value });
|
||||||
|
}
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
errorMessage.value = e?.response?.data?.message || TEXT.common.messages.loadFailed;
|
errorMessage.value = e?.response?.data?.message || TEXT.common.messages.loadFailed;
|
||||||
} finally {
|
} finally {
|
||||||
@@ -233,7 +232,7 @@ onMounted(async () => {
|
|||||||
.page {
|
.page {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 20px;
|
gap: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.page-header {
|
.page-header {
|
||||||
|
|||||||
@@ -1,14 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="page">
|
<div class="page">
|
||||||
<div class="page-header">
|
|
||||||
<div>
|
|
||||||
<h1 class="page-title">{{ TEXT.modules.feeContracts.title }}</h1>
|
|
||||||
</div>
|
|
||||||
<el-button type="primary" :disabled="!canWrite" @click="goNew" class="header-action-btn">
|
|
||||||
<el-icon class="el-icon--left"><Plus /></el-icon>
|
|
||||||
{{ TEXT.modules.feeContracts.newTitle }}
|
|
||||||
</el-button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="overview">
|
<div class="overview">
|
||||||
<el-row :gutter="20">
|
<el-row :gutter="20">
|
||||||
@@ -55,34 +46,39 @@
|
|||||||
</el-row>
|
</el-row>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<el-card class="filter-card" shadow="never">
|
<el-card shadow="never" class="main-content-card" v-if="!errorMessage && !loading">
|
||||||
<el-form :inline="true" :model="filters" class="filter-form">
|
<div class="filter-container">
|
||||||
<el-form-item label="" class="filter-item">
|
<el-form :inline="true" :model="filters" class="filter-form">
|
||||||
<el-select v-model="filters.centerId" clearable :placeholder="TEXT.common.fields.site" class="filter-select">
|
<el-form-item label="" class="filter-item">
|
||||||
<template #prefix>
|
<el-select v-model="filters.centerId" clearable :placeholder="TEXT.common.fields.site" class="filter-select">
|
||||||
<el-icon><Location /></el-icon>
|
<template #prefix>
|
||||||
</template>
|
<el-icon><Location /></el-icon>
|
||||||
<el-option
|
</template>
|
||||||
v-for="site in sites"
|
<el-option
|
||||||
:key="site.id"
|
v-for="site in sites"
|
||||||
:label="site.name || TEXT.common.fallback"
|
:key="site.id"
|
||||||
:value="site.id"
|
:label="site.name || TEXT.common.fallback"
|
||||||
/>
|
:value="site.id"
|
||||||
</el-select>
|
/>
|
||||||
</el-form-item>
|
</el-select>
|
||||||
<el-form-item label="" class="filter-item">
|
</el-form-item>
|
||||||
<el-input v-model="filters.q" :placeholder="TEXT.common.placeholders.keyword" clearable class="filter-input">
|
<el-form-item label="" class="filter-item">
|
||||||
<template #prefix>
|
<el-input v-model="filters.q" :placeholder="TEXT.common.placeholders.keyword" clearable class="filter-input">
|
||||||
<el-icon><Search /></el-icon>
|
<template #prefix>
|
||||||
</template>
|
<el-icon><Search /></el-icon>
|
||||||
</el-input>
|
</template>
|
||||||
</el-form-item>
|
</el-input>
|
||||||
<el-form-item class="filter-actions">
|
</el-form-item>
|
||||||
<el-button type="primary" @click="load">{{ TEXT.common.actions.search }}</el-button>
|
<el-form-item class="filter-actions">
|
||||||
<el-button @click="resetFilters">{{ TEXT.common.actions.reset }}</el-button>
|
<el-button @click="resetFilters">{{ TEXT.common.actions.reset }}</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
<div class="filter-spacer"></div>
|
||||||
</el-card>
|
<el-button type="primary" :disabled="!canWrite" @click="goNew" class="header-action-btn">
|
||||||
|
<el-icon class="el-icon--left"><Plus /></el-icon>
|
||||||
|
{{ TEXT.modules.feeContracts.newTitle }}
|
||||||
|
</el-button>
|
||||||
|
</el-form>
|
||||||
|
</div>
|
||||||
|
|
||||||
<StateError v-if="errorMessage" :description="errorMessage">
|
<StateError v-if="errorMessage" :description="errorMessage">
|
||||||
<template #action>
|
<template #action>
|
||||||
@@ -92,7 +88,6 @@
|
|||||||
|
|
||||||
<StateLoading v-else-if="loading" :rows="6" />
|
<StateLoading v-else-if="loading" :rows="6" />
|
||||||
|
|
||||||
<el-card v-else class="table-card" shadow="never">
|
|
||||||
<el-table
|
<el-table
|
||||||
:data="sortedContracts"
|
:data="sortedContracts"
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
@@ -100,26 +95,26 @@
|
|||||||
:row-class-name="contractRowClass"
|
:row-class-name="contractRowClass"
|
||||||
:header-cell-style="{ background: '#f8f9fb' }"
|
:header-cell-style="{ background: '#f8f9fb' }"
|
||||||
>
|
>
|
||||||
<el-table-column prop="center_name" :label="TEXT.common.fields.site" min-width="180">
|
<el-table-column prop="center_name" :label="TEXT.common.fields.site" min-width="160">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<div class="site-cell">
|
<div class="site-cell">
|
||||||
<span class="site-name">{{ scope.row.center_name || TEXT.common.fallback }}</span>
|
<span class="site-name">{{ scope.row.center_name || TEXT.common.fallback }}</span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column :label="TEXT.modules.feeContracts.contractAmount" width="160" align="right">
|
<el-table-column :label="TEXT.modules.feeContracts.contractAmount" width="140" align="right">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<span class="amount-text">{{ formatAmountWan(scope.row.contract_amount) }}</span>
|
<span class="amount-text">{{ formatAmountWan(scope.row.contract_amount) }}</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column :label="TEXT.modules.feeContracts.caseProgress" min-width="150" align="center">
|
<el-table-column :label="TEXT.modules.feeContracts.caseProgress" min-width="140" align="center">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-tag effect="plain" type="info">
|
<el-tag effect="plain" type="info">
|
||||||
{{ displayCases(scope.row.contract_cases, scope.row.actual_cases) }}
|
{{ displayCases(scope.row.contract_cases, scope.row.actual_cases) }}
|
||||||
</el-tag>
|
</el-tag>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column :label="TEXT.modules.feeContracts.paidSummary" min-width="180">
|
<el-table-column :label="TEXT.modules.feeContracts.paidSummary" min-width="200">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<div class="summary-line">
|
<div class="summary-line">
|
||||||
<span>{{ TEXT.modules.feeContracts.paidTotal }}</span>
|
<span>{{ TEXT.modules.feeContracts.paidTotal }}</span>
|
||||||
@@ -132,7 +127,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column :label="TEXT.modules.feeContracts.verifySummary" min-width="180">
|
<el-table-column :label="TEXT.modules.feeContracts.verifySummary" min-width="200">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<div class="summary-line">
|
<div class="summary-line">
|
||||||
<span>{{ TEXT.modules.feeContracts.verifiedTotal }}</span>
|
<span>{{ TEXT.modules.feeContracts.verifiedTotal }}</span>
|
||||||
@@ -145,7 +140,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column :label="TEXT.modules.feeContracts.recentDates" min-width="200">
|
<el-table-column :label="TEXT.modules.feeContracts.recentDates" min-width="180">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<div class="date-line">
|
<div class="date-line">
|
||||||
<span class="date-label">{{ TEXT.modules.feeContracts.lastPaid }}</span>
|
<span class="date-label">{{ TEXT.modules.feeContracts.lastPaid }}</span>
|
||||||
@@ -157,12 +152,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column :label="TEXT.common.fields.remark" min-width="180" show-overflow-tooltip>
|
<el-table-column :label="TEXT.common.labels.actions" width="100">
|
||||||
<template #default="scope">
|
|
||||||
{{ scope.row.remark || TEXT.common.fallback }}
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column :label="TEXT.common.labels.actions" width="120">
|
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-button
|
<el-button
|
||||||
link
|
link
|
||||||
@@ -182,7 +172,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, onMounted, reactive, ref } from "vue";
|
import { computed, onMounted, reactive, ref, watch } from "vue";
|
||||||
import { useRouter } from "vue-router";
|
import { useRouter } from "vue-router";
|
||||||
import { ElMessage, ElMessageBox } from "element-plus";
|
import { ElMessage, ElMessageBox } from "element-plus";
|
||||||
import { Coin, Wallet, CircleCheck, CircleClose, Plus, Location, Search } from "@element-plus/icons-vue";
|
import { Coin, Wallet, CircleCheck, CircleClose, Plus, Location, Search } from "@element-plus/icons-vue";
|
||||||
@@ -214,14 +204,26 @@ const siteActiveMap = computed(() => {
|
|||||||
return map;
|
return map;
|
||||||
});
|
});
|
||||||
const isInactiveSite = (siteId?: string) => !!siteId && siteActiveMap.value[siteId] === false;
|
const isInactiveSite = (siteId?: string) => !!siteId && siteActiveMap.value[siteId] === false;
|
||||||
|
const filteredContracts = computed(() => {
|
||||||
|
const keyword = filters.q.trim().toLowerCase();
|
||||||
|
return contracts.value.filter((item) => {
|
||||||
|
if (filters.centerId && item?.center_id !== filters.centerId) return false;
|
||||||
|
if (keyword) {
|
||||||
|
const fields = [item?.center_name, item?.contract_no, item?.contract_name];
|
||||||
|
const matched = fields.some((field) => String(field || "").toLowerCase().includes(keyword));
|
||||||
|
if (!matched) return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
});
|
||||||
const sortedContracts = computed(() =>
|
const sortedContracts = computed(() =>
|
||||||
[...contracts.value].sort((a, b) => Number(isInactiveSite(a?.center_id)) - Number(isInactiveSite(b?.center_id)))
|
[...filteredContracts.value].sort((a, b) => Number(isInactiveSite(a?.center_id)) - Number(isInactiveSite(b?.center_id)))
|
||||||
);
|
);
|
||||||
const contractRowClass = ({ row }: { row: any }) =>
|
const contractRowClass = ({ row }: { row: any }) =>
|
||||||
`${row?.id ? "clickable-row" : ""}${isInactiveSite(row?.center_id) ? " row-inactive" : ""}`.trim();
|
`${row?.id ? "clickable-row" : ""}${isInactiveSite(row?.center_id) ? " row-inactive" : ""}`.trim();
|
||||||
|
|
||||||
const filters = reactive({
|
const filters = reactive({
|
||||||
centerId: "",
|
centerId: study.currentSite?.id || "",
|
||||||
q: "",
|
q: "",
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -231,7 +233,7 @@ const toNumber = (value: any) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const overview = computed(() => {
|
const overview = computed(() => {
|
||||||
const totals = contracts.value.reduce(
|
const totals = filteredContracts.value.reduce(
|
||||||
(acc, item) => {
|
(acc, item) => {
|
||||||
acc.totalContractAmount += toNumber(item.contract_amount);
|
acc.totalContractAmount += toNumber(item.contract_amount);
|
||||||
acc.totalPaidAmount += toNumber(item.paid_total);
|
acc.totalPaidAmount += toNumber(item.paid_total);
|
||||||
@@ -248,7 +250,7 @@ const overview = computed(() => {
|
|||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
...totals,
|
...totals,
|
||||||
centerCount: contracts.value.length,
|
centerCount: filteredContracts.value.length,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -269,11 +271,7 @@ const load = async () => {
|
|||||||
loading.value = true;
|
loading.value = true;
|
||||||
errorMessage.value = "";
|
errorMessage.value = "";
|
||||||
try {
|
try {
|
||||||
const { data } = await listContractFees({
|
const { data } = await listContractFees({ projectId });
|
||||||
projectId,
|
|
||||||
centerId: filters.centerId || undefined,
|
|
||||||
q: filters.q || undefined,
|
|
||||||
});
|
|
||||||
contracts.value = data?.data || [];
|
contracts.value = data?.data || [];
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
errorMessage.value = e?.response?.data?.message || TEXT.common.messages.loadFailed;
|
errorMessage.value = e?.response?.data?.message || TEXT.common.messages.loadFailed;
|
||||||
@@ -285,7 +283,6 @@ const load = async () => {
|
|||||||
const resetFilters = () => {
|
const resetFilters = () => {
|
||||||
filters.centerId = "";
|
filters.centerId = "";
|
||||||
filters.q = "";
|
filters.q = "";
|
||||||
load();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const goNew = () => router.push("/fees/contracts/new");
|
const goNew = () => router.push("/fees/contracts/new");
|
||||||
@@ -327,6 +324,19 @@ const formatAmountWan = (value: any) => {
|
|||||||
return (numberValue / 10000).toFixed(2);
|
return (numberValue / 10000).toFixed(2);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
watch(() => filters.centerId, (val: string) => {
|
||||||
|
if (val) {
|
||||||
|
const matched = sites.value.find(s => s.id === val);
|
||||||
|
if (matched) study.setCurrentSite(matched);
|
||||||
|
} else {
|
||||||
|
study.setCurrentSite(null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
watch(() => study.currentSite, (newSite: any) => {
|
||||||
|
filters.centerId = newSite?.id || "";
|
||||||
|
});
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await loadSites();
|
await loadSites();
|
||||||
load();
|
load();
|
||||||
@@ -337,58 +347,21 @@ onMounted(async () => {
|
|||||||
.page {
|
.page {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 20px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.page-header {
|
.main-content-card :deep(.el-card__body) {
|
||||||
display: flex;
|
padding: 20px;
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
margin-bottom: 4px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.page-title {
|
.filter-container {
|
||||||
margin: 0;
|
margin-bottom: 20px;
|
||||||
font-size: 24px;
|
|
||||||
font-weight: 700;
|
|
||||||
color: var(--ctms-text-main);
|
|
||||||
letter-spacing: -0.5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.page-subtitle {
|
|
||||||
margin: 6px 0 0;
|
|
||||||
font-size: 14px;
|
|
||||||
color: var(--ctms-text-secondary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.header-action-btn {
|
|
||||||
height: 36px;
|
|
||||||
padding: 0 20px;
|
|
||||||
border-radius: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.overview {
|
|
||||||
margin-bottom: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.filter-card {
|
|
||||||
border: none;
|
|
||||||
background-color: transparent;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.filter-card :deep(.el-card__body) {
|
|
||||||
padding: 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.filter-form {
|
.filter-form {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
gap: 12px;
|
gap: 12px;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
background: white;
|
|
||||||
padding: 16px;
|
|
||||||
border-radius: 12px;
|
|
||||||
border: 1px solid var(--ctms-border-color);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.filter-item {
|
.filter-item {
|
||||||
@@ -398,14 +371,17 @@ onMounted(async () => {
|
|||||||
|
|
||||||
.filter-select,
|
.filter-select,
|
||||||
.filter-input {
|
.filter-input {
|
||||||
width: 240px;
|
width: 140px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.filter-actions {
|
.filter-actions {
|
||||||
margin-left: auto !important;
|
|
||||||
margin-bottom: 0 !important;
|
margin-bottom: 0 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.filter-spacer {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
.table-card {
|
.table-card {
|
||||||
border-radius: 12px;
|
border-radius: 12px;
|
||||||
border: 1px solid var(--ctms-border-color);
|
border: 1px solid var(--ctms-border-color);
|
||||||
@@ -424,22 +400,32 @@ onMounted(async () => {
|
|||||||
|
|
||||||
.summary-line {
|
.summary-line {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: flex-start;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
margin-bottom: 4px;
|
margin-bottom: 4px;
|
||||||
color: var(--ctms-text-regular);
|
color: var(--ctms-text-regular);
|
||||||
|
gap: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.summary-line:last-child {
|
.summary-line:last-child {
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.summary-line span:first-child {
|
||||||
|
color: var(--ctms-text-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
.amount-highlight {
|
.amount-highlight {
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
font-family: var(--el-font-family);
|
font-family: var(--el-font-family);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.summary-line .amount-highlight,
|
||||||
|
.summary-line .amount-muted {
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
.amount-highlight.success { color: var(--el-color-success); }
|
.amount-highlight.success { color: var(--el-color-success); }
|
||||||
.amount-highlight.warning { color: var(--el-color-warning); }
|
.amount-highlight.warning { color: var(--el-color-warning); }
|
||||||
.amount-highlight.info { color: var(--el-color-info); }
|
.amount-highlight.info { color: var(--el-color-info); }
|
||||||
@@ -447,9 +433,11 @@ onMounted(async () => {
|
|||||||
|
|
||||||
.date-line {
|
.date-line {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: flex-start;
|
||||||
|
align-items: center;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
margin-bottom: 2px;
|
margin-bottom: 2px;
|
||||||
|
gap: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.date-label {
|
.date-label {
|
||||||
|
|||||||
@@ -1,19 +1,13 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="page">
|
<div class="page">
|
||||||
<div class="page-header">
|
<div class="actions">
|
||||||
<div>
|
<el-button type="primary" :disabled="!canWrite || isReadOnly" @click="goEdit" class="header-action-btn copy-btn">
|
||||||
<h1 class="page-title">{{ TEXT.modules.feeSpecials.detailTitle }}</h1>
|
<el-icon class="el-icon--left"><Edit /></el-icon>
|
||||||
<p class="page-subtitle">{{ TEXT.modules.feeSpecials.detailSubtitle }}</p>
|
{{ TEXT.common.actions.edit }}
|
||||||
</div>
|
</el-button>
|
||||||
<div class="actions">
|
<el-button @click="goBack" class="header-action-btn">
|
||||||
<el-button type="primary" :disabled="!canWrite || isReadOnly" @click="goEdit" class="header-action-btn copy-btn">
|
{{ TEXT.common.actions.back }}
|
||||||
<el-icon class="el-icon--left"><Edit /></el-icon>
|
</el-button>
|
||||||
{{ TEXT.common.actions.edit }}
|
|
||||||
</el-button>
|
|
||||||
<el-button @click="goBack" class="header-action-btn">
|
|
||||||
{{ TEXT.common.actions.back }}
|
|
||||||
</el-button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<StateError v-if="errorMessage" :description="errorMessage">
|
<StateError v-if="errorMessage" :description="errorMessage">
|
||||||
@@ -178,6 +172,11 @@ const load = async () => {
|
|||||||
try {
|
try {
|
||||||
const { data } = await getSpecialExpense(expenseId);
|
const { data } = await getSpecialExpense(expenseId);
|
||||||
Object.assign(detail, data?.data || {});
|
Object.assign(detail, data?.data || {});
|
||||||
|
|
||||||
|
// 同步中心名称到面包屑
|
||||||
|
if (centerName.value) {
|
||||||
|
study.setViewContext({ siteName: centerName.value });
|
||||||
|
}
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
errorMessage.value = e?.response?.data?.message || TEXT.common.messages.loadFailed;
|
errorMessage.value = e?.response?.data?.message || TEXT.common.messages.loadFailed;
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -1,20 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="page">
|
<div class="page">
|
||||||
<div class="page-header">
|
|
||||||
<div>
|
|
||||||
<h1 class="page-title">{{ TEXT.modules.feeSpecials.title }}</h1>
|
|
||||||
</div>
|
|
||||||
<el-button type="primary" :disabled="!canWrite" @click="goNew" class="header-action-btn">
|
|
||||||
<el-icon class="el-icon--left"><Plus /></el-icon>
|
|
||||||
{{ TEXT.modules.feeSpecials.newTitle }}
|
|
||||||
</el-button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="overview">
|
<div class="overview">
|
||||||
<div class="overview-header">
|
|
||||||
<span class="overview-title">{{ TEXT.modules.feeSpecials.overviewTitle }}</span>
|
|
||||||
<el-tag effect="plain" type="info" size="small">{{ TEXT.modules.feeSpecials.recordCount }} {{ overview.recordCount }}</el-tag>
|
|
||||||
</div>
|
|
||||||
<el-row :gutter="20">
|
<el-row :gutter="20">
|
||||||
<el-col :xs="24" :sm="12" :md="6">
|
<el-col :xs="24" :sm="12" :md="6">
|
||||||
<KpiCard
|
<KpiCard
|
||||||
@@ -58,56 +45,51 @@
|
|||||||
</el-row>
|
</el-row>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<el-card class="filter-card" shadow="never">
|
<el-card shadow="never" class="main-content-card" v-if="!errorMessage && !loading">
|
||||||
<el-form :inline="true" :model="filters" class="filter-form">
|
<div class="filter-container">
|
||||||
<el-form-item label="" class="filter-item">
|
<el-form :inline="true" :model="filters" class="filter-form">
|
||||||
<el-select v-model="filters.centerId" clearable :placeholder="TEXT.common.fields.site" class="filter-select">
|
<el-form-item label="" class="filter-item">
|
||||||
<template #prefix>
|
<el-select v-model="filters.centerId" clearable :placeholder="TEXT.common.fields.site" class="filter-select">
|
||||||
<el-icon><Location /></el-icon>
|
<template #prefix>
|
||||||
</template>
|
<el-icon><Location /></el-icon>
|
||||||
<el-option
|
</template>
|
||||||
v-for="site in sites"
|
<el-option
|
||||||
:key="site.id"
|
v-for="site in sites"
|
||||||
:label="site.name || TEXT.common.fallback"
|
:key="site.id"
|
||||||
:value="site.id"
|
:label="site.name || TEXT.common.fallback"
|
||||||
|
:value="site.id"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="" class="filter-item">
|
||||||
|
<el-select v-model="filters.category" clearable :placeholder="TEXT.common.fields.category" class="filter-select">
|
||||||
|
<template #prefix>
|
||||||
|
<el-icon><Menu /></el-icon>
|
||||||
|
</template>
|
||||||
|
<el-option v-for="option in categoryOptions" :key="option.value" :label="option.label" :value="option.value" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="" class="filter-item">
|
||||||
|
<el-date-picker
|
||||||
|
v-model="filters.dateRange"
|
||||||
|
type="daterange"
|
||||||
|
unlink-panels
|
||||||
|
value-format="YYYY-MM-DD"
|
||||||
|
:start-placeholder="TEXT.common.placeholders.startDate"
|
||||||
|
:end-placeholder="TEXT.common.placeholders.endDate"
|
||||||
|
class="filter-date"
|
||||||
/>
|
/>
|
||||||
</el-select>
|
</el-form-item>
|
||||||
</el-form-item>
|
<el-form-item class="filter-actions">
|
||||||
<el-form-item label="" class="filter-item">
|
<el-button @click="resetFilters">{{ TEXT.common.actions.reset }}</el-button>
|
||||||
<el-select v-model="filters.category" clearable :placeholder="TEXT.common.fields.category" class="filter-select">
|
</el-form-item>
|
||||||
<template #prefix>
|
<div class="filter-spacer"></div>
|
||||||
<el-icon><Menu /></el-icon>
|
<el-button type="primary" :disabled="!canWrite" @click="goNew" class="header-action-btn">
|
||||||
</template>
|
<el-icon class="el-icon--left"><Plus /></el-icon>
|
||||||
<el-option v-for="option in categoryOptions" :key="option.value" :label="option.label" :value="option.value" />
|
{{ TEXT.modules.feeSpecials.newTitle }}
|
||||||
</el-select>
|
</el-button>
|
||||||
</el-form-item>
|
</el-form>
|
||||||
<el-form-item label="" class="filter-item">
|
</div>
|
||||||
<el-date-picker
|
|
||||||
v-model="filters.dateRange"
|
|
||||||
type="daterange"
|
|
||||||
unlink-panels
|
|
||||||
value-format="YYYY-MM-DD"
|
|
||||||
:start-placeholder="TEXT.common.placeholders.startDate"
|
|
||||||
:end-placeholder="TEXT.common.placeholders.endDate"
|
|
||||||
class="filter-date"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item class="filter-actions">
|
|
||||||
<el-button type="primary" @click="load">{{ TEXT.common.actions.search }}</el-button>
|
|
||||||
<el-button @click="resetFilters">{{ TEXT.common.actions.reset }}</el-button>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
</el-card>
|
|
||||||
|
|
||||||
<StateError v-if="errorMessage" :description="errorMessage">
|
|
||||||
<template #action>
|
|
||||||
<el-button type="primary" @click="load">{{ TEXT.common.actions.retry }}</el-button>
|
|
||||||
</template>
|
|
||||||
</StateError>
|
|
||||||
|
|
||||||
<StateLoading v-else-if="loading" :rows="6" />
|
|
||||||
|
|
||||||
<el-card v-else class="table-card" shadow="never">
|
|
||||||
<el-table
|
<el-table
|
||||||
:data="sortedExpenses"
|
:data="sortedExpenses"
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
@@ -132,7 +114,7 @@
|
|||||||
</el-tag>
|
</el-tag>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column :label="TEXT.common.fields.amount" width="140" align="right">
|
<el-table-column :label="TEXT.common.fields.amount" width="110" align="right">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<span class="amount-text">{{ formatAmount(scope.row.amount) }}</span>
|
<span class="amount-text">{{ formatAmount(scope.row.amount) }}</span>
|
||||||
</template>
|
</template>
|
||||||
@@ -142,7 +124,7 @@
|
|||||||
{{ scope.row.description || TEXT.common.fallback }}
|
{{ scope.row.description || TEXT.common.fallback }}
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column width="140" align="center" :label="TEXT.common.labels.status">
|
<el-table-column width="140" align="center" :label="TEXT.common.fields.status">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-tooltip :content="scope.row.is_paid ? `${TEXT.modules.feeSpecials.isPaid} (${displayDate(scope.row.paid_date)})` : TEXT.modules.feeSpecials.unpaid" placement="top">
|
<el-tooltip :content="scope.row.is_paid ? `${TEXT.modules.feeSpecials.isPaid} (${displayDate(scope.row.paid_date)})` : TEXT.modules.feeSpecials.unpaid" placement="top">
|
||||||
<el-icon :class="scope.row.is_paid ? 'status-icon success' : 'status-icon muted'"><Wallet /></el-icon>
|
<el-icon :class="scope.row.is_paid ? 'status-icon success' : 'status-icon muted'"><Wallet /></el-icon>
|
||||||
@@ -180,7 +162,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, onMounted, reactive, ref } from "vue";
|
import { computed, onMounted, reactive, ref, watch } from "vue";
|
||||||
import { useRouter } from "vue-router";
|
import { useRouter } from "vue-router";
|
||||||
import { ElMessage, ElMessageBox } from "element-plus";
|
import { ElMessage, ElMessageBox } from "element-plus";
|
||||||
import { Coin, Wallet, CircleCheck, Document, Plus, Location, Menu } from "@element-plus/icons-vue";
|
import { Coin, Wallet, CircleCheck, Document, Plus, Location, Menu } from "@element-plus/icons-vue";
|
||||||
@@ -214,19 +196,33 @@ const siteActiveMap = computed(() => {
|
|||||||
const isInactiveSite = (siteId?: string) => !!siteId && siteActiveMap.value[siteId] === false;
|
const isInactiveSite = (siteId?: string) => !!siteId && siteActiveMap.value[siteId] === false;
|
||||||
const expenseRowClass = ({ row }: { row: any }) =>
|
const expenseRowClass = ({ row }: { row: any }) =>
|
||||||
`${row?.id ? "clickable-row" : ""}${isInactiveSite(row?.center_id) ? " row-inactive" : ""}`.trim();
|
`${row?.id ? "clickable-row" : ""}${isInactiveSite(row?.center_id) ? " row-inactive" : ""}`.trim();
|
||||||
|
const filteredExpenses = computed(() => {
|
||||||
|
const [dateFrom, dateTo] = filters.dateRange || [];
|
||||||
|
return expenses.value.filter((item) => {
|
||||||
|
if (filters.centerId && item?.center_id !== filters.centerId) return false;
|
||||||
|
if (filters.category && item?.category !== filters.category) return false;
|
||||||
|
if (dateFrom || dateTo) {
|
||||||
|
const value = item?.happen_date;
|
||||||
|
if (!value) return false;
|
||||||
|
if (dateFrom && value < dateFrom) return false;
|
||||||
|
if (dateTo && value > dateTo) return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
});
|
||||||
const sortedExpenses = computed(() =>
|
const sortedExpenses = computed(() =>
|
||||||
[...expenses.value].sort((a, b) => Number(isInactiveSite(a?.center_id)) - Number(isInactiveSite(b?.center_id)))
|
[...filteredExpenses.value].sort((a, b) => Number(isInactiveSite(a?.center_id)) - Number(isInactiveSite(b?.center_id)))
|
||||||
);
|
);
|
||||||
|
|
||||||
const filters = reactive({
|
const filters = reactive({
|
||||||
centerId: "",
|
centerId: study.currentSite?.id || "",
|
||||||
category: "",
|
category: "",
|
||||||
dateRange: [] as string[],
|
dateRange: [] as string[],
|
||||||
});
|
});
|
||||||
|
|
||||||
const categoryOptions = Object.keys(TEXT.enums.feeSpecialCategory).map((value) => ({
|
const categoryOptions = Object.keys(TEXT.enums.feeSpecialCategory).map((value) => ({
|
||||||
value,
|
value,
|
||||||
label: TEXT.enums.feeSpecialCategory[value],
|
label: (TEXT.enums.feeSpecialCategory as any)[value],
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const toNumber = (value: any) => {
|
const toNumber = (value: any) => {
|
||||||
@@ -235,7 +231,7 @@ const toNumber = (value: any) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const overview = computed(() => {
|
const overview = computed(() => {
|
||||||
const totals = expenses.value.reduce(
|
const totals = filteredExpenses.value.reduce(
|
||||||
(acc, item) => {
|
(acc, item) => {
|
||||||
acc.totalAmount += toNumber(item.amount);
|
acc.totalAmount += toNumber(item.amount);
|
||||||
if (item.is_paid) acc.paidAmount += toNumber(item.amount);
|
if (item.is_paid) acc.paidAmount += toNumber(item.amount);
|
||||||
@@ -252,7 +248,6 @@ const overview = computed(() => {
|
|||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
...totals,
|
...totals,
|
||||||
recordCount: expenses.value.length,
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -273,14 +268,7 @@ const load = async () => {
|
|||||||
loading.value = true;
|
loading.value = true;
|
||||||
errorMessage.value = "";
|
errorMessage.value = "";
|
||||||
try {
|
try {
|
||||||
const [dateFrom, dateTo] = filters.dateRange || [];
|
const { data } = await listSpecialExpenses({ projectId });
|
||||||
const { data } = await listSpecialExpenses({
|
|
||||||
projectId,
|
|
||||||
centerId: filters.centerId || undefined,
|
|
||||||
category: filters.category || undefined,
|
|
||||||
dateFrom: dateFrom || undefined,
|
|
||||||
dateTo: dateTo || undefined,
|
|
||||||
});
|
|
||||||
expenses.value = data?.data || [];
|
expenses.value = data?.data || [];
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
errorMessage.value = e?.response?.data?.message || TEXT.common.messages.loadFailed;
|
errorMessage.value = e?.response?.data?.message || TEXT.common.messages.loadFailed;
|
||||||
@@ -293,7 +281,6 @@ const resetFilters = () => {
|
|||||||
filters.centerId = "";
|
filters.centerId = "";
|
||||||
filters.category = "";
|
filters.category = "";
|
||||||
filters.dateRange = [];
|
filters.dateRange = [];
|
||||||
load();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const goNew = () => router.push("/fees/special/new");
|
const goNew = () => router.push("/fees/special/new");
|
||||||
@@ -333,6 +320,19 @@ const getCategoryType = (category: string) => {
|
|||||||
return 'info';
|
return 'info';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
watch(() => filters.centerId, (val: string) => {
|
||||||
|
if (val) {
|
||||||
|
const matched = sites.value.find(s => s.id === val);
|
||||||
|
if (matched) study.setCurrentSite(matched);
|
||||||
|
} else {
|
||||||
|
study.setCurrentSite(null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
watch(() => study.currentSite, (newSite: any) => {
|
||||||
|
filters.centerId = newSite?.id || "";
|
||||||
|
});
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await loadSites();
|
await loadSites();
|
||||||
load();
|
load();
|
||||||
@@ -343,71 +343,21 @@ onMounted(async () => {
|
|||||||
.page {
|
.page {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 20px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.page-header {
|
.main-content-card :deep(.el-card__body) {
|
||||||
display: flex;
|
padding: 20px;
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
margin-bottom: 4px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.page-title {
|
.filter-container {
|
||||||
margin: 0;
|
margin-bottom: 20px;
|
||||||
font-size: 24px;
|
|
||||||
font-weight: 700;
|
|
||||||
color: var(--ctms-text-main);
|
|
||||||
letter-spacing: -0.5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.page-subtitle {
|
|
||||||
margin: 6px 0 0;
|
|
||||||
font-size: 14px;
|
|
||||||
color: var(--ctms-text-secondary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.header-action-btn {
|
|
||||||
height: 36px;
|
|
||||||
padding: 0 20px;
|
|
||||||
border-radius: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.overview {
|
|
||||||
margin-bottom: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.overview-header {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
padding: 0 4px 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.overview-title {
|
|
||||||
font-size: 14px;
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--ctms-text-main);
|
|
||||||
}
|
|
||||||
|
|
||||||
.filter-card {
|
|
||||||
border: none;
|
|
||||||
background-color: transparent;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.filter-card :deep(.el-card__body) {
|
|
||||||
padding: 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.filter-form {
|
.filter-form {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
gap: 12px;
|
gap: 12px;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
background: white;
|
|
||||||
padding: 16px;
|
|
||||||
border-radius: 12px;
|
|
||||||
border: 1px solid var(--ctms-border-color);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.filter-item {
|
.filter-item {
|
||||||
@@ -416,18 +366,21 @@ onMounted(async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.filter-select {
|
.filter-select {
|
||||||
width: 200px;
|
width: 140px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.filter-date {
|
.filter-date {
|
||||||
width: 280px;
|
width: 220px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.filter-actions {
|
.filter-actions {
|
||||||
margin-left: auto !important;
|
|
||||||
margin-bottom: 0 !important;
|
margin-bottom: 0 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.filter-spacer {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
.table-card {
|
.table-card {
|
||||||
border-radius: 12px;
|
border-radius: 12px;
|
||||||
border: 1px solid var(--ctms-border-color);
|
border: 1px solid var(--ctms-border-color);
|
||||||
|
|||||||
@@ -1,47 +1,53 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="page">
|
<div class="page">
|
||||||
<div class="page-header">
|
|
||||||
<div>
|
<el-card shadow="never" class="main-content-card">
|
||||||
<h1 class="page-title">{{ TEXT.modules.drugShipments.title }}</h1>
|
<div class="filter-container">
|
||||||
|
<el-form :inline="true" :model="filters" class="filter-form">
|
||||||
|
<el-form-item label="" class="filter-item">
|
||||||
|
<el-select v-model="filters.center_id" clearable :placeholder="TEXT.common.fields.site" class="filter-select">
|
||||||
|
<template #prefix>
|
||||||
|
<el-icon><Location /></el-icon>
|
||||||
|
</template>
|
||||||
|
<el-option
|
||||||
|
v-for="site in sites"
|
||||||
|
:key="site.id"
|
||||||
|
:label="site.name || TEXT.common.fallback"
|
||||||
|
:value="site.id"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="" class="filter-item">
|
||||||
|
<el-select v-model="filters.direction" clearable :placeholder="TEXT.common.fields.direction" class="filter-select">
|
||||||
|
<template #prefix>
|
||||||
|
<el-icon><Menu /></el-icon>
|
||||||
|
</template>
|
||||||
|
<el-option :label="TEXT.enums.shipmentDirection.SEND" value="SEND" />
|
||||||
|
<el-option :label="TEXT.enums.shipmentDirection.RETURN" value="RETURN" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="" class="filter-item">
|
||||||
|
<el-select v-model="filters.status" clearable :placeholder="TEXT.common.fields.status" class="filter-select">
|
||||||
|
<template #prefix>
|
||||||
|
<el-icon><CircleCheck /></el-icon>
|
||||||
|
</template>
|
||||||
|
<el-option :label="TEXT.enums.shipmentStatus.PENDING" value="PENDING" />
|
||||||
|
<el-option :label="TEXT.enums.shipmentStatus.IN_TRANSIT" value="IN_TRANSIT" />
|
||||||
|
<el-option :label="TEXT.enums.shipmentStatus.SIGNED" value="SIGNED" />
|
||||||
|
<el-option :label="TEXT.enums.shipmentStatus.RETURNED" value="RETURNED" />
|
||||||
|
<el-option :label="TEXT.enums.shipmentStatus.EXCEPTION" value="EXCEPTION" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item class="filter-actions">
|
||||||
|
<el-button @click="resetFilters">{{ TEXT.common.actions.reset }}</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
<div class="filter-spacer"></div>
|
||||||
|
<el-button type="primary" @click="goNew" class="header-action-btn">
|
||||||
|
<el-icon class="el-icon--left"><Plus /></el-icon>
|
||||||
|
{{ TEXT.modules.drugShipments.newTitle }}
|
||||||
|
</el-button>
|
||||||
|
</el-form>
|
||||||
</div>
|
</div>
|
||||||
<el-button type="primary" @click="goNew">{{ TEXT.modules.drugShipments.newTitle }}</el-button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<el-card class="filter-card">
|
|
||||||
<el-form :inline="true" :model="filters">
|
|
||||||
<el-form-item :label="TEXT.common.fields.site">
|
|
||||||
<el-select v-model="filters.center_id" :placeholder="TEXT.common.placeholders.select" clearable style="width: 200px">
|
|
||||||
<el-option
|
|
||||||
v-for="site in sites"
|
|
||||||
:key="site.id"
|
|
||||||
:label="site.name || TEXT.common.fallback"
|
|
||||||
:value="site.id"
|
|
||||||
/>
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item :label="TEXT.common.fields.direction">
|
|
||||||
<el-select v-model="filters.direction" :placeholder="TEXT.common.placeholders.select" clearable style="width: 160px">
|
|
||||||
<el-option :label="TEXT.enums.shipmentDirection.SEND" value="SEND" />
|
|
||||||
<el-option :label="TEXT.enums.shipmentDirection.RETURN" value="RETURN" />
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item :label="TEXT.common.fields.status">
|
|
||||||
<el-select v-model="filters.status" :placeholder="TEXT.common.placeholders.select" clearable style="width: 160px">
|
|
||||||
<el-option :label="TEXT.enums.shipmentStatus.PENDING" value="PENDING" />
|
|
||||||
<el-option :label="TEXT.enums.shipmentStatus.IN_TRANSIT" value="IN_TRANSIT" />
|
|
||||||
<el-option :label="TEXT.enums.shipmentStatus.SIGNED" value="SIGNED" />
|
|
||||||
<el-option :label="TEXT.enums.shipmentStatus.RETURNED" value="RETURNED" />
|
|
||||||
<el-option :label="TEXT.enums.shipmentStatus.EXCEPTION" value="EXCEPTION" />
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item>
|
|
||||||
<el-button type="primary" @click="load">{{ TEXT.common.actions.search }}</el-button>
|
|
||||||
<el-button @click="resetFilters">{{ TEXT.common.actions.reset }}</el-button>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
</el-card>
|
|
||||||
|
|
||||||
<el-card>
|
|
||||||
<el-table
|
<el-table
|
||||||
:data="sortedItems"
|
:data="sortedItems"
|
||||||
v-loading="loading"
|
v-loading="loading"
|
||||||
@@ -52,9 +58,9 @@
|
|||||||
<el-table-column prop="site_name" :label="TEXT.common.fields.site" min-width="160">
|
<el-table-column prop="site_name" :label="TEXT.common.fields.site" min-width="160">
|
||||||
<template #default="scope">{{ scope.row.site_name || TEXT.common.fallback }}</template>
|
<template #default="scope">{{ scope.row.site_name || TEXT.common.fallback }}</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="direction" :label="TEXT.common.fields.direction" width="100">
|
<el-table-column prop="direction" :label="TEXT.common.fields.direction" width="120">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-tag :type="scope.row.direction === 'SEND' ? 'primary' : 'warning'" disable-transitions>
|
<el-tag :class="['type-tag', scope.row.direction === 'SEND' ? 'type-send' : 'type-return']" effect="light">
|
||||||
{{ displayEnum(TEXT.enums.shipmentDirection, scope.row.direction) }}
|
{{ displayEnum(TEXT.enums.shipmentDirection, scope.row.direction) }}
|
||||||
</el-tag>
|
</el-tag>
|
||||||
</template>
|
</template>
|
||||||
@@ -71,9 +77,9 @@
|
|||||||
<el-table-column prop="batch_no" :label="TEXT.common.fields.batchNo" min-width="140">
|
<el-table-column prop="batch_no" :label="TEXT.common.fields.batchNo" min-width="140">
|
||||||
<template #default="scope">{{ scope.row.batch_no || TEXT.common.fallback }}</template>
|
<template #default="scope">{{ scope.row.batch_no || TEXT.common.fallback }}</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="status" :label="TEXT.common.fields.status" width="120">
|
<el-table-column prop="status" :label="TEXT.common.fields.status" width="140">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-tag :type="statusType(scope.row.status)" disable-transitions>
|
<el-tag :type="statusType(scope.row.status)" effect="plain" round size="small" class="status-tag">
|
||||||
{{ displayEnum(TEXT.enums.shipmentStatus, scope.row.status) }}
|
{{ displayEnum(TEXT.enums.shipmentStatus, scope.row.status) }}
|
||||||
</el-tag>
|
</el-tag>
|
||||||
</template>
|
</template>
|
||||||
@@ -101,9 +107,10 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, onMounted, reactive, ref } from "vue";
|
import { computed, onMounted, reactive, ref, watch } from "vue";
|
||||||
import { useRouter } from "vue-router";
|
import { useRouter } from "vue-router";
|
||||||
import { ElMessage, ElMessageBox } from "element-plus";
|
import { ElMessage, ElMessageBox } from "element-plus";
|
||||||
|
import { Location, Menu, CircleCheck, Plus } from "@element-plus/icons-vue";
|
||||||
import { useStudyStore } from "../../store/study";
|
import { useStudyStore } from "../../store/study";
|
||||||
import { listDrugShipments, deleteDrugShipment } from "../../api/drugShipments";
|
import { listDrugShipments, deleteDrugShipment } from "../../api/drugShipments";
|
||||||
import { fetchSites } from "../../api/sites";
|
import { fetchSites } from "../../api/sites";
|
||||||
@@ -118,7 +125,7 @@ const items = ref<any[]>([]);
|
|||||||
const sites = ref<any[]>([]);
|
const sites = ref<any[]>([]);
|
||||||
const siteActiveMap = ref<Record<string, boolean>>({});
|
const siteActiveMap = ref<Record<string, boolean>>({});
|
||||||
const filters = reactive({
|
const filters = reactive({
|
||||||
center_id: "",
|
center_id: study.currentSite?.id || "",
|
||||||
direction: "",
|
direction: "",
|
||||||
status: "",
|
status: "",
|
||||||
});
|
});
|
||||||
@@ -144,12 +151,8 @@ const load = async () => {
|
|||||||
if (!studyId) return;
|
if (!studyId) return;
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
try {
|
try {
|
||||||
const { data } = await listDrugShipments(studyId, {
|
const { data } = await listDrugShipments(studyId, {});
|
||||||
center_id: filters.center_id || undefined,
|
items.value = Array.isArray(data) ? data : data?.items || [];
|
||||||
direction: filters.direction || undefined,
|
|
||||||
status: filters.status || undefined,
|
|
||||||
});
|
|
||||||
items.value = Array.isArray(data) ? data : data.items || [];
|
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
ElMessage.error(e?.response?.data?.message || TEXT.common.messages.loadFailed);
|
ElMessage.error(e?.response?.data?.message || TEXT.common.messages.loadFailed);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -161,7 +164,6 @@ const resetFilters = () => {
|
|||||||
filters.center_id = "";
|
filters.center_id = "";
|
||||||
filters.direction = "";
|
filters.direction = "";
|
||||||
filters.status = "";
|
filters.status = "";
|
||||||
load();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const goNew = () => router.push("/drug/shipments/new");
|
const goNew = () => router.push("/drug/shipments/new");
|
||||||
@@ -173,8 +175,16 @@ const onRowClick = (row: any) => {
|
|||||||
const isInactiveSite = (siteId?: string) => !!siteId && siteActiveMap.value[siteId] === false;
|
const isInactiveSite = (siteId?: string) => !!siteId && siteActiveMap.value[siteId] === false;
|
||||||
const shipmentRowClass = ({ row }: { row: any }) =>
|
const shipmentRowClass = ({ row }: { row: any }) =>
|
||||||
`${row?.id ? "clickable-row" : ""}${isInactiveSite(row?.center_id) ? " row-inactive" : ""}`.trim();
|
`${row?.id ? "clickable-row" : ""}${isInactiveSite(row?.center_id) ? " row-inactive" : ""}`.trim();
|
||||||
|
const filteredItems = computed(() =>
|
||||||
|
items.value.filter((item) => {
|
||||||
|
if (filters.center_id && item?.center_id !== filters.center_id) return false;
|
||||||
|
if (filters.direction && item?.direction !== filters.direction) return false;
|
||||||
|
if (filters.status && item?.status !== filters.status) return false;
|
||||||
|
return true;
|
||||||
|
})
|
||||||
|
);
|
||||||
const sortedItems = computed(() =>
|
const sortedItems = computed(() =>
|
||||||
[...items.value].sort((a, b) => Number(isInactiveSite(a?.center_id)) - Number(isInactiveSite(b?.center_id)))
|
[...filteredItems.value].sort((a, b) => Number(isInactiveSite(a?.center_id)) - Number(isInactiveSite(b?.center_id)))
|
||||||
);
|
);
|
||||||
|
|
||||||
const statusType = (status: string) => {
|
const statusType = (status: string) => {
|
||||||
@@ -212,6 +222,19 @@ const remove = async (row: any) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
watch(() => filters.center_id, (val: string) => {
|
||||||
|
if (val) {
|
||||||
|
const matched = sites.value.find(s => s.id === val);
|
||||||
|
if (matched) study.setCurrentSite(matched);
|
||||||
|
} else {
|
||||||
|
study.setCurrentSite(null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
watch(() => study.currentSite, (newSite: any) => {
|
||||||
|
filters.center_id = newSite?.id || "";
|
||||||
|
});
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await loadSites();
|
await loadSites();
|
||||||
load();
|
load();
|
||||||
@@ -222,30 +245,79 @@ onMounted(async () => {
|
|||||||
.page {
|
.page {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 16px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.main-content-card :deep(.el-card__body) {
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
.page-header {
|
.filter-container {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-form {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
width: 100%;
|
||||||
align-items: flex-end;
|
gap: 12px;
|
||||||
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.page-title {
|
.filter-item {
|
||||||
margin: 0;
|
margin-bottom: 0 !important;
|
||||||
font-size: 22px;
|
margin-right: 0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-actions {
|
||||||
|
margin-bottom: 0 !important;
|
||||||
|
margin-right: 0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-actions :deep(.el-form-item__content) {
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-actions :deep(.el-button) {
|
||||||
|
height: 36px;
|
||||||
|
line-height: 36px;
|
||||||
|
padding: 0 18px;
|
||||||
|
border-radius: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-select {
|
||||||
|
width: 140px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-spacer {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-action-btn {
|
||||||
|
height: 36px;
|
||||||
|
padding: 0 20px;
|
||||||
|
border-radius: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.type-tag {
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
|
border: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.page-subtitle {
|
.type-send {
|
||||||
margin: 6px 0 0;
|
background-color: #fff7ed !important;
|
||||||
font-size: 13px;
|
color: #ea580c !important;
|
||||||
color: var(--ctms-text-secondary);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.filter-card :deep(.el-form-item) {
|
.type-return {
|
||||||
margin-bottom: 0;
|
background-color: #fefce8 !important;
|
||||||
|
color: #ca8a04 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-tag {
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-muted {
|
||||||
|
color: var(--ctms-text-placeholder);
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|||||||
@@ -1,26 +1,34 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="page">
|
<div class="page">
|
||||||
<div class="page-header">
|
|
||||||
<div>
|
|
||||||
<h1 class="page-title">{{ TEXT.modules.financeContracts.title }}</h1>
|
|
||||||
<p class="page-subtitle">{{ TEXT.modules.financeContracts.subtitle }}</p>
|
|
||||||
</div>
|
|
||||||
<el-button type="primary" @click="goNew">{{ TEXT.modules.financeContracts.newTitle }}</el-button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<el-card class="filter-card">
|
<el-card class="filter-card" shadow="never">
|
||||||
<el-form :inline="true" :model="filters">
|
<div class="filter-row">
|
||||||
<el-form-item :label="TEXT.common.fields.site">
|
<el-form :inline="true" :model="filters" class="filter-form">
|
||||||
<el-input v-model="filters.site_name" :placeholder="TEXT.common.placeholders.input + TEXT.common.fields.site" clearable />
|
<el-form-item label="" class="filter-item-form">
|
||||||
</el-form-item>
|
<el-input
|
||||||
<el-form-item :label="TEXT.common.fields.contractNo">
|
v-model="filters.site_name"
|
||||||
<el-input v-model="filters.contract_no" :placeholder="TEXT.common.placeholders.input + TEXT.common.fields.contractNo" clearable />
|
:placeholder="TEXT.common.fields.site"
|
||||||
</el-form-item>
|
clearable
|
||||||
<el-form-item>
|
class="filter-input-comp"
|
||||||
<el-button type="primary" @click="load">{{ TEXT.common.actions.search }}</el-button>
|
/>
|
||||||
<el-button @click="resetFilters">{{ TEXT.common.actions.reset }}</el-button>
|
</el-form-item>
|
||||||
</el-form-item>
|
<el-form-item label="" class="filter-item-form">
|
||||||
</el-form>
|
<el-input
|
||||||
|
v-model="filters.contract_no"
|
||||||
|
:placeholder="TEXT.common.fields.contractNo"
|
||||||
|
clearable
|
||||||
|
class="filter-input-comp"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item class="filter-item-form">
|
||||||
|
<el-button @click="resetFilters">{{ TEXT.common.actions.reset }}</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
<div class="filter-spacer"></div>
|
||||||
|
<el-button type="primary" @click="goNew" class="header-action-btn">
|
||||||
|
{{ TEXT.modules.financeContracts.newTitle }}
|
||||||
|
</el-button>
|
||||||
|
</el-form>
|
||||||
|
</div>
|
||||||
</el-card>
|
</el-card>
|
||||||
|
|
||||||
<el-card>
|
<el-card>
|
||||||
@@ -99,8 +107,17 @@ const siteActiveMap = computed(() => {
|
|||||||
const isInactiveSite = (siteName?: string) => !!siteName && siteActiveMap.value[siteName] === false;
|
const isInactiveSite = (siteName?: string) => !!siteName && siteActiveMap.value[siteName] === false;
|
||||||
const contractRowClass = ({ row }: { row: any }) =>
|
const contractRowClass = ({ row }: { row: any }) =>
|
||||||
`${row?.id ? "clickable-row" : ""}${isInactiveSite(row?.site_name) ? " row-inactive" : ""}`.trim();
|
`${row?.id ? "clickable-row" : ""}${isInactiveSite(row?.site_name) ? " row-inactive" : ""}`.trim();
|
||||||
|
const filteredItems = computed(() => {
|
||||||
|
const siteKeyword = filters.site_name.trim().toLowerCase();
|
||||||
|
const contractKeyword = filters.contract_no.trim().toLowerCase();
|
||||||
|
return items.value.filter((item) => {
|
||||||
|
if (siteKeyword && !String(item?.site_name || "").toLowerCase().includes(siteKeyword)) return false;
|
||||||
|
if (contractKeyword && !String(item?.contract_no || "").toLowerCase().includes(contractKeyword)) return false;
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
});
|
||||||
const sortedItems = computed(() =>
|
const sortedItems = computed(() =>
|
||||||
[...items.value].sort((a, b) => Number(isInactiveSite(a?.site_name)) - Number(isInactiveSite(b?.site_name)))
|
[...filteredItems.value].sort((a, b) => Number(isInactiveSite(a?.site_name)) - Number(isInactiveSite(b?.site_name)))
|
||||||
);
|
);
|
||||||
|
|
||||||
const loadSites = async () => {
|
const loadSites = async () => {
|
||||||
@@ -119,10 +136,7 @@ const load = async () => {
|
|||||||
if (!studyId) return;
|
if (!studyId) return;
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
try {
|
try {
|
||||||
const { data } = await listFinanceContracts(studyId, {
|
const { data } = await listFinanceContracts(studyId, {}) as any;
|
||||||
site_name: filters.site_name || undefined,
|
|
||||||
contract_no: filters.contract_no || undefined,
|
|
||||||
});
|
|
||||||
items.value = Array.isArray(data) ? data : data.items || [];
|
items.value = Array.isArray(data) ? data : data.items || [];
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
ElMessage.error(e?.response?.data?.message || TEXT.common.messages.loadFailed);
|
ElMessage.error(e?.response?.data?.message || TEXT.common.messages.loadFailed);
|
||||||
@@ -134,7 +148,6 @@ const load = async () => {
|
|||||||
const resetFilters = () => {
|
const resetFilters = () => {
|
||||||
filters.site_name = "";
|
filters.site_name = "";
|
||||||
filters.contract_no = "";
|
filters.contract_no = "";
|
||||||
load();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const goNew = () => router.push("/finance/contracts/new");
|
const goNew = () => router.push("/finance/contracts/new");
|
||||||
@@ -172,29 +185,55 @@ onMounted(async () => {
|
|||||||
.page {
|
.page {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 16px;
|
gap: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.page-header {
|
.filter-card {
|
||||||
|
border: none;
|
||||||
|
background-color: transparent;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-card :deep(.el-card__body) {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-form {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
width: 100%;
|
||||||
align-items: flex-end;
|
gap: 12px;
|
||||||
|
align-items: center;
|
||||||
|
background: white;
|
||||||
|
padding: 12px 16px;
|
||||||
|
border-radius: 10px;
|
||||||
|
border: 1px solid var(--ctms-border-color);
|
||||||
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
.page-title {
|
.filter-row {
|
||||||
margin: 0;
|
display: flex;
|
||||||
font-size: 22px;
|
align-items: center;
|
||||||
font-weight: 600;
|
gap: 12px;
|
||||||
|
flex-wrap: wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.page-subtitle {
|
.filter-item-form {
|
||||||
margin: 6px 0 0;
|
margin-bottom: 0 !important;
|
||||||
font-size: 13px;
|
margin-right: 0 !important;
|
||||||
color: var(--ctms-text-secondary);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.filter-card :deep(.el-form-item) {
|
.filter-input-comp {
|
||||||
margin-bottom: 0;
|
width: 160px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-spacer {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-action-btn {
|
||||||
|
height: 36px;
|
||||||
|
padding: 0 20px;
|
||||||
|
border-radius: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,31 +1,39 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="page">
|
<div class="page">
|
||||||
<div class="page-header">
|
|
||||||
<div>
|
|
||||||
<h1 class="page-title">{{ TEXT.modules.financeSpecials.title }}</h1>
|
|
||||||
<p class="page-subtitle">{{ TEXT.modules.financeSpecials.subtitle }}</p>
|
|
||||||
</div>
|
|
||||||
<el-button type="primary" @click="goNew">{{ TEXT.modules.financeSpecials.newTitle }}</el-button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<el-card class="filter-card">
|
<el-card class="filter-card" shadow="never">
|
||||||
<el-form :inline="true" :model="filters">
|
<div class="filter-row">
|
||||||
<el-form-item :label="TEXT.common.fields.site">
|
<el-form :inline="true" :model="filters" class="filter-form">
|
||||||
<el-input v-model="filters.site_name" :placeholder="TEXT.common.placeholders.input + TEXT.common.fields.site" clearable />
|
<el-form-item label="" class="filter-item-form">
|
||||||
</el-form-item>
|
<el-input
|
||||||
<el-form-item :label="TEXT.common.fields.type">
|
v-model="filters.site_name"
|
||||||
<el-select v-model="filters.fee_type" :placeholder="TEXT.common.placeholders.select" clearable>
|
:placeholder="TEXT.common.fields.site"
|
||||||
<el-option :label="TEXT.enums.financeSpecialType.TRAVEL" value="TRAVEL" />
|
clearable
|
||||||
<el-option :label="TEXT.enums.financeSpecialType.HOTEL" value="HOTEL" />
|
class="filter-input-comp"
|
||||||
<el-option :label="TEXT.enums.financeSpecialType.TRANSPORT" value="TRANSPORT" />
|
/>
|
||||||
<el-option :label="TEXT.enums.financeSpecialType.OTHER" value="OTHER" />
|
</el-form-item>
|
||||||
</el-select>
|
<el-form-item label="" class="filter-item-form">
|
||||||
</el-form-item>
|
<el-select
|
||||||
<el-form-item>
|
v-model="filters.fee_type"
|
||||||
<el-button type="primary" @click="load">{{ TEXT.common.actions.search }}</el-button>
|
:placeholder="TEXT.common.fields.type"
|
||||||
<el-button @click="resetFilters">{{ TEXT.common.actions.reset }}</el-button>
|
clearable
|
||||||
</el-form-item>
|
class="filter-select-comp"
|
||||||
</el-form>
|
>
|
||||||
|
<el-option :label="TEXT.enums.financeSpecialType.TRAVEL" value="TRAVEL" />
|
||||||
|
<el-option :label="TEXT.enums.financeSpecialType.HOTEL" value="HOTEL" />
|
||||||
|
<el-option :label="TEXT.enums.financeSpecialType.TRANSPORT" value="TRANSPORT" />
|
||||||
|
<el-option :label="TEXT.enums.financeSpecialType.OTHER" value="OTHER" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item class="filter-item-form">
|
||||||
|
<el-button @click="resetFilters">{{ TEXT.common.actions.reset }}</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
<div class="filter-spacer"></div>
|
||||||
|
<el-button type="primary" @click="goNew" class="header-action-btn">
|
||||||
|
{{ TEXT.modules.financeSpecials.newTitle }}
|
||||||
|
</el-button>
|
||||||
|
</el-form>
|
||||||
|
</div>
|
||||||
</el-card>
|
</el-card>
|
||||||
|
|
||||||
<el-card>
|
<el-card>
|
||||||
@@ -109,8 +117,16 @@ const siteActiveMap = computed(() => {
|
|||||||
const isInactiveSite = (siteName?: string) => !!siteName && siteActiveMap.value[siteName] === false;
|
const isInactiveSite = (siteName?: string) => !!siteName && siteActiveMap.value[siteName] === false;
|
||||||
const specialRowClass = ({ row }: { row: any }) =>
|
const specialRowClass = ({ row }: { row: any }) =>
|
||||||
`${row?.id ? "clickable-row" : ""}${isInactiveSite(row?.site_name) ? " row-inactive" : ""}`.trim();
|
`${row?.id ? "clickable-row" : ""}${isInactiveSite(row?.site_name) ? " row-inactive" : ""}`.trim();
|
||||||
|
const filteredItems = computed(() => {
|
||||||
|
const keyword = filters.site_name.trim().toLowerCase();
|
||||||
|
return items.value.filter((item) => {
|
||||||
|
if (keyword && !String(item?.site_name || "").toLowerCase().includes(keyword)) return false;
|
||||||
|
if (filters.fee_type && item?.fee_type !== filters.fee_type) return false;
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
});
|
||||||
const sortedItems = computed(() =>
|
const sortedItems = computed(() =>
|
||||||
[...items.value].sort((a, b) => Number(isInactiveSite(a?.site_name)) - Number(isInactiveSite(b?.site_name)))
|
[...filteredItems.value].sort((a, b) => Number(isInactiveSite(a?.site_name)) - Number(isInactiveSite(b?.site_name)))
|
||||||
);
|
);
|
||||||
|
|
||||||
const loadSites = async () => {
|
const loadSites = async () => {
|
||||||
@@ -129,10 +145,7 @@ const load = async () => {
|
|||||||
if (!studyId) return;
|
if (!studyId) return;
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
try {
|
try {
|
||||||
const { data } = await listFinanceSpecials(studyId, {
|
const { data } = await listFinanceSpecials(studyId, {}) as any;
|
||||||
site_name: filters.site_name || undefined,
|
|
||||||
fee_type: filters.fee_type || undefined,
|
|
||||||
});
|
|
||||||
items.value = Array.isArray(data) ? data : data.items || [];
|
items.value = Array.isArray(data) ? data : data.items || [];
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
ElMessage.error(e?.response?.data?.message || TEXT.common.messages.loadFailed);
|
ElMessage.error(e?.response?.data?.message || TEXT.common.messages.loadFailed);
|
||||||
@@ -144,7 +157,6 @@ const load = async () => {
|
|||||||
const resetFilters = () => {
|
const resetFilters = () => {
|
||||||
filters.site_name = "";
|
filters.site_name = "";
|
||||||
filters.fee_type = "";
|
filters.fee_type = "";
|
||||||
load();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const goNew = () => router.push("/finance/special/new");
|
const goNew = () => router.push("/finance/special/new");
|
||||||
@@ -182,29 +194,59 @@ onMounted(async () => {
|
|||||||
.page {
|
.page {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 16px;
|
gap: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.page-header {
|
.filter-card {
|
||||||
|
border: none;
|
||||||
|
background-color: transparent;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-card :deep(.el-card__body) {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-form {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
width: 100%;
|
||||||
align-items: flex-end;
|
gap: 12px;
|
||||||
|
align-items: center;
|
||||||
|
background: white;
|
||||||
|
padding: 12px 16px;
|
||||||
|
border-radius: 10px;
|
||||||
|
border: 1px solid var(--ctms-border-color);
|
||||||
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
.page-title {
|
.filter-row {
|
||||||
margin: 0;
|
display: flex;
|
||||||
font-size: 22px;
|
align-items: center;
|
||||||
font-weight: 600;
|
gap: 12px;
|
||||||
|
flex-wrap: wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.page-subtitle {
|
.filter-item-form {
|
||||||
margin: 6px 0 0;
|
margin-bottom: 0 !important;
|
||||||
font-size: 13px;
|
margin-right: 0 !important;
|
||||||
color: var(--ctms-text-secondary);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.filter-card :deep(.el-form-item) {
|
.filter-input-comp {
|
||||||
margin-bottom: 0;
|
width: 160px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-select-comp {
|
||||||
|
width: 140px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-spacer {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-action-btn {
|
||||||
|
height: 36px;
|
||||||
|
padding: 0 20px;
|
||||||
|
border-radius: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,28 +1,34 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="page">
|
<div class="page">
|
||||||
<div class="page-header">
|
|
||||||
<div>
|
<el-card shadow="never" class="main-content-card">
|
||||||
<h1 class="page-title">{{ TEXT.modules.knowledgeNotes.title }}</h1>
|
<div class="filter-container">
|
||||||
|
<el-form :inline="true" :model="filters" class="filter-form">
|
||||||
|
<el-form-item label="" class="filter-item-form">
|
||||||
|
<el-input
|
||||||
|
v-model="filters.site_name"
|
||||||
|
:placeholder="TEXT.common.fields.site"
|
||||||
|
clearable
|
||||||
|
class="filter-input-comp"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="" class="filter-item-form">
|
||||||
|
<el-input
|
||||||
|
v-model="filters.keyword"
|
||||||
|
:placeholder="TEXT.common.fields.keyword"
|
||||||
|
clearable
|
||||||
|
class="filter-input-comp"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item class="filter-item-form">
|
||||||
|
<el-button @click="resetFilters">{{ TEXT.common.actions.reset }}</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
<div class="filter-spacer"></div>
|
||||||
|
<el-button type="primary" @click="goNew" class="header-action-btn">
|
||||||
|
{{ TEXT.modules.knowledgeNotes.newTitle }}
|
||||||
|
</el-button>
|
||||||
|
</el-form>
|
||||||
</div>
|
</div>
|
||||||
<el-button type="primary" @click="goNew">{{ TEXT.modules.knowledgeNotes.newTitle }}</el-button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<el-card class="filter-card">
|
|
||||||
<el-form :inline="true" :model="filters">
|
|
||||||
<el-form-item :label="TEXT.common.fields.site">
|
|
||||||
<el-input v-model="filters.site_name" :placeholder="TEXT.common.placeholders.input + TEXT.common.fields.site" clearable />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item :label="TEXT.common.fields.keyword">
|
|
||||||
<el-input v-model="filters.keyword" :placeholder="TEXT.common.placeholders.input + TEXT.common.fields.keyword" clearable />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item>
|
|
||||||
<el-button type="primary" @click="load">{{ TEXT.common.actions.search }}</el-button>
|
|
||||||
<el-button @click="resetFilters">{{ TEXT.common.actions.reset }}</el-button>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
</el-card>
|
|
||||||
|
|
||||||
<el-card>
|
|
||||||
<el-table
|
<el-table
|
||||||
:data="sortedItems"
|
:data="sortedItems"
|
||||||
v-loading="loading"
|
v-loading="loading"
|
||||||
@@ -87,8 +93,17 @@ const siteActiveMap = computed(() => {
|
|||||||
const isInactiveSite = (siteName?: string) => !!siteName && siteActiveMap.value[siteName] === false;
|
const isInactiveSite = (siteName?: string) => !!siteName && siteActiveMap.value[siteName] === false;
|
||||||
const noteRowClass = ({ row }: { row: any }) =>
|
const noteRowClass = ({ row }: { row: any }) =>
|
||||||
`${row?.id ? "clickable-row" : ""}${isInactiveSite(row?.site_name) ? " row-inactive" : ""}`.trim();
|
`${row?.id ? "clickable-row" : ""}${isInactiveSite(row?.site_name) ? " row-inactive" : ""}`.trim();
|
||||||
|
const filteredItems = computed(() => {
|
||||||
|
const siteKeyword = filters.site_name.trim().toLowerCase();
|
||||||
|
const keyword = filters.keyword.trim().toLowerCase();
|
||||||
|
return items.value.filter((item) => {
|
||||||
|
if (siteKeyword && !String(item?.site_name || "").toLowerCase().includes(siteKeyword)) return false;
|
||||||
|
if (keyword && !String(item?.title || "").toLowerCase().includes(keyword)) return false;
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
});
|
||||||
const sortedItems = computed(() =>
|
const sortedItems = computed(() =>
|
||||||
[...items.value].sort((a, b) => Number(isInactiveSite(a?.site_name)) - Number(isInactiveSite(b?.site_name)))
|
[...filteredItems.value].sort((a, b) => Number(isInactiveSite(a?.site_name)) - Number(isInactiveSite(b?.site_name)))
|
||||||
);
|
);
|
||||||
|
|
||||||
const loadSites = async () => {
|
const loadSites = async () => {
|
||||||
@@ -107,10 +122,7 @@ const load = async () => {
|
|||||||
if (!studyId) return;
|
if (!studyId) return;
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
try {
|
try {
|
||||||
const { data } = await listKnowledgeNotes(studyId, {
|
const { data } = await listKnowledgeNotes(studyId, {}) as any;
|
||||||
site_name: filters.site_name || undefined,
|
|
||||||
keyword: filters.keyword || undefined,
|
|
||||||
});
|
|
||||||
items.value = Array.isArray(data) ? data : data.items || [];
|
items.value = Array.isArray(data) ? data : data.items || [];
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
ElMessage.error(e?.response?.data?.message || TEXT.common.messages.loadFailed);
|
ElMessage.error(e?.response?.data?.message || TEXT.common.messages.loadFailed);
|
||||||
@@ -122,7 +134,6 @@ const load = async () => {
|
|||||||
const resetFilters = () => {
|
const resetFilters = () => {
|
||||||
filters.site_name = "";
|
filters.site_name = "";
|
||||||
filters.keyword = "";
|
filters.keyword = "";
|
||||||
load();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const goNew = () => router.push("/knowledge/notes/new");
|
const goNew = () => router.push("/knowledge/notes/new");
|
||||||
@@ -160,29 +171,40 @@ onMounted(async () => {
|
|||||||
.page {
|
.page {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 16px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.page-header {
|
.main-content-card :deep(.el-card__body) {
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-container {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-form {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
width: 100%;
|
||||||
align-items: flex-end;
|
gap: 12px;
|
||||||
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.page-title {
|
.filter-item-form {
|
||||||
margin: 0;
|
margin-bottom: 0 !important;
|
||||||
font-size: 22px;
|
margin-right: 0 !important;
|
||||||
font-weight: 600;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.page-subtitle {
|
.filter-input-comp {
|
||||||
margin: 6px 0 0;
|
width: 160px;
|
||||||
font-size: 13px;
|
|
||||||
color: var(--ctms-text-secondary);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.filter-card :deep(.el-form-item) {
|
.filter-spacer {
|
||||||
margin-bottom: 0;
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-action-btn {
|
||||||
|
height: 36px;
|
||||||
|
padding: 0 20px;
|
||||||
|
border-radius: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -4,11 +4,6 @@
|
|||||||
<div class="page-header">
|
<div class="page-header">
|
||||||
<div>
|
<div>
|
||||||
<h1 class="page-title">项目概览</h1>
|
<h1 class="page-title">项目概览</h1>
|
||||||
<p class="study-meta">
|
|
||||||
<span class="study-name">{{ study.currentStudy.name }}</span>
|
|
||||||
<span class="study-divider">/</span>
|
|
||||||
<span class="study-code">{{ study.currentStudy.code }}</span>
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="header-meta">
|
<div class="header-meta">
|
||||||
<el-tag v-if="usingDemo" effect="plain" type="info" class="demo-tag">示例数据</el-tag>
|
<el-tag v-if="usingDemo" effect="plain" type="info" class="demo-tag">示例数据</el-tag>
|
||||||
|
|||||||
@@ -1,10 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="ctms-page">
|
<div class="ctms-page">
|
||||||
<div class="ctms-page-header">
|
|
||||||
<div>
|
|
||||||
<h1 class="ctms-page-title">{{ TEXT.modules.startupFeasibilityEthics.title }}</h1>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<el-card class="ctms-table-card">
|
<el-card class="ctms-table-card">
|
||||||
<el-tabs v-model="activeTab" class="ctms-tabs">
|
<el-tabs v-model="activeTab" class="ctms-tabs">
|
||||||
@@ -240,7 +235,7 @@ const loadFeasibility = async () => {
|
|||||||
if (!studyId) return;
|
if (!studyId) return;
|
||||||
loadingFeasibility.value = true;
|
loadingFeasibility.value = true;
|
||||||
try {
|
try {
|
||||||
const { data } = await listFeasibility(studyId);
|
const { data } = await listFeasibility(studyId) as any;
|
||||||
feasibilityItems.value = Array.isArray(data) ? data : data.items || [];
|
feasibilityItems.value = Array.isArray(data) ? data : data.items || [];
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
ElMessage.error(e?.response?.data?.message || TEXT.common.messages.loadFailed);
|
ElMessage.error(e?.response?.data?.message || TEXT.common.messages.loadFailed);
|
||||||
@@ -254,7 +249,7 @@ const loadEthics = async () => {
|
|||||||
if (!studyId) return;
|
if (!studyId) return;
|
||||||
loadingEthics.value = true;
|
loadingEthics.value = true;
|
||||||
try {
|
try {
|
||||||
const { data } = await listEthics(studyId);
|
const { data } = await listEthics(studyId) as any;
|
||||||
ethicsItems.value = Array.isArray(data) ? data : data.items || [];
|
ethicsItems.value = Array.isArray(data) ? data : data.items || [];
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
ElMessage.error(e?.response?.data?.message || TEXT.common.messages.loadFailed);
|
ElMessage.error(e?.response?.data?.message || TEXT.common.messages.loadFailed);
|
||||||
@@ -311,6 +306,12 @@ onMounted(() => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
.ctms-page {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
.ctms-tab-content {
|
.ctms-tab-content {
|
||||||
padding: 16px;
|
padding: 16px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="page">
|
<div class="page">
|
||||||
<div class="page-header">
|
|
||||||
<div>
|
|
||||||
<h1 class="page-title">{{ TEXT.modules.startupMeetingAuth.title }}</h1>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<el-card>
|
<el-card>
|
||||||
<el-table
|
<el-table
|
||||||
@@ -39,6 +34,7 @@
|
|||||||
import { computed, onMounted, ref } from "vue";
|
import { computed, onMounted, ref } from "vue";
|
||||||
import { useRouter } from "vue-router";
|
import { useRouter } from "vue-router";
|
||||||
import { ElMessage } from "element-plus";
|
import { ElMessage } from "element-plus";
|
||||||
|
import { useAuthStore } from "../../store/auth";
|
||||||
import { useStudyStore } from "../../store/study";
|
import { useStudyStore } from "../../store/study";
|
||||||
import { createKickoff, listKickoffs } from "../../api/startup";
|
import { createKickoff, listKickoffs } from "../../api/startup";
|
||||||
import { fetchSites } from "../../api/sites";
|
import { fetchSites } from "../../api/sites";
|
||||||
@@ -49,12 +45,14 @@ import StateEmpty from "../../components/StateEmpty.vue";
|
|||||||
import { TEXT } from "../../locales";
|
import { TEXT } from "../../locales";
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
const auth = useAuthStore();
|
||||||
const study = useStudyStore();
|
const study = useStudyStore();
|
||||||
const kickoffItems = ref<any[]>([]);
|
const kickoffItems = ref<any[]>([]);
|
||||||
const sites = ref<any[]>([]);
|
const sites = ref<any[]>([]);
|
||||||
const users = ref<any[]>([]);
|
const users = ref<any[]>([]);
|
||||||
const members = ref<any[]>([]);
|
const members = ref<any[]>([]);
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
|
const isAdmin = computed(() => auth.user?.role === "ADMIN");
|
||||||
|
|
||||||
const memberNameMap = computed(() => {
|
const memberNameMap = computed(() => {
|
||||||
const map: Record<string, string> = {};
|
const map: Record<string, string> = {};
|
||||||
@@ -62,7 +60,10 @@ const memberNameMap = computed(() => {
|
|||||||
if (u?.id) map[u.id] = u.full_name || u.username || u.id;
|
if (u?.id) map[u.id] = u.full_name || u.username || u.id;
|
||||||
});
|
});
|
||||||
members.value.forEach((m: any) => {
|
members.value.forEach((m: any) => {
|
||||||
if (m?.user_id && !map[m.user_id]) map[m.user_id] = m.full_name || m.username || m.user_id;
|
const user = m?.user;
|
||||||
|
if (m?.user_id && !map[m.user_id]) {
|
||||||
|
map[m.user_id] = user?.full_name || user?.username || user?.email || m.user_id;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return map;
|
return map;
|
||||||
});
|
});
|
||||||
@@ -111,16 +112,19 @@ const loadKickoffs = async () => {
|
|||||||
if (!studyId) return;
|
if (!studyId) return;
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
try {
|
try {
|
||||||
const [sitesResp, kickoffResp, membersResp, usersResp] = await Promise.all([
|
const requests = [
|
||||||
fetchSites(studyId, { limit: 500 }),
|
fetchSites(studyId, { limit: 500 }),
|
||||||
listKickoffs(studyId),
|
listKickoffs(studyId),
|
||||||
listMembers(studyId, { limit: 500 }),
|
listMembers(studyId, { limit: 500 }),
|
||||||
fetchUsers({ limit: 500 }),
|
];
|
||||||
]);
|
if (isAdmin.value) {
|
||||||
|
requests.push(fetchUsers({ limit: 500 }));
|
||||||
|
}
|
||||||
|
const [sitesResp, kickoffResp, membersResp, usersResp] = await Promise.all(requests) as any[];
|
||||||
sites.value = Array.isArray(sitesResp.data) ? sitesResp.data : sitesResp.data.items || [];
|
sites.value = Array.isArray(sitesResp.data) ? sitesResp.data : sitesResp.data.items || [];
|
||||||
kickoffItems.value = Array.isArray(kickoffResp.data) ? kickoffResp.data : kickoffResp.data.items || [];
|
kickoffItems.value = Array.isArray(kickoffResp.data) ? kickoffResp.data : kickoffResp.data.items || [];
|
||||||
members.value = Array.isArray(membersResp.data) ? membersResp.data : membersResp.data.items || [];
|
members.value = Array.isArray(membersResp.data) ? membersResp.data : membersResp.data.items || [];
|
||||||
users.value = usersResp.data?.items || [];
|
users.value = usersResp?.data?.items || [];
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
ElMessage.error(e?.response?.data?.message || TEXT.common.messages.loadFailed);
|
ElMessage.error(e?.response?.data?.message || TEXT.common.messages.loadFailed);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -141,7 +145,7 @@ const onKickoffRowClick = async (row: any) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const { data } = await createKickoff(studyId, { site_id: row.site_id });
|
const { data } = await createKickoff(studyId, { site_id: row.site_id }) as any;
|
||||||
goKickoffDetail(data.id);
|
goKickoffDetail(data.id);
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
ElMessage.error(e?.response?.data?.message || TEXT.common.messages.createFailed);
|
ElMessage.error(e?.response?.data?.message || TEXT.common.messages.createFailed);
|
||||||
@@ -158,7 +162,7 @@ onMounted(() => {
|
|||||||
.page {
|
.page {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 16px;
|
gap: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.page-header {
|
.page-header {
|
||||||
|
|||||||
@@ -1,31 +1,91 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="page">
|
<div class="page">
|
||||||
<div class="page-header">
|
|
||||||
<div>
|
|
||||||
<h1 class="page-title">{{ TEXT.modules.subjectManagement.title }}</h1>
|
|
||||||
</div>
|
|
||||||
<el-button type="primary" @click="goNew">{{ TEXT.common.actions.add }}{{ TEXT.modules.subjectManagement.subjectLabel }}</el-button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<el-card>
|
<el-card shadow="never" class="main-content-card">
|
||||||
|
<div class="filter-container">
|
||||||
|
<el-form :inline="true" :model="filters" class="filter-form">
|
||||||
|
<el-form-item label="" class="filter-item-form">
|
||||||
|
<el-input
|
||||||
|
v-model="filters.keyword"
|
||||||
|
:placeholder="TEXT.modules.subjectManagement.screeningNo"
|
||||||
|
clearable
|
||||||
|
class="filter-input-comp"
|
||||||
|
>
|
||||||
|
<template #prefix>
|
||||||
|
<el-icon><Search /></el-icon>
|
||||||
|
</template>
|
||||||
|
</el-input>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="" class="filter-item-form">
|
||||||
|
<el-select
|
||||||
|
v-model="filters.siteId"
|
||||||
|
:placeholder="TEXT.common.fields.site"
|
||||||
|
clearable
|
||||||
|
filterable
|
||||||
|
class="filter-select-comp"
|
||||||
|
>
|
||||||
|
<template #prefix>
|
||||||
|
<el-icon><Location /></el-icon>
|
||||||
|
</template>
|
||||||
|
<el-option :label="TEXT.common.labels.all" value="" />
|
||||||
|
<el-option v-for="site in siteOptions" :key="site.id" :label="site.name" :value="site.id" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="" class="filter-item-form">
|
||||||
|
<el-select
|
||||||
|
v-model="filters.status"
|
||||||
|
:placeholder="TEXT.common.fields.status"
|
||||||
|
clearable
|
||||||
|
class="filter-select-comp"
|
||||||
|
>
|
||||||
|
<template #prefix>
|
||||||
|
<el-icon><CircleCheck /></el-icon>
|
||||||
|
</template>
|
||||||
|
<el-option :label="TEXT.common.labels.all" value="" />
|
||||||
|
<el-option v-for="option in statusOptions" :key="option.value" :label="option.label" :value="option.value" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item class="filter-actions-comp">
|
||||||
|
<el-button @click="resetFilters">{{ TEXT.common.actions.reset }}</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
<div class="filter-spacer"></div>
|
||||||
|
<el-button type="primary" @click="goNew" class="header-action-btn">
|
||||||
|
<el-icon class="el-icon--left"><Plus /></el-icon>
|
||||||
|
{{ TEXT.common.actions.add }}{{ TEXT.modules.subjectManagement.subjectLabel }}
|
||||||
|
</el-button>
|
||||||
|
</el-form>
|
||||||
|
</div>
|
||||||
<el-table
|
<el-table
|
||||||
:data="sortedItems"
|
:data="pagedItems"
|
||||||
v-loading="loading"
|
v-loading="loading"
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
class="ctms-table"
|
class="ctms-table"
|
||||||
:row-class-name="subjectRowClass"
|
:row-class-name="subjectRowClass"
|
||||||
@row-click="onRowClick"
|
@row-click="onRowClick"
|
||||||
>
|
>
|
||||||
<el-table-column prop="subject_no" :label="TEXT.common.fields.subjectNo" min-width="140" />
|
<el-table-column prop="subject_no" :label="TEXT.modules.subjectManagement.screeningNo" min-width="160">
|
||||||
|
<template #default="scope">
|
||||||
|
<div class="subject-info-cell">
|
||||||
|
<span class="subject-no">{{ scope.row.subject_no || TEXT.common.fallback }}</span>
|
||||||
|
<span v-if="scope.row.has_ae" class="ae-badge">AE</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
<el-table-column :label="TEXT.common.fields.site" min-width="160">
|
<el-table-column :label="TEXT.common.fields.site" min-width="160">
|
||||||
<template #default="scope">{{ siteMap[scope.row.site_id] || TEXT.common.fallback }}</template>
|
<template #default="scope">{{ siteMap[scope.row.site_id] || TEXT.common.fallback }}</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
<el-table-column prop="consent_date" :label="TEXT.common.fields.consentDate" width="140">
|
||||||
|
<template #default="scope">{{ displayDate(scope.row.consent_date) }}</template>
|
||||||
|
</el-table-column>
|
||||||
<el-table-column prop="status" :label="TEXT.common.fields.status" width="120">
|
<el-table-column prop="status" :label="TEXT.common.fields.status" width="120">
|
||||||
<template #default="scope">{{ displayEnum(TEXT.enums.subjectStatus, scope.row.status) }}</template>
|
<template #default="scope">{{ displayEnum(TEXT.enums.subjectStatus, scope.row.status) }}</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="enrollment_date" :label="TEXT.common.fields.enrollmentDate" width="140">
|
<el-table-column prop="enrollment_date" :label="TEXT.common.fields.enrollmentDate" width="140">
|
||||||
<template #default="scope">{{ displayDate(scope.row.enrollment_date) }}</template>
|
<template #default="scope">{{ displayDate(scope.row.enrollment_date) }}</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
<el-table-column prop="completion_date" :label="TEXT.common.fields.completionDate" width="140">
|
||||||
|
<template #default="scope">{{ displayDate(scope.row.completion_date) }}</template>
|
||||||
|
</el-table-column>
|
||||||
<el-table-column :label="TEXT.common.labels.actions" width="120">
|
<el-table-column :label="TEXT.common.labels.actions" width="120">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-button
|
<el-button
|
||||||
@@ -40,15 +100,25 @@
|
|||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
|
<div class="table-pagination">
|
||||||
|
<el-pagination
|
||||||
|
v-model:current-page="pagination.currentPage"
|
||||||
|
v-model:page-size="pagination.pageSize"
|
||||||
|
:page-sizes="[10, 20, 50]"
|
||||||
|
:total="filteredItems.length"
|
||||||
|
layout="total, prev, pager, next, sizes"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
<StateEmpty v-if="!loading && sortedItems.length === 0" :description="TEXT.modules.subjectManagement.empty" />
|
<StateEmpty v-if="!loading && sortedItems.length === 0" :description="TEXT.modules.subjectManagement.empty" />
|
||||||
</el-card>
|
</el-card>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, onMounted, ref } from "vue";
|
import { computed, onMounted, ref, watch } from "vue";
|
||||||
import { useRouter } from "vue-router";
|
import { useRouter } from "vue-router";
|
||||||
import { ElMessage, ElMessageBox } from "element-plus";
|
import { ElMessage, ElMessageBox } from "element-plus";
|
||||||
|
import { Search, Location, CircleCheck, Plus } from "@element-plus/icons-vue";
|
||||||
import { useStudyStore } from "../../store/study";
|
import { useStudyStore } from "../../store/study";
|
||||||
import { deleteSubject, fetchSubjects } from "../../api/subjects";
|
import { deleteSubject, fetchSubjects } from "../../api/subjects";
|
||||||
import { fetchSites } from "../../api/sites";
|
import { fetchSites } from "../../api/sites";
|
||||||
@@ -60,14 +130,31 @@ const router = useRouter();
|
|||||||
const study = useStudyStore();
|
const study = useStudyStore();
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const items = ref<any[]>([]);
|
const items = ref<any[]>([]);
|
||||||
|
const siteOptions = ref<Array<{ id: string; name: string }>>([]);
|
||||||
const siteMap = ref<Record<string, string>>({});
|
const siteMap = ref<Record<string, string>>({});
|
||||||
const siteActiveMap = ref<Record<string, boolean>>({});
|
const siteActiveMap = ref<Record<string, boolean>>({});
|
||||||
|
const filters = ref({
|
||||||
|
keyword: "",
|
||||||
|
siteId: study.currentSite?.id || "",
|
||||||
|
status: "",
|
||||||
|
});
|
||||||
|
const pagination = ref({
|
||||||
|
currentPage: 1,
|
||||||
|
pageSize: 20,
|
||||||
|
});
|
||||||
|
const statusOptions = Object.entries(TEXT.enums.subjectStatus).map(([value, label]) => ({ value, label }));
|
||||||
|
const resetFilters = () => {
|
||||||
|
filters.value.keyword = "";
|
||||||
|
filters.value.siteId = "";
|
||||||
|
filters.value.status = "";
|
||||||
|
};
|
||||||
const loadSites = async () => {
|
const loadSites = async () => {
|
||||||
const studyId = study.currentStudy?.id;
|
const studyId = study.currentStudy?.id;
|
||||||
if (!studyId) return;
|
if (!studyId) return;
|
||||||
try {
|
try {
|
||||||
const { data } = await fetchSites(studyId, { limit: 500 });
|
const { data } = await fetchSites(studyId, { limit: 500 });
|
||||||
const list = Array.isArray(data) ? data : data.items || [];
|
const list = Array.isArray(data) ? data : data.items || [];
|
||||||
|
siteOptions.value = list.map((site: any) => ({ id: site.id, name: site.name }));
|
||||||
siteMap.value = list.reduce((acc: Record<string, string>, site: any) => {
|
siteMap.value = list.reduce((acc: Record<string, string>, site: any) => {
|
||||||
acc[site.id] = site.name;
|
acc[site.id] = site.name;
|
||||||
return acc;
|
return acc;
|
||||||
@@ -121,12 +208,47 @@ const remove = async (row: any) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const isInactiveSite = (siteId?: string) => !!siteId && siteActiveMap.value[siteId] === false;
|
const isInactiveSite = (siteId?: string) => !!siteId && siteActiveMap.value[siteId] === false;
|
||||||
|
const filteredItems = computed(() => {
|
||||||
|
const keyword = filters.value.keyword.trim().toLowerCase();
|
||||||
|
return items.value.filter((item) => {
|
||||||
|
if (keyword && !String(item?.subject_no || "").toLowerCase().includes(keyword)) return false;
|
||||||
|
if (filters.value.siteId && item?.site_id !== filters.value.siteId) return false;
|
||||||
|
if (filters.value.status && item?.status !== filters.value.status) return false;
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
});
|
||||||
const sortedItems = computed(() =>
|
const sortedItems = computed(() =>
|
||||||
[...items.value].sort((a, b) => Number(isInactiveSite(a?.site_id)) - Number(isInactiveSite(b?.site_id)))
|
[...filteredItems.value].sort((a, b) => Number(isInactiveSite(a?.site_id)) - Number(isInactiveSite(b?.site_id)))
|
||||||
);
|
);
|
||||||
|
const pagedItems = computed(() => {
|
||||||
|
const start = (pagination.value.currentPage - 1) * pagination.value.pageSize;
|
||||||
|
const end = start + pagination.value.pageSize;
|
||||||
|
return sortedItems.value.slice(start, end);
|
||||||
|
});
|
||||||
const subjectRowClass = ({ row }: { row: any }) =>
|
const subjectRowClass = ({ row }: { row: any }) =>
|
||||||
`${row?.id ? "clickable-row" : ""}${isInactiveSite(row?.site_id) ? " row-inactive" : ""}`.trim();
|
`${row?.id ? "clickable-row" : ""}${isInactiveSite(row?.site_id) ? " row-inactive" : ""}`.trim();
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => [filters.value.keyword, filters.value.siteId, filters.value.status, pagination.value.pageSize],
|
||||||
|
() => {
|
||||||
|
pagination.value.currentPage = 1;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => filteredItems.value.length,
|
||||||
|
(total) => {
|
||||||
|
const maxPage = Math.max(1, Math.ceil(total / pagination.value.pageSize));
|
||||||
|
if (pagination.value.currentPage > maxPage) {
|
||||||
|
pagination.value.currentPage = maxPage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
watch(() => study.currentSite, (newSite) => {
|
||||||
|
filters.value.siteId = newSite?.id || "";
|
||||||
|
});
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await loadSites();
|
await loadSites();
|
||||||
load();
|
load();
|
||||||
@@ -137,19 +259,92 @@ onMounted(async () => {
|
|||||||
.page {
|
.page {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 16px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.page-header {
|
.main-content-card :deep(.el-card__body) {
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-container {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-form {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
width: 100%;
|
||||||
align-items: flex-end;
|
gap: 12px;
|
||||||
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.page-title {
|
.filter-item-form {
|
||||||
margin: 0;
|
margin-bottom: 0 !important;
|
||||||
font-size: 22px;
|
margin-right: 0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-select-comp,
|
||||||
|
.filter-input-comp {
|
||||||
|
width: 140px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-spacer {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-action-btn {
|
||||||
|
height: 36px;
|
||||||
|
padding: 0 20px;
|
||||||
|
border-radius: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.subject-info-cell {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.subject-no {
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
|
color: var(--ctms-text-main);
|
||||||
|
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ae-badge {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
background: linear-gradient(135deg, #fff1f2 0%, #ffe4e6 100%);
|
||||||
|
color: #be123c;
|
||||||
|
border: 1px solid rgba(225, 29, 72, 0.2);
|
||||||
|
padding: 2px 6px;
|
||||||
|
height: 18px;
|
||||||
|
line-height: normal;
|
||||||
|
border-radius: 4px;
|
||||||
|
font-size: 10px;
|
||||||
|
font-weight: 700;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.02em;
|
||||||
|
box-shadow: 0 1px 2px rgba(225, 29, 72, 0.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
.ae-badge::before {
|
||||||
|
content: "";
|
||||||
|
display: inline-block;
|
||||||
|
width: 5px;
|
||||||
|
height: 5px;
|
||||||
|
background-color: #e11d48;
|
||||||
|
border-radius: 50%;
|
||||||
|
margin-right: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-pagination {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
margin-top: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-card {
|
||||||
|
border-radius: 12px;
|
||||||
|
border: 1px solid var(--ctms-border-color);
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.page-subtitle {
|
.page-subtitle {
|
||||||
|
|||||||
@@ -38,7 +38,7 @@
|
|||||||
:x2="axisRight"
|
:x2="axisRight"
|
||||||
:y2="axisBottom"
|
:y2="axisBottom"
|
||||||
/>
|
/>
|
||||||
<g v-for="tick in yTicks" :key="tick.value" class="axis-tick">
|
<g v-for="tick in yTicks" :key="`${tick.value}-${tick.minor ? 'm' : 'M'}`" class="axis-tick">
|
||||||
<text :x="axisLeft - 12" :y="tickY(tick.value)" class="tick-label">
|
<text :x="axisLeft - 12" :y="tickY(tick.value)" class="tick-label">
|
||||||
{{ formatNumber(tick.value) }}
|
{{ formatNumber(tick.value) }}
|
||||||
</text>
|
</text>
|
||||||
@@ -142,17 +142,13 @@ const maxValue = computed(() => {
|
|||||||
|
|
||||||
const yTicks = computed(() => {
|
const yTicks = computed(() => {
|
||||||
const max = maxValue.value;
|
const max = maxValue.value;
|
||||||
const majorStep = Math.max(1, Math.ceil(max / 4));
|
const step = max <= 12 ? 1 : Math.max(1, Math.ceil(max / 6));
|
||||||
const top = majorStep * 4;
|
const top = Math.max(1, Math.ceil(max / step) * step);
|
||||||
const ticks: Array<{ value: number; minor: boolean }> = [];
|
const ticks: Array<{ value: number; minor: boolean }> = [];
|
||||||
for (let i = 0; i <= 4; i += 1) {
|
for (let value = top; value >= 0; value -= step) {
|
||||||
const value = top - i * majorStep;
|
|
||||||
ticks.push({ value, minor: false });
|
ticks.push({ value, minor: false });
|
||||||
if (i < 4) {
|
|
||||||
ticks.push({ value: value - Math.round(majorStep / 2), minor: true });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return ticks.filter((tick) => tick.value >= 0).sort((a, b) => b.value - a.value);
|
return ticks;
|
||||||
});
|
});
|
||||||
|
|
||||||
const axisMax = computed(() => Math.max(1, yTicks.value[0]?.value ?? 1));
|
const axisMax = computed(() => Math.max(1, yTicks.value[0]?.value ?? 1));
|
||||||
|
|||||||
@@ -146,6 +146,7 @@
|
|||||||
import { computed, onMounted, reactive, ref } from "vue";
|
import { computed, onMounted, reactive, ref } from "vue";
|
||||||
import { useRoute, useRouter } from "vue-router";
|
import { useRoute, useRouter } from "vue-router";
|
||||||
import { ElMessage, ElMessageBox } from "element-plus";
|
import { ElMessage, ElMessageBox } from "element-plus";
|
||||||
|
import { useAuthStore } from "../../store/auth";
|
||||||
import { useStudyStore } from "../../store/study";
|
import { useStudyStore } from "../../store/study";
|
||||||
import {
|
import {
|
||||||
getKickoff,
|
getKickoff,
|
||||||
@@ -165,6 +166,7 @@ import { TEXT, requiredMessage } from "../../locales";
|
|||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
const auth = useAuthStore();
|
||||||
const study = useStudyStore();
|
const study = useStudyStore();
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const loadingTraining = ref(false);
|
const loadingTraining = ref(false);
|
||||||
@@ -175,6 +177,7 @@ const studyId = study.currentStudy?.id || "";
|
|||||||
const siteInfo = reactive<{ name: string; contact?: string | null; is_active?: boolean }>({ name: "" });
|
const siteInfo = reactive<{ name: string; contact?: string | null; is_active?: boolean }>({ name: "" });
|
||||||
const users = ref<any[]>([]);
|
const users = ref<any[]>([]);
|
||||||
const members = ref<any[]>([]);
|
const members = ref<any[]>([]);
|
||||||
|
const isAdmin = computed(() => auth.user?.role === "ADMIN");
|
||||||
const kickoffAttachmentGroups = [
|
const kickoffAttachmentGroups = [
|
||||||
{ entityType: "startup_kickoff_minutes", title: TEXT.modules.startupMeetingAuth.kickoffMinutesLabel },
|
{ entityType: "startup_kickoff_minutes", title: TEXT.modules.startupMeetingAuth.kickoffMinutesLabel },
|
||||||
{ entityType: "startup_kickoff_signin", title: TEXT.modules.startupMeetingAuth.kickoffSignInLabel },
|
{ entityType: "startup_kickoff_signin", title: TEXT.modules.startupMeetingAuth.kickoffSignInLabel },
|
||||||
@@ -221,7 +224,10 @@ const memberNameMap = computed(() => {
|
|||||||
if (u?.id) map[u.id] = u.full_name || u.username || u.id;
|
if (u?.id) map[u.id] = u.full_name || u.username || u.id;
|
||||||
});
|
});
|
||||||
members.value.forEach((m: any) => {
|
members.value.forEach((m: any) => {
|
||||||
if (m?.user_id && !map[m.user_id]) map[m.user_id] = m.full_name || m.username || m.user_id;
|
const user = m?.user;
|
||||||
|
if (m?.user_id && !map[m.user_id]) {
|
||||||
|
map[m.user_id] = user?.full_name || user?.username || user?.email || m.user_id;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return map;
|
return map;
|
||||||
});
|
});
|
||||||
@@ -420,10 +426,11 @@ const goBack = () => router.push("/startup/meeting-auth");
|
|||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
if (studyId) {
|
if (studyId) {
|
||||||
const [membersResp, usersResp] = await Promise.all([
|
const requests = [listMembers(studyId, { limit: 500 })];
|
||||||
listMembers(studyId, { limit: 500 }),
|
if (isAdmin.value) {
|
||||||
fetchUsers({ limit: 500 }),
|
requests.push(fetchUsers({ limit: 500 }));
|
||||||
]).catch(() => [null, null]);
|
}
|
||||||
|
const [membersResp, usersResp] = await Promise.all(requests).catch(() => [null, null]);
|
||||||
if (membersResp?.data) {
|
if (membersResp?.data) {
|
||||||
members.value = Array.isArray(membersResp.data) ? membersResp.data : membersResp.data.items || [];
|
members.value = Array.isArray(membersResp.data) ? membersResp.data : membersResp.data.items || [];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,6 +56,7 @@
|
|||||||
import { computed, onMounted, reactive, ref } from "vue";
|
import { computed, onMounted, reactive, ref } from "vue";
|
||||||
import { useRoute, useRouter } from "vue-router";
|
import { useRoute, useRouter } from "vue-router";
|
||||||
import { ElMessage } from "element-plus";
|
import { ElMessage } from "element-plus";
|
||||||
|
import { useAuthStore } from "../../store/auth";
|
||||||
import { useStudyStore } from "../../store/study";
|
import { useStudyStore } from "../../store/study";
|
||||||
import { createKickoff, getKickoff, updateKickoff } from "../../api/startup";
|
import { createKickoff, getKickoff, updateKickoff } from "../../api/startup";
|
||||||
import { fetchSites } from "../../api/sites";
|
import { fetchSites } from "../../api/sites";
|
||||||
@@ -67,6 +68,7 @@ import { TEXT } from "../../locales";
|
|||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
const auth = useAuthStore();
|
||||||
const study = useStudyStore();
|
const study = useStudyStore();
|
||||||
const saving = ref(false);
|
const saving = ref(false);
|
||||||
|
|
||||||
@@ -77,6 +79,7 @@ const siteInfo = reactive<{ name: string; contact?: string | null; is_active?: b
|
|||||||
const siteId = ref("");
|
const siteId = ref("");
|
||||||
const users = ref<any[]>([]);
|
const users = ref<any[]>([]);
|
||||||
const members = ref<any[]>([]);
|
const members = ref<any[]>([]);
|
||||||
|
const isAdmin = computed(() => auth.user?.role === "ADMIN");
|
||||||
|
|
||||||
const memberNameMap = computed(() => {
|
const memberNameMap = computed(() => {
|
||||||
const map: Record<string, string> = {};
|
const map: Record<string, string> = {};
|
||||||
@@ -84,7 +87,10 @@ const memberNameMap = computed(() => {
|
|||||||
if (u?.id) map[u.id] = u.full_name || u.username || u.id;
|
if (u?.id) map[u.id] = u.full_name || u.username || u.id;
|
||||||
});
|
});
|
||||||
members.value.forEach((m: any) => {
|
members.value.forEach((m: any) => {
|
||||||
if (m?.user_id && !map[m.user_id]) map[m.user_id] = m.full_name || m.username || m.user_id;
|
const user = m?.user;
|
||||||
|
if (m?.user_id && !map[m.user_id]) {
|
||||||
|
map[m.user_id] = user?.full_name || user?.username || user?.email || m.user_id;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return map;
|
return map;
|
||||||
});
|
});
|
||||||
@@ -174,10 +180,11 @@ const goBack = () => router.push("/startup/meeting-auth");
|
|||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
if (studyId.value) {
|
if (studyId.value) {
|
||||||
const [membersResp, usersResp] = await Promise.all([
|
const requests = [listMembers(studyId.value, { limit: 500 })];
|
||||||
listMembers(studyId.value, { limit: 500 }),
|
if (isAdmin.value) {
|
||||||
fetchUsers({ limit: 500 }),
|
requests.push(fetchUsers({ limit: 500 }));
|
||||||
]).catch(() => [null, null]);
|
}
|
||||||
|
const [membersResp, usersResp] = await Promise.all(requests).catch(() => [null, null]);
|
||||||
if (membersResp?.data) {
|
if (membersResp?.data) {
|
||||||
members.value = Array.isArray(membersResp.data) ? membersResp.data : membersResp.data.items || [];
|
members.value = Array.isArray(membersResp.data) ? membersResp.data : membersResp.data.items || [];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,27 +1,9 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="page">
|
<div class="page">
|
||||||
<div class="page-header">
|
|
||||||
<div>
|
|
||||||
<h1 class="page-title">{{ TEXT.modules.subjectDetail.title }}</h1>
|
|
||||||
<p class="page-subtitle">{{ TEXT.modules.subjectDetail.subtitle }}</p>
|
|
||||||
</div>
|
|
||||||
<div class="actions">
|
|
||||||
<template v-if="subjectEditing">
|
|
||||||
<el-button type="primary" :loading="subjectSaving" @click="saveSubjectEdit">{{ TEXT.common.actions.save }}</el-button>
|
|
||||||
<el-button @click="cancelSubjectEdit">{{ TEXT.common.actions.cancel }}</el-button>
|
|
||||||
</template>
|
|
||||||
<template v-else>
|
|
||||||
<el-button type="primary" :disabled="isReadOnly" @click="startSubjectEdit">
|
|
||||||
{{ TEXT.common.actions.edit }}
|
|
||||||
</el-button>
|
|
||||||
<el-button @click="goBack">{{ TEXT.common.actions.back }}</el-button>
|
|
||||||
</template>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<el-card v-loading="loading">
|
<el-card v-loading="loading">
|
||||||
<el-descriptions :column="2" border>
|
<el-descriptions :column="2" border>
|
||||||
<el-descriptions-item :label="TEXT.common.fields.subjectNo">{{ detail.subject_no || TEXT.common.fallback }}</el-descriptions-item>
|
<el-descriptions-item :label="TEXT.modules.subjectManagement.screeningNo">{{ detail.subject_no || TEXT.common.fallback }}</el-descriptions-item>
|
||||||
<el-descriptions-item :label="TEXT.common.fields.site">{{ siteMap[detail.site_id] || TEXT.common.fallback }}</el-descriptions-item>
|
<el-descriptions-item :label="TEXT.common.fields.site">{{ siteMap[detail.site_id] || TEXT.common.fallback }}</el-descriptions-item>
|
||||||
<el-descriptions-item :label="TEXT.common.fields.status">
|
<el-descriptions-item :label="TEXT.common.fields.status">
|
||||||
<el-select v-if="subjectEditing" v-model="subjectForm.status" size="small">
|
<el-select v-if="subjectEditing" v-model="subjectForm.status" size="small">
|
||||||
@@ -202,10 +184,23 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="term" :label="TEXT.common.fields.title" min-width="140" />
|
<el-table-column prop="term" :label="TEXT.common.fields.title" min-width="140" />
|
||||||
<el-table-column prop="seriousness" :label="TEXT.common.fields.seriousness" width="120">
|
<el-table-column prop="seriousness" :label="TEXT.common.fields.seriousness" width="120">
|
||||||
<template #default="scope">{{ displayEnum(TEXT.enums.aeSeriousness, scope.row.seriousness) }}</template>
|
<template #default="scope">
|
||||||
|
<el-tag
|
||||||
|
:type="getAeSeriousnessType(normalizeSeriousness(scope.row.seriousness))"
|
||||||
|
size="small"
|
||||||
|
effect="light"
|
||||||
|
class="seriousness-tag"
|
||||||
|
>
|
||||||
|
{{ displayEnum(TEXT.enums.aeSeriousness, normalizeSeriousness(scope.row.seriousness)) }}
|
||||||
|
</el-tag>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="causality" :label="TEXT.common.fields.causality" width="120">
|
||||||
|
<template #default="scope">{{ displayText(scope.row.causality, TEXT.enums.aeCausality) }}</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="outcome" :label="TEXT.common.fields.outcome" width="120">
|
||||||
|
<template #default="scope">{{ displayText(scope.row.outcome, TEXT.enums.aeOutcome) }}</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="causality" :label="TEXT.common.fields.causality" width="120" />
|
|
||||||
<el-table-column prop="outcome" :label="TEXT.common.fields.outcome" width="120" />
|
|
||||||
<el-table-column prop="description" :label="TEXT.common.fields.remark" min-width="200" />
|
<el-table-column prop="description" :label="TEXT.common.fields.remark" min-width="200" />
|
||||||
<el-table-column :label="TEXT.common.labels.actions" width="200">
|
<el-table-column :label="TEXT.common.labels.actions" width="200">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
@@ -254,9 +249,9 @@
|
|||||||
<el-form :model="visitForm" label-width="100px">
|
<el-form :model="visitForm" label-width="100px">
|
||||||
<template v-if="!visitEditingId">
|
<template v-if="!visitEditingId">
|
||||||
<el-form-item :label="TEXT.common.fields.visitCode" required>
|
<el-form-item :label="TEXT.common.fields.visitCode" required>
|
||||||
<el-input v-model="visitForm.visit_code" />
|
<el-input v-model="visitForm.visit_code" disabled />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item :label="TEXT.common.fields.plannedDate">
|
<el-form-item :label="TEXT.common.fields.plannedDate" :required="isFirstVisit">
|
||||||
<el-date-picker v-model="visitForm.planned_date" type="date" value-format="YYYY-MM-DD" />
|
<el-date-picker v-model="visitForm.planned_date" type="date" value-format="YYYY-MM-DD" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item :label="TEXT.common.fields.windowStart">
|
<el-form-item :label="TEXT.common.fields.windowStart">
|
||||||
@@ -291,22 +286,18 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item :label="TEXT.common.fields.seriousness" required>
|
<el-form-item :label="TEXT.common.fields.seriousness" required>
|
||||||
<el-select v-model="aeForm.seriousness">
|
<el-select v-model="aeForm.seriousness">
|
||||||
<el-option :label="TEXT.enums.aeSeriousness.SERIOUS" value="SERIOUS" />
|
<el-option v-for="option in aeSeriousnessOptions" :key="option.value" :label="option.label" :value="option.value" />
|
||||||
<el-option :label="TEXT.enums.aeSeriousness.NON_SERIOUS" value="NON_SERIOUS" />
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item :label="TEXT.common.fields.severity" required>
|
|
||||||
<el-select v-model="aeForm.severity">
|
|
||||||
<el-option :label="TEXT.enums.aeSeverity.MILD" value="MILD" />
|
|
||||||
<el-option :label="TEXT.enums.aeSeverity.MODERATE" value="MODERATE" />
|
|
||||||
<el-option :label="TEXT.enums.aeSeverity.SEVERE" value="SEVERE" />
|
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item :label="TEXT.common.fields.causality">
|
<el-form-item :label="TEXT.common.fields.causality">
|
||||||
<el-input v-model="aeForm.causality" />
|
<el-select v-model="aeForm.causality" clearable>
|
||||||
|
<el-option v-for="option in aeCausalityOptions" :key="option.value" :label="option.label" :value="option.value" />
|
||||||
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item :label="TEXT.common.fields.outcome">
|
<el-form-item :label="TEXT.common.fields.outcome">
|
||||||
<el-input v-model="aeForm.outcome" />
|
<el-select v-model="aeForm.outcome" clearable>
|
||||||
|
<el-option v-for="option in aeOutcomeOptions" :key="option.value" :label="option.label" :value="option.value" />
|
||||||
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item :label="TEXT.common.fields.remark">
|
<el-form-item :label="TEXT.common.fields.remark">
|
||||||
<el-input v-model="aeForm.description" type="textarea" :rows="3" />
|
<el-input v-model="aeForm.description" type="textarea" :rows="3" />
|
||||||
@@ -330,7 +321,7 @@ import { fetchSites } from "../../api/sites";
|
|||||||
import { listSubjectHistories, createSubjectHistory, updateSubjectHistory, deleteSubjectHistory } from "../../api/subjectHistories";
|
import { listSubjectHistories, createSubjectHistory, updateSubjectHistory, deleteSubjectHistory } from "../../api/subjectHistories";
|
||||||
import { fetchVisits, createVisit, updateVisit, deleteVisit } from "../../api/visits";
|
import { fetchVisits, createVisit, updateVisit, deleteVisit } from "../../api/visits";
|
||||||
import { fetchAes, createAe, updateAe, deleteAe } from "../../api/aes";
|
import { fetchAes, createAe, updateAe, deleteAe } from "../../api/aes";
|
||||||
import { displayDate, displayEnum } from "../../utils/display";
|
import { displayDate, displayEnum, displayText } from "../../utils/display";
|
||||||
import StateEmpty from "../../components/StateEmpty.vue";
|
import StateEmpty from "../../components/StateEmpty.vue";
|
||||||
import { TEXT } from "../../locales";
|
import { TEXT } from "../../locales";
|
||||||
|
|
||||||
@@ -393,20 +384,62 @@ const visitForm = reactive<any>({
|
|||||||
actual_date: "",
|
actual_date: "",
|
||||||
notes: "",
|
notes: "",
|
||||||
});
|
});
|
||||||
|
const isFirstVisit = computed(() => visitForm.visit_code === "V1");
|
||||||
|
|
||||||
const aeItems = ref<any[]>([]);
|
const aeItems = ref<any[]>([]);
|
||||||
const loadingAes = ref(false);
|
const loadingAes = ref(false);
|
||||||
const aeDialogVisible = ref(false);
|
const aeDialogVisible = ref(false);
|
||||||
const aeEditingId = ref<string | null>(null);
|
const aeEditingId = ref<string | null>(null);
|
||||||
|
const aeCausalityOptions = [
|
||||||
|
{ value: "肯定有关", label: TEXT.enums.aeCausality["肯定有关"] },
|
||||||
|
{ value: "很可能有关", label: TEXT.enums.aeCausality["很可能有关"] },
|
||||||
|
{ value: "可能有关", label: TEXT.enums.aeCausality["可能有关"] },
|
||||||
|
{ value: "可能无关", label: TEXT.enums.aeCausality["可能无关"] },
|
||||||
|
{ value: "无关", label: TEXT.enums.aeCausality["无关"] },
|
||||||
|
{ value: "待评估", label: TEXT.enums.aeCausality["待评估"] },
|
||||||
|
];
|
||||||
|
const aeOutcomeOptions = [
|
||||||
|
{ value: "痊愈", label: TEXT.enums.aeOutcome["痊愈"] },
|
||||||
|
{ value: "好转", label: TEXT.enums.aeOutcome["好转"] },
|
||||||
|
{ value: "持续", label: TEXT.enums.aeOutcome["持续"] },
|
||||||
|
{ value: "恶化", label: TEXT.enums.aeOutcome["恶化"] },
|
||||||
|
{ value: "死亡", label: TEXT.enums.aeOutcome["死亡"] },
|
||||||
|
{ value: "失访", label: TEXT.enums.aeOutcome["失访"] },
|
||||||
|
];
|
||||||
const aeForm = reactive({
|
const aeForm = reactive({
|
||||||
term: "",
|
term: "",
|
||||||
onset_date: "",
|
onset_date: "",
|
||||||
seriousness: "NON_SERIOUS",
|
seriousness: "I",
|
||||||
severity: "MILD",
|
|
||||||
causality: "",
|
causality: "",
|
||||||
outcome: "",
|
outcome: "",
|
||||||
description: "",
|
description: "",
|
||||||
});
|
});
|
||||||
|
const aeSeriousnessOptions = [
|
||||||
|
{ value: "I", label: TEXT.enums.aeSeriousness.I },
|
||||||
|
{ value: "II", label: TEXT.enums.aeSeriousness.II },
|
||||||
|
{ value: "III", label: TEXT.enums.aeSeriousness.III },
|
||||||
|
{ value: "IV", label: TEXT.enums.aeSeriousness.IV },
|
||||||
|
{ value: "V", label: TEXT.enums.aeSeriousness.V },
|
||||||
|
];
|
||||||
|
const normalizeSeriousness = (value?: string | null) => {
|
||||||
|
if (!value) return "I";
|
||||||
|
const normalized = String(value).trim().toUpperCase();
|
||||||
|
const digitMap: Record<string, string> = {
|
||||||
|
"1": "I",
|
||||||
|
"2": "II",
|
||||||
|
"3": "III",
|
||||||
|
"4": "IV",
|
||||||
|
"5": "V",
|
||||||
|
};
|
||||||
|
const legacyMap: Record<string, string> = {
|
||||||
|
SERIOUS: "IV",
|
||||||
|
NON_SERIOUS: "II",
|
||||||
|
};
|
||||||
|
if (digitMap[normalized]) return digitMap[normalized];
|
||||||
|
if (legacyMap[normalized]) return legacyMap[normalized];
|
||||||
|
if (["I", "II", "III", "IV", "V"].includes(normalized)) return normalized;
|
||||||
|
return "I";
|
||||||
|
};
|
||||||
|
|
||||||
const loadSites = async () => {
|
const loadSites = async () => {
|
||||||
if (!studyId) return;
|
if (!studyId) return;
|
||||||
@@ -487,7 +520,7 @@ const loadHistories = async () => {
|
|||||||
if (!studyId || !subjectId) return;
|
if (!studyId || !subjectId) return;
|
||||||
loadingHistory.value = true;
|
loadingHistory.value = true;
|
||||||
try {
|
try {
|
||||||
const { data } = await listSubjectHistories(studyId, subjectId);
|
const { data } = (await listSubjectHistories(studyId, subjectId)) as any;
|
||||||
historyItems.value = Array.isArray(data) ? data : data.items || [];
|
historyItems.value = Array.isArray(data) ? data : data.items || [];
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
ElMessage.error(e?.response?.data?.message || TEXT.common.messages.loadFailed);
|
ElMessage.error(e?.response?.data?.message || TEXT.common.messages.loadFailed);
|
||||||
@@ -551,8 +584,17 @@ const loadVisits = async () => {
|
|||||||
if (!studyId || !subjectId) return;
|
if (!studyId || !subjectId) return;
|
||||||
loadingVisits.value = true;
|
loadingVisits.value = true;
|
||||||
try {
|
try {
|
||||||
const { data } = await fetchVisits(studyId, subjectId);
|
const { data } = (await fetchVisits(studyId, subjectId)) as any;
|
||||||
visitItems.value = Array.isArray(data) ? data : data.items || [];
|
const items = Array.isArray(data) ? data : data.items || [];
|
||||||
|
visitItems.value = items.sort((a: any, b: any) => {
|
||||||
|
const getNum = (code: any) => {
|
||||||
|
const text = String(code || "");
|
||||||
|
if (!text.startsWith("V")) return Number.POSITIVE_INFINITY;
|
||||||
|
const num = Number(text.slice(1));
|
||||||
|
return Number.isFinite(num) ? num : Number.POSITIVE_INFINITY;
|
||||||
|
};
|
||||||
|
return getNum(a?.visit_code) - getNum(b?.visit_code);
|
||||||
|
});
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
ElMessage.error(e?.response?.data?.message || TEXT.common.messages.loadFailed);
|
ElMessage.error(e?.response?.data?.message || TEXT.common.messages.loadFailed);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -560,6 +602,21 @@ const loadVisits = async () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getNextVisitCode = () => {
|
||||||
|
const used = new Set<number>();
|
||||||
|
visitItems.value.forEach((item) => {
|
||||||
|
const code = String(item?.visit_code || "");
|
||||||
|
if (!code.startsWith("V")) return;
|
||||||
|
const num = Number(code.slice(1));
|
||||||
|
if (Number.isFinite(num) && num > 0) {
|
||||||
|
used.add(num);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
let next = 1;
|
||||||
|
while (used.has(next)) next += 1;
|
||||||
|
return `V${next}`;
|
||||||
|
};
|
||||||
|
|
||||||
const openVisitDialog = (row?: any) => {
|
const openVisitDialog = (row?: any) => {
|
||||||
if (isReadOnly.value) {
|
if (isReadOnly.value) {
|
||||||
ElMessage.warning("中心已停用");
|
ElMessage.warning("中心已停用");
|
||||||
@@ -570,7 +627,7 @@ const openVisitDialog = (row?: any) => {
|
|||||||
visitForm.actual_date = row.actual_date || "";
|
visitForm.actual_date = row.actual_date || "";
|
||||||
visitForm.notes = row.notes || "";
|
visitForm.notes = row.notes || "";
|
||||||
} else {
|
} else {
|
||||||
visitForm.visit_code = "";
|
visitForm.visit_code = getNextVisitCode();
|
||||||
visitForm.planned_date = "";
|
visitForm.planned_date = "";
|
||||||
visitForm.window_start = "";
|
visitForm.window_start = "";
|
||||||
visitForm.window_end = "";
|
visitForm.window_end = "";
|
||||||
@@ -657,6 +714,22 @@ const getVisitStatusTagType = (status: string) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getAeSeriousnessType = (seriousness: string) => {
|
||||||
|
switch (seriousness) {
|
||||||
|
case "I":
|
||||||
|
return "info";
|
||||||
|
case "II":
|
||||||
|
return "success";
|
||||||
|
case "III":
|
||||||
|
return "warning";
|
||||||
|
case "IV":
|
||||||
|
case "V":
|
||||||
|
return "danger";
|
||||||
|
default:
|
||||||
|
return "info";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const saveVisit = async () => {
|
const saveVisit = async () => {
|
||||||
if (isReadOnly.value) {
|
if (isReadOnly.value) {
|
||||||
ElMessage.warning("中心已停用");
|
ElMessage.warning("中心已停用");
|
||||||
@@ -671,6 +744,10 @@ const saveVisit = async () => {
|
|||||||
};
|
};
|
||||||
await updateVisit(studyId, subjectId, visitEditingId.value, payload);
|
await updateVisit(studyId, subjectId, visitEditingId.value, payload);
|
||||||
} else {
|
} else {
|
||||||
|
if (visitForm.visit_code === "V1" && !visitForm.planned_date) {
|
||||||
|
ElMessage.error("首次新增访视必须填写计划访视日期");
|
||||||
|
return;
|
||||||
|
}
|
||||||
const payload = {
|
const payload = {
|
||||||
subject_id: subjectId,
|
subject_id: subjectId,
|
||||||
visit_code: visitForm.visit_code,
|
visit_code: visitForm.visit_code,
|
||||||
@@ -707,7 +784,7 @@ const loadAes = async () => {
|
|||||||
if (!studyId || !subjectId) return;
|
if (!studyId || !subjectId) return;
|
||||||
loadingAes.value = true;
|
loadingAes.value = true;
|
||||||
try {
|
try {
|
||||||
const { data } = await fetchAes(studyId, { subject_id: subjectId });
|
const { data } = (await fetchAes(studyId, { subject_id: subjectId })) as any;
|
||||||
aeItems.value = Array.isArray(data) ? data : data.items || [];
|
aeItems.value = Array.isArray(data) ? data : data.items || [];
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
ElMessage.error(e?.response?.data?.message || TEXT.common.messages.loadFailed);
|
ElMessage.error(e?.response?.data?.message || TEXT.common.messages.loadFailed);
|
||||||
@@ -725,8 +802,7 @@ const openAeDialog = (row?: any) => {
|
|||||||
Object.assign(aeForm, {
|
Object.assign(aeForm, {
|
||||||
term: row?.term || "",
|
term: row?.term || "",
|
||||||
onset_date: row?.onset_date || "",
|
onset_date: row?.onset_date || "",
|
||||||
seriousness: row?.seriousness || "NON_SERIOUS",
|
seriousness: normalizeSeriousness(row?.seriousness),
|
||||||
severity: row?.severity || "MILD",
|
|
||||||
causality: row?.causality || "",
|
causality: row?.causality || "",
|
||||||
outcome: row?.outcome || "",
|
outcome: row?.outcome || "",
|
||||||
description: row?.description || "",
|
description: row?.description || "",
|
||||||
@@ -747,7 +823,6 @@ const saveAe = async () => {
|
|||||||
term: aeForm.term,
|
term: aeForm.term,
|
||||||
onset_date: aeForm.onset_date || null,
|
onset_date: aeForm.onset_date || null,
|
||||||
seriousness: aeForm.seriousness,
|
seriousness: aeForm.seriousness,
|
||||||
severity: aeForm.severity,
|
|
||||||
causality: aeForm.causality || null,
|
causality: aeForm.causality || null,
|
||||||
outcome: aeForm.outcome || null,
|
outcome: aeForm.outcome || null,
|
||||||
description: aeForm.description || null,
|
description: aeForm.description || null,
|
||||||
|
|||||||
@@ -10,11 +10,11 @@
|
|||||||
|
|
||||||
<el-card>
|
<el-card>
|
||||||
<el-form :model="form" label-width="120px">
|
<el-form :model="form" label-width="120px">
|
||||||
<el-form-item :label="TEXT.common.fields.subjectNo" required>
|
<el-form-item :label="TEXT.modules.subjectManagement.screeningNo" required>
|
||||||
<el-input
|
<el-input
|
||||||
v-model="form.subject_no"
|
v-model="form.subject_no"
|
||||||
:disabled="isEdit || isReadOnly"
|
:disabled="isEdit || isReadOnly"
|
||||||
:placeholder="TEXT.common.placeholders.input + TEXT.common.fields.subjectNo"
|
:placeholder="TEXT.common.placeholders.input + TEXT.modules.subjectManagement.screeningNo"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item :label="TEXT.common.fields.site" required>
|
<el-form-item :label="TEXT.common.fields.site" required>
|
||||||
|
|||||||
@@ -4,9 +4,6 @@
|
|||||||
<div class="workbench-header">
|
<div class="workbench-header">
|
||||||
<div class="header-content">
|
<div class="header-content">
|
||||||
<h1 class="welcome-title">{{ TEXT.modules.workbench.title }}</h1>
|
<h1 class="welcome-title">{{ TEXT.modules.workbench.title }}</h1>
|
||||||
<p class="welcome-subtitle">
|
|
||||||
{{ TEXT.modules.workbench.subtitle.replace("{role}", roleLabel) }}
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="header-actions">
|
<div class="header-actions">
|
||||||
<el-tag effect="dark" class="role-badge">{{ roleLabel }}</el-tag>
|
<el-tag effect="dark" class="role-badge">{{ roleLabel }}</el-tag>
|
||||||
@@ -24,6 +21,9 @@
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<template v-if="currentStudyId">
|
<template v-if="currentStudyId">
|
||||||
|
<!-- 汇总框 -->
|
||||||
|
<CenterSummary :data="centerSummaryData" :loading="loading" />
|
||||||
|
|
||||||
<!-- 核心看板层 -->
|
<!-- 核心看板层 -->
|
||||||
<div class="stats-row">
|
<div class="stats-row">
|
||||||
<div class="stats-col">
|
<div class="stats-col">
|
||||||
@@ -36,13 +36,41 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="stats-col">
|
<div class="stats-col">
|
||||||
<SectionCard
|
<div class="notifications-card">
|
||||||
:title="TEXT.modules.workbench.overdueTitle"
|
<div class="notifications-header">
|
||||||
:items="overdueList"
|
<div class="notifications-title-group">
|
||||||
:loading="loading"
|
<span class="notifications-title">{{ TEXT.modules.projectOverview.notificationsTitle }}</span>
|
||||||
:empty-text="TEXT.modules.workbench.overdueEmpty"
|
<span class="notifications-subtitle">{{ TEXT.modules.projectOverview.notificationsSubtitle }}</span>
|
||||||
@more="goMore(overdueMorePath)"
|
</div>
|
||||||
/>
|
<el-button v-if="notifications.length" type="primary" link @click="goMore('/documents')" class="notifications-more">
|
||||||
|
{{ TEXT.common.actions.more }} <el-icon class="el-icon--right"><ArrowRight /></el-icon>
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
<el-skeleton v-if="loading" :rows="3" animated />
|
||||||
|
<StateEmpty v-else-if="!notifications.length" :description="TEXT.modules.projectOverview.notificationsEmpty" />
|
||||||
|
<div v-else class="notification-list">
|
||||||
|
<div
|
||||||
|
class="notification-item"
|
||||||
|
v-for="item in notifications.slice(0, 5)"
|
||||||
|
:key="item.id"
|
||||||
|
@click="openDocument(item.document_id)"
|
||||||
|
>
|
||||||
|
<div class="notification-main">
|
||||||
|
<div class="notification-title">
|
||||||
|
<span class="notification-doc">{{ item.document_title }}</span>
|
||||||
|
<span class="notification-version">V{{ item.version_no }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="notification-meta">
|
||||||
|
<span class="notification-time">{{ formatDate(item.effective_at || item.created_at) }}</span>
|
||||||
|
<span v-if="item.change_summary" class="notification-summary">{{ item.change_summary }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="notification-update-badge">
|
||||||
|
<span class="update-text">更新</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -50,11 +78,11 @@
|
|||||||
<div class="secondary-row">
|
<div class="secondary-row">
|
||||||
<div class="action-col">
|
<div class="action-col">
|
||||||
<SectionCard
|
<SectionCard
|
||||||
:title="TEXT.modules.workbench.actionTitle"
|
:title="TEXT.modules.workbench.overdueTitle"
|
||||||
:items="actionList"
|
:items="overdueList"
|
||||||
:loading="loading"
|
:loading="loading"
|
||||||
:empty-text="TEXT.modules.workbench.actionEmpty"
|
:empty-text="TEXT.modules.workbench.overdueEmpty"
|
||||||
@more="goMore(actionMorePath)"
|
@more="goMore(overdueMorePath)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="quick-col">
|
<div class="quick-col">
|
||||||
@@ -83,10 +111,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 个人备忘层 -->
|
|
||||||
<div v-if="showPersonalTodo" class="todo-row">
|
|
||||||
<PersonalTodo :storage-key="todoStorageKey" />
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -98,10 +122,14 @@ import { ElMessage } from "element-plus";
|
|||||||
import { useAuthStore } from "../../store/auth";
|
import { useAuthStore } from "../../store/auth";
|
||||||
import { useStudyStore } from "../../store/study";
|
import { useStudyStore } from "../../store/study";
|
||||||
import { fetchAes } from "../../api/aes";
|
import { fetchAes } from "../../api/aes";
|
||||||
import { listFinanceContracts } from "../../api/financeContracts";
|
import { fetchLostVisits, fetchCenterSummary } from "../../api/dashboard";
|
||||||
import { Right, Timer, UserFilled, Warning, Money, Collection } from "@element-plus/icons-vue";
|
import { listNotifications } from "../../api/notifications";
|
||||||
|
import { Right, Timer, Warning, Money, Collection, RefreshRight, ArrowRight } from "@element-plus/icons-vue";
|
||||||
|
import StateEmpty from "../../components/StateEmpty.vue";
|
||||||
import { displayEnum } from "../../utils/display";
|
import { displayEnum } from "../../utils/display";
|
||||||
import { TEXT } from "../../locales";
|
import { TEXT } from "../../locales";
|
||||||
|
import type { NotificationItem } from "../../types/notifications";
|
||||||
|
import type { VisitLostItem } from "../../types/visits";
|
||||||
|
|
||||||
interface WorkItem {
|
interface WorkItem {
|
||||||
title: string;
|
title: string;
|
||||||
@@ -112,8 +140,7 @@ interface WorkItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const SectionCard = defineAsyncComponent(() => import("./components/SectionCard.vue"));
|
const SectionCard = defineAsyncComponent(() => import("./components/SectionCard.vue"));
|
||||||
const PersonalTodo = defineAsyncComponent(() => import("./components/PersonalTodo.vue"));
|
const CenterSummary = defineAsyncComponent(() => import("./components/CenterSummary.vue"));
|
||||||
|
|
||||||
const auth = useAuthStore();
|
const auth = useAuthStore();
|
||||||
const study = useStudyStore();
|
const study = useStudyStore();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@@ -121,15 +148,14 @@ const router = useRouter();
|
|||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const todayList = ref<WorkItem[]>([]);
|
const todayList = ref<WorkItem[]>([]);
|
||||||
const overdueList = ref<WorkItem[]>([]);
|
const overdueList = ref<WorkItem[]>([]);
|
||||||
const actionList = ref<WorkItem[]>([]);
|
const notifications = ref<NotificationItem[]>([]);
|
||||||
|
const lostVisits = ref<VisitLostItem[]>([]);
|
||||||
|
const centerSummaryData = ref<any[]>([]);
|
||||||
|
|
||||||
const currentStudyId = computed(() => study.currentStudy?.id || "");
|
const currentStudyId = computed(() => study.currentStudy?.id || "");
|
||||||
const todayStr = computed(() => new Date().toISOString().slice(0, 10));
|
const todayStr = computed(() => new Date().toISOString().slice(0, 10));
|
||||||
const roleLabel = computed(() => displayEnum(TEXT.enums.userRole, auth.user?.role));
|
const roleLabel = computed(() => displayEnum(TEXT.enums.userRole, auth.user?.role));
|
||||||
const emptyText = TEXT.modules.workbench.quickEmpty;
|
const emptyText = TEXT.modules.workbench.quickEmpty;
|
||||||
const showPersonalTodo = computed(() => role.value !== "ADMIN");
|
|
||||||
const todoStorageKey = computed(() => `workbench_todos_${auth.user?.id || "guest"}`);
|
|
||||||
|
|
||||||
const role = computed(() => auth.user?.role || "");
|
const role = computed(() => auth.user?.role || "");
|
||||||
const quickActions = computed(() => {
|
const quickActions = computed(() => {
|
||||||
if (!currentStudyId.value) return [];
|
if (!currentStudyId.value) return [];
|
||||||
@@ -150,10 +176,6 @@ const quickActions = computed(() => {
|
|||||||
|
|
||||||
const todayMorePath = computed(() => "/subjects");
|
const todayMorePath = computed(() => "/subjects");
|
||||||
const overdueMorePath = computed(() => "/subjects");
|
const overdueMorePath = computed(() => "/subjects");
|
||||||
const actionMorePath = computed(() => {
|
|
||||||
if (role.value === "PM" || role.value === "ADMIN") return "/finance/contracts";
|
|
||||||
return "/subjects";
|
|
||||||
});
|
|
||||||
|
|
||||||
const isOverdue = (d?: string | null) => {
|
const isOverdue = (d?: string | null) => {
|
||||||
if (!d) return false;
|
if (!d) return false;
|
||||||
@@ -162,18 +184,18 @@ const isOverdue = (d?: string | null) => {
|
|||||||
|
|
||||||
const toAeItem = (ae: any): WorkItem => ({
|
const toAeItem = (ae: any): WorkItem => ({
|
||||||
title: ae.term || TEXT.modules.workbench.aeTitleFallback,
|
title: ae.term || TEXT.modules.workbench.aeTitleFallback,
|
||||||
subtitle: study.currentStudy?.name || "",
|
subtitle: "",
|
||||||
status: ae.status,
|
status: ae.status,
|
||||||
overdue: isOverdue(ae.expected_resolution_date || ae.updated_at),
|
overdue: isOverdue(ae.expected_resolution_date || ae.updated_at),
|
||||||
path: ae.subject_id ? `/subjects/${ae.subject_id}` : "/subjects",
|
path: ae.subject_id ? `/subjects/${ae.subject_id}` : "/subjects",
|
||||||
});
|
});
|
||||||
|
|
||||||
const toContractItem = (fi: any): WorkItem => ({
|
const toLostVisitItem = (visit: VisitLostItem): WorkItem => ({
|
||||||
title: fi.contract_no || TEXT.modules.workbench.contractTitleFallback,
|
title: `${visit.subject_no} ${visit.visit_code}`,
|
||||||
subtitle: study.currentStudy?.name || "",
|
subtitle: "",
|
||||||
status: fi.site_name,
|
status: isNewLostVisit(visit.updated_at) ? TEXT.modules.workbench.newLostVisit : TEXT.enums.visitStatus.LOST,
|
||||||
overdue: false,
|
overdue: true,
|
||||||
path: `/finance/contracts/${fi.id}`,
|
path: `/subjects/${visit.subject_id}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
const loadData = async () => {
|
const loadData = async () => {
|
||||||
@@ -182,13 +204,21 @@ const loadData = async () => {
|
|||||||
try {
|
try {
|
||||||
const studyId = currentStudyId.value;
|
const studyId = currentStudyId.value;
|
||||||
const aesReq = fetchAes(studyId, { status: "NEW", limit: 50 });
|
const aesReq = fetchAes(studyId, { status: "NEW", limit: 50 });
|
||||||
|
const overdueReq = fetchAes(studyId, { overdue: true, limit: 50 });
|
||||||
const [aesRes, financeRes] = await Promise.allSettled([aesReq, listFinanceContracts(studyId, { limit: 50 })]);
|
const [aesRes, overdueRes, noticeRes, lostRes, centerRes] = await Promise.allSettled([
|
||||||
|
aesReq,
|
||||||
|
overdueReq,
|
||||||
|
listNotifications(studyId, { limit: 5 }),
|
||||||
|
fetchLostVisits(studyId, { limit: 20 }),
|
||||||
|
fetchCenterSummary(studyId),
|
||||||
|
]);
|
||||||
const aes = aesRes.status === "fulfilled" ? (aesRes.value.data.items || aesRes.value.data || []) : [];
|
const aes = aesRes.status === "fulfilled" ? (aesRes.value.data.items || aesRes.value.data || []) : [];
|
||||||
const finances =
|
const overdueAes = overdueRes.status === "fulfilled" ? (overdueRes.value.data.items || overdueRes.value.data || []) : [];
|
||||||
financeRes.status === "fulfilled" ? (financeRes.value.data.items || financeRes.value.data || []) : [];
|
notifications.value = noticeRes.status === "fulfilled" ? noticeRes.value.data || [] : [];
|
||||||
|
lostVisits.value = lostRes.status === "fulfilled" ? lostRes.value.data || [] : [];
|
||||||
|
centerSummaryData.value = centerRes.status === "fulfilled" ? centerRes.value.data || [] : [];
|
||||||
|
|
||||||
buildSections(aes, finances);
|
buildSections(aes, overdueAes, lostVisits.value);
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
ElMessage.error(e?.response?.data?.message || TEXT.modules.workbench.loadFailed);
|
ElMessage.error(e?.response?.data?.message || TEXT.modules.workbench.loadFailed);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -196,29 +226,23 @@ const loadData = async () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const buildSections = (aes: any[], finances: any[]) => {
|
const buildSections = (aes: any[], overdueAes: any[], lost: VisitLostItem[]) => {
|
||||||
todayList.value = [];
|
todayList.value = [];
|
||||||
overdueList.value = [];
|
overdueList.value = [];
|
||||||
actionList.value = [];
|
|
||||||
|
|
||||||
const openAes = aes.filter((a) => a.status !== "CLOSED");
|
const openAes = aes.filter((a) => a.status !== "CLOSED");
|
||||||
const financePending = finances;
|
const lostVisitItems = lost.map(toLostVisitItem);
|
||||||
const overdueAes = openAes.filter((a) => isOverdue(a.expected_resolution_date || a.updated_at));
|
|
||||||
|
|
||||||
if (role.value === "CRA") {
|
if (role.value === "CRA") {
|
||||||
todayList.value = openAes.slice(0, 5).map(toAeItem);
|
todayList.value = openAes.slice(0, 5).map(toAeItem);
|
||||||
overdueList.value = overdueAes.slice(0, 5).map(toAeItem);
|
overdueList.value = [...lostVisitItems, ...overdueAes.map(toAeItem)].slice(0, 5);
|
||||||
actionList.value = openAes.slice(0, 5).map(toAeItem);
|
|
||||||
} else if (role.value === "PM" || role.value === "ADMIN") {
|
} else if (role.value === "PM" || role.value === "ADMIN") {
|
||||||
todayList.value = openAes.slice(0, 5).map(toAeItem);
|
todayList.value = openAes.slice(0, 5).map(toAeItem);
|
||||||
overdueList.value = overdueAes.slice(0, 5).map(toAeItem);
|
overdueList.value = [...lostVisitItems, ...overdueAes.map(toAeItem)].slice(0, 5);
|
||||||
const financeTodo = financePending.slice(0, 3).map(toContractItem);
|
|
||||||
actionList.value = [...financeTodo, ...openAes.slice(0, 2).map(toAeItem)].slice(0, 5);
|
|
||||||
} else if (role.value === "PV") {
|
} else if (role.value === "PV") {
|
||||||
const aeOpen = aes.filter((a) => a.status !== "CLOSED");
|
const aeOpen = aes.filter((a) => a.status !== "CLOSED");
|
||||||
todayList.value = aeOpen.slice(0, 5).map(toAeItem);
|
todayList.value = aeOpen.slice(0, 5).map(toAeItem);
|
||||||
overdueList.value = aeOpen.filter((a) => isOverdue(a.updated_at)).slice(0, 5).map(toAeItem);
|
overdueList.value = [...lostVisitItems, ...overdueAes.map(toAeItem)].slice(0, 5);
|
||||||
actionList.value = aeOpen.slice(0, 5).map(toAeItem);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -227,6 +251,23 @@ const goMore = (path: string) => {
|
|||||||
router.push(path);
|
router.push(path);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const formatDate = (value?: string | null) => {
|
||||||
|
if (!value) return TEXT.common.fallback;
|
||||||
|
return value.replace("T", " ").replace("Z", "").split(".")[0];
|
||||||
|
};
|
||||||
|
|
||||||
|
const isNewLostVisit = (value?: string | null) => {
|
||||||
|
if (!value) return false;
|
||||||
|
const updatedAt = new Date(value);
|
||||||
|
if (Number.isNaN(updatedAt.getTime())) return false;
|
||||||
|
const now = new Date();
|
||||||
|
return now.getTime() - updatedAt.getTime() <= 24 * 60 * 60 * 1000;
|
||||||
|
};
|
||||||
|
|
||||||
|
const openDocument = (documentId: string) => {
|
||||||
|
router.push(`/documents/${documentId}`);
|
||||||
|
};
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
if (!auth.user && auth.token) {
|
if (!auth.user && auth.token) {
|
||||||
await auth.fetchMe().catch(() => {});
|
await auth.fetchMe().catch(() => {});
|
||||||
@@ -239,141 +280,458 @@ onMounted(async () => {
|
|||||||
.workbench-container {
|
.workbench-container {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 24px;
|
gap: 28px;
|
||||||
|
animation: fadeIn 0.5s ease-out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@keyframes fadeIn {
|
||||||
|
from {
|
||||||
|
opacity: 0;
|
||||||
|
transform: translateY(10px);
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
opacity: 1;
|
||||||
|
transform: translateY(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 头部区域 - 添加渐变背景 */
|
||||||
.workbench-header {
|
.workbench-header {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: flex-end;
|
align-items: flex-end;
|
||||||
|
padding: 32px;
|
||||||
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||||
|
border-radius: 16px;
|
||||||
|
margin: -8px -8px 0 -8px;
|
||||||
|
box-shadow: 0 8px 32px rgba(102, 126, 234, 0.2);
|
||||||
|
position: relative;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.workbench-header::before {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
|
||||||
|
opacity: 0.4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-content {
|
||||||
|
position: relative;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-actions {
|
||||||
|
position: relative;
|
||||||
|
z-index: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.welcome-title {
|
.welcome-title {
|
||||||
font-size: 28px;
|
font-size: 32px;
|
||||||
font-weight: 700;
|
font-weight: 800;
|
||||||
color: var(--ctms-text-main);
|
color: #ffffff;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
text-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||||
|
letter-spacing: -0.5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.welcome-subtitle {
|
.welcome-subtitle {
|
||||||
margin: 8px 0 0;
|
margin: 10px 0 0;
|
||||||
font-size: 15px;
|
font-size: 16px;
|
||||||
color: var(--ctms-text-secondary);
|
color: rgba(255, 255, 255, 0.9);
|
||||||
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
.role-badge {
|
.role-badge {
|
||||||
background-color: var(--ctms-primary);
|
background: rgba(255, 255, 255, 0.25);
|
||||||
border: none;
|
backdrop-filter: blur(10px);
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.3);
|
||||||
|
color: #ffffff;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
padding: 0 12px;
|
padding: 0 16px;
|
||||||
height: 28px;
|
height: 32px;
|
||||||
line-height: 28px;
|
line-height: 32px;
|
||||||
|
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
.stats-row, .secondary-row {
|
.stats-row, .secondary-row {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(2, 1fr);
|
grid-template-columns: repeat(2, 1fr);
|
||||||
gap: 24px;
|
gap: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.todo-row {
|
|
||||||
margin-top: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.study-alert {
|
.study-alert {
|
||||||
border: none;
|
border: none;
|
||||||
border-left: 4px solid var(--ctms-warning);
|
border-left: 4px solid var(--ctms-warning);
|
||||||
background-color: #fffbe6;
|
background: linear-gradient(90deg, #fffbe6 0%, #ffffff 100%);
|
||||||
|
box-shadow: var(--ctms-shadow-sm);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 快捷入口卡片样式 */
|
/* 快捷入口卡片样式 - 大幅优化 */
|
||||||
.quick-entry-card {
|
.quick-entry-card {
|
||||||
background-color: #fff;
|
background: linear-gradient(135deg, #ffffff 0%, #f8f9ff 100%);
|
||||||
border: 1px solid var(--ctms-border-color);
|
border: 1px solid rgba(102, 126, 234, 0.1);
|
||||||
border-radius: 8px;
|
border-radius: 16px;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.quick-entry-card:hover {
|
||||||
|
box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
|
||||||
|
transform: translateY(-2px);
|
||||||
}
|
}
|
||||||
|
|
||||||
.entry-header {
|
.entry-header {
|
||||||
padding: 16px 20px;
|
padding: 20px 24px;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
border-bottom: 1px solid var(--ctms-border-color);
|
border-bottom: 1px solid rgba(102, 126, 234, 0.08);
|
||||||
background-color: #fafafa;
|
background: linear-gradient(135deg, rgba(102, 126, 234, 0.03) 0%, rgba(118, 75, 162, 0.02) 100%);
|
||||||
}
|
}
|
||||||
|
|
||||||
.entry-title {
|
.entry-title {
|
||||||
font-size: 16px;
|
font-size: 17px;
|
||||||
font-weight: 600;
|
font-weight: 700;
|
||||||
color: var(--ctms-text-main);
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||||
|
-webkit-background-clip: text;
|
||||||
|
-webkit-text-fill-color: transparent;
|
||||||
|
background-clip: text;
|
||||||
}
|
}
|
||||||
|
|
||||||
.entry-more {
|
.entry-more {
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
.quick-grid {
|
.quick-grid {
|
||||||
padding: 20px;
|
padding: 24px;
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
|
grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
|
||||||
gap: 16px;
|
gap: 20px;
|
||||||
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.quick-item {
|
.quick-item {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 10px;
|
gap: 12px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: all 0.3s ease;
|
transition: all 0.4s cubic-bezier(0.22, 1, 0.36, 1);
|
||||||
padding: 12px;
|
padding: 16px 12px;
|
||||||
border-radius: 8px;
|
border-radius: 12px;
|
||||||
|
background: #ffffff;
|
||||||
|
border: 1px solid transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
.quick-item:hover {
|
.quick-item:hover {
|
||||||
background-color: var(--ctms-primary-light);
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||||
transform: translateY(-2px);
|
transform: translateY(-4px) scale(1.02);
|
||||||
|
box-shadow: 0 12px 28px rgba(102, 126, 234, 0.3);
|
||||||
|
border-color: rgba(255, 255, 255, 0.2);
|
||||||
}
|
}
|
||||||
|
|
||||||
.quick-icon-box {
|
.quick-icon-box {
|
||||||
width: 40px;
|
width: 56px;
|
||||||
height: 40px;
|
height: 56px;
|
||||||
background-color: #fff;
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||||
border: 1px solid var(--ctms-border-color);
|
border: none;
|
||||||
border-radius: 10px;
|
border-radius: 16px;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
font-size: 20px;
|
font-size: 26px;
|
||||||
color: var(--ctms-primary);
|
color: #ffffff;
|
||||||
box-shadow: var(--ctms-shadow-sm);
|
box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
|
||||||
transition: all 0.3s ease;
|
transition: all 0.4s cubic-bezier(0.22, 1, 0.36, 1);
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.quick-icon-box::before {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
border-radius: 16px;
|
||||||
|
padding: 2px;
|
||||||
|
background: linear-gradient(135deg, rgba(255, 255, 255, 0.4), rgba(255, 255, 255, 0.1));
|
||||||
|
-webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
|
||||||
|
-webkit-mask-composite: xor;
|
||||||
|
mask-composite: exclude;
|
||||||
}
|
}
|
||||||
|
|
||||||
.quick-item:hover .quick-icon-box {
|
.quick-item:hover .quick-icon-box {
|
||||||
border-color: var(--ctms-primary);
|
background: #ffffff;
|
||||||
background-color: var(--ctms-primary);
|
color: #667eea;
|
||||||
color: #fff;
|
transform: scale(1.1) rotate(5deg);
|
||||||
|
box-shadow: 0 12px 32px rgba(255, 255, 255, 0.4);
|
||||||
}
|
}
|
||||||
|
|
||||||
.quick-label {
|
.quick-label {
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
font-weight: 500;
|
font-weight: 600;
|
||||||
color: var(--ctms-text-regular);
|
color: var(--ctms-text-regular);
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.quick-item:hover .quick-label {
|
||||||
|
color: #ffffff;
|
||||||
|
transform: scale(1.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 通知卡片 - 增强样式 */
|
||||||
|
.notifications-card {
|
||||||
|
background: linear-gradient(135deg, #ffffff 0%, #fef7ff 100%);
|
||||||
|
border: 1px solid rgba(118, 75, 162, 0.1);
|
||||||
|
border-radius: 16px;
|
||||||
|
padding: 20px 24px;
|
||||||
|
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notifications-card:hover {
|
||||||
|
box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
|
||||||
|
transform: translateY(-2px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.notifications-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
padding-bottom: 12px;
|
||||||
|
border-bottom: 2px solid rgba(118, 75, 162, 0.08);
|
||||||
|
}
|
||||||
|
|
||||||
|
.notifications-title-group {
|
||||||
|
display: flex;
|
||||||
|
align-items: baseline;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notifications-more {
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 600;
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notifications-more:hover {
|
||||||
|
transform: translateX(4px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.notifications-title {
|
||||||
|
font-size: 17px;
|
||||||
|
font-weight: 700;
|
||||||
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||||
|
-webkit-background-clip: text;
|
||||||
|
-webkit-text-fill-color: transparent;
|
||||||
|
background-clip: text;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notifications-subtitle {
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--ctms-text-secondary);
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notification-list {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notification-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 14px 16px;
|
||||||
|
border-radius: 12px;
|
||||||
|
background: #ffffff;
|
||||||
|
border: 1px solid rgba(102, 126, 234, 0.08);
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notification-item:hover {
|
||||||
|
background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
|
||||||
|
border-color: rgba(102, 126, 234, 0.2);
|
||||||
|
transform: translateX(4px);
|
||||||
|
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.notification-main {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notification-title {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--ctms-text-main);
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notification-version {
|
||||||
|
font-size: 11px;
|
||||||
|
padding: 3px 8px;
|
||||||
|
border-radius: 12px;
|
||||||
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||||
|
color: #ffffff;
|
||||||
|
font-weight: 700;
|
||||||
|
box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.notification-meta {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--ctms-text-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.notification-summary {
|
||||||
|
max-width: 360px;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 锯齿状更新徽章 - 扁平版 */
|
||||||
|
.notification-update-badge {
|
||||||
|
position: relative;
|
||||||
|
width: 56px;
|
||||||
|
height: 28px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
flex-shrink: 0;
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notification-update-badge::before {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
background: linear-gradient(135deg, #ff4757 0%, #ff6b81 100%);
|
||||||
|
clip-path: polygon(
|
||||||
|
10% 0%,
|
||||||
|
20% 8%,
|
||||||
|
30% 0%,
|
||||||
|
40% 8%,
|
||||||
|
50% 0%,
|
||||||
|
60% 8%,
|
||||||
|
70% 0%,
|
||||||
|
80% 8%,
|
||||||
|
90% 0%,
|
||||||
|
100% 15%,
|
||||||
|
95% 50%,
|
||||||
|
100% 85%,
|
||||||
|
90% 100%,
|
||||||
|
80% 92%,
|
||||||
|
70% 100%,
|
||||||
|
60% 92%,
|
||||||
|
50% 100%,
|
||||||
|
40% 92%,
|
||||||
|
30% 100%,
|
||||||
|
20% 92%,
|
||||||
|
10% 100%,
|
||||||
|
0% 85%,
|
||||||
|
5% 50%,
|
||||||
|
0% 15%
|
||||||
|
);
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 透明内层 - 镂空效果 */
|
||||||
|
.notification-update-badge::after {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
top: 2px;
|
||||||
|
left: 2px;
|
||||||
|
width: calc(100% - 4px);
|
||||||
|
height: calc(100% - 4px);
|
||||||
|
background: #ffffff;
|
||||||
|
clip-path: polygon(
|
||||||
|
10% 0%,
|
||||||
|
20% 10%,
|
||||||
|
30% 0%,
|
||||||
|
40% 10%,
|
||||||
|
50% 0%,
|
||||||
|
60% 10%,
|
||||||
|
70% 0%,
|
||||||
|
80% 10%,
|
||||||
|
90% 0%,
|
||||||
|
100% 18%,
|
||||||
|
94% 50%,
|
||||||
|
100% 82%,
|
||||||
|
90% 100%,
|
||||||
|
80% 90%,
|
||||||
|
70% 100%,
|
||||||
|
60% 90%,
|
||||||
|
50% 100%,
|
||||||
|
40% 90%,
|
||||||
|
30% 100%,
|
||||||
|
20% 90%,
|
||||||
|
10% 100%,
|
||||||
|
0% 82%,
|
||||||
|
6% 50%,
|
||||||
|
0% 18%
|
||||||
|
);
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.update-text {
|
||||||
|
position: relative;
|
||||||
|
z-index: 2;
|
||||||
|
font-size: 11px;
|
||||||
|
font-weight: 800;
|
||||||
|
color: #1a1a2e;
|
||||||
|
letter-spacing: 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notification-item:hover .notification-update-badge {
|
||||||
|
transform: scale(1.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.notification-item:hover .notification-update-badge::before {
|
||||||
|
box-shadow: 0 4px 16px rgba(255, 71, 87, 0.4);
|
||||||
}
|
}
|
||||||
|
|
||||||
.empty-quick {
|
.empty-quick {
|
||||||
padding: 40px;
|
padding: 48px 24px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
color: var(--ctms-text-disabled);
|
color: var(--ctms-text-disabled);
|
||||||
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 992px) {
|
@media (max-width: 992px) {
|
||||||
.stats-row, .secondary-row {
|
.stats-row, .secondary-row {
|
||||||
grid-template-columns: 1fr;
|
grid-template-columns: 1fr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.workbench-header {
|
||||||
|
padding: 24px;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.welcome-title {
|
||||||
|
font-size: 26px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -0,0 +1,100 @@
|
|||||||
|
<template>
|
||||||
|
<div class="center-summary-box">
|
||||||
|
<div class="box-header">
|
||||||
|
<span class="box-title">各中心进展汇总</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="summary-table-container">
|
||||||
|
<el-table
|
||||||
|
:data="data"
|
||||||
|
style="width: 100%"
|
||||||
|
v-loading="loading"
|
||||||
|
empty-text="暂无数据"
|
||||||
|
class="custom-table"
|
||||||
|
>
|
||||||
|
<el-table-column prop="name" label="管理中心" min-width="180">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<span class="center-name">{{ row.name }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
|
||||||
|
<el-table-column prop="stage" label="进展阶段" width="120">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<el-tag :type="getStageType(row.stage_status)" effect="light" size="small" round>
|
||||||
|
{{ row.stage }}
|
||||||
|
</el-tag>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
|
||||||
|
<el-table-column label="实际入组例数/计划例数" width="200" align="right">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<div class="enrollment-ratio">
|
||||||
|
<span class="actual">{{ row.actual_enrolled }}</span>
|
||||||
|
<span class="separator">/</span>
|
||||||
|
<span class="planned">{{ row.planned_enrolled }}</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
|
||||||
|
|
||||||
|
defineProps<{
|
||||||
|
data: any[];
|
||||||
|
loading: boolean;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const getStageType = (status?: string) => {
|
||||||
|
if (status === "COMPLETED") return "success";
|
||||||
|
if (status === "IN_PROGRESS") return "warning";
|
||||||
|
if (status === "BLOCKED") return "danger";
|
||||||
|
return "info";
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.center-summary-box {
|
||||||
|
background: #ffffff;
|
||||||
|
border-radius: 16px;
|
||||||
|
padding: 24px;
|
||||||
|
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
|
||||||
|
margin-bottom: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.box-header {
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.box-title {
|
||||||
|
font-size: 18px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: var(--ctms-text-main, #1a1a2e);
|
||||||
|
}
|
||||||
|
|
||||||
|
.center-name {
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--ctms-text-main, #1a1a2e);
|
||||||
|
}
|
||||||
|
|
||||||
|
.enrollment-ratio {
|
||||||
|
font-family: 'Roboto Mono', monospace;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.actual {
|
||||||
|
color: var(--ctms-primary, #667eea);
|
||||||
|
}
|
||||||
|
|
||||||
|
.separator {
|
||||||
|
margin: 0 4px;
|
||||||
|
color: #ccc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.planned {
|
||||||
|
color: var(--ctms-text-secondary, #808080);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -2,7 +2,12 @@
|
|||||||
<el-card shadow="never" class="section-card">
|
<el-card shadow="never" class="section-card">
|
||||||
<template #header>
|
<template #header>
|
||||||
<div class="section-header">
|
<div class="section-header">
|
||||||
<span class="section-title">{{ title }}</span>
|
<div class="section-title-wrapper">
|
||||||
|
<div class="section-icon">
|
||||||
|
<el-icon><component :is="getIcon()" /></el-icon>
|
||||||
|
</div>
|
||||||
|
<span class="section-title">{{ title }}</span>
|
||||||
|
</div>
|
||||||
<el-button v-if="!loading" type="primary" link @click="$emit('more')" class="more-btn">
|
<el-button v-if="!loading" type="primary" link @click="$emit('more')" class="more-btn">
|
||||||
{{ TEXT.common.actions.more }} <el-icon class="el-icon--right"><ArrowRight /></el-icon>
|
{{ TEXT.common.actions.more }} <el-icon class="el-icon--right"><ArrowRight /></el-icon>
|
||||||
</el-button>
|
</el-button>
|
||||||
@@ -43,12 +48,12 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useRouter } from "vue-router";
|
import { useRouter } from "vue-router";
|
||||||
import { ArrowRight } from "@element-plus/icons-vue";
|
import { ArrowRight, Calendar, Warning, Document } from "@element-plus/icons-vue";
|
||||||
import StateEmpty from "../../../components/StateEmpty.vue";
|
import StateEmpty from "../../../components/StateEmpty.vue";
|
||||||
import StateLoading from "../../../components/StateLoading.vue";
|
import StateLoading from "../../../components/StateLoading.vue";
|
||||||
import { TEXT } from "../../../locales";
|
import { TEXT } from "../../../locales";
|
||||||
|
|
||||||
defineProps<{
|
const props = defineProps<{
|
||||||
title: string;
|
title: string;
|
||||||
items: any[];
|
items: any[];
|
||||||
loading?: boolean;
|
loading?: boolean;
|
||||||
@@ -62,32 +67,89 @@ const go = (path: string) => {
|
|||||||
if (!path) return;
|
if (!path) return;
|
||||||
router.push(path);
|
router.push(path);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getIcon = () => {
|
||||||
|
// 根据标题返回不同的图标
|
||||||
|
if (props.title.includes("今日") || props.title.includes("待办")) return Calendar;
|
||||||
|
if (props.title.includes("逾期")) return Warning;
|
||||||
|
return Document;
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.section-card {
|
.section-card {
|
||||||
border: 1px solid var(--ctms-border-color);
|
border: 1px solid rgba(102, 126, 234, 0.12);
|
||||||
border-radius: 8px;
|
border-radius: 16px;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
background: linear-gradient(135deg, #ffffff 0%, #fafcff 100%);
|
||||||
|
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
|
||||||
|
overflow: hidden;
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-card:hover {
|
||||||
|
box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
|
||||||
|
transform: translateY(-2px);
|
||||||
|
border-color: rgba(102, 126, 234, 0.2);
|
||||||
}
|
}
|
||||||
|
|
||||||
:deep(.el-card__header) {
|
:deep(.el-card__header) {
|
||||||
padding: 16px 20px;
|
padding: 20px 24px;
|
||||||
border-bottom: 1px solid var(--ctms-border-color);
|
border-bottom: 1px solid rgba(102, 126, 234, 0.08);
|
||||||
background-color: #fafafa;
|
background: linear-gradient(135deg, rgba(102, 126, 234, 0.03) 0%, rgba(118, 75, 162, 0.02) 100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-header {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-title-wrapper {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-icon {
|
||||||
|
width: 36px;
|
||||||
|
height: 36px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||||
|
border-radius: 10px;
|
||||||
|
font-size: 18px;
|
||||||
|
color: #ffffff;
|
||||||
|
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.25);
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-card:hover .section-icon {
|
||||||
|
transform: rotate(-5deg) scale(1.05);
|
||||||
|
box-shadow: 0 6px 16px rgba(102, 126, 234, 0.35);
|
||||||
}
|
}
|
||||||
|
|
||||||
.section-title {
|
.section-title {
|
||||||
font-size: 16px;
|
font-size: 17px;
|
||||||
font-weight: 600;
|
font-weight: 700;
|
||||||
color: var(--ctms-text-main);
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||||
|
-webkit-background-clip: text;
|
||||||
|
-webkit-text-fill-color: transparent;
|
||||||
|
background-clip: text;
|
||||||
}
|
}
|
||||||
|
|
||||||
.more-btn {
|
.more-btn {
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
color: var(--ctms-primary);
|
color: var(--ctms-primary);
|
||||||
|
font-weight: 600;
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.more-btn:hover {
|
||||||
|
transform: translateX(4px);
|
||||||
}
|
}
|
||||||
|
|
||||||
.section-body {
|
.section-body {
|
||||||
@@ -101,13 +163,25 @@ const go = (path: string) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.list-item {
|
.list-item {
|
||||||
padding: 16px 20px;
|
padding: 16px 24px;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: all 0.2s ease;
|
transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
|
||||||
border-bottom: 1px solid var(--ctms-border-color);
|
border-bottom: 1px solid rgba(102, 126, 234, 0.06);
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.list-item::before {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
width: 0;
|
||||||
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||||
|
transition: width 0.3s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
.list-item:last-child {
|
.list-item:last-child {
|
||||||
@@ -115,23 +189,35 @@ const go = (path: string) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.list-item:hover {
|
.list-item:hover {
|
||||||
background-color: var(--ctms-primary-light);
|
background: linear-gradient(135deg, rgba(102, 126, 234, 0.04) 0%, rgba(118, 75, 162, 0.04) 100%);
|
||||||
|
transform: translateX(6px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.list-item:hover::before {
|
||||||
|
width: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.item-main {
|
.item-main {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
margin-right: 16px;
|
margin-right: 16px;
|
||||||
|
position: relative;
|
||||||
|
z-index: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.item-title {
|
.item-title {
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
font-weight: 500;
|
font-weight: 600;
|
||||||
color: var(--ctms-text-main);
|
color: var(--ctms-text-main);
|
||||||
margin-bottom: 4px;
|
margin-bottom: 6px;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
|
transition: color 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.list-item:hover .item-title {
|
||||||
|
color: #667eea;
|
||||||
}
|
}
|
||||||
|
|
||||||
.item-subtitle {
|
.item-subtitle {
|
||||||
@@ -140,13 +226,41 @@ const go = (path: string) => {
|
|||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.item-meta {
|
||||||
|
position: relative;
|
||||||
|
z-index: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.status-tag {
|
.status-tag {
|
||||||
border-radius: 4px;
|
border-radius: 12px;
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 12px;
|
||||||
|
padding: 4px 10px;
|
||||||
|
border: 1px solid transparent;
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-tag.el-tag--danger {
|
||||||
|
background: linear-gradient(135deg, rgba(194, 75, 75, 0.12) 0%, rgba(194, 75, 75, 0.08) 100%);
|
||||||
|
color: var(--ctms-danger);
|
||||||
|
border-color: rgba(194, 75, 75, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-tag.el-tag--info {
|
||||||
|
background: linear-gradient(135deg, rgba(100, 116, 139, 0.12) 0%, rgba(100, 116, 139, 0.08) 100%);
|
||||||
|
color: var(--ctms-info);
|
||||||
|
border-color: rgba(100, 116, 139, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.list-item:hover .status-tag {
|
||||||
|
transform: scale(1.05);
|
||||||
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
.empty-state {
|
.empty-state {
|
||||||
padding: 8px 0;
|
padding: 16px 0;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user