HAP_级联功能

现在有两个字段role 和user
role

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

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

用户名称用户id用户类型
admin1000110001
jessen1000210001
hailen1000310002
eric1000410002
tony1000510002
rodgers1000610003

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


13265172-7c31af5a5a864517.png
image.png

13265172-6856781838537dea.png
image.png

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

新建LOVORA_20796_ORG_ROLE

13265172-be9bf85e10b706e8.png
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

13265172-acc3874415606c5a.png
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
                    }));
                }
            },


参数说明:


13265172-b8f4e4e49b4aa4c5.png
image.png
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值