llmage: 记账失败记录-原因改为toolbar按钮弹窗显示

This commit is contained in:
Hermes Agent 2026-06-18 11:55:08 +08:00
parent 1aa28430e0
commit 88d2fd2c86
2 changed files with 55 additions and 1 deletions

View File

@ -3,8 +3,34 @@
"title": "记账失败记录",
"params": {
"sortby": "failed_time desc",
"toolbar": {
"tools": [
{
"name": "show_reason",
"label": "原因",
"selected_row": true
}
]
},
"binds": [
{
"wid": "self",
"event": "show_reason",
"actiontype": "urlwidget",
"target": "PopupWindow",
"popup_options": {
"title": "失败原因",
"cwidth": 30,
"cheight": 20
},
"options": {
"url": "{{entire_url('../api/show_failed_reason.dspy')}}",
"params": {"id": "${id}$"}
}
}
],
"browserfields": {
"exclouded": ["id"],
"exclouded": ["id", "failed_reason"],
"alters": {}
},
"editexclouded": ["id", "llmusageid", "failed_time"],

View File

@ -0,0 +1,28 @@
record_id = params_kw.get('id', '')
reason = '未找到记录'
if record_id:
dbname = get_module_dbname('llmage')
async with DBPools().sqlorContext(dbname) as sor:
rows = await sor.R('llmusage_accounting_failed', {'id': record_id})
if rows:
reason = rows[0].get('failed_reason', '') or '(空)'
return {
"widgettype": "VScrollPanel",
"options": {
"width": "100%",
"height": "100%",
"css": "card",
"padding": "12px"
},
"subwidgets": [
{
"widgettype": "Text",
"options": {
"text": reason,
"i18n": False
}
}
]
}