from django.shortcuts import render

from .services import list_scenario_issues, list_scenarios


def index(request):
    # 首页只消费服务层给出的场景摘要和错误摘要，
    # 不自行读取 YAML，更不在 View 里做字段拼装。
    return render(
        request,
        "scenarios/index.html",
        {
            "scenarios": list_scenarios(),
            "scenario_issues": list_scenario_issues(),
            "hero_metrics": [
                {"label": "资料齐套率", "value": "82%", "note": "已识别 42 / 51 个法规模板项"},
                {"label": "法规命中率", "value": "89%", "note": "公告附件包 6 类规则已加载"},
                {"label": "字段抽取完成度", "value": "67%", "note": "48 个核心字段进入统一字段池"},
                {"label": "高风险问题", "value": "03", "note": "含 1 个缺失项与 1 个命名冲突"},
            ],
            "workflow_overview": [
                {"title": "资料进入系统", "detail": "导入本批次注册申报资料、法规原文与模板文件。"},
                {"title": "知识底座装载", "detail": "以章-条-要求项-模板字段组织法规规则。"},
                {"title": "解析与切片", "detail": "完成页数统计、表格抽取、章节点归类和向量入库。"},
                {"title": "Agent 审核执行", "detail": "发起完整性检查、字段抽取和一致性比对。"},
                {"title": "结论输出与留痕", "detail": "形成风险清单、证据引用、责任人动作和审计日志。"},
            ],
            "risk_board": [
                {"level": "高风险", "title": "CH1.11.5 沟通记录缺失", "detail": "监管沟通事项未形成可追溯文件，无法支撑本轮章节齐套性。"},
                {"level": "高风险", "title": "产品名称在申请表与说明书中不一致", "detail": "Agent 判定为跨文档命名冲突，需进入人工复核。"},
                {"level": "中风险", "title": "2 份 Word 文档页数可信度不足", "detail": "版式页数使用估算值，建议复核目录页码与正文总页数。"},
            ],
        },
    )
