"""交叉评查 VO。"""

from __future__ import annotations

from datetime import datetime

from pydantic import BaseModel, Field


class CrossReviewTaskItemVO(BaseModel):
    """任务列表项。"""

    taskId: int = Field(..., description="任务ID")
    taskName: str = Field(..., description="任务名称")
    taskType: str = Field(..., description="任务类型")
    docTypeId: int | None = Field(None, description="文档类型ID")
    docTypeCode: str | None = Field(None, description="文档类型编码")
    status: str = Field(..., description="任务状态")
    progress: float = Field(0, description="进度百分比")
    totalDocuments: int = Field(0, description="文档总数")
    completedDocuments: int = Field(0, description="已完成文档数")
    createdAt: datetime | None = Field(None, description="创建时间")


class CrossReviewTaskPageVO(BaseModel):
    """任务分页响应。"""

    total: int = Field(0, description="总数")
    page: int = Field(1, description="页码")
    pageSize: int = Field(20, description="每页大小")
    items: list[CrossReviewTaskItemVO] = Field(default_factory=list, description="任务列表")


class CrossReviewTaskProgressVO(BaseModel):
    """任务进度。"""

    taskId: int = Field(..., description="任务ID")
    totalDocuments: int = Field(0, description="文档总数")
    completedDocuments: int = Field(0, description="已完成文档数")
    progress: float = Field(0, description="进度百分比")


class CrossReviewTaskDocumentVO(BaseModel):
    """任务文档列表项。"""

    documentId: int = Field(..., description="文档ID")
    name: str = Field("", description="文档名称")
    documentNumber: str | None = Field(None, description="文号")
    typeId: int | None = Field(None, description="文档类型ID")
    typeName: str | None = Field(None, description="文档类型名称")
    processingStatus: str | None = Field(None, description="处理状态")
    versionNo: int = Field(1, description="版本号")
    isLatestVersion: bool = Field(True, description="是否最新版本")
    auditStatus: int = Field(0, description="任务内完成状态")
    createdAt: datetime | None = Field(None, description="创建时间")
    fileSize: int = Field(0, description="文件大小（字节）")


class CrossReviewTaskDocumentPageVO(BaseModel):
    """任务文档分页响应。"""

    taskId: int = Field(..., description="任务ID")
    total: int = Field(0, description="总数")
    page: int = Field(1, description="页码")
    pageSize: int = Field(20, description="每页大小")
    items: list[CrossReviewTaskDocumentVO] = Field(default_factory=list, description="文档列表")


class CrossReviewPermissionVO(BaseModel):
    """是否有权确认完成。"""

    canConfirm: bool = Field(False, description="是否可以确认完成")
    reason: str = Field("", description="原因")


class CrossReviewTaskCreateVO(BaseModel):
    """创建任务结果。"""

    taskId: int = Field(..., description="任务ID")
    taskName: str = Field(..., description="任务名称")
    memberCount: int = Field(0, description="成员数")
    documentCount: int = Field(0, description="挂载文档数")


class CrossReviewTaskCompleteVO(BaseModel):
    """确认任务文档完成结果。"""

    taskId: int = Field(..., description="任务ID")
    documentId: int = Field(..., description="文档ID")
    auditStatus: int = Field(..., description="任务内完成状态")
    taskStatus: str = Field(..., description="任务状态")
    taskCompleted: bool = Field(False, description="任务是否已全部完成")


class CrossReviewProposalCreateVO(BaseModel):
    """创建提案结果。"""

    proposalId: int = Field(..., description="提案ID")
    createdAt: datetime | None = Field(None, description="创建时间")


class CrossReviewProposalVoteVO(BaseModel):
    """提案投票结果。"""

    proposalId: int = Field(..., description="提案ID")
    voterId: int = Field(..., description="投票人ID")
    voteType: str = Field(..., description="投票类型")
    proposalStatus: str = Field(..., description="提案状态")


class CrossReviewProposalCancelVO(BaseModel):
    """撤销提案结果。"""

    proposalId: int = Field(..., description="提案ID")
    status: str = Field(..., description="提案状态")


class CrossReviewProposalVoteItemVO(BaseModel):
    """提案已投票明细。"""

    voter: str = Field("", description="投票人姓名")
    voteType: str = Field(..., description="投票类型")


class CrossReviewProposalItemVO(BaseModel):
    """提案列表项。"""

    proposalId: int = Field(..., description="提案ID")
    evaluationPointName: str = Field("", description="评查点名称")
    proposedScore: float = Field(..., description="调整分值")
    reason: str = Field("", description="提案理由")
    proposer: str = Field("", description="提案人姓名")
    votes: list[CrossReviewProposalVoteItemVO] = Field(default_factory=list, description="已投票明细")
    agreeVoters: list[str] = Field(default_factory=list, description="同意人")
    disagreeVoters: list[str] = Field(default_factory=list, description="反对人")
    pendingVoters: list[str] = Field(default_factory=list, description="待投票人")
    canVote: bool = Field(False, description="当前用户是否可投票")
    problemMessage: str = Field("", description="问题描述")
    proposerId: int = Field(..., description="提案人ID")
    createdAt: datetime | None = Field(None, description="创建时间")
    status: str = Field("pending", description="提案状态")


class CrossReviewProposalPageVO(BaseModel):
    """提案分页结果。"""

    total: int = Field(0, description="总数")
    page: int = Field(1, description="页码")
    pageSize: int = Field(20, description="每页数量")
    items: list[CrossReviewProposalItemVO] = Field(default_factory=list, description="提案列表")


class CrossReviewPendingProposalVO(BaseModel):
    """待投票提案摘要。"""

    evaluationPointName: str = Field("", description="评查点名称")
    pendingVotersNum: int = Field(0, description="待投票人数")


class CrossReviewPendingVotesVO(BaseModel):
    """文档待投票检查结果。"""

    hasPendingVotes: bool = Field(False, description="是否存在待投票")
    pendingProposals: list[CrossReviewPendingProposalVO] = Field(default_factory=list, description="待投票提案摘要")


class CrossReviewTaskDocumentUploadVO(BaseModel):
    """交叉评查任务补传文档结果。"""

    taskId: int = Field(..., description="任务ID")
    documentId: int = Field(..., description="文档ID")
    auditStatus: int = Field(0, description="任务内评查状态")
    processingStatus: str | None = Field(None, description="文档处理状态")
