fix: 预览按 draft-{id} 命名且重建全量同构 + C1 空台账改判数据待补 + 立项经费结余结论 + CLI 拆分 import-*/list-* + docx 占位黄底

This commit is contained in:
chenfuqiang
2026-09-27 21:47:56 +08:00
parent 7b24521b43
commit db11f22dc8
11 changed files with 508 additions and 107 deletions

View File

@@ -32,13 +32,15 @@ def write_docx(project: dict[str, Any], sections: dict[str, list[str]], batch_no
"""生成《结题报告(初稿)》docx,返回文件路径。"""
_check_docx_available()
import docx
from docx.enum.text import WD_COLOR_INDEX
from docx.shared import Pt
log = _log()
log.info("docx_render_start project_no=%s stage=docx", project.get("project_no"))
document = docx.Document()
log = _log()
if log:
log.info("docx_render_start project_no=%s stage=docx", project.get("project_no"))
title = document.add_heading("结题报告(初稿)", level=0)
title.alignment = 1
@@ -68,8 +70,8 @@ def write_docx(project: dict[str, Any], sections: dict[str, list[str]], batch_no
p = document.add_paragraph()
run = p.add_run(text)
if text.startswith("[待补充"):
run.font.color.rgb = None # 占位文本以提示语区分,不依赖颜色
run.italic = True
run.font.highlight_color = WD_COLOR_INDEX.YELLOW # 占位黄底提示,便于教师定位待写章节
notice = document.add_paragraph()
notice_run = notice.add_run(
@@ -82,5 +84,6 @@ def write_docx(project: dict[str, Any], sections: dict[str, list[str]], batch_no
filename = f"结题报告初稿-{project_no}.docx"
path = get_output_dir() + "/" + filename
document.save(path)
log.info("docx_render_done project_no=%s path=%s stage=docx", project_no, path)
if log:
log.info("docx_render_done project_no=%s path=%s stage=docx", project_no, path)
return path