HAP_级联功能

现在有两个字段role 和user
role

角色名称 角色
管理员 10001
员工 10002

user用户类型对应role的角色(管理员、员工)

用户名称 用户id 用户类型
admin 10001 10001
jessen 10002 10001
hailen 10003 10002
eric 10004 10002
tony 10005 10002
rodgers 10006 10003

需求:在选择用户的时候,根据前面的角色弹出对应的user
如图:


image.png

image.png

需求清楚了,那开始动手吧!

新建LOVORA_20796_ORG_ROLE

image.png

自定义SQL

select
r.role_id,
r.role_name
from sys_role_b r
<where>
<if test="roleId!= null">
r.role_id LIKE concat( concat("%",#{roleId,jdbcType=VARCHAR}),"%")
</if>
</where>

新建LOVORA_20796_ORG_USER

image.png

自定义SQL

select u.user_id,u.user_name,u.user_type from sys_user u
<where><if test="userId !=null">u.user_id like concat(concat("%",#{userId,jdbcType=VARCHAR}),"%")</if>
<if test="userName !=null ">u.user_name like concat(concat("%",#{userName,jdbcType=VARCHAR}),"%")</if>
<if test="userType !=null"> u.user_type =#{userType}</if>
</where>

修改html中的字段:

             {
                field: "roleId",
                title: '<@spring.message "ora20796orgaccess.roleid"/>',
                width: 120,
                template: function (dataItem) {
                    return dataItem['roleName'] || ''; /* 数据列默认显示值 */
                },
                editor: function (container, options) {
                    $('<input name="'+ options.field +'" />').appendTo(container)
                        .kendoLov($.extend(<@lov "ORA_20796_ORG_ROLE" />, {
                        query: function (e) {
                            e.param['enableFlag'] = 'Y';
                            options.model.set('userId',null);
                            options.model.set('userName', null);
                        },
                        select: function (e) {
                            // 将选择后的属性更新到数据模型中以保存
                            options.model.set('roleId', e.item.roleId);
                        },
                        textField: 'roleName', /* 编辑器显示的值 */
                        model: options.model
                    }));
                }
            },

          {
                field: "userId",
                title: '<@spring.message "ora20796orgaccess.userid"/>',
                width: 120,
                template: function (dataItem) {
                    return dataItem['userName'] || ''; /* 数据列默认显示值 */
                },
                editor: function (container, options) {
                    $('<input name="'+ options.field +'" />').appendTo(container)
                        .kendoLov($.extend(<@lov "ORA_20796_ORG_USER" />, {
                        query: function (e) {
                            e.param['enableFlag'] = 'Y';
                            e.param['userType'] = options.model.get("roleId");
                        },
                        select: function (e) {
                            // 将选择后的属性更新到数据模型中以保存
                            options.model.set('userId', e.item.userId);
                        },
                        textField: 'userName', /* 编辑器显示的值 */
                        model: options.model
                    }));
                }
            },


参数说明:


image.png
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 关于Mongodb的全面总结 MongoDB的内部构造《MongoDB The Definitive Guide》...
    中v中阅读 32,046评论 2 89
  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 135,001评论 19 139
  • 一直以来,都有个小小的愿望,希望能把看到的一切用一支小小的铅笔,细细的描绘出来 现在最低点的好处就是,从哪个方向努...
    太阳花花瓣阅读 427评论 4 50
  • 小时候生长在农村,泥砖房,瓦顶屋,家家户户有个大烟囱,那是最感动我的记忆。 从小就喜欢每家每户炊烟升起的时候,那是...
    海无潮阅读 251评论 0 0