diff --git a/apps/chat/views.py b/apps/chat/views.py
index 63ce642..50a10a0 100644
--- a/apps/chat/views.py
+++ b/apps/chat/views.py
@@ -161,12 +161,19 @@ def _build_workspace_summary(conversation: Conversation, batch: SubmissionBatch
notify_status = node_status_map.get("飞书通知", "待处理")
export_status = node_status_map.get("Word 回填导出", "待处理")
highest_risk_level = "高" if risk_status in {"已阻断", "待复核"} else "中"
- export_allowed = "否" if risk_status in {"已阻断", "待复核"} else "是"
+ export_allowed = (
+ "否"
+ if risk_status in {"已阻断", "待复核"} or export_status in {"已阻断", "待复核", "失败"}
+ else "是"
+ )
+ latest_summary = conversation.latest_summary or {}
+ structured_output = latest_summary.get("structured_output") or {}
return {
"highest_risk_level": highest_risk_level,
"export_allowed": export_allowed,
"notify_status": notify_status,
"export_status": export_status,
+ "download_url": structured_output.get("download_url", ""),
"file_count": batch.file_count if batch else 0,
"page_count": batch.page_count if batch else 0,
}
@@ -180,6 +187,7 @@ def _apply_agent_result_to_conversation(conversation: Conversation, result: Agen
"answer": result.answer,
"status": result.status,
"error": result.error,
+ "structured_output": result.structured_output,
"notification_payload": result.notification_payload,
}
conversation.last_run_at = timezone.now()
diff --git a/templates/chat/index.html b/templates/chat/index.html
index 8faf8c9..f658eb3 100644
--- a/templates/chat/index.html
+++ b/templates/chat/index.html
@@ -157,6 +157,10 @@
导出状态
{{ workspace_summary.export_status }}
+
+ 导出下载地址
+ {{ workspace_summary.download_url|default:"-" }}
+
当前会话围绕 `conversation_id / batch_id / product_name` 串联。
{% if audit_log %}
查看本次处理历史
diff --git a/tests/test_chat.py b/tests/test_chat.py
index 5e4a200..da32432 100644
--- a/tests/test_chat.py
+++ b/tests/test_chat.py
@@ -373,6 +373,34 @@ def test_chat_page_shows_upload_entry_and_dynamic_context_cards(client, db):
assert "飞书通知 / 待处理" in content
+def test_chat_page_blocks_formal_export_when_word_export_node_is_blocked(client, db):
+ batch, conversation = _create_conversation_with_batch()
+ conversation.node_results = [
+ {"label": "资料包导入", "status": "已完成"},
+ {"label": "目录汇总", "status": "已完成"},
+ {"label": "法规完整性检查", "status": "已完成"},
+ {"label": "字段抽取", "status": "已完成"},
+ {"label": "一致性核查", "status": "已完成"},
+ {"label": "风险预警", "status": "已完成"},
+ {"label": "Word 回填导出", "status": "已阻断"},
+ {"label": "飞书通知", "status": "待处理"},
+ ]
+ conversation.latest_summary = {
+ "structured_output": {
+ "download_url": "/downloads/export.docx",
+ }
+ }
+ conversation.save(update_fields=["node_results", "latest_summary", "updated_at"])
+
+ response = client.get(reverse("chat:detail", args=[conversation.conversation_id]))
+
+ content = response.content.decode("utf-8")
+ assert response.status_code == 200
+ assert "是否允许正式导出" in content
+ assert ">否<" in content
+ assert "/downloads/export.docx" in content
+
+
def test_chat_upload_keeps_existing_conversation_binding_and_adds_documents(client, db):
batch, conversation = _create_conversation_with_batch()
existing_document = UploadedDocument.objects.create(