父层:
<div class="col-xs-12"> <div class="box"> <div class="box-header"> <h3 class="box-title">主机监控列表</h3> </div> <!-- /.box-header --> <div class="box-body" style="overflow: auto"> <table id="example2" class="table table-bordered table-hover"> <thead> <tr> <th>ID</th> <th>标签</th> <th>IP地址</th> <th>主机名</th> <th>监控用户名</th> <th>主机通断告警</th> <th>CPU使用率告警</th> <th>内存使用率告警</th> <th>磁盘使用率告警</th> <th style="width: 10px"></th> <th style="width: 10px"></th> </tr> </thead> {% for linux_server in linuxs_servers %} <tr> <td>{{ forloop.counter }} </td> <td>{{ linux_server.tags}} </td> <td>{{ linux_server.host}} </td> <td>{{ linux_server.host_name}} </td> <td>{{ linux_server.user}} </td> <td align="center">{{ linux_server.connect_cn}} </td> <td align="center">{{ linux_server.cpu_cn }} </td> <td align="center">{{ linux_server.mem_cn }} </td> <td align="center">{{ linux_server.disk_cn }} </td> <td> <div class="box-tools pull-right"> <a href="#" rel="external nofollow" > <button type="button" class="btn btn-default btn-sm" οnclick="return pop(this.value)" value="{{ linux_server.id }}"><i class="fa fa-edit"></i></button></a> </div> </td> <td> <div class="box-tools pull-right"> <a href="/linux_servers_del?id={{ linux_server.id }}" rel="external nofollow" > <button type="button" class="btn btn-default btn-sm"><i class="fa fa-trash-o"></i></button></a> </div> </td> </tr> {% endfor %} </table> </div> <div c<strong style="color:transparent">本文来源gaodai#ma#com搞@@代~&码*网/</strong>lass="box-footer clearfix"> <span class="step-links"> {% if linuxs_servers.has_previous %} <a href="?page_linux={{ linuxs_servers.previous_page_number }}" rel="external nofollow" >上一页</a> {% endif %} <span class="current"> 当前页{{ linuxs_servers.number }} 共计{{ linuxs_servers.paginator.num_pages }} </span> {% if linuxs_servers.has_next %} <a href="?page_linux={{ linuxs_servers.next_page_number }}" rel="external nofollow" >下一页</a> {% endif %} </span> <div class="pull-right"> <a href="/linux_servers_add" rel="external nofollow" class="btn btn-primary btn-block btn-flat">新增</a> </div> </div> <!-- /.box-body --> </div> <!-- /.box --> {#用于接收linux_server__edit.html中layui子层的传值#} <input id="handle_status" value="" hidden="hidden"> </div>
点击编辑按钮,执行方法:
<script> function pop(n){ layer.open({ type: 2, title: '编辑主机信息', closeBtn: 1, area: ['700px', '550px'], shadeClose: true, //点击遮罩关闭 content: ['/linux_servers_edit?id='+n,], end:function(){ var handle_status = $("#handle_status").val(); if ( handle_status == '1' ) { layer.msg('保存成功!',{ icon: 1, time: 2000 //2秒关闭(如果不配置,默认是3秒) },function(){ history.go(0); }); } else if ( handle_status == '2' ) { layer.msg('修改失败!',{ icon: 2, time: 2000 //2秒关闭(如果不配置,默认是3秒) },function(){ history.go(0); }); } } }); } </script>