fix(opp): 附件按平台副本状态诚实渲染——已存副本才给下载按钮,未存(如需登录)给打开原始页,不伪装可下载

This commit is contained in:
yumoqing 2026-09-08 23:57:56 +08:00
parent 45cec8987e
commit f44e5f7f83

View File

@ -154,12 +154,25 @@ else:
size_txt = "%.1f MB" % (a_size / 1048576.0)
elif a_size > 0:
size_txt = "%.0f KB" % (a_size / 1024.0)
dl_query = "?tender_id=" + item_id
if a_id:
dl_query += "&att_id=" + a_id
act_btns = []
if a.get("downloaded"):
# 平台已存副本 → 走代理下载
dl_query = "?tender_id=" + item_id
if a_id:
dl_query += "&att_id=" + a_id
elif a_url:
dl_query += "&att_url=" + a_url
dl_href = dl_base + dl_query
act_btns.append({"widgettype": "Button", "options": {"label": "下载", "css": "small"},
"binds": [{"wid": "self", "event": "click", "actiontype": "script",
"target": "self",
"script": "window.location.href=" + _json.dumps(dl_href) + ";"}]})
elif a_url:
dl_query += "&att_url=" + a_url
dl_href = dl_base + dl_query
# 平台未存副本(如需登录才能取)→ 如实给原始页入口,不伪装成可下载
act_btns.append({"widgettype": "Button", "options": {"label": "打开原始页", "css": "small"},
"binds": [{"wid": "self", "event": "click", "actiontype": "script",
"target": "self",
"script": "window.open(" + _json.dumps(a_url) + ",'_blank','noopener');"}]})
body.append({
"widgettype": "HBox",
"options": {"width": "100%", "gap": "10px", "alignItems": "center",
@ -171,12 +184,8 @@ else:
"wrap": True}},
{"widgettype": "Text", "options": {"text": size_txt,
"cfontsize": 0.75, "color": "#94a3b8"}},
{"widgettype": "Filler"},
{"widgettype": "Button", "options": {"label": "下载", "css": "small"},
"binds": [{"wid": "self", "event": "click", "actiontype": "script",
"target": "self",
"script": "window.location.href=" + _json.dumps(dl_href) + ";"}]}
]
{"widgettype": "Filler"}
] + act_btns
})
return {