<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>





<!DOCTYPE html>
<html lang="zh-cn">

<jsp:include page="/admin/head.jsp"></jsp:include>

<body>

<div class="panel admin-panel">
    <form method="post" action="${domain}ListSearch.do" >
        <div class="panel-head"><strong class="icon-reorder"> ${tableNameCn}列表</strong> <a href="#" style="float:right; display:block;"></a></div>
        <div class="padding border-bottom">
            <ul class="search" style="padding-left:10px;">
                <#--<li> <a class="layui-btn" href="${domain}_add.jsp"> 添加</a> </li>-->
                <li>
                    <input type="text" placeholder="请输入搜索名称" name="name" class="input" style="width:250px; line-height:17px;display:inline-block" />
                    <input type="submit"  class="button border-main icon-search" value="搜索" >
                </li>
            </ul>
        </div>
    </form>
    <table class="table table-hover text-center layui-table" lay-filter="mylist" lay-size="lg">
        <thead>
        <tr>
            <th lay-data="{field:'xh', align:'center',width:60}">序号</th>
            <#list fieldList as field>
                <#if field.nameHump!="pubtime" && field.nameHump!="id"&& field.nameHump!="note">
                <th lay-data="{field:'${field.nameHump}', align:'center',minWidth:100}">${field.nameCn}</th>
                </#if>
            </#list>
            <th lay-data="{field:'addr2',align:'center',minWidth:250}">操作</th>
        </tr>
        </thead>
        <tbody>

        <c:forEach items=${r'"${'}list${r'}"'} var="u" varStatus="num">
            <tr>
                <td>${r"${"}num.count${r"}"}</td>
            <#list fieldList as field>
                <#if field.nameHump!="pubtime" && field.nameHump!="id"&& field.nameHump!="img"&& field.nameHump!="note">
                <td>${r'${'}u.${field.nameHump}${r'}'}</td>
                </#if>
                <#if field.nameHump=="img" >
                <td><img src="../upload/${r'${'}u.${field.nameHump}${r'}'}" style="width: 50px;height: 50px;" ></td>
                </#if>
            </#list>
                <td><div class="button-group">
                    <a class="layui-btn " onclick="look(${r"${"}u.id${r"}"})" lay-event="userAdd" style="height: 40px;">查看</a>
                    <a class="button border-main border-small "  href="doUpdate${Domain}.do?id=${r"${"}u.id${r"}"}" style="height: 40px;" ><span class="icon-trash-o"></span>修改</a>
                    <a class="button border-red  border-small " href="delete${Domain}.do?id=${r"${"}u.id${r"}"}" onclick="return del(1,1,1)" style="height: 40px;"><span class="icon-trash-o"></span> 删除</a> </div>
                </td>
            </tr>
        </c:forEach>
        </tbody>
    </table>
    <script type="text/html" id="toolbarDemo">
        <div class="layui-btn-container">
            <button class="layui-btn" onclick="window.location.href='doAdd${Domain}.do'"  lay-event="userAdd">添加</button>
        </div>
    </script>
</div>

<script type="text/javascript">
    //单个删除
    function del(id,mid,iscid){
        if(confirm("您确定要删除吗?")){
            return true;
        }else{
            return false;
        }
    }
</script>
<script type="text/javascript">
    //静态表格
    layui.use('table',function(){
        var table = layui.table;
        //转换静态表格
        table.init('mylist', {
            height: 'full-130' //高度最大化减去差值,也可以自己设置高度值：如 height:300
            ,count: 50 //数据总数 服务端获得
            ,limit: 5 //每页显示条数 注意：请务必确保 limit 参数（默认：10）是与你服务端限定的数据条数一致
            ,page:true //开启分页
            ,toolbar: '#toolbarDemo'//工具栏
            /* ,defaultToolbar:['filter', 'exports']*/
            ,limits:[ 5, 10, 15, 20, 30, 50]//分页显示每页条目下拉选择
            ,cellMinWidth: 60//定义全局最小单元格宽度，其余自动分配宽度
        });
        //监听行工具事件
        table.on('tool(mylist)', function(obj){ //注：tool 是工具条事件名，mylist 是 table 原始容器的属性 lay-filter="对应的值"
            var data = obj.data //获得当前行数据
                    ,layEvent = obj.event; //获得 lay-event 对应的值
            if(layEvent === 'del'){
                layer.confirm('真的删除行么', function(index){
                    obj.del(); //删除对应行（tr）的DOM结构
                    layer.close(index);
                    //向服务端发送删除指令
                });
            } else if(layEvent === 'edit'){
                alert(layEvent);
                layer.msg('修改操作');
            }
        });
        //监听头工具栏事件
        table.on('toolbar(mylist)', function(obj){
            var checkStatus = table.checkStatus(obj.config.id)
                    ,data = checkStatus.data; //获取选中的数据
            /* switch(obj.event){
            case 'getCheckLength':
                if(data.length === 0){
                layer.msg('请选择一行');
                } else {
                layer.msg('删除');
                }
            break;
            }; */
        });
    });
    //  iframe层  详情信息
    function look(id){
        //iframe层
        layer.open({
            type: 2,//层板块
             title: "查看${tableNameCn}",//标题
            closeBtn: 1, //不显示关闭按钮
            shade: [0.3],//遮罩
            skin: 'demo_class_color',//iframe皮肤
            shadeClose:Boolean,//点击遮罩关闭
            area: ['900px', '460px'],
            // offset: 'rb', //右下角弹出
            // time: 2000, //2秒后自动关闭
            anim: 5,//动画
            maxmin:true,
            content: ['doLook${Domain}.do?id='+id, 'yes'], //iframe的url，no代表不显示滚动条
        });

    }
</script>
</body>
</html>

