feat(rag-ui): 维护/检索角色改多选checkbox(multicheck)+role_options.dspy角色选项
This commit is contained in:
parent
1c1ef65931
commit
728dbc328e
@ -10,8 +10,8 @@
|
|||||||
"fields": [
|
"fields": [
|
||||||
{"name": "name", "label": "名称", "uitype": "str", "required": true},
|
{"name": "name", "label": "名称", "uitype": "str", "required": true},
|
||||||
{"name": "description", "label": "描述", "uitype": "text"},
|
{"name": "description", "label": "描述", "uitype": "text"},
|
||||||
{"name": "maintain_roles", "label": "维护角色", "uitype": "str", "tip": "逗号分隔角色名(如 RBACorg.admin);空=同机构登录用户均可维护;*=全部"},
|
{"name": "maintain_roles", "label": "维护角色(可多选)", "uitype": "checkbox", "multicheck": true, "dataurl": "{{entire_url('./role_options.dspy')}}", "valueField": "value", "textField": "text", "tip": "不选=同机构登录用户均可维护"},
|
||||||
{"name": "search_roles", "label": "检索角色", "uitype": "str", "tip": "逗号分隔角色名;空=同机构登录用户均可检索/下载;*=全部"},
|
{"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"}
|
{"name": "embedding_type", "label": "向量引擎", "uitype": "code", "value": "bge-m3", "dataurl": "{{entire_url('./embedding_options.dspy')}}", "valueField": "value", "textField": "text"}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
30
wwwroot/knowledge_bases_list/role_options.dspy
Normal file
30
wwwroot/knowledge_bases_list/role_options.dspy
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
# 角色多选选项:value={orgtypeid}.{name}(与 RBAC 校验格式一致)
|
||||||
|
ns = params_kw.copy()
|
||||||
|
db = DBPools()
|
||||||
|
dbname = get_module_dbname('rag')
|
||||||
|
opts = [{"value": "*", "text": "*(全部角色)"}]
|
||||||
|
try:
|
||||||
|
async with db.sqlorContext(dbname) as sor:
|
||||||
|
recs = await sor.sqlExe(
|
||||||
|
"SELECT DISTINCT orgtypeid, name FROM role "
|
||||||
|
"WHERE orgtypeid IS NOT NULL AND name IS NOT NULL "
|
||||||
|
"ORDER BY orgtypeid, name LIMIT 60", {})
|
||||||
|
await sor.sqlExe("COMMIT", {})
|
||||||
|
seen = set()
|
||||||
|
for r in (recs or []):
|
||||||
|
o = getattr(r, 'orgtypeid', '') or ''
|
||||||
|
n = getattr(r, 'name', '') or ''
|
||||||
|
if not o or not n:
|
||||||
|
continue
|
||||||
|
key = o + '.' + n
|
||||||
|
if key in seen:
|
||||||
|
continue
|
||||||
|
seen.add(key)
|
||||||
|
opts.append({"value": key, "text": key})
|
||||||
|
# 机构通配选项
|
||||||
|
orgs = sorted({(getattr(r, 'orgtypeid', '') or '') for r in (recs or []) if getattr(r, 'orgtypeid', '')})
|
||||||
|
for o in orgs:
|
||||||
|
opts.append({"value": o + ".*", "text": o + ".*(该机构全部)"})
|
||||||
|
except Exception as e:
|
||||||
|
info('role_options: ' + str(e))
|
||||||
|
return json.dumps(opts, ensure_ascii=False)
|
||||||
Loading…
x
Reference in New Issue
Block a user