【JSON2WEB】11 基于 Amis 角色功能权限设置页面

news/2024/10/18 0:25:19/

【JSON2WEB】01 WEB管理信息系统架构设计

【JSON2WEB】02 JSON2WEB初步UI设计

【JSON2WEB】03 go的模板包html/template的使用

【JSON2WEB】04 amis低代码前端框架介绍

【JSON2WEB】05 前端开发三件套 HTML CSS JavaScript 速成

【JSON2WEB】06 JSON2WEB前端框架搭建

【JSON2WEB】07 Amis可视化设计器CRUD增删改查

【JSON2WEB】08 Amis的事件和校验

【JSON2WEB】09 Amis-editor的代码移植到json2web

【JSON2WEB】10 基于 Amis 做个登录页面login.html


1 角色功能权限设置设计

页面分2栏,左边角色,右边为角色功能权限。角色授权保存在数据库表中。

1.1 页面布局

角色功能
角色列表功能列表

1.2 角色表

-- Create table
create table S_ROLE
(p_id       VARCHAR2(17) not null,s_name     VARCHAR2(52),s_note     VARCHAR2(52),time_stamp TIMESTAMP(6) default CURRENT_TIMESTAMP
)

1.3 功能表

-- Create table
create table S_MENU
(p_id    VARCHAR2(4) not null,s_name  VARCHAR2(63),s_ename VARCHAR2(63),s_winp  VARCHAR2(63),s_note  VARCHAR2(63),s_parm  VARCHAR2(63)
)

1.4 角色功能权限关系表

-- Create table
create table S_ROLE_MENU
(pf_role    VARCHAR2(17) not null,pf_menu    VARCHAR2(17) not null,time_stamp TIMESTAMP(6) default CURRENT_TIMESTAMP
)

1.5 角色功能视图

用于功能列表显示与操作。

create or replace view 
role_menu_v -- 角色功能视图
as
select m.p_id as m_id,m.s_name ,s.pf_role,r.p_id as r_id,decode(length(s.pf_role),4,1,0) as b_ynfrom s_menu m
cross join s_role r --先做一个角色与功能的笛卡尔交叉,再连接角色功能表
left join s_role_menu s on s.pf_menu = m.p_id and s.pf_role = r.p_id
order by r.p_id,m.p_id;

授权的功能b_yn = 1
在这里插入图片描述

2 页面布局与设计

布局容器用分栏,角色及功能权限用2个增删改查crud。
在这里插入图片描述

2.1 角色crud增加行点击事件

行点击时刷新角色功能的数据。
在这里插入图片描述

 "onEvent": {"rowClick": {"weight": 0,"actions": [{"componentId": "u:1f6f2d0609fc","ignoreError": false,"actionType": "reload","dataMergeMode": "override","data": {"where": "r_id='$event.data.item.P_ID'"}}]}}

Data为我的后台查询条件,就是url上query条件。

2.2 勾选事件

勾选列定义2个值变化事件,勾选插入数据,去勾删除数据。
在这里插入图片描述

插入数据事件

