diff --git a/json/llmusage_accounting_failed.json b/json/llmusage_accounting_failed.json index 125d1f2..5c5bd17 100644 --- a/json/llmusage_accounting_failed.json +++ b/json/llmusage_accounting_failed.json @@ -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"], diff --git a/wwwroot/api/show_failed_reason.dspy b/wwwroot/api/show_failed_reason.dspy new file mode 100644 index 0000000..4c0eed4 --- /dev/null +++ b/wwwroot/api/show_failed_reason.dspy @@ -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 + } + } + ] +}