This commit is contained in:
yumoqing 2025-01-23 16:00:38 +08:00
parent b025495d4e
commit 93eb1cbb01
4 changed files with 35 additions and 4 deletions

View File

@ -43,7 +43,7 @@ def get_apikey_from_token(token):
return None return None
async def get_user_roles(userid): async def get_user_roles(userid):
sql = "select concat(b.orgtypeid, '.' b.name) as name from userrole a, role b where a.userid=${userid}$ and a.roleid = b.id" sql = "select concat(b.orgtypeid, '.', b.name) as name from userrole a, role b where a.userid=${userid}$ and a.roleid = b.id"
db = DBPools() db = DBPools()
roles = [] roles = []
dbname = await get_dbname() dbname = await get_dbname()

27
wwwroot/user/myrole.ui Normal file
View File

@ -0,0 +1,27 @@
{
"widgettype":"VBox",
"options":{
"height":"100%"
},
"subwidgets":[
{
"widgettype":"Title4",
"options":{
"otext":"我的角色",
"i18n":true
}
},
{% set roles = get_user_roles(get_user()) %}
{% for role in roles %}
{
"widgettype":"Text",
"options":{
"text":"{{role}}"
}
},
{% endfor %}
{
"oops":true
}
]
}

View File

@ -3,7 +3,7 @@
"widgettype":"HBox", "widgettype":"HBox",
"options":{ "options":{
"css":"clickable", "css":"clickable",
"cwidth":14 "cwidth":12
}, },
"binds":[ "binds":[
{ {
@ -31,8 +31,7 @@
{ {
"widgettype":"Text", "widgettype":"Text",
"options":{ "options":{
"wrap":false, "text":"{{get_username()}}"
"text":"{{get_username()}}({{str(get_user_roles(get_user()))}})"
} }
} }
] ]

View File

@ -1,7 +1,12 @@
{ {
"widgettype":"Menu", "widgettype":"Menu",
"options":{ "options":{
"cwidth":10,
"target":"PopupWindow", "target":"PopupWindow",
"popup_options":{
"height":"70%",
"width":"70%"
},
"items":[ "items":[
{% if 'customer' in get_user_roles(get_user()) %} {% if 'customer' in get_user_roles(get_user()) %}
{ {