feat: bid_task_io 交付件改共享渲染(md→MdWidget+下载,office/pdf→下载)

This commit is contained in:
yumoqing 2026-09-03 16:41:29 +08:00
parent c8ff8d02d5
commit b3a8a15fd1

View File

@ -77,42 +77,26 @@ async with DBPools().sqlorContext(dbname) as sor:
elif raw_id.startswith('del:'):
did = raw_id[4:]
recs = await sor.sqlExe(
"SELECT id, task_id, deliverable_type, title, content, file_path, review_status, "
"review_comment, quality_score FROM pipeline_deliverables WHERE id=${d}$", {"d": did})
"SELECT id, task_id, deliverable_type, title, content, file_path, project_id, "
"review_status, review_comment, quality_score FROM pipeline_deliverables WHERE id=${d}$",
{"d": did})
if recs:
d = recs[0]
task_id = getattr(d, 'task_id', '') or ''
del_focus = did
sc = '#16a34a'
subwidgets = [
{"widgettype": "Text",
"options": {"text": "\U0001f4e4 " + (getattr(d, 'title', '') or getattr(d, 'deliverable_type', '') or ''),
"halign": "left", "cfontsize": 1.1,
"style": {"fontWeight": "bold", "color": "#1e293b"}}},
{"widgettype": "HBox", "options": {"gap": "12px", "width": "100%"},
"subwidgets": [
{"widgettype": "Text", "options": {"text": getattr(d, 'deliverable_type', '') or '',
"cfontsize": 0.8, "color": "#3b82f6"}},
{"widgettype": "Text", "options": {"text": getattr(d, 'review_status', '') or '',
"cfontsize": 0.75, "color": "#94a3b8"}},
{"widgettype": "Text", "options": {"text": "评分: " + str(getattr(d, 'quality_score', '') or '-'),
"cfontsize": 0.75, "color": "#94a3b8"}},
{"widgettype": "Filler"},
]},
]
fp = getattr(d, 'file_path', '') or ''
if fp:
subwidgets.append({"widgettype": "Text",
"options": {"text": "文件: " + fp, "cfontsize": 0.78,
"color": "#64748b", "wrap": True, "halign": "left"}})
subwidgets.append({"widgettype": "Text",
"options": {"text": (getattr(d, 'content', '') or '')[:8000],
"cfontsize": 0.82, "color": "#334155", "wrap": True,
"halign": "left", "css": "card"}})
if getattr(d, 'review_comment', ''):
subwidgets.append({"widgettype": "Text",
"options": {"text": "审核意见: " + str(getattr(d, 'review_comment', ''))[:500],
"cfontsize": 0.78, "color": "#f0a040", "wrap": True, "halign": "left"}})
from pipeline_service.task_io_render import deliverable_widgets
subwidgets = [{"widgettype": "Text",
"options": {"text": "\U0001f4e4 " + (getattr(d, 'title', '') or getattr(d, 'deliverable_type', '') or ''),
"halign": "left", "cfontsize": 1.1,
"style": {"fontWeight": "bold", "color": "#1e293b"}}}]
subwidgets += deliverable_widgets({
"deliverable_type": getattr(d, 'deliverable_type', '') or '',
"title": getattr(d, 'title', '') or '',
"content": getattr(d, 'content', '') or '',
"file_path": getattr(d, 'file_path', '') or '',
"project_id": getattr(d, 'project_id', '') or '',
"review_status": getattr(d, 'review_status', '') or '',
"quality_score": getattr(d, 'quality_score', '') or '',
"review_comment": getattr(d, 'review_comment', '') or '',
}, entire_url("/pipeline-sdlc/api/project_file.dspy"))
return json.dumps({
"widgettype": "VBox",
"options": {"width": "100%", "padding": "12px", "gap": "6px", "overflowY": "auto"},
@ -155,11 +139,14 @@ async with DBPools().sqlorContext(dbname) as sor:
except Exception:
description = params_str
# 输出:交付件
# 输出:交付件md→MdWidget渲染+下载office/pdf→下载链接全产线统一
dels = await sor.sqlExe(
"SELECT deliverable_type, title, content, file_path, review_status, quality_score, review_comment "
"SELECT deliverable_type, title, content, file_path, project_id, review_status, "
"quality_score, review_comment "
"FROM pipeline_deliverables WHERE task_id=${t}$ ORDER BY created_at DESC", {"t": task_id})
proj_file_url = entire_url("/pipeline-sdlc/api/project_file.dspy")
# 执行步骤
steps = await sor.sqlExe(
"SELECT step_name, display_name, state, error_msg, started_at, completed_at "
@ -258,41 +245,18 @@ async with DBPools().sqlorContext(dbname) as sor:
subwidgets.append({"widgettype": "Text",
"options": {"text": "(暂无交付件)", "cfontsize": 0.8, "color": "#94a3b8"}})
else:
from pipeline_service.task_io_render import deliverable_card
for d in dels:
d_type = getattr(d, 'deliverable_type', '') or ''
d_title = getattr(d, 'title', '') or ''
d_content = getattr(d, 'content', '') or ''
d_file = getattr(d, 'file_path', '') or ''
d_status = getattr(d, 'review_status', '') or ''
d_score = getattr(d, 'quality_score', '') or ''
d_comment = getattr(d, 'review_comment', '') or ''
card = {
"widgettype": "VBox",
"options": {"css": "card", "gap": "4px", "width": "100%", "padding": "8px"},
"subwidgets": [
{"widgettype": "HBox", "options": {"gap": "8px", "width": "100%"},
"subwidgets": [
{"widgettype": "Text", "options": {"text": d_type,
"cfontsize": 0.8, "color": "#3b82f6"}},
{"widgettype": "Text", "options": {"text": d_title[:60],
"cfontsize": 0.8, "color": "#1e293b"}},
{"widgettype": "Filler"},
{"widgettype": "Text", "options": {"text": (d_status or '') + ((" " + str(d_score)) if d_score else ''),
"cfontsize": 0.75, "color": "#94a3b8"}},
]},
{"widgettype": "Text", "options": {"text": d_content[:5000],
"cfontsize": 0.78, "color": "#475569", "wrap": True, "halign": "left"}},
],
}
if d_file:
card["subwidgets"].append({"widgettype": "Text",
"options": {"text": "\U0001f4ce " + d_file, "cfontsize": 0.75,
"color": "#64748b", "wrap": True, "halign": "left"}})
if d_comment:
card["subwidgets"].append({"widgettype": "Text",
"options": {"text": "审核意见: " + d_comment[:300],
"cfontsize": 0.75, "color": "#f0a040", "wrap": True, "halign": "left"}})
subwidgets.append(card)
subwidgets.append(deliverable_card({
"deliverable_type": getattr(d, 'deliverable_type', '') or '',
"title": getattr(d, 'title', '') or '',
"content": getattr(d, 'content', '') or '',
"file_path": getattr(d, 'file_path', '') or '',
"project_id": getattr(d, 'project_id', '') or '',
"review_status": getattr(d, 'review_status', '') or '',
"quality_score": getattr(d, 'quality_score', '') or '',
"review_comment": getattr(d, 'review_comment', '') or '',
}, proj_file_url))
return json.dumps({
"widgettype": "VBox",