F2-10: 用户组/角色-菜单写端点 + 三维权限分配页 + menu-all 叶子层修复
platform-metadata 新增 AdminWriteController(用户组 CRUD、成员/角色加减、 角色菜单差量整存)及单测 14 条;sys-admin-assign.json amis 三维分配页入库; 修复 AdminController.buildMenuChildren 叶子层 menuroot=null 导致叶子不显示的 bug;SQL upsert 脚本两库均已执行。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,470 @@
|
||||
{
|
||||
"type": "page",
|
||||
"title": "权限分配",
|
||||
"body": [
|
||||
{
|
||||
"type": "grid",
|
||||
"columns": [
|
||||
{
|
||||
"md": 4,
|
||||
"body": [
|
||||
{
|
||||
"type": "panel",
|
||||
"title": "用户组",
|
||||
"headerClassName": "bg-primary text-white",
|
||||
"bodyClassName": "p-0",
|
||||
"body": [
|
||||
{
|
||||
"type": "toolbar",
|
||||
"className": "p-xs",
|
||||
"body": [
|
||||
{
|
||||
"type": "button",
|
||||
"label": "新建用户组",
|
||||
"level": "primary",
|
||||
"size": "sm",
|
||||
"actionType": "dialog",
|
||||
"dialog": {
|
||||
"title": "新建用户组",
|
||||
"body": {
|
||||
"type": "form",
|
||||
"api": {
|
||||
"method": "post",
|
||||
"url": "/api/admin/usergroups/create"
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "input-text",
|
||||
"name": "name",
|
||||
"label": "名称",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "input-text",
|
||||
"name": "description",
|
||||
"label": "描述"
|
||||
}
|
||||
]
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "button",
|
||||
"label": "取消",
|
||||
"actionType": "close"
|
||||
},
|
||||
{
|
||||
"type": "submit",
|
||||
"label": "保存",
|
||||
"level": "primary",
|
||||
"reload": "groupList"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "crud",
|
||||
"name": "groupList",
|
||||
"syncLocation": false,
|
||||
"api": {
|
||||
"method": "get",
|
||||
"url": "/api/admin/usergroups",
|
||||
"adaptor": "var d=payload.data||{};return {status:0,data:{items:d.items||[],total:d.total||0}};"
|
||||
},
|
||||
"perPage": 20,
|
||||
"headerToolbar": [],
|
||||
"footerToolbar": ["pagination"],
|
||||
"selectable": true,
|
||||
"multiple": false,
|
||||
"keepItemSelectionOnPageChange": false,
|
||||
"onSelect": {
|
||||
"actionType": "setValue",
|
||||
"componentId": "selectedGroup",
|
||||
"args": {
|
||||
"value": "${event.data.selectedItems[0]}"
|
||||
}
|
||||
},
|
||||
"columns": [
|
||||
{
|
||||
"name": "name",
|
||||
"label": "用户组名称"
|
||||
},
|
||||
{
|
||||
"type": "operation",
|
||||
"label": "操作",
|
||||
"width": 100,
|
||||
"buttons": [
|
||||
{
|
||||
"type": "button",
|
||||
"label": "编辑",
|
||||
"level": "link",
|
||||
"actionType": "dialog",
|
||||
"dialog": {
|
||||
"title": "编辑用户组",
|
||||
"body": {
|
||||
"type": "form",
|
||||
"api": {
|
||||
"method": "post",
|
||||
"url": "/api/admin/usergroups/${id}/update"
|
||||
},
|
||||
"initApi": {
|
||||
"method": "get",
|
||||
"url": "/api/admin/usergroups/${id}"
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "input-text",
|
||||
"name": "name",
|
||||
"label": "名称",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "input-text",
|
||||
"name": "description",
|
||||
"label": "描述"
|
||||
}
|
||||
]
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "button",
|
||||
"label": "取消",
|
||||
"actionType": "close"
|
||||
},
|
||||
{
|
||||
"type": "submit",
|
||||
"label": "保存",
|
||||
"level": "primary",
|
||||
"reload": "groupList"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "删除",
|
||||
"level": "link",
|
||||
"className": "text-danger",
|
||||
"actionType": "ajax",
|
||||
"confirmText": "确认删除用户组「${name}」?",
|
||||
"api": {
|
||||
"method": "post",
|
||||
"url": "/api/admin/usergroups/${id}/delete"
|
||||
},
|
||||
"reload": "groupList"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"md": 4,
|
||||
"body": [
|
||||
{
|
||||
"type": "panel",
|
||||
"title": "该组的角色",
|
||||
"headerClassName": "bg-info text-white",
|
||||
"bodyClassName": "p-0",
|
||||
"body": [
|
||||
{
|
||||
"type": "service",
|
||||
"name": "roleAssignPanel",
|
||||
"api": {
|
||||
"method": "get",
|
||||
"url": "/api/admin/usergroups/${selectedGroup.id}/roles",
|
||||
"sendOn": "${selectedGroup.id}",
|
||||
"adaptor": "var d=payload.data||{};return {status:0,data:{items:d.items||[],total:d.total||0}};"
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "tpl",
|
||||
"tpl": "<div class='text-muted p-sm' style='font-size:0.85em'>请先在左侧选择用户组</div>",
|
||||
"visibleOn": "!${selectedGroup.id}"
|
||||
},
|
||||
{
|
||||
"type": "crud",
|
||||
"name": "roleList",
|
||||
"source": "${items}",
|
||||
"visibleOn": "${selectedGroup.id}",
|
||||
"headerToolbar": [
|
||||
{
|
||||
"type": "button",
|
||||
"label": "添加角色",
|
||||
"level": "success",
|
||||
"size": "sm",
|
||||
"actionType": "dialog",
|
||||
"disabledOn": "!${selectedGroup.id}",
|
||||
"dialog": {
|
||||
"title": "添加角色到「${selectedGroup.name}」",
|
||||
"body": {
|
||||
"type": "form",
|
||||
"api": {
|
||||
"method": "post",
|
||||
"url": "/api/admin/usergroups/${selectedGroup.id}/add-role"
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "select",
|
||||
"name": "roleId",
|
||||
"label": "选择角色",
|
||||
"required": true,
|
||||
"source": {
|
||||
"method": "get",
|
||||
"url": "/api/org/roles",
|
||||
"adaptor": "var d=payload.data||{};return {status:0,data:{options:(d.items||[]).map(function(r){return {label:r.name,value:r.id};})}};"
|
||||
},
|
||||
"searchable": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "button",
|
||||
"label": "取消",
|
||||
"actionType": "close"
|
||||
},
|
||||
{
|
||||
"type": "submit",
|
||||
"label": "确认",
|
||||
"level": "primary",
|
||||
"reload": "roleAssignPanel"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"footerToolbar": [],
|
||||
"columns": [
|
||||
{
|
||||
"name": "name",
|
||||
"label": "角色名称"
|
||||
},
|
||||
{
|
||||
"type": "operation",
|
||||
"label": "操作",
|
||||
"width": 80,
|
||||
"buttons": [
|
||||
{
|
||||
"type": "button",
|
||||
"label": "移除",
|
||||
"level": "link",
|
||||
"className": "text-danger",
|
||||
"actionType": "ajax",
|
||||
"confirmText": "从「${selectedGroup.name}」移除角色「${name}」?",
|
||||
"api": {
|
||||
"method": "post",
|
||||
"url": "/api/admin/usergroups/${selectedGroup.id}/remove-role",
|
||||
"data": {
|
||||
"roleId": "${id}"
|
||||
}
|
||||
},
|
||||
"reload": "roleAssignPanel"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "查看菜单",
|
||||
"level": "link",
|
||||
"actionType": "setValue",
|
||||
"componentId": "selectedRole",
|
||||
"args": {
|
||||
"value": "${&}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "panel",
|
||||
"title": "该组的成员",
|
||||
"className": "mt-sm",
|
||||
"headerClassName": "bg-light",
|
||||
"bodyClassName": "p-0",
|
||||
"body": [
|
||||
{
|
||||
"type": "service",
|
||||
"name": "userAssignPanel",
|
||||
"api": {
|
||||
"method": "get",
|
||||
"url": "/api/admin/usergroups/${selectedGroup.id}/users",
|
||||
"sendOn": "${selectedGroup.id}",
|
||||
"adaptor": "var d=payload.data||{};return {status:0,data:{items:d.items||[],total:d.total||0}};"
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "crud",
|
||||
"name": "memberList",
|
||||
"source": "${items}",
|
||||
"visibleOn": "${selectedGroup.id}",
|
||||
"headerToolbar": [
|
||||
{
|
||||
"type": "button",
|
||||
"label": "添加成员",
|
||||
"level": "default",
|
||||
"size": "sm",
|
||||
"actionType": "dialog",
|
||||
"disabledOn": "!${selectedGroup.id}",
|
||||
"dialog": {
|
||||
"title": "添加成员到「${selectedGroup.name}」",
|
||||
"body": {
|
||||
"type": "form",
|
||||
"api": {
|
||||
"method": "post",
|
||||
"url": "/api/admin/usergroups/${selectedGroup.id}/add-user"
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "select",
|
||||
"name": "userId",
|
||||
"label": "选择用户",
|
||||
"required": true,
|
||||
"source": {
|
||||
"method": "get",
|
||||
"url": "/api/admin/users",
|
||||
"adaptor": "var d=payload.data||{};return {status:0,data:{options:(d.items||[]).map(function(u){return {label:u.account+'('+u.name+')',value:u.id};})}};"
|
||||
},
|
||||
"searchable": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "button",
|
||||
"label": "取消",
|
||||
"actionType": "close"
|
||||
},
|
||||
{
|
||||
"type": "submit",
|
||||
"label": "确认",
|
||||
"level": "primary",
|
||||
"reload": "userAssignPanel"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"footerToolbar": [],
|
||||
"columns": [
|
||||
{
|
||||
"name": "account",
|
||||
"label": "账号"
|
||||
},
|
||||
{
|
||||
"name": "name",
|
||||
"label": "姓名"
|
||||
},
|
||||
{
|
||||
"type": "operation",
|
||||
"label": "操作",
|
||||
"width": 80,
|
||||
"buttons": [
|
||||
{
|
||||
"type": "button",
|
||||
"label": "移除",
|
||||
"level": "link",
|
||||
"className": "text-danger",
|
||||
"actionType": "ajax",
|
||||
"confirmText": "从「${selectedGroup.name}」移除成员「${account}」?",
|
||||
"api": {
|
||||
"method": "post",
|
||||
"url": "/api/admin/usergroups/${selectedGroup.id}/remove-user",
|
||||
"data": {
|
||||
"userId": "${id}"
|
||||
}
|
||||
},
|
||||
"reload": "userAssignPanel"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"md": 4,
|
||||
"body": [
|
||||
{
|
||||
"type": "panel",
|
||||
"title": "角色菜单权限",
|
||||
"headerClassName": "bg-warning",
|
||||
"bodyClassName": "p-sm",
|
||||
"body": [
|
||||
{
|
||||
"type": "tpl",
|
||||
"tpl": "<div class='text-muted mb-sm' style='font-size:0.85em'>请先在中栏点击角色的「查看菜单」</div>",
|
||||
"visibleOn": "!${selectedRole.id}"
|
||||
},
|
||||
{
|
||||
"type": "service",
|
||||
"name": "menuAssignPanel",
|
||||
"api": {
|
||||
"method": "get",
|
||||
"url": "/api/admin/roles/${selectedRole.id}/menus",
|
||||
"sendOn": "${selectedRole.id}",
|
||||
"adaptor": "var d=payload.data||{};return {status:0,data:{checkedMenuIds:d.checkedMenuIds||[]}};"
|
||||
},
|
||||
"visibleOn": "${selectedRole.id}",
|
||||
"body": [
|
||||
{
|
||||
"type": "tpl",
|
||||
"tpl": "<div class='mb-xs font-weight-bold'>角色:${selectedRole.name}</div>"
|
||||
},
|
||||
{
|
||||
"type": "form",
|
||||
"name": "menuForm",
|
||||
"api": {
|
||||
"method": "post",
|
||||
"url": "/api/admin/roles/${selectedRole.id}/set-menus"
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "input-tree",
|
||||
"name": "menuIds",
|
||||
"label": "菜单权限",
|
||||
"multiple": true,
|
||||
"cascade": false,
|
||||
"withChildren": false,
|
||||
"joinValues": false,
|
||||
"extractValue": true,
|
||||
"value": "${checkedMenuIds}",
|
||||
"source": {
|
||||
"method": "get",
|
||||
"url": "/api/admin/menu-all",
|
||||
"adaptor": "var roots=payload.roots||[];var nodes=[];roots.forEach(function(r){r.children&&r.children.forEach(function(dir){var dirNode={value:dir.id,label:dir.name,children:[]};(dir.children||[]).forEach(function(leaf){dirNode.children.push({value:leaf.id,label:leaf.name});});nodes.push(dirNode);});});return {status:0,data:{options:nodes}};"
|
||||
},
|
||||
"showIcon": false,
|
||||
"className": "max-h-400 overflow-y-auto"
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
{
|
||||
"type": "submit",
|
||||
"label": "保存菜单权限",
|
||||
"level": "primary",
|
||||
"reload": "menuAssignPanel"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user