勾选时执行。
在这里插入图片描述

 "actions": [{"ignoreError": false,"outputVar": "responseResult","actionType": "ajax","options": {},"api": {"url": "http://127.0.0.1:5217/rest/s_role_menu/","method": "post","requestAdaptor": "","adaptor": "","messages": {},"sendOn": "","data": {"pf_role": "${R_ID}","pf_menu": "${M_ID}"}},"expression": "${event.data.value === 1}","stopPropagation": "${event.data.value===0}"},

删除数据事件

去勾时执行。
在这里插入图片描述

{"ignoreError": false,"outputVar": "responseResult","actionType": "ajax","options": {},"api": {"url": "http://127.0.0.1:5217/rest/s_role_menu/?where=pf_role='${R_ID}' and pf_menu='${M_ID}'","method": "delete","requestAdaptor": "","adaptor": "","messages": {}},"expression": "${event.data.value===0}","stopPropagation": "${event.data.value===1}"}

2.2 角色功能crud设置

接口初始化是不拉取数据。
在这里插入图片描述

2.3 页面全部代码

{"type": "page","title": "角色功能权限设置","body": [{"type": "grid","columns": [{"body": [{"id": "u:091b9d57f777","type": "crud","mode": "table","syncLocation": false,"primaryField": "P_ID","api": {"url": "http://127.0.0.1:5217/rest/s_role","method": "get"},"headerToolbar": [{"type": "button","id": "u:16551379d280","label": "新增","actionType": "drawer","level": "primary","editorSetting": {"behavior": "create"},"drawer": {"title": "新增","body": [{"type": "form","api": {"method": "post","url": "http://127.0.0.1:5217/rest/s_role","requestAdaptor": "","adaptor": "","messages": {}},"body": [{"type": "input-text","name": "p_id","label": "P_ID","id": "u:4d1b8b17dd50","required": true},{"type": "input-text","name": "s_name","label": "角色名称","id": "u:8cc7cb12757f","required": true},{"type": "input-text","name": "s_note","label": "备注","id": "u:2b9c33a07acf"}],"id": "u:f58f36c84f4c","actions": [{"type": "submit","label": "提交","primary": true}],"feat": "Insert","dsType": "api"}],"id": "u:747ffedb9a7c","actions": [{"type": "button","actionType": "cancel","label": "取消","id": "u:ceb03306d65f"},{"type": "button","actionType": "confirm","label": "确定","primary": true,"id": "u:3d9c4d86cfb2"}]},"icon": "fa fa-plus"},{"type": "export-excel","id": "u:5d48d559aa25"},{"type": "bulk-actions"}],"columns": [{"type": "text","name": "P_ID","id": "u:bbe6028ae0c5","label": "角色ID","searchable": true,"visible": true,"placeholder": "-"},{"type": "text","name": "S_NAME","id": "u:12be864daeab","placeholder": "-","label": "名称","searchable": true,"toggled": true,"fixed": "","className": ""},{"type": "datetime","name": "TIME_STAMP","id": "u:6bace394776e","label": "更新时间","format": "YYYY-MM-DD HH:mm:ss"},{"type": "text","name": "S_NOTE","id": "u:db13008a4821","label": "备注"},{"type": "operation","label": "操作","buttons": [{"label": "编辑","type": "button","actionType": "drawer","level": "link","editorSetting": {"behavior": "update"},"id": "u:2d2b520123cf","drawer": {"title": "编辑","body": [{"type": "form","api": {"method": "put","url": "http://127.0.0.1:5217/rest/s_role/?where=p_id='${P_ID}'","requestAdaptor": "","adaptor": "","messages": {}},"body": [{"name": "P_ID","label": "P_ID","type": "input-text","id": "u:2593d30c1ccb","required": true},{"label": "角色名称","name": "S_NAME","type": "input-text","id": "u:36fb4cfb08d6","showCounter": false,"required": true},{"label": "备注","name": "S_NOTE","type": "input-text","id": "u:d154d931e0a3"}],"id": "u:987f23c51645","actions": [{"type": "submit","label": "提交","primary": true}],"feat": "Insert","dsType": "api"}],"id": "u:7c6e61a902ce","actions": [{"type": "button","actionType": "cancel","label": "取消","id": "u:780ad561efc1"},{"type": "button","actionType": "confirm","label": "确定","primary": true,"id": "u:45527a149fd6"}]}},{"label": "查看","type": "button","actionType": "drawer","level": "link","editorSetting": {"behavior": "view"},"id": "u:e2047bc65d6b","drawer": {"title": "查看详情","body": [{"type": "form","api": "xxx/update","body": [{"name": "P_ID","label": "P_ID","type": "static","id": "u:08156f086042","quickEdit": false,"popOver": false,"copyable": false},{"label": "角色名称","name": "S_NAME","type": "static","id": "u:487232bc451c","quickEdit": false,"popOver": false,"copyable": false},{"label": "更新时间","name": "TIME_STAMP","type": "static-datetime","id": "u:aba51eac1e1c","quickEdit": false,"popOver": false,"copyable": false,"format": "YYYY-MM-DD HH:mm:ss"},{"label": "备注","name": "S_NOTE","type": "static","id": "u:60c73035a649","quickEdit": false,"popOver": false,"copyable": false}],"id": "u:929916bb02e0","actions": [{"type": "submit","label": "提交","primary": true}],"feat": "Insert"}],"id": "u:34c165044747","actions": [{"type": "button","actionType": "cancel","label": "取消","id": "u:62278f468936"},{"type": "button","actionType": "confirm","label": "确定","primary": true,"id": "u:38c71e71e647"}]}},{"type": "button","label": "删除","actionType": "ajax","level": "link","className": "text-danger","confirmText": "确定要删除?","api": {"method": "delete","url": "http://127.0.0.1:5217/rest/s_role/?where=p_id='${P_ID}'"},"editorSetting": {"behavior": "delete"},"id": "u:c08fb59a9328","onEvent": {"click": {"weight": 0,"actions": []}}}],"id": "u:ea0dc035e0ec"}],"loadDataOnce": true,"showHeader": true,"bulkActions": [],"itemActions": [],"perPageAvailable": [10],"messages": {},"autoGenerateFilter": {"columnsNum": 2,"showBtnToolbar": true},"matchFunc": "","title": "","showFooter": true,"visible": true,"dsType": "api","editorSetting": {"mock": {"enable": true,"maxDisplayRows": 5}},"onEvent": {"rowClick": {"weight": 0,"actions": [{"componentId": "u:1f6f2d0609fc","ignoreError": false,"actionType": "reload","dataMergeMode": "override","data": {"where": "r_id='$event.data.item.P_ID'"}}]}}}],"id": "u:18b68e993a8d","themeCss": {"baseControlClassName": {"border:default": {"top-border-style": "var(--borders-style-2)","left-border-style": "var(--borders-style-2)","right-border-style": "var(--borders-style-2)","bottom-border-style": "var(--borders-style-2)","right-border-width": "var(--borders-width-3)","top-border-width": "var(--borders-width-3)","left-border-width": "var(--borders-width-3)","bottom-border-width": "var(--borders-width-3)"},"padding-and-margin:default": {"marginTop": "var(--sizes-size-5)","marginRight": "var(--sizes-size-5)","marginBottom": "var(--sizes-size-5)","marginLeft": "var(--sizes-size-5)","paddingTop": "var(--sizes-size-5)","paddingRight": "var(--sizes-size-5)","paddingBottom": "var(--sizes-size-5)","paddingLeft": "var(--sizes-size-5)"}}},"md": 6},{"id": "u:d0513919f0fb","md": 6,"body": [{"id": "u:1f6f2d0609fc","type": "crud","mode": "table2","dsType": "api","syncLocation": true,"primaryField": "pf_role,pf_menu","loadType": "pagination","api": {"url": "http://127.0.0.1:5217/rest/role_menu_v/","method": "get","requestAdaptor": "","adaptor": "","messages": {}},"headerToolbar": [{"type": "flex","direction": "row","justify": "flex-start","alignItems": "stretch","style": {"position": "static"},"items": [{"type": "container","align": "left","behavior": ["Insert","BulkEdit","BulkDelete"],"body": [],"wrapperBody": false,"style": {"flexGrow": 1,"flex": "1 1 auto","position": "static","display": "flex","flexBasis": "auto","flexDirection": "row","flexWrap": "nowrap","alignItems": "stretch","justifyContent": "flex-start"},"id": "u:bef09c369eab"},{"type": "container","align": "right","behavior": ["FuzzyQuery"],"body": [],"wrapperBody": false,"style": {"flexGrow": 1,"flex": "1 1 auto","position": "static","display": "flex","flexBasis": "auto","flexDirection": "row","flexWrap": "nowrap","alignItems": "stretch","justifyContent": "flex-end"},"id": "u:b86c79951137"}],"id": "u:2259c57591f9"}],"footerToolbar": [{"type": "flex","direction": "row","justify": "flex-start","alignItems": "stretch","style": {"position": "static"},"items": [{"type": "container","align": "left","body": [],"wrapperBody": false,"style": {"flexGrow": 1,"flex": "1 1 auto","position": "static","display": "flex","flexBasis": "auto","flexDirection": "row","flexWrap": "nowrap","alignItems": "stretch","justifyContent": "flex-start"},"id": "u:950df6025af1"},{"type": "container","align": "right","body": [{"type": "pagination","behavior": "Pagination","layout": ["total","perPage","pager"],"perPage": 999,"perPageAvailable": [10,20,50,100],"align": "right","id": "u:cf75f0430847","size": ""}],"wrapperBody": false,"style": {"flexGrow": 1,"flex": "1 1 auto","position": "static","display": "flex","flexBasis": "auto","flexDirection": "row","flexWrap": "nowrap","alignItems": "stretch","justifyContent": "flex-end"},"id": "u:cbf1a9ad79d2"}],"id": "u:3052aef717a9"}],"columns": [{"type": "checkbox","title": "勾选授权","name": "B_YN","id": "u:26ec6ff796a9","placeholder": "-","align": "center","trueValue": 1,"falseValue": 0,"onEvent": {"change": {"weight": 0,"actions": [{"ignoreError": false,"outputVar": "responseResult","actionType": "ajax","options": {},"api": {"url": "http://127.0.0.1:5217/rest/s_role_menu/","method": "post","requestAdaptor": "","adaptor": "","messages": {},"sendOn": "","data": {"pf_role": "${R_ID}","pf_menu": "${M_ID}"}},"expression": "${event.data.value === 1}","stopPropagation": "${event.data.value===0}"},{"ignoreError": false,"outputVar": "responseResult","actionType": "ajax","options": {},"api": {"url": "http://127.0.0.1:5217/rest/s_role_menu/?where=pf_role='${R_ID}' and pf_menu='${M_ID}'","method": "delete","requestAdaptor": "","adaptor": "","messages": {}},"expression": "${event.data.value===0}","stopPropagation": "${event.data.value===1}"}]}}},{"type": "tpl","title": "功能ID","name": "M_ID","id": "u:8884f7cfc750"},{"type": "tpl","title": "功能名称","name": "S_NAME","id": "u:cea732fa69f4"},{"type": "tpl","title": "授权","name": "PF_ROLE","id": "u:86372060e12d"},{"type": "tpl","title": "角色ID","name": "R_ID","id": "u:b29521a345f6"}],"editorSetting": {"mock": {"enable": true,"maxDisplayRows": 5}},"placeholder": "暂无数据","loadDataOnce": true,"perPage": 999,"showHeader": true,"lineHeight": "","keepItemSelectionOnPageChange": false,"onEvent": {},"matchFunc": "","messages": {},"initFetch": false,"showBadge": false}]}],"id": "u:35740fa147ea","align": "left","themeCss": {"baseControlClassName": {"border:default": {"top-border-style": "var(--borders-style-2)","left-border-style": "var(--borders-style-2)","right-border-style": "var(--borders-style-2)","bottom-border-style": "var(--borders-style-2)","top-border-width": "var(--borders-width-1)","left-border-width": "var(--borders-width-1)","right-border-width": "var(--borders-width-1)","bottom-border-width": "var(--borders-width-1)"}}},"gap": "base","valign": "top"}],"id": "u:6cd046ec534c","asideResizor": false,"pullRefresh": {"disabled": true},"regions": ["body","header"],"onEvent": {}
}

3 实操演练

Step 1 页面加载

在这里插入图片描述
功能列表不拉取数据。

Step 2 点击角色行

在这里插入图片描述

Step 3 勾选授权

在这里插入图片描述

Step 4 去勾收权

在这里插入图片描述


本文完


http://www.ppmy.cn/news/1401963.html

相关文章

浏览器页面缓存机制

HTTP缓存机制的核心思想是,对于已经请求过的资源,如果其在服务器上没有发生变化,那么浏览器就可以直接从本地缓存中获取这些资源,而无需再次向服务器发送请求。 强缓存 就是确定可用的缓存 浏览器和和服务器对每个缓存资源先商量一…

Ubuntu下udp通信

一、知识准备阶段 socket是什么?套接字是什么? https://blog.csdn.net/m0_37925202/article/details/80286946 Socket程序从Windows移植到Linux下的一些注意事项 sockaddr和sockaddr_in详解 bzero和memset函数 函数原型:void bzero&…

Android开发 OCR:通过Tesseract实现图片文字识别

下面是整个详解步骤过程 效果图一、OCR的含义二、什么是Tesseract三、前提准备1、添加依赖2、数据文件下载路径 四、实际代码案例Demo如下:Main.xmlMain.java 效果图 流程:获取assets中的图片显示到页面,提取照片内的文字 一、OCR的含义 o…

二、分布式事务

目录 二、分布式事务2.1 什么是分布式事务2.2 分布式事务产生的背景2.3 分布式事务产生的场景2.4 分布式事务理论4.1 CAP理论4.2 Base理论 5、分布式事务的解决方案 二、分布式事务 2.1 什么是分布式事务 一组操作会产⽣多个数据库session会话 此时就会出现分布式事务 2.2 分…

开源AI引擎:文本自动分类在公安及消防执法办案自动化中的应用

一、实际案例介绍 通过文本分类算法自动化处理文本数据,快速识别案件性质和关键特征,极大地提高了案件管理和分派的效率。本文将探讨这两种技术如何帮助执法机构优化资源分配,确保案件得到及时而恰当的处理,并增强公共安全管理的…

Android数据存储:SQLite、Room

在Android平台上,集成了一个嵌入式关系型数据库—SQLite,SQLite3支持 NULL、INTEGER、REAL(浮点数字)、TEXT(字符串文本)和BLOB(二进制对象)数据类型,虽然它支持的类型只有五种,但实际上sqlite3也接受varch…

阿里云服务器初始化简记

文章目录 推荐版本CPU、内存、硬盘视活动而定,一般活动价99元一年注意带宽云服务器具体设置建议系统推荐CentOS 7.9本地系统推荐MacOSiTerm2本地系统推荐Win11Linux子系统推荐开发环境NginxPythonMySQL 机器和系统基本状况测试网速设置Vim显示中文其他系统状态监控和…

复制构造函数的使用

#include<iostream> using namespace std; class sample{ public:int v;sample(int n):v(n){}sample(const sample & c){v2*c.v;} }; int main(){sample a(5);sample ba;cout<<b.v;return 0; }