//先得到当前iframe层的索引 var index = parent.layer.getFrameIndex(window.name); //再执行关闭 parent.layer.close(index); //关闭父级页面的表格 parent.layui.table.reload('vehicleAlertInfoTableReload',{page:{curr:1}});
其他参考
layui.use(['tree', 'util','table'], function(){ var tree = layui.tree ,layer = layui.layer ,util = layui.util ,table = layui.table ,$ = layui.$; var reportId = "{{ $_GET['reportId'] }}"; table.render({ elem: '#pbi_role' ,url:"地址" ,cols: [[ {type:'radio',event:'roleRadio'} ,{field:'name', title: 'Role Name'} ,{field:'description', title: 'Description'} ]] ,page: false ,id:'roleTable' ,height: 'full-160' , done: function (res, curr, count) { $.each(res.data, function (key, value) { // console.log(key, value) if (value.if_checked == '1') { $(".layui-table-view[lay-id='roleTable'] .layui-table-body tr[data-index='"+key+"'] .layui-form-radio").click(); } }); } }); table.render({ elem: '#users' ,url:"地址" ,cols: [[ {type:'checkbox'/*,LAY_CHECKED:true*/} ,{field:'id', title: 'ID',width:80} ,{field:'username', title: '8ID'} ,{field:'name', title: 'Name'} ]] ,height: 'full-160' ,id:'userTable' , done: function (res, curr, count) { // console.log(res, curr, count) // //可以自行添加判断的条件是否选中 // //这句才是真正选中,通过设置关键字LAY_CHECKED为true选中,这里只对第一行选中 // res.data[0]["LAY_CHECKED"]='true'; // //下面三句是通过更改css来实现选中的效果 // var index= res.data[0]['LAY_TABLE_INDEX']; // $('tr[data-index=' + index + '] input[type="checkbox"]').prop('checked', true); // $('tr[data-index=' + index + '] input[type="checkbox"]').next().addClass('layui-form-checked'); // $(".layui-table-view[lay-id='tableDataId'] .layui-table-body tr[data-index = '0' ] .layui-form-radio").click(); } ,page: false }); table.on('tool(pbi_role)', function(obj){ var data = obj.data; var tr = obj.tr; if(obj.event === 'roleRadio' && ($(this).find('input').is(':checked')== true)){ // user_render(data.id) user_render({id:data.id}) } }); function user_render(data){ console.log(data); table.reload('userTable', { where: { id: data.id } }, 'data'); } //search $('#search_user').on('click', function(){ var checkStatus = table.checkStatus('roleTable') ,data = checkStatus.data; var id; if (data.length !== 0){ var id = data[0]['id']; } var username = $('#username').val(); var filter = {id:id,username:username}; // console.log(filter); user_render(filter); }); var active = { deleteRole: function(){ var checkStatus = table.checkStatus('roleTable') ,data = checkStatus.data; var info = data[0]; if (info == undefined){ layer.tips('Please choose one!', $(".layui-table-view[lay-id='roleTable'] .layui-table-body"), { tips: [3,'#FF5722'], time:5000, }); return false; } layer.confirm('Are you sure to delete ['+info.name+']?', { title:'Delete', btn: ['Confirm','Cancel'] //按钮 }, function(){ var url = "地址?id="+info.id; $.ajaxSetup({ headers: { 'X-CSRF-TOKEN' : '{{ csrf_token() }}' } }); $.ajax({ url:url, data:{id:info.id}, type:'post', success:function(res) { if(res.code == 200) { table.reload('roleTable'); layer.msg('successful', {icon: 1}); } else { layer.msg(res.msg, {icon: 5,time:2000}); } } }) return false; // }, function(){ }); }, editRole: function(){ var checkStatus = table.checkStatus('roleTable') ,data = checkStatus.data; var info = data[0]; if (info == undefined){ layer.tips('Please choose one !', $(".layui-table-view[lay-id='roleTable'] .layui-table-body"), { tips: [3,'#FF5722'], time:5000, }); return false; } var url = "地址?id="+info.id; layer.open({ type: 2, title: info.name, shadeClose: false, maxmin: false, shade: 0.7, area: ["40%", "90%"], offset: 'auto', anim: 0, content: url }); }, addUser:function () { var checkStatus = table.checkStatus('roleTable') ,data = checkStatus.data; var info = data[0]; // console.log(info); if (info == undefined){ layer.tips('Please choose one !', $(".layui-table-view[lay-id='roleTable'] .layui-table-body"), { tips: [3,'#FF5722'], time:5000, }); return false; } var url = "地址?id="+info.id+"&reportId="+info.reportId; layer.open({ type: 2, title: info.name, shadeClose: false, maxmin: false, shade: 0.7, area: ["40%", "90%"], offset: 'auto', anim: 0, content: url }); }, deleteUser:function () { var checkStatus = table.checkStatus('userTable') ,data = checkStatus.data; console.log(data); if (data){ layer.tips('Please choose !', $(".layui-table-view[lay-id='userTable'] .layui-table-body"), { tips: [3,'#FF5722'], time:5000, }); return false; } } }; $('.headerButton .layui-btn').on('click', function(){ var type = $(this).data('type'); active[type] ? active[type].call(this) : ''; }); });