From c9a2f4d7e8ecd4650279120056a761dcca972d0d Mon Sep 17 00:00:00 2001 From: ymq Date: Wed, 2 Sep 2026 14:52:25 +0800 Subject: [PATCH] =?UTF-8?q?fix(rag-ui):=20=E6=96=B0=E5=BB=BA=E7=9F=A5?= =?UTF-8?q?=E8=AF=86=E5=BA=93submit=E5=90=8E=E5=88=B7=E6=96=B0=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E2=80=94=E2=80=94Form=E5=8A=A0submited=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6bind=E9=87=8D=E5=BB=BAkb=5Flist?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wwwroot/knowledge_bases_list/create_kb.dspy | 10 ++++++--- wwwroot/knowledge_bases_list/index.ui | 17 ++++++++++++--- wwwroot/knowledge_bases_list/new_kb_form.ui | 23 ++++++++++++++++++++- 3 files changed, 43 insertions(+), 7 deletions(-) diff --git a/wwwroot/knowledge_bases_list/create_kb.dspy b/wwwroot/knowledge_bases_list/create_kb.dspy index c742c38..4610c98 100644 --- a/wwwroot/knowledge_bases_list/create_kb.dspy +++ b/wwwroot/knowledge_bases_list/create_kb.dspy @@ -11,9 +11,13 @@ async with db.sqlorContext(dbname) as sor: emb_type = ns.get("embedding_type", "") or ns.get("embedding_engine", "") if emb_type not in ("bge-m3", "clip-vith14", "qwen3-vl-embedding"): emb_type = "bge-m3" - # 知识库级角色权限:维护角色/检索角色(逗号分隔,空=同机构默认可用) - maintain_roles = ns.get("maintain_roles", "") or "" - search_roles = ns.get("search_roles", "") or "" + # 知识库级角色权限:维护角色/检索角色(多选 checkbox 提交 list,兼容逗号串) + def _roles_csv(v): + if isinstance(v, (list, tuple)): + return ','.join([str(x) for x in v if str(x).strip()]) + return str(v or '') + maintain_roles = _roles_csv(ns.get("maintain_roles", "")) + search_roles = _roles_csv(ns.get("search_roles", "")) await sor.sqlExe( "INSERT INTO rag_knowledge_bases (id, name, description, org_id, embedding_engine, vdb_collection, doc_count, total_size, chunk_count, status, maintain_roles, search_roles, created_at) " "VALUES (${id}$, ${name}$, ${desc}$, ${org_id}$, ${emb}$, 'rag_collection', 0, 0, 0, 'active', ${mr}$, ${sr}$, NOW())", diff --git a/wwwroot/knowledge_bases_list/index.ui b/wwwroot/knowledge_bases_list/index.ui index f82713b..6be9677 100644 --- a/wwwroot/knowledge_bases_list/index.ui +++ b/wwwroot/knowledge_bases_list/index.ui @@ -114,10 +114,21 @@ } }, { - "widgettype": "urlwidget", + "widgettype": "VBox", + "id": "rag_main_content", "options": { - "url": "{{entire_url('./kb_list.dspy')}}" - } + "css": "filler", + "width": "100%", + "height": "100%" + }, + "subwidgets": [ + { + "widgettype": "urlwidget", + "options": { + "url": "{{entire_url('./kb_list.dspy')}}" + } + } + ] } ] } diff --git a/wwwroot/knowledge_bases_list/new_kb_form.ui b/wwwroot/knowledge_bases_list/new_kb_form.ui index 009a3b5..0859f46 100644 --- a/wwwroot/knowledge_bases_list/new_kb_form.ui +++ b/wwwroot/knowledge_bases_list/new_kb_form.ui @@ -1,6 +1,18 @@ { "widgettype": "Form", "id": "kb_form", + "binds": [ + { + "wid": "self", + "event": "submited", + "actiontype": "urlwidget", + "target": "app.rag_main_content", + "mode": "replace", + "options": { + "url": "{{entire_url('./kb_list.dspy')}}" + } + } + ], "options": { "cols": 1, "title": "新建知识库", @@ -14,5 +26,14 @@ {"name": "search_roles", "label": "检索角色(可多选)", "uitype": "checkbox", "multicheck": true, "dataurl": "{{entire_url('./role_options.dspy')}}", "valueField": "value", "textField": "text", "tip": "不选=同机构登录用户均可检索/下载"}, {"name": "embedding_type", "label": "向量引擎", "uitype": "code", "value": "bge-m3", "dataurl": "{{entire_url('./embedding_options.dspy')}}", "valueField": "value", "textField": "text"} ] - } + }, + "binds": [ + { + "wid": "self", + "event": "submited", + "actiontype": "script", + "target": "self", + "script": "var u='/rag/knowledge_bases_list/kb_list.dspy?_webbricks_=1';fetch(u).then(function(r){return r.json()}).then(function(d){var mc=bricks.getWidgetById('rag_main_content',bricks.app.root);if(mc){mc.clear_widgets();bricks.widgetBuild(d,mc).then(function(w){if(w)mc.add_widget(w)})}})" + } + ] }