Layui(二级页面) 弹出层打开页面|传递参数

原创
05/09 08:59
阅读数 527

一级弹出层:弹出打开页面

layer.open({
			type: 2,
			title: '添加用户',
			content: '../user/goAdd',
			area: ['460px', '450px'],
			btnAlign: 'c',
			btn: ['确定', '取消'],
			yes: function(index, layero){
				var iframeWindow = window['layui-layer-iframe'+ index],
				submitID = 'ZX_iframe_submit',
				submit = layero.find('iframe').contents().find('#'+ submitID);
				//监听提交
				iframeWindow.layui.form.on('submit('+ submitID +')', function(data){
					$.ajax({
						type: "POST",
						url: '../user/insert',
						data: data.field,
						dataType: "json",
						success: function(data){
							if(data.code==0){
								layer.msg(data.msg);
								table.reload('ZX_table_list');
								layer.close(index);
							}else{
								layer.msg(data.msg);
							}
						}
					});
				});
				submit.trigger('click');
			}
		});

二级弹出层:弹出页面再弹出打开页面    

parent.layer.open({
            type: 2,
            title: '选择会员室设备',
            content: '../processNote/goSetNoteRole',
            area: ['700px', '300px'],
            btnAlign: 'c',
            id: 'select_Equip', //设定一个id,防止重复弹出
            shade:false,
            btn: ['确定'],
            zIndex: parent.layer.zIndex, //重点1
            success: function(layero,index){
                parent.layer.setTop(layero); //重点2
            },
            yes: function (l_index, layero) {
				//获取弹出页面传递的参数值
                var isSuppInfo = $(layero).find("iframe")[0].contentWindow.document.getElementById('isSuppInfo').value;
                console.log(obj);
                parent.layer.close(select);
            }
        });

二级弹出层:弹出页面再弹出打开页面

parent.layer.open({
                    type: 2,
                    title: '增加权限',
                    content:  '../processNote/goSetNoteRole',//请求打开页面地址
                    area: ['70%', '95%'],
                    btnAlign: 'c',
                    btn: ['确认','关闭'],
                    yes: function(index,layero){
							//获取弹出页面值
                            var isSuppInfo = layero.find('iframe').contents().find('#isSuppInfo').val();
                            var approvalRoleId = layero.find('iframe').contents().find('#approvalRoleId').val();
                            //验证非空
                            if(null==approvalRoleId || approvalRoleId==''){
                                parent.layer.msg("请选择审批角色");
                                return;
                            }

//tip:扩展--start
//单选按钮的值
				iframe.find("input[@type='radio']").attr("checked","true");
//一个下拉框的值
				var  processFieldId = iframe.find("select[name='processFieldId']").val();
//多个下拉选择框的值
   var conditionArray = [];
   var conditionSelect = iframe.find("select[name='condition']");
                            $(conditionSelect).each(function (j, item) {
                                conditionArray[j] = item.value;
                            });
//tip:扩展--end

                            $.ajax({
                                type: "POST",
                                url: '../processNote/insertNoteApproval',
                                data: {
                                    isSuppInfo:isSuppInfo,
                                    approvalRoleId:approvalRoleId,
                                    conditionArray: JSON.stringify(conditionArray) //tip:扩展
                                },
                                dataType: "json",
                                success: function(data){
                                    parent.layer.msg(data.msg);
                                    parent.layer.close(index);
                                    table.reload('ZX_table_list');
                                }
                            });
                    },
                    btn2: function(){
					//关闭按钮
                    }
                });

前端JSON数组传递参数JAVA后台字符串接收
 

String conditionArray = noteApproval.getConditionArray();
LinkedList<String> conditionList = new Gson().fromJson(conditionArray, new TypeToken<LinkedList<String>>() {}.getType());
             

 

展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
OSCHINA
登录后可查看更多优质内容
返回顶部
顶部